all2md.search.vector

Vector search index built on FAISS and sentence-transformers.

class all2md.search.vector.VectorIndexConfig

Bases: object

Runtime configuration for vector search.

model_name: str = 'sentence-transformers/all-MiniLM-L6-v2'
batch_size: int = 32
device: str | None = None
normalize_embeddings: bool = True
__init__(model_name: str = 'sentence-transformers/all-MiniLM-L6-v2', batch_size: int = 32, device: str | None = None, normalize_embeddings: bool = True) None
class all2md.search.vector.VectorIndex

Bases: BaseIndex

Approximate nearest-neighbour search powered by FAISS.

Create a vector index using the provided configuration options.

backend_name = 'vector'
__init__(*, config: VectorIndexConfig | None = None, index_id: str | None = None, options_snapshot: Mapping[str, object] | None = None) None

Create a vector index using the provided configuration options.

search(query: SearchQuery, *, top_k: int = 10) list[SearchResult]

Return the nearest top_k chunks to query in vector space.

save(directory: Path) None

Persist FAISS index, embeddings, and configuration to directory.

classmethod load(directory: Path) VectorIndex

Restore a vector index that was previously saved to directory.