本页介绍了 Open Interpreter 的本地模型功能,解释了如何在本地机器上运行语言模型,而不是使用云 API。有关使用 OpenAI 或 Claude 等托管模型的信息,请参阅托管模型。
Open Interpreter 支持在您的机器上本地运行大型语言模型,提供多项优势:
本地模型支持通过与几个本地模型提供商集成实现,这些提供商负责实际的模型加载和推理。
来源: interpreter/terminal_interface/local_setup.py190-203
Open Interpreter 集成了四个主要的本地模型提供商:
Ollama 提供了一种在本地轻松运行开源大型语言模型的方法。它通过简单的 API 处理模型的下载、管理和运行。
主要功能:
ollama pull <model_name> 轻松安装模型设置过程:
来源: interpreter/terminal_interface/local_setup.py237-329
Llamafile 创建可移植的自包含可执行文件,其中包含模型权重和推理引擎。
主要功能:
可用模型包括:
来源: interpreter/terminal_interface/local_setup.py16-188 interpreter/terminal_interface/local_setup.py379-456
LM Studio 是一款用于运行各种开源语言模型的桌面应用程序。
主要功能:
设置过程:
来源: interpreter/terminal_interface/local_setup.py218-236
Jan.ai 是另一个在本地运行语言模型的桌面应用程序。
主要功能:
设置过程:
来源: interpreter/terminal_interface/local_setup.py331-377
使用本地模型的简单方法是通过本地浏览器界面,它提供引导式设置:
pip install open-interpreterinterpreter --local> Open Interpreter supports multiple local model providers.
>
> ? Select a provider
> Ollama
> Llamafile
> LM Studio
> Jan
来源: interpreter/terminal_interface/local_setup.py190-217
选择本地模型时,请考虑您的硬件规格:
> 30GB 内存:Mixtral-8x7B 或 Gemma-2-27b 等大型模型
Open Interpreter 将分析您的系统并推荐合适的模型
Your machine has `16.00GB` of RAM, and `256.45GB` of free storage space.
Your computer could handle a mid-sized model (4-10GB), Mistral-7B might be the best model for your computer.
来源: interpreter/terminal_interface/local_setup.py16-45
通过 Python API 使用本地模型:
来源: docs/guides/running-locally.mdx39-50
如果您使用的本地模型提供商未直接支持,您可以连接到任何与 OpenAI 兼容的 API 端点。
来源: docs/guides/running-locally.mdx25-36
本地模型通常需要额外的指导才能实现最佳性能。Open Interpreter 提供多项设置来提供帮助:
这些模板有助于为发送到本地模型的提示提供一致的结构
# Configure templates
interpreter.user_message_template = "User: {message}\nAssistant: "
interpreter.always_apply_user_message_template = True
interpreter.code_output_template = "Output: {content}\nNext step:"
interpreter.empty_code_output_template = "The code executed successfully with no output."
这些模板有助于为模型提供更多上下文和结构,而无需用户修改其消息。
来源: docs/guides/running-locally.mdx52-66 interpreter/terminal_interface/profiles/defaults/local-assistant.py106-110
Open Interpreter 包含为本地模型优化的预配置配置文件
local-assistant 配置文件为 Open Interpreter 配置了适合本地模型的系统消息和模板,包括:
来源: interpreter/terminal_interface/profiles/defaults/local-assistant.py1-120
使用本地模型时:
Open Interpreter 会根据您的硬件自动调整参数
来源: interpreter/terminal_interface/local_setup.py457-466
对于 Llamafile 模型,Open Interpreter 提供了一个管理界面:
此命令列出所有已下载的模型并允许您:
模型存储在 Open Interpreter 的 models 目录中,通常位于:
~/.openinterpreter/models/%USERPROFILE%\.openinterpreter\models\来源: interpreter/terminal_interface/local_setup.py173-176 interpreter/terminal_interface/local_setup.py379-456