Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Facebook's library for efficient similarity search and clustering of dense vectors. Supports billions of vectors, GPU acceleration, and various index types (Flat, IVF, HNSW). Use for fast k-NN search, large-scale vector retrieval, or when you need pure similarity search without metadata. Best for high-performance applications.
.claude/skills/openlair-faiss/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 39% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 128% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 86% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 16% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 101% | 0% |
Facebook AI's library for billion-scale vector similarity search.
Use FAISS when:
Metrics:
Use alternatives instead:
bash# CPU only pip install faiss-cpu # GPU support pip install faiss-gpu
pythonimport faiss import numpy as np # Create sample data (1000 vectors, 128 dimensions) d = 128 nb = 1000 vectors = np.random.random((nb, d)).astype('float32') # Create index index = faiss.IndexFlatL2(d) # L2 distance index.add(vectors) # Add vectors # Search k = 5 # Find 5 nearest neighbors query = np.random.random((1, d)).astype('float32') distances, indices = index.search(query, k) print(f"Nearest neighbors: {indices}") print(f"Distances: {distances}")
python# L2 (Euclidean) distance index = faiss.IndexFlatL2(d) # Inner product (cosine similarity if normalized) index = faiss.IndexFlatIP(d) # Slowest, most accurate
python# Create quantizer quantizer = faiss.IndexFlatL2(d) # IVF index with 100 clusters nlist = 100 index = faiss.IndexIVFFlat(quantizer, d, nlist) # Train on data index.train(vectors) # Add vectors index.add(vectors) # Search (nprobe = clusters to search) index.nprobe = 10 distances, indices = index.search(query, k)
python# HNSW index M = 32 # Number of connections per layer index = faiss.IndexHNSWFlat(d, M) # No training needed index.add(vectors) # Search distances, indices = index.search(query, k)
python# PQ reduces memory by 16-32× m = 8 # Number of subquantizers nbits = 8 index = faiss.IndexPQ(d, m, nbits) # Train and add index.train(vectors) index.add(vectors)
python# Save index faiss.write_index(index, "large.index") # Load index index = faiss.read_index("large.index") # Continue using distances, indices = index.search(query, k)
python# Single GPU res = faiss.StandardGpuResources() index_cpu = faiss.IndexFlatL2(d) index_gpu = faiss.index_cpu_to_gpu(res, 0, index_cpu) # GPU 0 # Multi-GPU index_gpu = faiss.index_cpu_to_all_gpus(index_cpu) # 10-100× faster than CPU
pythonfrom langchain_community.vectorstores import FAISS from langchain_openai import OpenAIEmbeddings # Create FAISS vector store vectorstore = FAISS.from_documents(docs, OpenAIEmbeddings()) # Save vectorstore.save_local("faiss_index") # Load vectorstore = FAISS.load_local( "faiss_index", OpenAIEmbeddings(), allow_dangerous_deserialization=True ) # Search results = vectorstore.similarity_search("query", k=5)
pythonfrom llama_index.vector_stores.faiss import FaissVectorStore import faiss # Create FAISS index d = 1536 faiss_index = faiss.IndexFlatL2(d) vector_store = FaissVectorStore(faiss_index=faiss_index)
| Index Type | Build Time | Search Time | Memory | Accuracy | |------------|------------|-------------|--------|----------| | Flat | Fast | Slow | High | 100% | | IVF | Medium | Fast | Medium | 95-99% | | HNSW | Slow | Fastest | High | 99% | | PQ | Medium | Fast | Low | 90-95% |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-05 | pass→pass | 6,790 | 4,936 | -27% | 1 | 1 | 0% | 1,326 | 2,466 | +86% | 0 | 0 | — |
case-01 | pass→pass | 16,973 | 13,998 | -18% | 1 | 1 | 0% | 3,156 | 3,669 | +16% | 0 | 0 | — |
case-02 | pass→pass | 7,500 | 7,181 | -4% | 1 | 1 | 0% | 1,366 | 2,744 | +101% | 0 | 0 | — |
case-03 | fail→pass | 14,746 | 13,645 | -7% | 1 | 1 | 0% | 2,885 | 4,000 | +39% | 0 | 0 | — |
case-04 | pass→pass | 4,283 | 3,784 | -12% | 1 | 1 | 0% | 858 | 2,198 | +156% | 0 | 0 | — |
case-06 | pass→pass | 3,131 | 3,059 | -2% | 1 | 1 | 0% | 590 | 1,958 | +232% | 0 | 0 | — |
case-07 | pass→pass | 2,756 | 2,768 | +0% | 1 | 1 | 0% | 449 | 1,888 | +320% | 0 | 0 | — |
case-08 | fail→pass | 5,240 | 4,199 | -20% | 1 | 1 | 0% | 1,007 | 2,291 | +128% | 0 | 0 | — |
case-09 | pass→pass | 7,191 | 8,636 | +20% | 1 | 1 | 0% | 1,422 | 3,137 | +121% | 0 | 0 | — |
case-10 | pass→pass | 5,523 | 1,890 | -66% | 1 | 1 | 0% | 1,075 | 1,718 | +60% | 0 | 0 | — |
case-11 | pass→pass | 3,249 | 3,100 | -5% | 1 | 1 | 0% | 631 | 1,826 | +189% | 0 | 0 | — |
case-12 | pass→pass | 5,713 | 4,060 | -29% | 1 | 1 | 0% | 1,082 | 2,099 | +94% | 0 | 0 | — |
case-13 | pass→pass | 3,508 | 3,601 | +3% | 1 | 1 | 0% | 484 | 2,002 | +314% | 0 | 0 | — |
case-14 | pass→pass | 5,744 | 3,995 | -30% | 1 | 1 | 0% | 1,223 | 2,248 | +84% | 0 | 0 | — |
case-15 | pass→pass | 4,955 | 4,174 | -16% | 1 | 1 | 0% | 917 | 2,221 | +142% | 0 | 0 | — |
case-16 | pass→pass | 4,495 | 2,689 | -40% | 1 | 1 | 0% | 768 | 1,884 | +145% | 0 | 0 | — |
case-17 | pass→pass | 4,788 | 3,983 | -17% | 1 | 1 | 0% | 989 | 2,178 | +120% | 0 | 0 | — |
case-18 | pass→pass | 3,794 | 4,366 | +15% | 1 | 1 | 0% | 697 | 2,217 | +218% | 0 | 0 | — |
case-19 | pass→pass | 2,718 | 2,245 | -17% | 1 | 1 | 0% | 504 | 1,780 | +253% | 0 | 0 | — |
case-20 | pass→pass | 9,294 | 2,514 | -73% | 1 | 1 | 0% | 1,733 | 1,832 | +6% | 0 | 0 | — |
case-21 | pass→pass | 11,073 | 9,743 | -12% | 1 | 1 | 0% | 1,780 | 3,088 | +73% | 0 | 0 | — |
case-22 | pass→pass | 10,033 | 6,928 | -31% | 1 | 1 | 0% | 1,668 | 2,718 | +63% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.