介绍 lms:LM Studio 的 CLI 工具

2024-05-02

LM Studio

今天,伴随着 LM Studio 0.2.22 的发布,我们推出了 lms 的第一个版本——这是 LM Studio 的配套命令行工具。

通过 lms,你可以加载/卸载模型、启动/停止 API 服务器,以及检查 LLM 的原始输入(不仅仅是输出)。它在 GitHub 上开发,我们欢迎社区提交 Issue 和 PR。

lms 随 LM Studio 一起安装,位于 LM Studio 的工作目录中,路径为 ~/.lmstudio/bin/。当你更新 LM Studio 时,它也会同时更新你的 lms 版本。如果你是开发者,也可以通过源码构建 lms

在系统上初始化 lms

在使用 lms 之前,你需要至少运行过一次 LM Studio。

然后,打开终端并根据你的操作系统运行相应命令

# 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 的模型目录,该目录可以在应用的 📂 My Models (我的模型) 选项卡中设置。

列出当前已加载的模型

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 允许你检查发送到模型的准确输入字符串。

这对于调试提示词模板 (prompt template) 问题和其他意外的 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 的所有功能及更多功能。


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 (X): https://twitter.com/lmstudio