跳到主要内容
llama.cpp python 库是 @ggerganov llama.cpp 的一个简单的 Python 绑定。 此软件包提供:
  • 通过 ctypes 接口低层访问 C API。
  • 用于文本补全的高级 Python API
    • OpenAI 风格的 API
    • LangChain 兼容性
    • LlamaIndex 兼容性
  • 与 OpenAI 兼容的 Web 服务器
    • 本地 Copilot 替代品
    • 函数调用支持
    • 视觉 API 支持
    • 多模型
pip install -qU  llama-cpp-python
from langchain_community.embeddings import LlamaCppEmbeddings
llama = LlamaCppEmbeddings(model_path="/path/to/model/ggml-model-q4_0.bin")
text = "This is a test document."
query_result = llama.embed_query(text)
doc_result = llama.embed_documents([text])

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.