ONNX Runtime Setup (Advanced)¶
Use this path when you want embedding.provider: onnx.
Pali's ONNX provider uses github.com/yalue/onnxruntime_go, which requires a platform-native ONNX Runtime shared library at runtime.
Requirements¶
- ONNX model files:
models/all-MiniLM-L6-v2/model.onnxmodels/all-MiniLM-L6-v2/tokenizer.json- ONNX Runtime shared library (
.dylib,.so, or.dll)
macOS¶
- Install ONNX Runtime:
brew install onnxruntime- Formula reference: https://formulae.brew.sh/formula/onnxruntime
- Verify library path:
- usually
/opt/homebrew/lib/libonnxruntime.dylibon Apple Silicon - If needed, set:
export ONNXRUNTIME_SHARED_LIBRARY_PATH=/opt/homebrew/lib/libonnxruntime.dylib
Windows¶
- Download ONNX Runtime release package (C/C++ binaries):
- https://github.com/microsoft/onnxruntime/releases
- Extract and locate
onnxruntime.dll. - Set environment variable:
setx ONNXRUNTIME_SHARED_LIBRARY_PATH "C:\\path\\to\\onnxruntime.dll"- Install Microsoft Visual C++ 2019 runtime if missing:
- requirement noted by
onnxruntime_go: https://github.com/yalue/onnxruntime_go/blob/master/README.md
Linux¶
- Download ONNX Runtime package from releases:
- https://github.com/microsoft/onnxruntime/releases
- Locate
libonnxruntime.soand set: export ONNXRUNTIME_SHARED_LIBRARY_PATH=/path/to/libonnxruntime.so
Config Example¶
embedding:
provider: onnx
model_path: ./models/all-MiniLM-L6-v2/model.onnx
tokenizer_path: ./models/all-MiniLM-L6-v2/tokenizer.json
Troubleshooting¶
- Error:
Error loading ONNX shared library ... - shared library path is missing/wrong
- set
ONNXRUNTIME_SHARED_LIBRARY_PATHexplicitly - Error: model file not found
- run
pali init -download-modelto fetch missing model artifacts
References¶
- ONNX Runtime install docs: https://onnxruntime.ai/docs/install/
- ONNX Runtime C/C++ package notes: https://onnxruntime.ai/docs/get-started/with-c.html
onnxruntime_goREADME: https://github.com/yalue/onnxruntime_go/blob/master/README.md