LFM2.5——设备上AI聊天和MCP服务器
跑 Liquid AI的LFM2.5-1.2B-说明书 在Mac上本地建模,具有漂亮的聊天界面和MCP集成,可用于Claude Desktop、Cursor和OpenClaw等工具。
苹果硅上约120 tok/s · 4台Mac的传输速度约为480 tok/s · 1.5GB内存 · 100%私人&离线
✨ 特性
- 🖥️ 漂亮的聊天界面 --深色主题、响应式聊天界面,带有markdown渲染、代码突出显示和实时性能指标
- ⚡ MLX加速 --通过8位量化的MLX在Apple Silicon上原生运行
- 🔌 MCP服务器 --将LFM2.5作为Claude Desktop、Cursor、OpenClaw和任何MCP兼容客户端的工具公开
- 🔀 多Mac集群 --通过自动负载平衡和故障转移在多台M4 Mac上分发推理
- 📊 实时统计数据 --实时显示令牌计数、生成速度(tok/s)和响应时间
- 🎯 快速提示 --常见任务的预构建提示(CRISPR解释、代码架构、创意写作、数据分析)
🏗️ 建筑
Single-Mac Mode:
Client → MLX Server (:8080)
Cluster Mode (4× throughput):
Client → Cluster LB (:5200) → Mac 1 MLX (:8080)
→ Mac 2 MLX (:8080)
→ Mac 3 MLX (:8080)
→ Mac 4 MLX (:8080)🚀 快速开始
先决条件
- 带苹果硅(M1/M2/M3/M4)的macOS
- Python 3.10+
1.安装
# Clone the repo
git clone https://github.com/WispAyr/LFM2.5-local.git
cd LFM2.5-local
# Install MLX dependencies (if needed)
pip install mlx-lm
# Install MCP dependencies
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt2.跑步
# Just the MLX server + chat UI
./start_server.sh
# MLX + MCP server (for Claude Desktop, Cursor, OpenClaw)
./start_server.sh --mcp
# Everything (MLX + MCP + web UI)
./start_server.sh --all
# Multi-Mac cluster (MLX + Load Balancer + MCP + web UI)
./start_server.sh --cluster3.打开
| 服务 | URL | 描述 |
|---|---|---|
| 聊天界面 | http://localhost:3000 | 网络聊天界面 |
| API MLX | http://localhost:8080/v1 | 兼容OpenAI的API |
| 集群LB | http://localhost:5200/v1 | 负载平衡API(集群模式) |
| 群集状态 | http://localhost:5200/cluster/status | 实时节点运行状况 |
| MCP服务器 | http://localhost:5100/mcp | MCP协议端点 |
🔌 MCP集成
MCP服务器公开LFM2.5作为任何MCP兼容客户端都可以调用的工具。
工具
| 工具 | 说明 |
|---|---|
chat | 通用聊天——提问、推理、写作 |
summarize | 用可配置的长度总结文本 |
analyze_code | 代码审查、错误检测、建议 |
translate | 将文本翻译成任何语言 |
资源
| URI | 描述 |
|---|---|
lfm25://model/info | 模型架构、规格、功能 |
lfm25://server/status | 实时MLX服务器连接状态 |
提示
| 提示 | 描述 |
|---|---|
code_review | 结构化代码审查模板 |
explain_concept | ELI5风格概念说明 |
连接到克劳德桌面
添加 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"lfm25": {
"command": "/path/to/LFM2.5-local/.venv/bin/python3",
"args": ["/path/to/LFM2.5-local/mcp_server.py"]
}
}
}连接到光标
设置→ MCP服务器→ 添加并粘贴相同的配置。
连接到OpenClaw
指向 http://localhost:5100/mcp 作为MCP服务器端点。
📁 项目结构
├── index.html # Chat web UI (single-file, no build step)
├── mcp_server.py # FastMCP server with tools, resources, prompts
├── cluster.py # Multi-Mac cluster load balancer
├── cluster_config.json # Cluster node configuration
├── server.py # Web UI proxy server (serves static + proxies API)
├── mcp_config.json # MCP config template for Claude Desktop / Cursor
├── start_server.sh # Launcher script (--mcp, --all, --cluster flags)
├── demo_lfm25.py # Python demo script
└── requirements.txt # Python dependencies🔀 多Mac集群
在多台M4 Mac上分发推理 ~480tok/s的综合吞吐量 以及自动故障转移。
设置
1.在每台Mac上,启动MLX服务器:
pip install mlx-lm
python3 -m mlx_lm.server --model LiquidAI/LFM2.5-1.2B-Instruct-MLX-8bit --port 8080 --host 0.0.0.02.编辑 cluster_config.json 在主Mac上使用每个节点的IP:
{
"nodes": [
{"name": "Mac-1", "host": "192.168.1.10", "port": 8080, "weight": 1},
{"name": "Mac-2", "host": "192.168.1.11", "port": 8080, "weight": 1},
{"name": "Mac-3", "host": "192.168.1.12", "port": 8080, "weight": 1},
{"name": "Mac-4", "host": "192.168.1.13", "port": 8080, "weight": 1}
]
}3.启动集群:
./start_server.sh --cluster特性
- 负载最小的路由 对于POST请求,GET采用轮转
- 健康检查 每5秒进行一次自动故障切换
- SSE流媒体 passthrough用于实时令牌生成
- 节点权重 优先考虑更快的Mac
- 状态仪表板 在
/cluster/status每个节点的度量
🧠 关于LFM2.5
LFM2.5是 不是变压器这是一种混合架构 液态AI 结合:
- 10×门控短卷积 图层--快速顺序处理
- 6×分组查询注意力 层次——选择性注意
这赋予了它独特的性能:极快的推理速度(在M系列Mac上约为120+tok/s),参数占用空间较小,为1.17B。
| 规格 | 值 |
|---|---|
| 参数 | 1.17B |
| 图层 | 16 |
| 上下文 | 32K令牌 |
| 词汇表 | 65536 |
| 培训 | 28T代币 |
| 量化 | 8位(MLX) |
📄 许可证
麻省理工学院
