介绍 lms:LM Studio 的 CLI

2024-05-02

LM Studio

今天,伴随 LM Studio 0.2.22 的发布,我们发布了 lms 的首个版本 —— LM Studio 的配套命令行工具。

使用 lms,你可以加载/卸载模型、启动/停止 API 服务器,并检查原始 LLM 输入(不仅仅是输出)。它在 github 上开发,我们欢迎来自社区的问题和 PR。

lms 随 LM Studio 一起发布,并位于 LM Studio 的工作目录下的 ~/.lmstudio/bin/。当你更新 LM Studio 时,它也会更新你的 lms 版本。如果你是开发者,你也可以从源代码构建 lms

在你的系统上引导 lms

你需要在至少运行一次 LM Studio 后才能使用 lms

之后,打开你的终端并运行以下命令之一,具体取决于你的操作系统

# Mac / Linux:
~/.lmstudio/bin/lms bootstrap

# Windows:
cmd /c %USERPROFILE%/.lmstudio/bin/lms.exe bootstrap

之后,打开一个新的终端窗口并运行 lms

这是你将获得的当前输出

$ lms
lms - LM Studio CLI - v0.2.22
GitHub: https://github.com/lmstudio-ai/lmstudio-cli

Usage
lms <subcommand>

where <subcommand> can be one of:

- status - Prints the status of LM Studio
- server - Commands for managing the local server
- ls - List all downloaded models
- ps - List all loaded models
- load - Load a model
- unload - Unload a model
- create - Create a new project with scaffolding
- log - Log operations. Currently only supports streaming logs from LM Studio via `lms log stream`
- version - Prints the version of the CLI
- bootstrap - Bootstrap the CLI

For more help, try running `lms <subcommand> --help`

lms 使用 MIT 许可证,并在 GitHub 上的此仓库中开发

https://github.com/lmstudio-ai/lms

使用 lms 自动化和调试你的工作流程

启动和停止本地服务器

lms server start
lms server stop

列出机器上的本地模型

lms ls

这将反映当前的 LM Studio 模型目录,你可以在应用程序的 📂 “我的模型” 选项卡中设置。

列出当前已加载的模型

lms ps

加载模型(带选项)

lms load [--gpu=max|auto|0.0-1.0] [--context-length=1-N]

--gpu=1.0 表示“尝试将 100% 的计算卸载到 GPU”。

  • (可选)为你的本地 LLM 分配一个标识符
lms load TheBloke/phi-2-GGUF --identifier="gpt-4-turbo"

如果你想保持模型标识符一致,这将很有用。

卸载模型

lms unload [--all]

使用 lms log stream 调试你的提示

lms log stream 允许你检查发送到模型的确切输入字符串。

这对于调试提示模板问题和其他意外的 LLM 行为尤其有用。

$ lms log stream
I Streaming logs from LM Studio

timestamp: 5/2/2024, 9:49:47 PM
type: llm.prediction.input
modelIdentifier: TheBloke/TinyLlama-1.1B-1T-OpenOrca-GGUF/tinyllama-1.1b-1t-openorca.Q2_K.gguf
modelPath: TheBloke/TinyLlama-1.1B-1T-OpenOrca-GGUF/tinyllama-1.1b-1t-openorca.Q2_K.gguf
input: "Below is an instruction that describes a task. Write a response that appropriately completes the request.
#### Instruction:
Hello, what's your name?
#### Response:
"

lmstudio.js

lms 使用 lmstudio.js 与 LM Studio 交互。

你可以构建自己的程序,实现 lms 的功能以及更多。

lmstudio.js 处于预发布公开 alpha 阶段。在 GitHub 上关注:https://github.com/lmstudio-ai/lmstudio.js


在 LM Studio Discord 服务器上新的 #dev-chat 频道中讨论关于 lmslmstudio.js 的所有内容。

https://lm-studio.cn/ 下载适用于 Mac / Windows / Linux 的 LM Studio。

LM Studio 0.2.22 AMD ROCm - 技术预览版可在 https://lm-studio.cn/rocm 获取

LM Studio Twitter: https://twitter.com/lmstudio