requests
需求类似于不希望内部数据上传到其他网页,于是希望在本地同时部署 Embedding Model 和 LLM.
于是,我用 llama-server
同时 serve 了 BGE-m3
和 Deepseek-R1-Distill-Llama-8B
,前者作为 Embedding 模型暴露在 http://localhost:8081
,后者作为 LLM 暴露在 http://localhost:8080
然后就遇到了一个小问题,怎么通过 Python 去获取 Embedding 呢?我这里的解决方案是直接用 requests
库发送请求了。好在 llama.cpp
提供的 llama-server
能够兼容 OpenAI 的 API 接口。
1 | import requests |