semantica.embeddings converts text and graph structures into dense vector representations:
- Provider-agnostic API: FastEmbed (default, ONNX, no GPU), Sentence-Transformers, OpenAI, BGE
- Powers semantic search, entity resolution, GraphRAG retrieval, and deduplication
GraphEmbeddingManagerembeds KG nodes and edges for graph database backends- Five pooling strategies: Mean (default), Max, CLS, Attention, Hierarchical
check_available_providers()shows which backends are installed in your environment
Why Embeddings Matter
Raw text can’t be compared mathematically. Embeddings translate meaning into geometry: two semantically similar sentences produce vectors that are close together in high-dimensional space, even when they share no words. Semantica uses embeddings for:- Semantic search: find knowledge graph nodes by meaning, not just keywords
- Entity resolution: detect that “Apple Inc.” and “Apple Computer” refer to the same entity
- Deduplication:
semantic_v2strategy measures entity similarity via embedding distance - GraphRAG retrieval: hybrid vector + graph traversal for grounded LLM answers
- Semantic chunking: detect topic shift boundaries in
TextSplitter(method="semantic_transformer")
Exported Classes
What You Get
- EmbeddingGenerator — Main entry point: provider-agnostic, handles batching automatically across all backends.
- TextEmbedder — Text-specific with automatic batching and progress tracking. Default method is FastEmbed.
- GraphEmbeddingManager — Node and edge embeddings for graph databases: Neo4j, NetworkX, FalkorDB.
- VectorEmbeddingManager — Prepare, normalize, and format embeddings for FAISS, Weaviate, Qdrant, and Milvus.
- Provider Stores —
OpenAIStore,BGEStore,FastEmbedStore, andProviderStoreFactory. - Pooling Strategies — Mean, Max, CLS, Attention, and Hierarchical: control token-to-vector aggregation.
Provider Setup
- FastEmbed (default)
- Sentence-Transformers
- BGE
- OpenAI
ONNX-accelerated local embeddings. No GPU required, no API key. Best starting point.
Default model is
BAAI/bge-small-en-v1.5. Zero cost, zero GPU, works on any machine.Getting Started
EmbeddingGenerator is the fastest path to embeddings: the default method is FastEmbed (ONNX, no GPU needed):
Quick Start
1
Install and initialize a provider
2
Generate embeddings
3
Compute similarity
4
Prepare for a vector database
Supported Models
EmbeddingGenerator
- FastEmbed (default)
- Sentence-Transformers
- OpenAI
- GPU acceleration
Constructor Parameters
Use
generator.set_text_model(method, model_name) to switch the embedding model after construction.
TextEmbedder
Direct text embedding with batch processing:TextEmbedder Constructor Parameters
Key behaviours:
- If FastEmbed or sentence-transformers is unavailable, falls back to a 128-dimensional hash-based embedding. Hash embeddings are deterministic but not semantic: do not use in production.
- Large batches are chunked internally by the underlying library to avoid OOM.
Provider Stores
Use provider stores directly when you need fine-grained control over a single backend:LlamaStore exists in the module but is a placeholder: it does not connect to Ollama and always raises ProcessingError at embed time. Do not use it in production.Pooling Strategies
Pooling aggregates a set of embeddings into a single vector: useful when you have multiple chunk embeddings to combine:- MeanPooling (default)
- MaxPooling
- CLSPooling
- HierarchicalPooling
- Strategy Comparison
GraphEmbeddingManager
Embed graph nodes and edges for storage in graph databases:"neo4j", "networkx", "falkordb"
VectorEmbeddingManager
Prepare and validate embeddings for vector database storage:"faiss", "weaviate", "qdrant", "milvus"
Common Workflows
- Batch Text Embedding
- Provider Comparison
- Graph Node Embedding
- Similarity Search
Similarity Computation
Convenience Functions
- Vector Store — Store and search the generated embeddings.
- Split — Chunk text before embedding for better retrieval quality.
- KG Module — Distance Intelligence uses graph embeddings for semantic neighbourhoods.
- Deduplication — Semantic deduplication uses embedding distance for entity resolution.
