Git Product home page Git Product logo

developermindset-com / faiss-mobile Goto Github PK

View Code? Open in Web Editor NEW
36.0 3.0 6.0 3.8 MB

FAISS library compiled for iOS, macOS, tvOS, watchOS

Home Page: https://www.developermindset.com/faiss-mobile/

License: MIT License

Ruby 0.05% Swift 0.02% CMake 1.76% JavaScript 0.01% Shell 0.76% C++ 61.12% Python 17.65% C 2.01% Batchfile 0.03% Cuda 16.59%
c cpp embeddings faiss ios knn macos neighbor-search search similarity-search

faiss-mobile's Introduction

FAISS Mobile

This library provides means to compile and distribute FAISS library for iOS.

FAISS is a library — developed by Facebook AI — that enables efficient similarity search. So, given a set of vectors, we can index them using Faiss — then using another vector (the query vector), we search for the most similar vectors within the index.

Version

Latest supported version of FAISS is 1.7.4.

Supported platforms

  • iOS
  • iOS Simulator
  • tvOS
  • tvOS Simulator
  • watchOS
  • watchOS Simulator
  • macOS

Requirements

  • Git LFS
  • Xcode (including multiple platforms)
  • LLVM with Clang
  • Homebrew
  • g++
  • CMake
  • node
  • python
  • perl
  • ruby (for Cocoapods)
  • carthage
  • swift
  • OpenMP

Why

Modern machine learning tools focus on the server side or desktop solutions, few of them optimise their code bases for mobile, this repository is a structured way to get the FAISS source code compiled and distributed to iOS developers.

Getting started

Run ./faiss.sh and it will create dist/faiss.xcframework that you can use in your Xcode project.

faiss.xcframework

Once the compilation is done, you'll have XCframework created with the files below:

tree dist/faiss.xcframework -P '*.a'
dist/faiss.xcframework
├── ios-arm64_arm64e
│   ├── Headers
│   │   └── faiss
│   │       ├── c_api
│   │       │   ├── impl
│   │       │   └── utils
│   │       ├── impl
│   │       │   └── code_distance
│   │       ├── invlists
│   │       └── utils
│   │           ├── approx_topk
│   │           ├── approx_topk_hamming
│   │           ├── distances_fused
│   │           ├── hamming_distance
│   │           └── transpose
│   └── libfaiss.a
├── ios-arm64_arm64e_x86_64-simulator
│   ├── Headers
│   │   └── faiss
│   │       ├── c_api
│   │       │   ├── impl
│   │       │   └── utils
│   │       ├── impl
│   │       │   └── code_distance
│   │       ├── invlists
│   │       └── utils
│   │           ├── approx_topk
│   │           ├── approx_topk_hamming
│   │           ├── distances_fused
│   │           ├── hamming_distance
│   │           └── transpose
│   └── libfaiss.a
├── macos-arm64_arm64e_x86_64
│   ├── Headers
│   │   └── faiss
│   │       ├── c_api
│   │       │   ├── impl
│   │       │   └── utils
│   │       ├── impl
│   │       │   └── code_distance
│   │       ├── invlists
│   │       └── utils
│   │           ├── approx_topk
│   │           ├── approx_topk_hamming
│   │           ├── distances_fused
│   │           ├── hamming_distance
│   │           └── transpose
│   └── libfaiss.a
├── tvos-arm64
│   ├── Headers
│   │   └── faiss
│   │       ├── c_api
│   │       │   ├── impl
│   │       │   └── utils
│   │       ├── impl
│   │       │   └── code_distance
│   │       ├── invlists
│   │       └── utils
│   │           ├── approx_topk
│   │           ├── approx_topk_hamming
│   │           ├── distances_fused
│   │           ├── hamming_distance
│   │           └── transpose
│   └── libfaiss.a
├── tvos-x86_64-simulator
│   ├── Headers
│   │   └── faiss
│   │       ├── c_api
│   │       │   ├── impl
│   │       │   └── utils
│   │       ├── impl
│   │       │   └── code_distance
│   │       ├── invlists
│   │       └── utils
│   │           ├── approx_topk
│   │           ├── approx_topk_hamming
│   │           ├── distances_fused
│   │           ├── hamming_distance
│   │           └── transpose
│   └── libfaiss.a
├── watchos-arm64_32_armv7k
│   ├── Headers
│   │   └── faiss
│   │       ├── c_api
│   │       │   ├── impl
│   │       │   └── utils
│   │       ├── impl
│   │       │   └── code_distance
│   │       ├── invlists
│   │       └── utils
│   │           ├── approx_topk
│   │           ├── approx_topk_hamming
│   │           ├── distances_fused
│   │           ├── hamming_distance
│   │           └── transpose
│   └── libfaiss.a
└── watchos-i386-simulator
    ├── Headers
    │   └── faiss
    │       ├── c_api
    │       │   ├── impl
    │       │   └── utils
    │       ├── impl
    │       │   └── code_distance
    │       ├── invlists
    │       └── utils
    │           ├── approx_topk
    │           ├── approx_topk_hamming
    │           ├── distances_fused
    │           ├── hamming_distance
    │           └── transpose
    └── libfaiss.a

106 directories, 7 files

faiss_c.xcframework

A C only version, without C++ dependency is inside faiss_c.xcframework.

dist/faiss_c.xcframework
├── Info.plist
├── ios-arm64_arm64e
│   ├── Headers
│   │   ├── AutoTune_c.h
│   │   ├── Clustering_c.h
│   │   ├── IndexBinary_c.h
│   │   ├── IndexFlat_c.h
│   │   ├── IndexIVFFlat_c.h
│   │   ├── IndexIVF_c.h
│   │   ├── IndexLSH_c.h
│   │   ├── IndexPreTransform_c.h
│   │   ├── IndexReplicas_c.h
│   │   ├── IndexScalarQuantizer_c.h
│   │   ├── IndexShards_c.h
│   │   ├── Index_c.h
│   │   ├── MetaIndexes_c.h
│   │   ├── VectorTransform_c.h
│   │   ├── clone_index_c.h
│   │   ├── error_c.h
│   │   ├── error_impl.h
│   │   ├── faiss_c.h
│   │   ├── impl
│   │   │   └── AuxIndexStructures_c.h
│   │   ├── index_factory_c.h
│   │   ├── index_io_c.h
│   │   ├── macros_impl.h
│   │   └── utils
│   │       └── distances_c.h
│   └── libfaiss_c.a
├── ios-arm64_arm64e_x86_64-simulator
│   ├── Headers
│   │   ├── AutoTune_c.h
│   │   ├── Clustering_c.h
│   │   ├── IndexBinary_c.h
│   │   ├── IndexFlat_c.h
│   │   ├── IndexIVFFlat_c.h
│   │   ├── IndexIVF_c.h
│   │   ├── IndexLSH_c.h
│   │   ├── IndexPreTransform_c.h
│   │   ├── IndexReplicas_c.h
│   │   ├── IndexScalarQuantizer_c.h
│   │   ├── IndexShards_c.h
│   │   ├── Index_c.h
│   │   ├── MetaIndexes_c.h
│   │   ├── VectorTransform_c.h
│   │   ├── clone_index_c.h
│   │   ├── error_c.h
│   │   ├── error_impl.h
│   │   ├── faiss_c.h
│   │   ├── impl
│   │   │   └── AuxIndexStructures_c.h
│   │   ├── index_factory_c.h
│   │   ├── index_io_c.h
│   │   ├── macros_impl.h
│   │   └── utils
│   │       └── distances_c.h
│   └── libfaiss_c.a
├── macos-arm64_arm64e_x86_64
│   ├── Headers
│   │   ├── AutoTune_c.h
│   │   ├── Clustering_c.h
│   │   ├── IndexBinary_c.h
│   │   ├── IndexFlat_c.h
│   │   ├── IndexIVFFlat_c.h
│   │   ├── IndexIVF_c.h
│   │   ├── IndexLSH_c.h
│   │   ├── IndexPreTransform_c.h
│   │   ├── IndexReplicas_c.h
│   │   ├── IndexScalarQuantizer_c.h
│   │   ├── IndexShards_c.h
│   │   ├── Index_c.h
│   │   ├── MetaIndexes_c.h
│   │   ├── VectorTransform_c.h
│   │   ├── clone_index_c.h
│   │   ├── error_c.h
│   │   ├── error_impl.h
│   │   ├── faiss_c.h
│   │   ├── impl
│   │   │   └── AuxIndexStructures_c.h
│   │   ├── index_factory_c.h
│   │   ├── index_io_c.h
│   │   ├── macros_impl.h
│   │   └── utils
│   │       └── distances_c.h
│   └── libfaiss_c.a
├── tvos-arm64
│   ├── Headers
│   │   ├── AutoTune_c.h
│   │   ├── Clustering_c.h
│   │   ├── IndexBinary_c.h
│   │   ├── IndexFlat_c.h
│   │   ├── IndexIVFFlat_c.h
│   │   ├── IndexIVF_c.h
│   │   ├── IndexLSH_c.h
│   │   ├── IndexPreTransform_c.h
│   │   ├── IndexReplicas_c.h
│   │   ├── IndexScalarQuantizer_c.h
│   │   ├── IndexShards_c.h
│   │   ├── Index_c.h
│   │   ├── MetaIndexes_c.h
│   │   ├── VectorTransform_c.h
│   │   ├── clone_index_c.h
│   │   ├── error_c.h
│   │   ├── error_impl.h
│   │   ├── faiss_c.h
│   │   ├── impl
│   │   │   └── AuxIndexStructures_c.h
│   │   ├── index_factory_c.h
│   │   ├── index_io_c.h
│   │   ├── macros_impl.h
│   │   └── utils
│   │       └── distances_c.h
│   └── libfaiss_c.a
├── tvos-x86_64-simulator
│   ├── Headers
│   │   ├── AutoTune_c.h
│   │   ├── Clustering_c.h
│   │   ├── IndexBinary_c.h
│   │   ├── IndexFlat_c.h
│   │   ├── IndexIVFFlat_c.h
│   │   ├── IndexIVF_c.h
│   │   ├── IndexLSH_c.h
│   │   ├── IndexPreTransform_c.h
│   │   ├── IndexReplicas_c.h
│   │   ├── IndexScalarQuantizer_c.h
│   │   ├── IndexShards_c.h
│   │   ├── Index_c.h
│   │   ├── MetaIndexes_c.h
│   │   ├── VectorTransform_c.h
│   │   ├── clone_index_c.h
│   │   ├── error_c.h
│   │   ├── error_impl.h
│   │   ├── faiss_c.h
│   │   ├── impl
│   │   │   └── AuxIndexStructures_c.h
│   │   ├── index_factory_c.h
│   │   ├── index_io_c.h
│   │   ├── macros_impl.h
│   │   └── utils
│   │       └── distances_c.h
│   └── libfaiss_c.a
├── watchos-arm64_32_armv7k
│   ├── Headers
│   │   ├── AutoTune_c.h
│   │   ├── Clustering_c.h
│   │   ├── IndexBinary_c.h
│   │   ├── IndexFlat_c.h
│   │   ├── IndexIVFFlat_c.h
│   │   ├── IndexIVF_c.h
│   │   ├── IndexLSH_c.h
│   │   ├── IndexPreTransform_c.h
│   │   ├── IndexReplicas_c.h
│   │   ├── IndexScalarQuantizer_c.h
│   │   ├── IndexShards_c.h
│   │   ├── Index_c.h
│   │   ├── MetaIndexes_c.h
│   │   ├── VectorTransform_c.h
│   │   ├── clone_index_c.h
│   │   ├── error_c.h
│   │   ├── error_impl.h
│   │   ├── faiss_c.h
│   │   ├── impl
│   │   │   └── AuxIndexStructures_c.h
│   │   ├── index_factory_c.h
│   │   ├── index_io_c.h
│   │   ├── macros_impl.h
│   │   └── utils
│   │       └── distances_c.h
│   └── libfaiss_c.a
└── watchos-i386-simulator
    ├── Headers
    │   ├── AutoTune_c.h
    │   ├── Clustering_c.h
    │   ├── IndexBinary_c.h
    │   ├── IndexFlat_c.h
    │   ├── IndexIVFFlat_c.h
    │   ├── IndexIVF_c.h
    │   ├── IndexLSH_c.h
    │   ├── IndexPreTransform_c.h
    │   ├── IndexReplicas_c.h
    │   ├── IndexScalarQuantizer_c.h
    │   ├── IndexShards_c.h
    │   ├── Index_c.h
    │   ├── MetaIndexes_c.h
    │   ├── VectorTransform_c.h
    │   ├── clone_index_c.h
    │   ├── error_c.h
    │   ├── error_impl.h
    │   ├── faiss_c.h
    │   ├── impl
    │   │   └── AuxIndexStructures_c.h
    │   ├── index_factory_c.h
    │   ├── index_io_c.h
    │   ├── macros_impl.h
    │   └── utils
    │       └── distances_c.h
    └── libfaiss_c.a

29 directories, 169 files

Distribution

This package is available using following package managers.

Swift Package Manager

./Pacakage.swift points to remote release hosted on this GitHub repository. Use these instructions to add this GitHub repository.

SPM version points to both libraries FAISS in C++ and its C version FAISS_C.

Cocoapods

./FAISS.podspec and ./FAISS_C.podspec include all the specific details about the build.

In your Podfile you can add this library using this syntax:

pod 'FAISS', :git => 'https://github.com/eugenehp/faiss-mobile.git', :tag => 'v1.7.4'
pod 'FAISS_C', :git => 'https://github.com/eugenehp/faiss-mobile.git', :tag => 'v1.7.4'

Carthage

In Cartfile add following:

binary "https://raw.githubusercontent.com/eugenehp/faiss-mobile/master/carthage/faiss-static-xcframework.json" ~> 1.7.4

Slightly different for a C version:

binary "https://raw.githubusercontent.com/eugenehp/faiss-mobile/master/carthage/faiss-c-static-xcframework.json" ~> 1.7.4

Releases

Release management works using gh.

brew install gh tree

To release a draft:

./faiss.sh release

Examples

Contributing

Contributions are welcome, feel free to submit an issue or open a pull request.

License

MIT

Copyright © 2023 Eugene Hauptmann

Legal

Faiss is MIT-licensed, refer to the LICENSE file in the top level directory.

Copyright © Meta Platforms, Inc. See the Terms of Use and Privacy Policy for this project.

faiss-mobile's People

Contributors

developermindsetcom avatar eugenehp avatar jbrummack avatar jkrukowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

faiss-mobile's Issues

Swift example

Hi, can you provide an example of importing and using faiss.xcframework in a Swift project? Thank you!

A Swift example for iOS or macOS

Hi folks, thanks for creating the library. Can you give me an example of a Swift project for iOS and macOS? I've been unsuccessful so far.

Unable to build for iOS

Hi,
I want to add faiss into my project, i did an xcframework and place it into my project, i was able to add fais into my source code, but i wasn't able to build a source code

Undefined symbols for architecture arm64:
  "faiss::index_factory(int, char const*, faiss::MetricType)", referenced from:
      _faiss_index_factory in libfaiss_c.a(index_factory_c.o)
  "typeinfo for faiss::FaissException", referenced from:
      std::exception_ptr std::make_exception_ptr[abi:v15006]<faiss::FaissException>(faiss::FaissException) in libfaiss_c.a(Index_c.o)
      GCC_except_table1 in libfaiss_c.a(Index_c.o)
      GCC_except_table19 in libfaiss_c.a(Index_c.o)
      GCC_except_table20 in libfaiss_c.a(Index_c.o)
      GCC_except_table21 in libfaiss_c.a(Index_c.o)
      GCC_except_table22 in libfaiss_c.a(Index_c.o)
      GCC_except_table23 in libfaiss_c.a(Index_c.o)
      ...
  "vtable for faiss::FaissException", referenced from:
      faiss::FaissException::FaissException(faiss::FaissException const&) in libfaiss_c.a(Index_c.o)
      faiss::FaissException::~FaissException() in libfaiss_c.a(Index_c.o)
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.