REST API for generating text embeddings using the BGE-M3 model.
Available variants:
cpu-latest: CPU-only version with smaller image sizegpu-latest: GPU-enabled version with CUDA supportlatest: Points to GPU-enabled version (same as gpu-latest)Tagged versions are also available:
cpu-v1.0.0, gpu-v1.0.0, v1.0.0 etc.CPU version:
docker run -d -p 8000:8000 \
-e DEVICE=cpu \
ggwozdz/embed-api:cpu-latest
GPU version:
docker run -d -p 8000:8000 \
-e DEVICE=cuda \
--gpus all \
ggwozdz/embed-api:gpu-latest
Create a docker-compose.yml file with the following content and run docker-compose up:
services:
# CPU version
api-cpu:
image: ggwozdz/embed-api:cpu-latest
environment:
- DEVICE=cpu
- LOG_LEVEL=INFO
ports:
- "8000:8000"
# GPU version
api-gpu:
image: ggwozdz/embed-api:gpu-latest
environment:
- DEVICE=cuda
- LOG_LEVEL=INFO
ports:
- "8001:8000"
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
Request:
curl -X POST "http://localhost:8000/embeddings" \
-H "Content-Type: application/json" \
-d '{
"texts": ["Hello world"],
"include_dense": true,
"include_sparse": true,
"include_colbert": true
}'
Response:
{
"embeddings": [
{
"text": "Hello world",
"dense": [0.1, 0.2, 0.3, -0.1, 0.5, 0.8, -0.2, 0.4],
"sparse": {
"indices": [1, 5, 10, 15, 23, 45, 67],
"values": [0.8, 0.6, 0.4, 0.3, 0.2, 0.1, 0.05]
},
"colbert": [
[0.1, 0.2, 0.3, 0.4],
[0.5, 0.6, 0.7, 0.8],
[0.9, 0.1, 0.2, 0.3]
]
}
]
}
Request:
curl -X GET "http://localhost:8000/model/status"
Response:
{
"is_loaded": true,
"model_name": "BAAI/bge-m3",
"device": "cpu"
}
Request:
curl -X GET "http://localhost:8000/healthcheck"
Response:
{
"status": "OK"
}
The application uses environment variables for configuration. Below are the available options:
| Variable | Description | Default value |
|---|---|---|
DEVICE | Device: cpu or cuda | cpu |
LOG_LEVEL | Logging level (DEBUG, INFO, WARNING, ERROR) | INFO |
FASTAPI_HOST | Server host | 127.0.0.1 |
FASTAPI_PORT | Server port | 8000 |
MODEL_IDLE_TIMEOUT | Model timeout (seconds) | 60 |
BGE-M3 is a multilingual embedding model offering:
Full documentation available at: GitHub Repository
Content type
Image
Digest
sha256:ccaca1fa7…
Size
3.8 GB
Last updated
about 1 year ago
docker pull ggwozdz/embed-api