跳转到主要内容

运行GGUF文件分发的模型

项目描述

llm-gguf

PyPI Changelog Tests License

使用LLM运行以GGUF文件形式分发的模型

安装

在LLM相同的环境中安装此插件

llm install llm-gguf

用法

此插件运行以GGUF文件形式分发的模型。

您可以让插件直接下载这些文件,或者您可以注册已下载的模型。

要下载Llama 3.1 8B Instruct的LM Studio GGUF,请运行以下命令

llm gguf download-model \
  https://hugging-face.cn/lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF/resolve/main/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf \
  --alias llama-3.1-8b-instruct --alias l31i

使用--alias选项设置该模型的别名,如果您不想设置任何别名,则可以省略。

此命令将下载4.92GB的文件,并将其存储在运行llm gguf models-dir时显示的目录中 - 在macOS上,这将是在~/Library/Application Support/io.datasette.llm/gguf/models

运行llm models以确认已安装模型。

然后您可以像这样运行该模型的提示

llm -m gguf/Meta-Llama-3.1-8B-Instruct-Q4_K_M 'Five great names for a pet lemur'

或者使用您设置的别名之一,例如

llm -m l31i 'Five great names for a pet lemur'

您可以使用llm chat与该模型启动持久聊天会话 - 这将避免在每个提示时将模型加载到内存中

llm chat -m l31i
Chatting with gguf/Meta-Llama-3.1-8B-Instruct-Q4_K_M
Type 'exit' or 'quit' to exit
Type '!multi' to enter multiple lines, then '!end' to finish
> tell me a joke about a walrus, a pelican and a lemur getting lunch
Here's one: Why did the walrus, the pelican, and the lemur go to the cafeteria for lunch? ...

如果您已经下载了模型,则可以像这样使用插件注册它,同时保持文件在当前位置

llm gguf register-model \
  ~/Downloads/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf \
  --alias llama-3.1-8b-instruct --alias l31i

此插件目前仅适用于聊天模型 - 这些模型通常以具有前缀-Instruct-Chat或类似的文件分发。

对于非聊天模型,您可能更适合使用较旧的llm-llama-cpp插件

开发

要本地设置此插件,首先检出代码。然后创建一个新的虚拟环境

cd llm-gguf
python3 -m venv venv
source venv/bin/activate

现在安装依赖项和测试依赖项

llm install -e '.[test]'

运行测试

pytest

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

llm_gguf-0.1a0.tar.gz (8.5 kB 查看哈希值)

上传时间

构建分发

llm_gguf-0.1a0-py3-none-any.whl (8.8 kB 查看哈希值)

上传时间 Python 3