This is a simple FastAPI server that uses the Sentence Transformers model (all-mpnet-base-v2) to generate text embeddings. It’s designed to be used as a microservice for applications like matching systems, search, and recommendation engines.
- Generate Embeddings: POST text to the
/embedendpoint and get back a vector embedding. - Easy to Deploy: Runs locally or on any cloud platform.
- Fast & Lightweight: Built with FastAPI and Uvicorn for high performance.
- Clone the repository
- Create and activate a virtual environment
python -m venv venvsource venv/bin/activate
venv\Scripts\activate- Install the dependencies
pip install -r requirements.txtuvicorn main:app --reloadEndpoint: POST /embed
Request Body
{
"text": "Explain how AI works"
}Successful response
{
"embedding": [0.123, -0.456, ... ]
}Text-to-Vector Conversion
- The model processes your text and returns an array of numbers (vector embedding) that encodes the semantic meaning of the text.
Use Cases
These vector embeddings can be used to :-
- Compare text similarity
- Perform matching between user queries and available content or profiles