Embeddings
An embedding turns text into a fixed-length float vector. Nearby meanings produce nearby vectors. RAG uses this for nearest-neighbor search—not for chat.
Two primary paths in this course; neither requires a GPU:
For Chinese retrieval, evaluate bge-m3 first (Ollama name bge-m3, Hub id BAAI/bge-m3). If RAM is tight, BAAI/bge-small-zh-v1.5 runs on CPU. See Ollama Embeddings for /api/embed, and Hugging Face for model cards and sentence-transformers.
Index and query must use the same model. Changing models means re-embedding the store.
Environment
OpenAI: set OPENAI_API_KEY. Ollama: install the app and ollama pull bge-m3 (CPU works; first run is slower).
OpenAI: text-embedding-3-small
The API accepts dimensions to shrink vectors (e.g. 512) and save storage. Do not change dimensionality after you have indexed. Batch many strings in one input list; do not HTTP-loop one text at a time.
Local: Ollama bge-m3
No CUDA setup. Ollama can embed on CPU.
REST is POST http://localhost:11434/api/embed. The OpenAI-compatible path is POST /v1/embeddings. PowerShell:
Do not embed with chat models (llama3, qwen, …): they are slow and not trained for retrieval.
Local Python: BAAI / sentence-transformers (optional)
If you want Hub weights without the Ollama daemon:
pip install sentence-transformers pulls a CPU PyTorch wheel. The first model download needs disk and patience. A GPU helps but is not required.
Hand-off to a vector store
All three stores accept precomputed vectors:
Chroma can also embed for you with its built-in function. For Chinese, pass your own OpenAI or bge-m3 vectors so you are not stuck with a tiny English default.