A lightweight, self-contained text embedding microservice for Baserow's AI Assistant features. This service provides fast sentence embeddings using an ONNX-optimized model.
This service converts text into dense vector representations (embeddings) that can be used for:
- Semantic search and similarity matching
- Document retrieval for RAG (Retrieval-Augmented Generation)
- Finding relevant database rows based on natural language queries
- Clustering and classification tasks
Model: sentence-transformers/all-MiniLM-L6-v2
- Embedding dimension: 384
- Optimized for semantic similarity tasks
- Converted to ONNX format for faster inference
- Compact size with good performance trade-off
The service uses a multi-stage Docker build:
- Builder stage: Downloads the model and converts it to ONNX format
- Runtime stage: Minimal Python image with only runtime dependencies
- Result: Small, production-ready container (~500MB)
- ONNX Runtime: 2-3x faster inference compared to PyTorch
- Mean pooling: Converts token embeddings to sentence embeddings
- L2 normalization: Enables cosine similarity via dot product
- Batch support: Process multiple texts in a single request
- Health checks: Built-in health endpoint for monitoring
docker run -p 8080:80 baserow/embeddings:1.0.0
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t baserow/embeddings:1.0.0 \
-t baserow/embeddings:latest \
--push .
Generate embeddings for one or more texts.
Request:
{
"texts": "Your text here"
}or for batching:
{
"texts": ["First text", "Second text", "Third text"]
}Response:
{
"embeddings": [[0.123, -0.456, ...], ...]
}Example:
curl -X POST http://localhost:8080/embed \
-H "Content-Type: application/json" \
-d '{"texts": "What is the capital of France?"}'Health check endpoint.
Response:
{
"status": "healthy"
}docker build -t baserow-embeddings .docker run -p 8080:80 baserow-embeddingsThe service will be available at http://localhost:8080.
# Install dependencies
pip install optimum[onnxruntime]==1.27.0 transformers==4.53.0 starlette==0.48.0 uvicorn==0.37.0
# Download model
python -c "
from optimum.onnxruntime import ORTModelForFeatureExtraction
from transformers import AutoTokenizer
model = ORTModelForFeatureExtraction.from_pretrained('sentence-transformers/all-MiniLM-L6-v2', export=True)
tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
model.save_pretrained('./model')
tokenizer.save_pretrained('./model')
"
# Run locally
uvicorn app:app --host 0.0.0.0 --port 8080import requests
response = requests.post('http://localhost:8080/embed', json={
'text': ['Hello world', 'How are you?']
})
embeddings = response.json()['embeddings']
print(f"Generated {len(embeddings)} embeddings of dimension {len(embeddings[0])}")This service is used by Baserow's AI Assistant to:
- Index database content: Convert rows into searchable embeddings
- Semantic search: Find relevant rows based on user questions
- Context retrieval: Provide relevant data to the LLM for answering questions
The embeddings enable the assistant to understand the semantic meaning of user queries and match them with the most relevant database records, even when there's no exact keyword match.
- Inference time: ~10-30ms per text on CPU
- Batch processing: More efficient for multiple texts
- Memory usage: ~200MB RAM
- Throughput: ~100-300 requests/second (CPU-dependent)
- Python 3.14
- optimum[onnxruntime] 1.27.0
- transformers 4.53.0
- starlette 0.48.0
- uvicorn 0.37.0
This service is part of the Baserow project. See the main repository for license information.