kasinathansj/text-embedding
0
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Embedding API
This is a FastAPI-based embedding server that uses the multi-qa-mpnet-base-dot-v1 model from SentenceTransformers to generate text embeddings.
Model Specification
- Model Name: multi-qa-mpnet-base-dot-v1
- Architecture: MPNet (Microsoft Pretrained Network)
- Embedding Size: 768
- Use Case: Optimized for multi-question answering (QA) and semantic search
- Number of Layers: 12
- Number of Attention Heads: 12
- Hidden Size: 768
- Intermediate Size: 3072
- Vocabulary Size: 30,527
- Framework: SentenceTransformers (Hugging Face)
API Endpoints
1. Health Check
Endpoint: GET /
Description: Checks if the embedding server is running.
Response:
{
"message": "Embedding server is running!"
}2. Generate Embedding
Endpoint: POST /embed/
Description: Generates an embedding for the provided input text.
Request Body:
{
"text": "Sample input text"
}Response:
{
"embedding": [0.12345, -0.6789, ...] // 768-dimensional vector
}Running the API
To start the API server, run:
uvicorn main:app --host 0.0.0.0 --port 8000Installation
- Install dependencies:
pip install fastapi uvicorn sentence-transformers- Make sure the model is available in
./saved_model/. - Start the server as mentioned above.
Usage
You can test the API using curl, Postman, or any HTTP client:
curl -X POST "http://localhost:8000/embed/" \
-H "Content-Type: application/json" \
-d '{"text": "Hello world"}'This will return the 768-dimensional embedding for the text input.
Notes
- Ensure that
./saved_modelcontains the pre-trained multi-qa-mpnet-base-dot-v1 model. - The API is optimized for embedding short text snippets for semantic search and retrieval tasks.
