18 Commits
Author SHA1 Message Date
Tia Lim 0f0f728166 Format faiss Python files with black (line length 80) (#5349)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5349

# this is a no-op change

Ran `black -l 80` over all tracked Python files under `fbcode/faiss/`, using line length 80 to match faiss's documented coding style (`CONTRIBUTING.md`: "80 character line length (both for C++ and Python)"). 172 files were reformatted; 28 were already compliant.

This is a pure-formatting change. `black` runs its AST-equivalence safety check on every file, so no identifiers, string/numeric values, operators, or control flow were altered — only whitespace, indentation, line wrapping, blank lines, trailing commas, and string-quote normalization (single to double quotes).

`fbcode/faiss/` is intentionally excluded from Meta's standard Python autoformatter (`arc f` / `arc lint -a` report no formatter for these paths) because it mirrors to public GitHub, so the Python had drifted out of any consistent style. The C++ is already clang-format-clean (0 of 807 files change), so this effort is Python-only. This diff brings the Python to canonical `black` formatting.

Excluded `demos/index_pq_flat_separate_codes_from_codebook.py`: it contains a Jupyter `!rm` shell-magic line and is not valid Python, so `black` cannot parse it.

This is the base of a 3-diff stack: (1) this black reformat; (2) `.flake8` alignment (max-line-length 80 + black-compatible ignores E203/W503); (3) genuine lint fixes (F401/F403/F841/B011).

Reviewed By: mnorris11

Differential Revision: D109736099

fbshipit-source-id: 9a054635766ed11aa3760a788395babd3d198abf
2026-06-29 17:29:05 -07:00
Saim-naushad 506600962f Add Python HNSW tutorial (#5260)
Summary:
This PR adds a Python HNSW tutorial corresponding to the existing C++ HNSW tutorial.

The example creates synthetic vectors, builds an IndexHNSWFlat index, runs a search, and prints the nearest-neighbor IDs and distances for the final queries.

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5260

Reviewed By: mnorris11

Differential Revision: D107272616

Pulled By: alibeklfc

fbshipit-source-id: 721d7a1a95aa79150d6cb9653bd803065c82dcd7
2026-06-03 13:28:20 -07:00
Mihai Capotă 4627695179 Fix SVS Python tutorial (#4720)
Summary:
Update naming and add missing graph degree parameters.

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4720

Reviewed By: mnorris11

Differential Revision: D89226673

Pulled By: zoeyeye

fbshipit-source-id: 11df972dcce1e04e19d81f9acf230cc4cee6e345
2025-12-16 11:09:33 -08:00
Aaron Lin a695814f4c Enable Intel ScalableVectorSearch support (#4548)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/issues/4450

This pull request introduces support for [Intel ScalableVectorSearch](https://github.com/intel/ScalableVectorSearch), integrating Intel's proprietary LVQ and LeanVec technologies in binary form. The following index types are now supported: `IndexSVSVamana`, `IndexSVSVamanaLVQ`, `IndexSVSVamanaLeanVec`, and `IndexSVSFlat`. `IndexSVSVamana` and `IndexSVSFlat` utilizes SVS open-source float32/float16/int8 implementation.

Key features and enhancements include:
- Implemented `search`, `add`, and `remove_ids`
- Implemented filter search and `range_search`
- Enabled SVS open-source fp16 and scalar quantization implementation
- Enabled factory methods
- Enabled save/load
- Enabled Python bindings
- Enable fallback mechanism that fallbacks to 8-bit scalar quantization if LVQ/LeanVec is used on non-intel hardware CPUs
- Added examples in both Python and C++ under the `tutorial/` directory
- Added `FAISS_ENABLE_SVS` flag to allows users to optionally enable SVS

TODOs:
- Support more indices such as `IndexSVSIVF` and `IndexSVSFlat` with LVQ and LeanVec
- Documentation

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4548

Reviewed By: subhadeepkaran

Differential Revision: D84713772

Pulled By: mnorris11

fbshipit-source-id: 290365eb3337f685dd46696935b621c57dad3174
2025-12-05 16:03:58 -08:00
Subhadeep Karan 451ca8429d Fix typos in documentation, tutorials, and C API (#4666)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4666

*   `for OpenMP support support` → `for OpenMP support`
*   `neccesary` → `necessary`
*   `journal= {arXiv:1702.08734},,` → `journal = {arXiv:1702.08734},`
*   `verinsion` → `version`
*   `consistency_check--config` → `consistency_check --config`
*   `etracted` → `extracted` (2 occurrences)
*   `sb` → `xb` (variable reference)
*   `statists` → `statistics`
*   `elemnts` → `elements`

Reviewed By: alibeklfc

Differential Revision: D86474214

fbshipit-source-id: f63272423b0a767f7576cd433004c87d85e2d740
2025-11-07 21:38:52 -08:00
Tarang Jain cd3699ea73 Faiss + Cuvs Example Notebook (#4434)
Summary:
Example notebook

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4434

Reviewed By: subhadeepkaran

Differential Revision: D78492311

Pulled By: mnorris11

fbshipit-source-id: a15207af2e6c7b0e9f7c8edcca5e2b504efab8c0
2025-07-17 13:43:01 -07:00
Michael Norris eff0898a13 Enable linting: lint config changes plus arc lint command (#3966)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3966

This actually enables the linting.

Manual changes:
- tools/arcanist/lint/fbsource-licenselint-config.toml
- tools/arcanist/lint/fbsource-lint-engine.toml

Automated changes:
`arc lint --apply-patches --take LICENSELINT --paths-cmd 'hg files faiss'`

Reviewed By: asadoughi

Differential Revision: D64484165

fbshipit-source-id: 4f2f6e953c94ef6ebfea8a5ae035ccfbea65ed04
2024-10-22 09:46:48 -07:00
Xiao Fu 6e423cc649 Add python tutorial on different indexs refinement and respect accuracy measurement (#3480)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3480

This tutorial summarize the methods to construct different indexs for PQFastScan refinement. It shows how the choice can impact on accuracy.

Reviewed By: junjieqi

Differential Revision: D57799598

fbshipit-source-id: a75c52c60a5217366f3361676da8f03f0c4a9feb
2024-05-27 11:55:06 -07:00
Xiao Fu 7d7fef0b58 Add FastScan refinement tutorial for python (#3469)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3469

Reviewed By: junjieqi

Differential Revision: D57650807

fbshipit-source-id: 5e642a8140455e4a3f1f21afe2f06771462e61f4
2024-05-22 09:30:18 -07:00
Xiao Fu 4489773fd4 Add tutorial for FastScan (#3465)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3465

This commit include python version of tutorial for FastScan. It includes all the parameters enabled within PQFastScan.

Reviewed By: junjieqi

Differential Revision: D57594044

fbshipit-source-id: cb12679b6fc241a654b9545c5bc7bd0517aa1813
2024-05-21 09:50:41 -07:00
Lucas Hosseini a8118acbc5 Facebook sync (May 2019) + relicense (#838)
Changelog:

- changed license: BSD+Patents -> MIT
- propagates exceptions raised in sub-indexes of IndexShards and IndexReplicas
- support for searching several inverted lists in parallel (parallel_mode != 0)
- better support for PQ codes where nbit != 8 or 16
- IVFSpectralHash implementation: spectral hash codes inside an IVF
- 6-bit per component scalar quantizer (4 and 8 bit were already supported)
- combinations of inverted lists: HStackInvertedLists and VStackInvertedLists
- configurable number of threads for OnDiskInvertedLists prefetching (including 0=no prefetch)
- more test and demo code compatible with Python 3 (print with parentheses)
- refactored benchmark code: data loading is now in a single file
2019-05-28 16:17:22 +02:00
Lucas Hosseini 16aed09c0f Make tutorial examples use dynamic linkage. (#343)
* Add shared lib target for GPU version.

* Dynamically link tutorial examples.

* Add shared lib to clean target in GPU Makefile.

* Add clean target to tutorial examples Makefile.

* Minor modifications to tutorial GPU examples.
2018-02-21 15:36:29 +01:00
Lucas Hosseini 2c9aea24e7 [WIP] Update tutorial examples (#342)
* Remove transitional print import.

* Add example for multiple GPUs in python.

* Add example on GPU in C++.

* Add example on multiple GPUs in C++.

* Add IVFFlat example on GPU in python.

* Add Makefile for C++ tutorial examples.

* Add IVF index on GPU example in C++.
2018-02-20 15:53:56 +01:00
Matthijs Douze 1a9b814873 Update 4-GPU.py 2017-12-18 19:23:30 +01:00
matthijs c4ebee7feb added tuto for GPU 2017-12-07 09:12:19 -08:00
matthijs 8e3dc6f2b0 changed license 2017-07-30 00:18:45 -07:00
matthijs 784e2facd8 Synchronization with FB version 2017-06-21
* moved most FAISS_ASSERT calls to C++ exceptions, and adjusted
  memory allocation to avoid mem leaks

* added an IndexIVFScalarQuantizer type that offers an
  intermediate compression between IVFFlat and IVFPQ

* support removal of indices in IndexIDMap / IndexFlat combination

* various fixes in GPU code
2017-06-21 09:01:06 -07:00
Matthijs Douze c670118a4e Initial commit 2017-02-22 23:26:44 +01:00