Instructions to use whcl412/LycheeAI-coder-1b-II with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use whcl412/LycheeAI-coder-1b-II with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download whcl412/LycheeAI-coder-1b-II --local-dir LycheeAI-coder-1b-II
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use whcl412/LycheeAI-coder-1b-II with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "whcl412/LycheeAI-coder-1b-II"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "whcl412/LycheeAI-coder-1b-II" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use whcl412/LycheeAI-coder-1b-II with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "whcl412/LycheeAI-coder-1b-II"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default whcl412/LycheeAI-coder-1b-II
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use whcl412/LycheeAI-coder-1b-II with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "whcl412/LycheeAI-coder-1b-II"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "whcl412/LycheeAI-coder-1b-II" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
docs: V4
Browse files
README.md
CHANGED
|
@@ -1,7 +1,167 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
library_name: mlx
|
| 4 |
-
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
-
- mlx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
+
- mlx
|
| 5 |
+
- code
|
| 6 |
+
- minicpm
|
| 7 |
+
- chinese
|
| 8 |
+
- conversational
|
| 9 |
+
base_model: openbmb/MiniCPM5-1B
|
| 10 |
---
|
| 11 |
+
|
| 12 |
+
# LycheeAI-coder-1b-II
|
| 13 |
+
|
| 14 |
+
> **当前版本:V4**(代码打磨版)
|
| 15 |
+
> 基于 [MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B) 微调的轻量编程助手 · Apache 2.0
|
| 16 |
+
|
| 17 |
+
**这是个人开发者的初次尝试,模型能力有限,1B 参数注定它只是个"轻量小助手",请不要用 GPT / Claude / DeepSeek 的标准来要求它。** 如果你愿意,可以把它当成一个跑在本地、不用联网、响应飞快的小工具。
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## 这个模型是什么
|
| 22 |
+
|
| 23 |
+
基于面壁智能 [MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B)(Apache 2.0),用 **QLoRA(4-bit)** 微调而来。
|
| 24 |
+
|
| 25 |
+
相比同尺寸模型,它有三个明确打磨过的行为特点:
|
| 26 |
+
|
| 27 |
+
### 1. 会纠正你,而不是附和你
|
| 28 |
+
|
| 29 |
+
这是 V3 重点解决的问题。面对带错误前提的提问,它不会顺着你说:
|
| 30 |
+
|
| 31 |
+
```
|
| 32 |
+
你:地球是平的,对吧?
|
| 33 |
+
它:不是。地球是近似椭球体(接近球形),不是平的。
|
| 34 |
+
|
| 35 |
+
你:1+1=3,对吗?
|
| 36 |
+
它:不是,1+1 等于 2,不是 3。
|
| 37 |
+
|
| 38 |
+
你:Python 是编译型语言,对吧?
|
| 39 |
+
它:不是。Python 主要由解释器执行。
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
同时它**不会变成杠精**——天气好、咖啡好喝、主观喜好这类,它照样好好附和。原则是:**纠正事实,不纠正口味**。
|
| 43 |
+
|
| 44 |
+
### 2. 思考可以开关
|
| 45 |
+
|
| 46 |
+
原生支持思考开关(底层是 `enable_thinking` 参数):
|
| 47 |
+
|
| 48 |
+
| 模式 | 行为 | 适合 |
|
| 49 |
+
|------|------|------|
|
| 50 |
+
| **开思考** | 先推理再作答,多步推理更准 | 数学、逻辑、复杂问题 |
|
| 51 |
+
| **关思考** | 直接给答案,不推理 | 日常聊天、简单题、写代码 |
|
| 52 |
+
|
| 53 |
+
> ⚠️ 关思考时数学准确率会下降——这很正常,不让推理就只能凭记忆。复杂计算请开思考。
|
| 54 |
+
|
| 55 |
+
### 3. 代码格式完整
|
| 56 |
+
|
| 57 |
+
写一个能直接跑的 HTML 页面没问题,标签闭合、结构完整:
|
| 58 |
+
|
| 59 |
+
```html
|
| 60 |
+
<!DOCTYPE html>
|
| 61 |
+
<html>
|
| 62 |
+
<head><meta charset="UTF-8"><title>简单页面</title></head>
|
| 63 |
+
<body>
|
| 64 |
+
<h1>我的网页</h1>
|
| 65 |
+
<button onclick="alert('你好!')">点我</button>
|
| 66 |
+
</body>
|
| 67 |
+
</html>
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
---
|
| 71 |
+
|
| 72 |
+
## 快速开始
|
| 73 |
+
|
| 74 |
+
### Ollama(推荐,GGUF 版)
|
| 75 |
+
|
| 76 |
+
```bash
|
| 77 |
+
ollama run whcl412/LycheeAI-coder-1b-II-GGUF
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
### MLX(Apple Silicon 原生)
|
| 81 |
+
|
| 82 |
+
```python
|
| 83 |
+
from mlx_lm import load, generate
|
| 84 |
+
|
| 85 |
+
model, tokenizer = load("LycheeAI-coder-1b-II")
|
| 86 |
+
|
| 87 |
+
messages = [
|
| 88 |
+
{"role": "system", "content": "你是 LycheeAI-coder-1b-II,由 MiniCPM5-1B 通过 LoRA 微调而来的编程助手。"},
|
| 89 |
+
{"role": "user", "content": "用 Python 写个判断质数的函数"},
|
| 90 |
+
]
|
| 91 |
+
prompt = tokenizer.apply_chat_template(
|
| 92 |
+
messages, tokenize=False, add_generation_prompt=True, enable_thinking=True
|
| 93 |
+
)
|
| 94 |
+
print(generate(model, tokenizer, prompt=prompt, max_tokens=512))
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
`enable_thinking=False` 即可切换到直答模式。
|
| 98 |
+
|
| 99 |
+
### 用 LoRA adapter
|
| 100 |
+
|
| 101 |
+
本仓库的 `adapters/` 目录是 V4 的 adapter,可加载到 MiniCPM5-1B 基座上:
|
| 102 |
+
|
| 103 |
+
```bash
|
| 104 |
+
mlx_lm.fuse --model openbmb/MiniCPM5-1B-MLX \
|
| 105 |
+
--adapter-path ./adapters \
|
| 106 |
+
--save-path ./LycheeAI-coder-1b-II
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
---
|
| 110 |
+
|
| 111 |
+
## 推荐参数
|
| 112 |
+
|
| 113 |
+
| 项目 | 值 |
|
| 114 |
+
|------|-----|
|
| 115 |
+
| 上下文长度 | 4096 |
|
| 116 |
+
| 最大输出 | 2048 |
|
| 117 |
+
| 温度 | 0.4(写代码可降到 0.2~0.3) |
|
| 118 |
+
|
| 119 |
+
---
|
| 120 |
+
|
| 121 |
+
## 训练说明
|
| 122 |
+
|
| 123 |
+
从零训练(不是从旧模型续训),数据来自作者手工编写与整理,当前数据 **1740 条**,经过四轮迭代:
|
| 124 |
+
|
| 125 |
+
| 版本 | 重点 |
|
| 126 |
+
|------|------|
|
| 127 |
+
| V1 | 基础能力:代码、多语言(中/英/粤)、日常、情感、身份 |
|
| 128 |
+
| V2 | 补齐"关思考时答难题"的能力;修掉思考里乱判断语言的 bug |
|
| 129 |
+
| V3 | 反谄媚:教会它纠正用户给出的错误前提,同时防止矫枉过正 |
|
| 130 |
+
| **V4** | **代码打磨**:根据第三方体验报告定向补齐——Python 语义陷阱(`dict.get` 不抛错等)、requests 指数退避、Pydantic v2 正确用法、不编造 API、算法边界处理、模糊需求澄清、数学应用题理解 |
|
| 131 |
+
|
| 132 |
+
训练配置:LoRA rank 8 / 16 层 / batch 2 / seq 2048 / lr 5e-5,MLX-LM 框架,Apple Silicon 本地训练。
|
| 133 |
+
|
| 134 |
+
数据分布:带思考样本 566 条,直答样本 1174 条,各类题型在两个模式下都有覆盖。
|
| 135 |
+
|
| 136 |
+
---
|
| 137 |
+
|
| 138 |
+
## 老实说,它做不到什么
|
| 139 |
+
|
| 140 |
+
1. **复杂算法会翻车** —— 快排、动态规划这类,它可能写出语法对但逻辑错的代码。写完请自己跑一遍。
|
| 141 |
+
2. **事实细节偶尔胡说** —— 它知道"这话不对",但未必说得清哪儿不对。重要信息请核实。
|
| 142 |
+
3. **超纲的逻辑题会绕圈** —— 比如多人的真假话推理,它可能推不出来。
|
| 143 |
+
4. **关思考时数学会算错** —— 这是本质权衡,不是 bug。
|
| 144 |
+
5. **长上下文会迷失** —— 微调时序列长度 2048,别指望它记住很长的对话。
|
| 145 |
+
|
| 146 |
+
它的正确打开方式:**简单代码 + 日常聊天 + 离线快问���答**。
|
| 147 |
+
|
| 148 |
+
---
|
| 149 |
+
|
| 150 |
+
## 许可与致谢
|
| 151 |
+
|
| 152 |
+
- 许可:**Apache 2.0**(跟随基座 MiniCPM5-1B)
|
| 153 |
+
- 基座:[MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B) by 面壁智能(OpenBMB)
|
| 154 |
+
- 训练框架:[MLX-LM](https://github.com/ml-explore/mlx-lm)
|
| 155 |
+
- 量化工具:[llama.cpp](https://github.com/ggml-org/llama.cpp)
|
| 156 |
+
|
| 157 |
+
---
|
| 158 |
+
|
| 159 |
+
## 关注作者
|
| 160 |
+
|
| 161 |
+
📺 **B站**:[space.bilibili.com/3493128967293256](https://space.bilibili.com/3493128967293256)
|
| 162 |
+
|
| 163 |
+
不定期分享 AI 模型训练与折腾记录,欢迎来玩~
|
| 164 |
+
|
| 165 |
+
---
|
| 166 |
+
|
| 167 |
+
*由一位个人开发者在惠州用一台 Mac 慢慢搓出来的模型。有问题欢迎提 issue,我会看,但回得可能慢。*
|