Quick Setup
A hands-on walkthrough of downshift-server 1.0: an embedding model behind the OpenAI route, your own PyTorch model, and a check that catches a wrong ONNX export.
Step 1:Install torch (the CPU build is fine) and downshift with the Hugging Face extra:
pip install torch --index-url https://download.pytorch.org/whl/cpu pip install "downshift-server[hf]" openai
Enter fullscreen mode
Exit fullscreen mode
Step 2: Download an encoder type embedding model from HF
hf download BAAI/bge-small-en-v1.5 --local-dir ./bge-small-en-v1.5
Enter fullscreen mode
Exit fullscreen mode
Step 3: Serve it out!
downshift serve ./bge-small-en-v1.5 --port 8000
Enter fullscreen mode
Exit fullscreen mode
downshift-server exports the model to ONNX and checks it against the original weights to ensure that the model still performs the same.
What just happened?
You are now the creator of a tiny FastAPI server which is serving the model in an OpenAI compatible API.
from openai import OpenAI
client = OpenAI (…