faiss serving :)

Overview

faiss-server

faiss-server provides gRPC services to for similarity search using faiss. It is written in C++ and now supports only CPU environments.

Installation

Currently, installation is from source only.

$ git clone https://github.com/ynqa/faiss-server
$ cd faiss-server

To build faiss-server on your local, please use cmake.

$ mkdir build; cd build
$ cmake ..
$ make

[Beta] To build as docker image:

$ docker build -t faiss-server .

Demo

  1. Create indexed file, which is composed of the word vectors. Indexed words are on text8 corpus and those vectors are trained by word2vec model of gensim.
$ python example/indexing/indexing.py
  1. Select the indexed file and then execute faiss-server.
$ ./build/bin/faiss_server -file_path example/indexing/faiss.index
  • If you build with docker:
    $ docker run -p 8080:8080 -v $(pwd)/example/indexing:/tmp faiss-server -file_path /tmp/faiss.index
    
  1. Throw the requests for similarity search
$ PYTHONPATH=python python example/client/search.py

Usage

faiss_server:
    -file_path (index file name) type: string default: ""
    -host (host of faiss server) type: string default: "0.0.0.0"
    -port (port of faiss server) type: string default: "8080"
    -top_k (default number of neighbor) type: uint64 default: 5
Issues
  • Use google provided Empty type

    Use google provided Empty type

    I see you are using a custom message type as the request type to:

    message HealthCheckRequest {};

    rpc HealthCheck (HealthCheckRequest) returns (HealthCheckResponse);

    Assuming you never actually a need to add parms to this, you can use the Google Empty message type:

    https://github.com/google/protobuf/blob/master/src/google/protobuf/empty.proto

    opened by curtpm 3
  • faiss-server/src/protobuf/faiss.pb.h:8:10: fatal error: google/protobuf/arena.h: No such file or directory  #include <google/protobuf/arena.h>

    faiss-server/src/protobuf/faiss.pb.h:8:10: fatal error: google/protobuf/arena.h: No such file or directory #include

    @ynqa I get this error when I try to run the cmake command and then the make -j command. When I look at the Build folder, the relevant file appears under protobuf/include.

    opened by zeynepkoyun 0
  • which protobuf version?

    which protobuf version?

    I can't make:

    /root/faiss-server/src/protobuf/faiss.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
     #error This file was generated by an older version of protoc which is
      ^~~~~
    /root/faiss-server/src/protobuf/faiss.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
     #error incompatible with your Protocol Buffer headers.  Please
      ^~~~~
    /root/faiss-server/src/protobuf/faiss.pb.h:19:2: error: #error regenerate this file with a newer version of protoc.
     #error regenerate this file with a newer version of protoc.
      ^~~~~
    In file included from /root/faiss-server/src/protobuf/faiss.grpc.pb.h:7:0,
                     from /root/faiss-server/src/main.cpp:6:
    /root/faiss-server/src/protobuf/faiss.pb.h:27:10: fatal error: google/protobuf/inlined_string_field.h: No such file or directory
     #include <google/protobuf/inlined_string_field.h>
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    CMakeFiles/faiss_server.dir/build.make:75: recipe for target 'CMakeFiles/faiss_server.dir/main.o' failed
    make[5]: *** [CMakeFiles/faiss_server.dir/main.o] Error 1
    CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/faiss_server.dir/all' failed
    make[4]: *** [CMakeFiles/faiss_server.dir/all] Error 2
    Makefile:90: recipe for target 'all' failed
    make[3]: *** [all] Error 2
    CMakeFiles/faiss-server.dir/build.make:85: recipe for target 'faiss-server/src/faiss-server-stamp/faiss-server-build' failed
    make[2]: *** [faiss-server/src/faiss-server-stamp/faiss-server-build] Error 2
    CMakeFiles/Makefile2:100: recipe for target 'CMakeFiles/faiss-server.dir/all' failed
    make[1]: *** [CMakeFiles/faiss-server.dir/all] Error 2
    Makefile:90: recipe for target 'all' failed
    make: *** [all] Error 2
    
    opened by roeniss 2
  • CMake Error at /usr/bin/cmake/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:137

    CMake Error at /usr/bin/cmake/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:137

    Microsoft Windows [Version 10.0.20251.1] (c) 2020 Microsoft Corporation. All rights reserved.

    C:\Users\polyt>pushd z:\repos

    z:\repos>git clone http://github.com/ynqa/faiss-server.git Cloning into 'faiss-server'... warning: redirecting to https://github.com/ynqa/faiss-server.git/ remote: Enumerating objects: 284, done. remote: Total 284 (delta 0), reused 0 (delta 0), pack-reused 284 eceiving objects: 79% Receiving objects: 100% (284/284), 65.09 KiB | 1.42 MiB/s, done. Resolving deltas: 100% (140/140), done.

    z:\repos>cd faiss-server

    z:\repos\faiss-server>docker build -t faiss-server . .......... [ 95%] Performing configure step for 'faiss-server' loading initial cache file /builder/build/faiss-server/tmp/faiss-server-cache-.cmake -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE CMake Error at /usr/bin/cmake/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR) Call Stack (most recent call first): /usr/bin/cmake/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) /usr/bin/cmake/share/cmake-3.11/Modules/FindProtobuf.cmake:543 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:6 (find_package)

    CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as

    cmake_minimum_required(VERSION 3.11)
    

    should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000". This warning is for project developers. Use -Wno-dev to suppress it.

    -- Configuring incomplete, errors occurred! See also "/builder/build/bin/CMakeFiles/CMakeOutput.log". See also "/builder/build/bin/CMakeFiles/CMakeError.log". CMakeFiles/faiss-server.dir/build.make:110: recipe for target 'faiss-server/src/faiss-server-stamp/faiss-server-configure' failed CMakeFiles/Makefile2:71: recipe for target 'CMakeFiles/faiss-server.dir/all' failed make[2]: *** [faiss-server/src/faiss-server-stamp/faiss-server-configure] Error 1 make[1]: *** [CMakeFiles/faiss-server.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2 The command '/bin/sh -c make' returned a non-zero code: 2

    opened by jiangweiatgithub 1
  • run with docker issue

    run with docker issue

    -- Looking for pthread_create
    -- Looking for pthread_create - not found
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - found
    -- Found Threads: TRUE
    CMake Error at /usr/bin/cmake/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
      Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR)
    Call Stack (most recent call first):
      /usr/bin/cmake/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
      /usr/bin/cmake/share/cmake-3.11/Modules/FindProtobuf.cmake:543 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
      CMakeLists.txt:6 (find_package)
    
    opened by hao-sharethis 0
Owner
Software Engineer
null
A flexible, high-performance serving system for machine learning models

XGBoost Serving This is a fork of TensorFlow Serving, extended with the support for XGBoost, alphaFM and alphaFM_softmax frameworks. For more informat

iQIYI 115 Jun 20, 2022
MozoLM: A language model (LM) serving library

A language model serving library, with middleware functionality including mixing of probabilities from disparate base language model types and tokenizations along with RPC client/server interactions.

Google Research 35 Jun 19, 2022
null 5.5k Jun 21, 2022
Faiss is a library for efficient similarity search and clustering of dense vectors.

Faiss is a library for efficient similarity search and clustering of dense vectors. It contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM. It also contains supporting code for evaluation and parameter tuning. Faiss is written in C++ with complete wrappers for Python/numpy.

Facebook Research 17.3k Jun 27, 2022
Yggdrasil Decision Forests (YDF) is a collection of state-of-the-art algorithms for the training, serving and interpretation of Decision Forest models.

Yggdrasil Decision Forests (YDF) is a collection of state-of-the-art algorithms for the training, serving and interpretation of Decision Forest models. The library is developed in C++ and available in C++, CLI (command-line-interface, i.e. shell commands) and in TensorFlow under the name TensorFlow Decision Forests (TF-DF).

Google 157 Jun 16, 2022
A flexible, high-performance serving system for machine learning models

XGBoost Serving This is a fork of TensorFlow Serving, extended with the support for XGBoost, alphaFM and alphaFM_softmax frameworks. For more informat

iQIYI 115 Jun 20, 2022
MozoLM: A language model (LM) serving library

A language model serving library, with middleware functionality including mixing of probabilities from disparate base language model types and tokenizations along with RPC client/server interactions.

Google Research 35 Jun 19, 2022
Flutter plugin serving utilities related to Windows taskbar. 💙

windows_taskbar Flutter plugin serving utilities related to Windows taskbar ?? Install dependencies: windows_taskbar: ^0.0.1 Demo Checkout the exam

Hitesh Kumar Saini 83 Jun 25, 2022
Simple embeddable C++11 async tcp,http and websocket serving.

net11 Simple embeddable C++11 async tcp,http and websocket serving. What is it? An easily embeddable C++11 networking library designed to make buildin

Jonas Lund 9 Mar 28, 2020