Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:ANative Lab EvoAgentX FAISS

From Leeroopedia
Knowledge Sources
Domains RAG, Vector_Search, Infrastructure
Last Updated 2026-10-21 00:00 GMT

Overview

Python 3.10+ environment with `faiss-cpu` (1.8.0.post1), `llama-index-vector-stores-faiss`, and `numpy` for vector similarity search in RAG pipelines.

Description

This environment provides the vector store backend for RAG pipelines that use FAISS (Facebook AI Similarity Search). It wraps the LlamaIndex `FaissMapVectorStore` with an `IndexIDMap2` for ID-based vector management. Two index metrics are supported: `flat_l2` (exact L2 distance) and `ivf_flat` (inverted file with L2 quantizer for approximate search). The FAISS vector store is the default backend when `VectorStoreConfig(vector_name="faiss")` is configured.

Usage

Use this environment when the RAGEngine or StorageHandler is configured with a FAISS vector store. It is the mandatory prerequisite for running any RAG pipeline that stores and retrieves embeddings via FAISS. Install via the `rag` extra: `pip install evoagentx[rag]`.

System Requirements

Category Requirement Notes
OS Linux / macOS / Windows OS Independent
Hardware Any CPU GPU optional (faiss-gpu for large-scale)
Disk Depends on corpus size Vectors stored in memory + optional persistence
RAM Depends on vector count FAISS indices are loaded in-memory

Dependencies

System Packages

  • None OS-specific (faiss-cpu ships pre-compiled wheels)

Python Packages

  • `faiss-cpu` == 1.8.0.post1
  • `llama-index-vector-stores-faiss`
  • `llama-index` (core)
  • `numpy` >= 1.26.4
  • `sentence-transformers` (for HuggingFace embeddings)
  • `transformers` >= 4.41, < 5

Credentials

No credentials required for FAISS itself. If using OpenAI embeddings, an `OPENAI_API_KEY` is needed (see Environment:ANative_Lab_EvoAgentX_OpenAI_API).

Quick Install

# Install RAG dependencies (includes FAISS)
pip install evoagentx[rag]

# Or install FAISS components directly
pip install faiss-cpu==1.8.0.post1 llama-index-vector-stores-faiss \
    llama-index numpy>=1.26.4 sentence-transformers transformers>=4.41,<5

Code Evidence

FAISS index creation from `evoagentx/storages/vectore_stores/faiss.py:21-29`:

def _create_index(self) -> faiss.Index:
    if self.metrics == "flat_l2":
        return faiss.IndexFlatL2(self.dimensions)
    elif self.metrics == "ivf_flat":
        quantizer = faiss.IndexFlatL2(self.dimensions)
        return faiss.IndexIVFFlat(quantizer, self.dimensions, 100)
    else:
        raise ValueError(f"Unsupported FAISS index type: {self.metrics}")

Vector store wrapper from `evoagentx/storages/vectore_stores/faiss.py:11-19`:

class FaissVectorStoreWrapper(VectorStoreBase):
    def __init__(self, dimensions: int = 1536,
                 metrics: Union[Literal["flat_l2", "ivf_flat"]] = "flat_l2", **kwargs):
        self.dimensions = dimensions
        self.metrics = metrics
        self.faiss_index = self._create_index()
        self.vector_store = FaissMapVectorStore(faiss_index=faiss.IndexIDMap2(self.faiss_index))

Dependency pin from `pyproject.toml:55`:

"faiss-cpu==1.8.0.post1"

Common Errors

Error Message Cause Solution
`Unsupported FAISS index type: xxx` Invalid metrics value Use `flat_l2` or `ivf_flat`
`ModuleNotFoundError: No module named 'faiss'` faiss-cpu not installed `pip install faiss-cpu==1.8.0.post1`
`ImportError: cannot import name 'FaissMapVectorStore'` llama-index-vector-stores-faiss not installed `pip install llama-index-vector-stores-faiss`

Compatibility Notes

  • faiss-gpu: For GPU-accelerated search, replace `faiss-cpu` with `faiss-gpu`. The API is compatible.
  • Dimensions: Default is 1536 (OpenAI `text-embedding-ada-002`). Must match the embedding model's output dimension.
  • IVF index: The `ivf_flat` metric uses 100 clusters by default. The index must be trained before adding vectors.
  • Deduplication: The `aload` method checks `_node_id_to_faiss_id_map` to skip duplicate node insertions.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment