An index is a data structure that organizes vectors so similarity search retrieves nearby items efficiently instead of comparing every vector by brute force. In FAISS, it parallels a relational-database table index: it points retrieval toward stored data. Embeddings are normalized before indexing so vectors share a common scale. section 2.1.3
Operationally, an index connects embedding preparation with retrieval:
- Create embeddings for text, choose an index compatible with the vector dimension, normalize vectors when required, and add them to the index. section 2.1.3
- Embed each query using the same preparation steps, then search for a chosen number of neighbors. section 2.1.3
- Use returned distances and vector positions to join similar results back to their source text or metadata. section 2.1.3
- In RAG, build or update indexes offline as documents change, then query them online to retrieve context for generation. section 13.2
Classifying superhero text by nearest vectors
Encode four sentences labeled spiderman, ironman, or captainamerica, add their normalized embeddings to a FAISS L2 index, and search with “He throws webs.” The nearest results are the two spiderman sentences, with their distances and original positions returned for merging with the DataFrame. section 2.1.3







