A lightweight REST API service that provides sentence embeddings using the all-MiniLM-L6-v2 model.
- Fast and efficient sentence embeddings
- Async REST API using Axum
- Multi-architecture support (x86_64 and ARM)
- Health check endpoint
- Containerized deployment
- Pre-downloaded model for faster startup
You have a docker image available on GitHub Container Registry.
You can pull it using the following command:
docker pull ghcr.io/wosherco/all-minilm-l6-v2-restapi-service:latestCheckout the example docker-compose.yml file to see how to use it.
Generate embeddings for a given text.
Request:
{
"text": "This is a sample sentence to embed"
}Response:
{
"embedding": [0.123, -0.456, ...] // 384-dimensional vector
}Check the service health status.
Response:
{
"status": "ok",
"version": "0.1.0"
}- Build the image (this will download the model during build):
docker build -t embedding-service .- Run the container:
docker run -p 3000:3000 embedding-serviceThe container will start immediately with the model pre-loaded, no need to download it on first run.
You can test the service using curl:
# Health check
curl http://localhost:3000/health
# Response:
# {
# "status": "ok",
# "version": "0.1.0"
# }
# Generate embeddings
curl -X POST http://localhost:3000/embed \
-H "Content-Type: application/json" \
-d '{"text": "This is a sample sentence to embed"}'
# Response:
# {
# "embedding": [0.123, -0.456, ...]
# }- Rust 1.75 or later
- Docker (for containerized deployment)
cargo build --releasecargo testThis repository includes a GitHub Actions workflow to automatically build and push the Docker image to GitHub Container Registry (ghcr.io) when changes are pushed to the main branch.
-
Ensure your repository has the appropriate permissions:
- Go to Settings > Actions > General > Workflow permissions
- Select "Read and write permissions"
-
To use the published Docker image:
# Latest version docker pull ghcr.io/<username>/all-MiniLM-L6-v2-restapi-service:latest # Specific version (from Cargo.toml) docker pull ghcr.io/<username>/all-MiniLM-L6-v2-restapi-service:0.1.0 # Run the container docker run -p 3000:3000 ghcr.io/<username>/all-MiniLM-L6-v2-restapi-service:latest
docker build -t embedding-service .
docker run -p 3000:3000 embedding-service