faiss

facebookresearchMIT活跃维护

面向稠密向量的高效相似度检索与聚类库,支持十亿级向量近邻搜索,是构建向量数据库和 RAG 检索层的底层引擎。

A library for efficient similarity search and clustering of dense vectors.

v1.15.1发布于 2026-09-16 19:24 UTC41,307star +46 / 7 天4,590fork同步于 2026-11-10 11:19 UTC

怎么上手

由 README 提炼,执行前请确认
conda install -c pytorch faiss-cpu
硬件要求按 README 说明

README 未说明具体显存要求;可选 GPU 支持通过 CUDA 或 AMD ROCm 提供,也支持 NVIDIA cuVS 后端;CPU 版本仅依赖 BLAS 实现即可运行。

需要 CUDA支持 ROCm / AMD多卡 / 张量并行
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Meta 开源的稠密向量相似度搜索与聚类库,支持十亿级向量检索

面向稠密向量的高效相似度检索与聚类库,支持十亿级向量近邻搜索,是构建向量数据库和 RAG 检索层的底层引擎。

核心能力

  • 支持 L2 距离、点积与余弦相似度的近邻搜索
  • 提供二值向量与量化编码压缩索引,单机可扩展到十亿级
  • HNSW、NSG 等图索引在原始向量上加速检索
  • GPU 索引可替换 CPU 索引,支持单卡与多卡
  • C++ 实现并提供完整的 Python/numpy 封装

容易踩的坑

CPU 与 GPU 版本是分开的 conda 包(faiss-cpu / faiss-gpu),需按硬件选择;GPU 支持需自行准备 CUDA 或 ROCm 环境;部分压缩索引需要先用无监督数据训练后才能添加向量。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.15.1
  1. v1.15.1最新正式版2026-09-16 · 2026-09-16 19:24 UTC

    See CHANGELOG.md for the full list of changes.

  2. v1.15.02026-08-03 · 2026-08-03 17:10 UTC
    查看更新说明

    [1.15.0] - 2026-07-31

    Full changelog

    Added

    • 4332ceb99492e3ba4ce09aada9bd9e48dc4e2f0b Enable byte-LUT gather path for QT_8bit_eden distance computation (#5498)
    • 41133fde4222a8862650601d85f9af684314ebc8 Add EDEN quantizer indexes (#5278)
    • 3110fd242458bf1458507d9d281847543e3b4d92 Add MetalIndexIVFPQ with product quantization and residual encoding support (#5288)
    • 6c2b68775a21a24870f7fd10788ebc4ec0582650 Adding cuVS IVF-SQ backend (#5306)
    • 4d778bc595917de51a0e76de8351984b8bd8203f Add multi-GPU CAGRA → HNSW build with trainAllNeighbors and multi-GPU optimize (#5282)
    • 42dc2862c293b7c7f788be686cf6c9ac93abf6cf Implement memory-mapped I/O for Flat and static Vamana SVS indices (#5271)
    • d22107beca7a6db4ff146700b19d507e52b595b1 feat(riscv): Add RISC-V RVV rabitq kernels (#5369)
    • df51012a606bc352058e95fe58d45b348ffb201a feat(riscv): Add RISC-V RVV vector distance kernels (#5354)
    • 3b52da37c40973d4816ff7d2a4e3fb9f74379988 Add AVX2 and AVX512 byte-domain kernels for QT_8bit_direct_signed (#5409)
    • 88b6c47cf514d3bee7d1995c09a39234fa89d8f9 Implement IVFRaBitQ FastScan conversion constructor (#5422)
    • d24cc844d2cabce819cda806217b243177293e09 Implement GPU IVF add_preassigned via add_core (implement #3908) (#5372)
    • 5826578a7e8f3f9e45bdb74df0c504c242dfdba0 Read/Write support for IndexHNSW base class (#5305)
    • a3350f6641f85d1e2d08fa191863bde6be470df9 faiss: support METRIC_L1 and extra metrics in IndexFlat range_search (#5391)
    • 432e8b4248c2778b5023d5e2ac15b264ec120d02 Extend DistanceComputer batching to PQ, SQ, and PreTransform (#5309)
    • 7d4bb39f7eb3e9bb4d160aa38ec821ee1a407afc Extract super_kmeans_assign_iteration as a shared public SuperKMeans kernel (#5443)
    • aff8589c9e1c2d6ee6a0de615aa719a9a4fd6e86 c_api: expose ScalarQuantizer codec and complete FaissQuantizerType enum (#5477)
    • 13aa39b7916824bc09ca6af7b5e241c2cba68f6d Clone index support for HadamardRotation (#5475)
    • 3e313e4c496b6a042b71193fe0bd9dd713efc7a2 SIMDConfig::has_dynamic_dispatch() (#5460)
    • a6f97750aeaf760c72d0526c3a346513823c4a0c Add faiss-gpu-cuvs pip wheel packaging (#5250)
    • 6227323ffd0341679299ba9a8e71cac1e15674ee pyfaiss_gpu_cuvs_2602: cuVS faiss Python for aarch64/GH200 (26.02, CUDA 12.4)
    • 522644cb2b7a29737fe669b263eccb946217dc93 Stand up parallel cuVS 26.02 IVF-PQ targets (rmm/raft/cuvs) at CUDA 12.8 (#5414)
    • edebabf90fe79829ede6eaa02f3d9a78d3008a5b Include Python type stubs (init.pyi, py.typed) in conda packages (#5394)
    • 9579d8f0a4dbc91bd7ce195ef0aceb937c89159e Add type stubs for SVS index classes + IndexIVFFlatPanorama.batch_size (#5489)
    • fd7be0cfb0c8cee0d475bb6285ad996a87ebf917 Add QT_0bit and QT_2bit_tq..QT_5bit_tq to ScalarQuantizer pyi stub (#5323)
    • ccecc847db5e1d20e929cf8df4a8ddb654769890 Add ClusteringInitMethod enum constants to init.pyi stub (#5324)
    • 55990eb91f9042d811a76d72e43f9ca126d77beb Port test_rabitq_utils from C++ to Python (#5442)

    Changed

    • 0236390f2fd8e63ff5e4c6d4ca981b7ba032cd17 Optimize RaBitQ fastscan query setup + 80% qps (#5396)
    • b1d61c3b883fb82063e024979404dd6ebe134eca Fuse RaBitQ AND-dot and popcount scan (#5412)
    • 81031a97892896ca9167e5203e27420de4617e67 RaBitQ fastscan avx512 lut quant (#5397)
    • b7f2b0f1fd8d62e902bdcdcb9ae9694a6fd8f792 RaBitQ SIMD-optimized bit-plane operation (#5392)
    • 0a27700e05429e60221b0eccbf50c4a79ad2e450 Reuse RaBitQ IVF scanner distance computer (#5390)
    • a3d59f0999c69015eeff54fdde3e0d051798179e faiss DD: use 256-bit fast-scan QBS kernel on AMD Zen 4 (split AVX-512) (#5488)
    • c374dd917b75c8b1fef56e487d26e18d3aae5605 Panorama HNSW Optimizations (~x1.2) (#5190)
    • cb9a72ac03f4e7f7d563e3e54ab4e86b8ce1af12 Reuse the HNSW visited table across searches instead of reallocating per call (#5448)
    • 4d1657471f8590ccadf5c2f37d6b58999b8010ec Raise HNSW visited-table hash-set threshold from 500k to 10M (#5446)
    • a4b4c0f2de14d30719e0750e40922e47517eaa80 Optimize exhaustive_L2sqr_blas_cmax with AVX-512 intrinsics. (#4569)
    • 4a2f7e63280ec095bb16dbf0d8e837b2ab79c27f
  3. v1.14.32026-06-13 · 2026-06-13 04:03 UTC
    查看更新说明

    Highlights

    • Metal GPU backend expansion — new MetalIndexIVFFlat with IVF scan/merge kernels and expanded top-k support (#5202); Metal now enabled by default on Apple Silicon machines (#5280)
    • TurboQuant in ScalarQuantizer — full Algorithm 2 (QJL stage) with SIMD and optimizations (#5170)
    • Sapphire Rapids (SPR) optimizations — ScalarQuantizer L2/IP (#5173), VPOPCNTDQ-based HammingComputer (#5183), and VPOPCNTDQ-based RaBitQ kernel (#5149)
    • faiss-gpu pip wheels — new GPU wheel packaging (#5131); musllinux wheels re-enabled for faiss-cpu (#5299)
    • SVS static vamana support (#5224)
    • HNSW is_similarity mode for IP/similarity metrics (#5246, #5226)
    • HNSW search performance — reserve VisitedTableSet capacity to avoid rehashes (#5290), search_from_candidate_unbounded templatized for VisitedTable devirtualization (#5270), and runtime checks avoided in VisitedTable (#5234)
    • NEON FINE_SIZE=2 specializations for Index2LevelDecoderImpl and IndexPQDecoder (#5255)
    • cuVS upgraded to 26.06 (#5240); CI updated to ROCm 7 (#5196)
    • Deserialization hardening — bool-field validation (#5279) and null inner-index rejection in IDMap / BinaryFromFloat (#5239)
    • Build robustness — fix non-AVX2 import SIGILL via .rodata partitioning tables (#5298), Windows ARM64 (MSVC) NEON build fix (#5274), and AVX512_SPR dispatch fix on AMD (#5281)

    Full Changelog

    Added

    • 261d8f25aac03c980f1faf5df775248eff96cb6d Add IVFSQTurboQSearchParameters to init.pyi stub (#5304)
    • 684a32d0404758bddd4f7fb9ec76db54252819e0 Add manual Faiss nightly workflow dispatch (#5300)
    • 10b6b2a1e554afc4cbd66fe73d864728ff9e310c Add MetalIndexIVFFlat with IVF scan/merge kernels and expanded top-k support (#5202)
    • 74d36198faac528fce715aa8731bf589727bef6d TurboQuant in ScalarQuantizer: full Algorithm 2 (QJL stage) with SIMD and optimizations (#5170)
    • 506600962f8a58926710edd24715bc9002eb18e9 Add Python HNSW tutorial (#5260)
    • 3cff0f419c459bdc7c4f56ea49effb6d7da1475c Add Sapphire Rapids optimizations for ScalarQuantizer (L2, IP) (#5173)
    • 46ef80db639e4de03720e3c404065636846ed47e Support IndexIDMap/IndexIDMap2 in reverse_index_factory (#5266)
    • 420158b10e0136228ff634d464fa90c4370a1ead Add VPOPCNTDQ-based HammingComputer for Sapphire Rapids+ (#5183)
    • d8f1c2716d9c2c070c0d7e4e0c1017331e9e9e8a Implement NEON-based FINE_SIZE=2 specializations for Index2LevelDecoderImpl and IndexPQDecoder (#5262)
    • 0951b5337b72755ade5c02705396fb7d7cedceac Support user provided blas library (#5189)
    • 215740ecc3add92d7c27e24436b2dffd8fdb157c SVS static vamana support (#5224)
    • d24ad6ef5b3e40c0e4cf8b695923cbcd674d2573 Add is_similarity mode to HNSW (#5246)
    • aa332cd5f0d6984075c849b32c387fffe067a49a Implement NEON-based FINE_SIZE=2 specializations for Index2LevelDecoderImpl and IndexPQDecoder (#5255)
    • 5d9aae6ee81078d33ff3c4e2fc97f7583e2e450d Add faiss-gpu pip wheel packaging (#5131)
    • 6f1cf64531130db04843737d1f538999fc295583 Add VPOPCNTDQ-based RaBitQ kernel for Sapphire Rapids+ (#5149)

    Changed

    • 262fc3c7a2ec099cdd0cd21482931702171c60eb Re-enable musllinux wheels for faiss-cpu (#5299)
    • 1cdc3709c656eea41ce3725024070f2516e3b30b Run CI on push to main to refresh ccache cache (#5291)
    • 379ee758b1bb49cd167c6ed86e80be331e94c593 Reserve VisitedTableSet capacity to avoid rehashes during HNSW search (#5290)
    • 6513a2497cbc29f5c0c74c0d17bbe8b9f6ff3230 Enable Metal by default on Apple machines (#5280)
    • fe46c3c804296cc04238c2e17b02c671887791a8 Validate bool fields during deserialization (#5279)
    • 480f91790080c8daa92fcb1941c5e8d0f56de237 Type imbalance_factor and wire the .pyi stub into the buck build (#5269)
    • e60baeb7b61e617a483310fccb239ba204458c7b Templatize search_from_candidate_unbounded for VisitedTable devirtualization (#5270)
    • c000190dc07c161898093a72a16f3918bd9fd621 Accelerate ScalarQuantizer::QT_bf16 with AVX512-BF16. (#4889)
    • 7504fc8ddebdade7fcabd9dacd9861318d475b50 Upgrade CUVS Version to 26.06 (#5240)
    • d12683c3b00247ca6333ac717f3a
  4. v1.14.22026-05-22 · 2026-05-22 20:05 UTC
    查看更新说明

    Highlights

    • SuperKMeans — faster k-means via ADSampling + PDX progressive pruning (#5168)
    • Metal GPU backend for Apple Silicon, starting with IndexFlat (#5144)
    • RVV (RISC-V Vector) SIMD backend + RISC-V cross-compilation CI (#5156, #5184)
    • pip install support via scikit-build-core + cibuildwheel (#4862)
    • SVS IVF index enabled; SVS upgraded to 0.3.0 (#4801, #4999); SVSVamana usable as IVF coarse quantizer via index_factory (#5175)
    • TurboQuant (CPU) quantizer (#5049)
    • HNSW improvements — optional persistent locks for incremental adds (#5031), prune_headroom to avoid O(n²) pruning (#4847), narrower add-time critical section (#4915)
    • Extensive index deserialization hardening — validation and OOM/overflow protection across ~40 PRs (binary, IVF, HNSW, FastScan, ScalarQuantizer, AdditiveQuantizer, ProductQuantizer, SVS, VectorTransform, …)
    • Major Dynamic Dispatch refactor across distances, hamming, partitioning, RaBitQ, FastScan; dynamic dispatch now builds on Windows (#5127)
    • cuVS upgraded to 26.02 (#4945, #4788); CI moved to CUDA 13.2 (#5207); C++20 for cuVS (#4881); filtered search for cuVS indexes (#4858)
    • OMP exception safety across IndexHNSW, IndexNNDescent, IndexNSG, IndexFlatCodes, IndexIVF (#5106, #5105, #5111, #5133, #5037, #5053)

    Full Changelog

    Added

    • b7618fadc7fdf9b677277fbe96864c1902a6d8dc Add SuperKMeans: faster k-means via ADSampling+PDX progressive pruning (#5168)
    • 66c9d082651659fb6e78d67c547b035d3c2c8228 Add SuperKMeans foundations: math primitives, PDX layout, SIMD kernels
    • dc7afcfdf0d4bf7cc694f4974db77e471422d4cb Support SVSVamana as IVF coarse quantizer via index_factory (#5175)
    • 7a8e4ddaca3d25363a79942e9fcd26de78436607 CI: cross-compile for riscv64 with RVV dynamic dispatch (#5184)
    • 03202795b6451f2c6942262c998de3b980e96157 Introduce RVV (#5156)
    • 417c53e0ce23e8c3f2843bc727c9493e35b1d5d0 Add NoneSIMDLevel context manager for cross-level reference checks (#5158)
    • 46def46902231ed57552ddbcfd751e17720c6d32 Enable SVS IVF Index in FAISS (#4801)
    • 585ba7954afb4da180a897bf195acd7516a44632 Add pip install support via scikit-build-core + cibuildwheel (#4862)
    • 799bf3aaeca910113fd2f1b0287568f07eb002fa Introduce early stop facilities for IVF, attempt 2 (#5160)
    • 66cea524339ee7cd1b3954e3b5a677edb2adad74 Add Metal GPU backend for Apple Silicon (IndexFlat) (#5144)
    • 17fd3332c77c2801da4b467de67b5cadf045b328 Add database-parallel flat search for few-query workloads (#5000)
    • c7f07bbc0ad0e9c0b68c6c7a3696850f42500906 Add C++ per-SIMD-level tests for distance utility functions (#5154)
    • 0242758a3d073be0f5b0117b524a1fbdfcf02860 Add bit-exact RQ encode cross-level test (#5155)
    • 2f68a3730777f88da34d562bc90f637bb39c1cb3 Add per-SIMD-level tests for hamming.h utils + fix crosshamming bug (#5153)
    • a7116ed4ec2ab4f0889d305592f579d5b2fb5745 Add TurboQuant (CPU) (#5049)
    • 11e5d3916054b23bf60253763abf5e9033fca39e Add optional persistent locks to IndexHNSW for incremental adds (#5031)
    • e82aa28b838d1cad66044c3888b75eb832a39fb4 Add OMP exception capture helpers and migrate IndexIVF (#5111)
    • 6299bff1f60e5423fa8cfe8e8d3926f8d87bdafb Add QT_0bit to ScalarQuantizer for centroid-only IVF distance (#5079)
    • 3030fe0635b743ccfddf3684752438269a5ab0c5 Add filtered search for cuVS indexes (#4858)
    • f83ea51eaa60987315fcd2deca153924abd7995d Support IVFRaBitQSearchParameters in RaBitQFastScan scanner (#5081)
    • 82a823513d8a7a7e497de11e7da0cba2aae7721d Add iterator callbacks for distance computation and heap admission (#5082)
    • b068fd985a7460c04ec6c4f909900409392520d0 Support IO_FLAG_MMAP_IFC on Darwin (#5058)
    • 113bf6ceac4e9d1bfeaf29279b29a8293759f83b Expose fast_scan_code_size from non-IVF FastScan indices (#5077)
    • 786d993dbfb8b74b2a0d4d9543b2b08310acabbe Expose a fast scan code size from fast scan indices (#5064)
    • 95f1e45221ede8caf1b0139a3c8864d473e0e47d OMP build diagnostics (#4842)
    • c4ac852e5b5aa2ba4bde8a977633c367aa85d5db Add a balanced assignment function
  5. v1.14.12026-03-06 · 2026-03-06 17:49 UTC
    查看更新说明

    [1.14.0] - 2026-03-06

    Added

    • 6cf2c63bc3953c31476a7e0330e61d09d79c96d9 Update SVS to v0.2.0 and install from conda forge (#4860)
    • 1cb3d4653f43f546bcab5c6798acf835f1bf05b9 feat(svs): LeanVec OOD support (#4773)
    • 5cf2c4203f0e52f67504f154ae4dbea84906bc1f Expose IndexBinaryFlat to the C API. (#4834)
    • db9ba35118d5230f92d466e17e19f5019ff8601d add hadamard transformation as an index for IVF (#4856)

    Changed

    • c8579de513a02198e90c6a9defb42e2900240fe7 Try to force relative import statement (#4878)
    • 471ddad72cb617dcce9f11966ed991a71609d49b Increment to next release, v1.14.1 (#4861)
    • c90c9dc544a8a82108d6499d7fafb3c3dc6fda2f Update python to include 3.13 and 3.14 (#4859)
    • 8af77fe730f141d58fa7b0de8d3a33663e8c4b23 SIMD-optimize multi-bit RaBitQ inner product (#4850)
    • ccc934f58660f42da677d5c253b550e61b153d5f ScalarQuantizer: split SIMD specializations into per-SIMD TUs + DD dispatch (#4839)

    Fixed

    • 5622e93733b64b2e033362dbdfda019b2ab33ef0 (HEAD -> main, origin/main, origin/HEAD) v1.14.1 Fix build-release (#4876)
    • 8431e04f88c22b59f769a94cb7415dc56756e32d Replace squared-distance IP with direct dot-product in multi-bit RaBitQ (#4877)
    • 28f79bd98efcb00c2bbf50a7eb30abc507ae49b6 Fix SWIG 4.4 multi-phase init: replace import_array() with import_array1(-1) (#4846)

    Deprecated

    • d2f8d3514003986ec9ed37c9b29d70818ccf686a removed conda-forge install documentation (#4843)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Faiss

    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. Some of the most useful algorithms are implemented on the GPU. It is developed primarily at Meta's Fundamental AI Research group.

    News

    See CHANGELOG.md for detailed information about latest features.

    Introduction

    Faiss contains several methods for similarity search. It assumes that the instances are represented as vectors and are identified by an integer, and that the vectors can be compared with L2 (Euclidean) distances or dot products. Vectors that are similar to a query vector are those that have the lowest L2 distance or the highest dot product with the query vector. It also supports cosine similarity, since this is a dot product on normalized vectors.

    Some of the methods, like those based on binary vectors and compact quantization codes, solely use a compressed representation of the vectors and do not require to keep the original vectors. This generally comes at the cost of a less precise search but these methods can scale to billions of vectors in main memory on a single server. Other methods, like HNSW and NSG add an indexing structure on top of the raw vectors to make searching more efficient.

    The GPU implementation can accept input from either CPU or GPU memory. On a server with GPUs, the GPU indexes can be used a drop-in replacement for the CPU indexes (e.g., replace IndexFlatL2 with GpuIndexFlatL2) and copies to/from GPU memory are handled automatically. Results will be faster however if both input and output remain resident on the GPU. Both single and multi-GPU usage is supported.

    Installing

    Faiss comes with precompiled libraries for Anaconda in Python, see faiss-cpu, faiss-gpu and faiss-gpu-cuvs. The library is mostly implemented in C++, the only dependency is a BLAS implementation. Optional GPU support is provided via CUDA or AMD ROCm, and the Python interface is also optional. The backend GPU implementations of NVIDIA cuVS can also be enabled optionally. It compiles with cmake. See INSTALL.md for details.

    How Faiss works

    Faiss is built around an index type that stores a set of vectors, and provides a function to search in them with L2 and/or dot product vector comparison. Some index types are simple baselines, such as exact search. Most of the available indexing structures correspond to various trade-offs with respect to

    • search time
    • search quality
    • memory used per index vector
    • training time
    • adding time
    • need for external data for unsupervised training

    The optional GPU implementation provides what is likely (as of March 2017) the fastest exact and approximate (compressed-domain) nearest neighbor search implementation for high-dimensional vectors, fastest Lloyd's k-means, and fastest small k-selection algorithm known. The implementation is detailed here.

    Full documentation of Faiss

    The following are entry points for documentation:

    Authors

    The main authors of Faiss are:

    • Hervé Jégou initiated the Faiss project and wrote its first implementation
    • Matthijs Douze implemented most of the CPU Faiss
    • Jeff Johnson implemented all of the GPU Faiss
    • Lucas Hosseini implemented the binary indexes and the build system
    • Chengqi Deng implemented NSG, NNdescent and much of the additive quantization code.
    • Alexandr Guzhva many optimizations: SIMD, memory allocation and layout, fast decoding kernels for vector codecs, etc.
    • Gergely Szilvasy build system, benchmarking framework.

    Reference

    References to cite when you use Faiss in a research paper:

    @article{douze2024faiss,
          title={The Faiss library},
          author={Matthijs Douze and Alexandr Guzhva and Chengqi Deng and Jeff Johnson and Gergely Szilvasy and Pierre-Emmanuel Mazaré and Maria Lomeli and Lucas Hosseini and Hervé Jégou},
          year={2024},
          eprint={2401.08281},
          archivePrefix={arXiv},
          primaryClass={cs.LG}
    }
    

    For the GPU version of Faiss, please cite:

    @article{johnson2019billion,
      title={Billion-scale similarity search with {GPUs}},
      author={Johnson, Jeff and Douze, Matthijs and J{\'e}gou, Herv{\'e}},
      journal={IEEE Transactions on Big Data},
      volume={7},
      number={3},
      pages={535--547},
      year={2019},
      publisher={IEEE}
    }
    

    Join the Faiss community

    For public discussion of Faiss or for questions, visit https://github.com/facebookresearch/faiss/discussions.

    We monitor the issues page of the repository. You can report bugs, ask questions, etc.

    Legal

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

    Copyright © Meta Platforms, Inc.