Sign inSign up

beloved70020/bge-m3

By beloved70020

Updated over 1 year ago

Out-of-the-box FastAPI service for BAAI/bge-m3 text embeddings. OpenAI-compatible API.

Image
0

5.3K

beloved70020/bge-m3 repository overview

BGE-M3 Embedding API Service (beloved70020/bge-m3)

This Docker image provides a ready-to-use, high-performance API service for generating text embeddings using the BAAI/bge-m3 model. It's built with FastAPI and Uvicorn, offering an OpenAI-compatible /v1/embeddings endpoint for an immediate, out-of-the-box experience. The service inside the container listens on port 8080.

Features

  • Optimized for BAAI/bge-m3: Pre-configured and dedicated to the BAAI/bge-m3 model for high-quality text embeddings.
  • Out-of-the-Box: Designed for immediate use. Simply map to the internal port 8080.
  • OpenAI-Compatible API: Easy integration with existing tools using the /v1/embeddings endpoint.
  • Performance: Uses the FlagEmbedding library for efficient inference. Supports FP16 on CUDA-enabled GPUs for faster processing (if the host environment provides GPU access to the container).
  • Health Check: Includes a /health endpoint to monitor service status and the loaded BAAI/bge-m3 model.

Target Model

This image is specifically built and configured for:

  • Model ID: BAAI/bge-m3

The model is downloaded and cached within the image during its build process.

How to Use

Running the Container

The service inside the container listens on port 8080. Map your desired host port to the container's port 8080.

To run the service, mapping host port 8080 to the container's port 8080:

docker run -d -p 8080:8080 -v /dev/shm:/dev/shm beloved70020/bge-m3:latest

If you want to use a different host port (e.g., 8100):

docker run -d -p 8100:8080 -v /dev/shm:/dev/shm beloved70020/bge-m3:latest
API Endpoint: /v1/embeddings

This endpoint is compatible with the OpenAI embeddings API. Ensure the model field in your request is BAAI/bge-m3.

Request:

  • POST /v1/embeddings
  • Headers: Content-Type: application/json
  • Body:
    {
      "input": "Your text string goes here", // or a list of strings
      "model": "BAAI/bge-m3 // Must be BAAI/bge-m3 for this service
    }
    

Example using cURL (assuming service is mapped to host port 8080):

curl -X POST http://localhost:8080/v1/embeddings \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Hello, world!",
    "model": "BAAI/bge-m3"
  }'

Response:

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [0.0123, -0.0456, ...], // Embedding vector from BAAI/bge-m3
      "index": 0
    }
  ],
  "model": "BAAI/bge-m3",
  "usage": {
    "prompt_tokens": 4, // Example token count
    "total_tokens": 4
  }
}
Health Check Endpoint
  • GET /health

Example using cURL (assuming service is mapped to host port 8080):

curl http://localhost:8080/health

Response:

{
  "status": "ok",
  "models_loaded": {
    "embedding": true
  },
  "model_ids": {
    "embedding": "BAAI/bge-m3" // Confirms the specific model loaded
  }
}

Environment Variables

This image is designed for an out-of-the-box experience and does not require users to set any environment variables for standard operation. Internal environment variables such as PORT (fixed to 8080), EMBEDDING_MODEL_ID (fixed to BAAI/bge-m3), HF_HOME, HOST, etc., are pre-configured for optimal functionality and are not intended for user modification.

Tag summary

Content type

Image

Digest

sha256:0ce07b7b7

Size

5.6 GB

Last updated

over 1 year ago

docker pull beloved70020/bge-m3