FastEmbed VectorStore
A high-performance, in-memory vector store with FastEmbed integration for Python applications.
Supported Embedding Models
The library supports a wide variety of embedding models:
- BGE Models: BGEBaseENV15, BGELargeENV15, BGESmallENV15 (with quantized variants)
- Nomic Models: NomicEmbedTextV1, NomicEmbedTextV15 (with quantized variants)
- GTE Models: GTEBaseENV15, GTELargeENV15 (with quantized variants)
- Multilingual Models: MultilingualE5Small, MultilingualE5Base, MultilingualE5Large
- Specialized Models: ClipVitB32, JinaEmbeddingsV2BaseCode, ModernBertEmbedLarge
- And many more...
Installation
Prerequisites
- Python 3.8 or higher
Install from PyPI
pip install fastembed-vectorstore
From Source
- Clone the repository:
git clone https://github.com/sauravniraula/fastembed_vectorstore.git
cd fastembed_vectorstore
- Install the package:
pip install -e .
Quick Start
from fastembed_vectorstore import FastembedVectorstore, FastembedEmbeddingModel
# Initialize with a model
model = FastembedEmbeddingModel.BGESmallENV15
vectorstore = FastembedVectorstore(model)
# Optional Configurations
# vectorstore = FastembedVectorstore(
# model,
# show_download_progress=False, # default: True
# cache_directory="fastembed_cache", # default: fastembed_cache
# )
# Add documents
documents = [
"The quick brown fox jumps over the lazy dog",
"A quick brown dog jumps over the lazy fox",
"The lazy fox sleeps while the quick brown dog watches",
"Python is a programming language",
"Rust is a systems programming language"
]
# Embed and store documents
success = vectorstore.embed_documents(documents)
print(f"Documents embedded: {success}")
# Search for similar documents
query = "What is Python?"
results = vectorstore.search(query, n=3)
for doc, similarity in results:
print(f"Document: {doc}")
print(f"Similarity: {similarity:.4f}")
print("---")
# Save the vector store
vectorstore.save("my_vectorstore.json")
# Load the vector store later
loaded_vectorstore = FastembedVectorstore.load(model, "my_vectorstore.json")
# Optional Configurations
# loaded_vectorstore = FastembedVectorstore.load(
# model,
# "my_vectorstore.json",
# show_download_progress=False, # default: True
# cache_directory="fastembed_cache", # default: fastembed_cache
# )
API Reference
FastembedEmbeddingModel
Enum containing all supported embedding models. Choose based on your use case:
- Small models: Faster, lower memory usage (e.g.,
BGESmallENV15) - Base models: Balanced performance (e.g.,
BGEBaseENV15) - Large models: Higher quality embeddings (e.g.,
BGELargeENV15) - Quantized models: Reduced memory usage (e.g.,
BGESmallENV15Q)
FastembedVectorstore
Constructor
vectorstore = FastembedVectorstore(
model: FastembedEmbeddingModel,
show_download_progress: bool | None = ...,
cache_directory: str | os.PathLike[str] | None = ...,
)
Args:
model: Embedding model to use.show_download_progress: Whether to show model download progress. Defaults to True.cache_directory: Directory to cache/download model files. Defaults to./fastembed.
Methods
embed_documents(documents: List[str]) -> bool
Embeds a list of documents and stores them in the vector store.
search(query: str, n: int) -> List[Tuple[str, float]]
Searches for the most similar documents to the query. Returns a list of tuples containing (document, similarity_score).
save(path: str) -> bool
Saves the vector store to a JSON file.
load(model: FastembedEmbeddingModel, path: str) -> FastembedVectorstore
Loads a vector store from a JSON file.
Performance Considerations
- Memory Usage: All embeddings are stored in memory, so consider the size of your document collection
- Model Selection: Smaller models are faster but may have lower quality embeddings
- Batch Processing: The
embed_documentsmethod processes documents in batches for efficiency
Use Cases
- Semantic Search: Find documents similar to a query
- Document Clustering: Group similar documents together
- Recommendation Systems: Find similar items or content
- Question Answering: Retrieve relevant context for Q&A systems
- Content Discovery: Help users find related content
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Author
- Saurav Niraula - sauravniraula
- Email: developmentsaurav@gmail.com
Acknowledgments
- Built with FastEmbed for efficient text embeddings
Metadata
Release files for fastembed-vectorstore 0.5.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastembed_vectorstore-0.5.3.tar.gz | 4.8 kB | Without provenance | Details for fastembed_vectorstore-0.5.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastembed_vectorstore-0.5.3-py3-none-any.whl | Python 3 | none | any | Details for fastembed_vectorstore-0.5.3-py3-none-any.whl |
Total release size: 10.6 kB
Release files / fastembed_vectorstore-0.5.3.tar.gz
| Download URL | fastembed_vectorstore-0.5.3.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c00aa9886840d77f11e637185c34edc7ec3e1aa3e319dd4c3268141d21aec8e
|
|
BLAKE2b-256 checksum How to use checksums |
18d902b99231016586081f6f1200ebf592a64ea860b1c37403a50ad0b6c7db21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|
Release files / fastembed_vectorstore-0.5.3-py3-none-any.whl
| Download URL | fastembed_vectorstore-0.5.3-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4e3fb506fcc02c46373ad5dcac829f52a988f422f3354281622c6128bb3cc89
|
|
BLAKE2b-256 checksum How to use checksums |
3b332e28641dd141bd1002d71b8f604076f0201a675ec50ae969422ef1556230
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|
Security for fastembed-vectorstore 0.5.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.