Image-Text-to-Text
GGUF
rknn
rockchip
rk3588
rk1820
intern-decision
multimodal
decision
npu
conversational
Instructions to use wardner/Intern_Decision-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use wardner/Intern_Decision-4B with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf wardner/Intern_Decision-4B # Run inference directly in the terminal: llama cli -hf wardner/Intern_Decision-4B
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf wardner/Intern_Decision-4B # Run inference directly in the terminal: llama cli -hf wardner/Intern_Decision-4B
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf wardner/Intern_Decision-4B # Run inference directly in the terminal: ./build/bin/llama cli -hf wardner/Intern_Decision-4B
Use Docker
docker model run hf.co/wardner/Intern_Decision-4B
- Llama new
- LM Studio
- Jan
- vLLM
How to use wardner/Intern_Decision-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "wardner/Intern_Decision-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wardner/Intern_Decision-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/wardner/Intern_Decision-4B
- Ollama
How to use wardner/Intern_Decision-4B with Ollama:
ollama run hf.co/wardner/Intern_Decision-4B
- Unsloth Desktop
- Pi
How to use wardner/Intern_Decision-4B with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf wardner/Intern_Decision-4B
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "wardner/Intern_Decision-4B" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use wardner/Intern_Decision-4B with Docker Model Runner:
docker model run hf.co/wardner/Intern_Decision-4B
- Lemonade
How to use wardner/Intern_Decision-4B with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull wardner/Intern_Decision-4B
Run and chat with the model
lemonade run user.Intern_Decision-4B-{{QUANT_TAG}}List all available models
lemonade list
- Hermes Agent
How to use wardner/Intern_Decision-4B with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf wardner/Intern_Decision-4B
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:9931/v1 hermes config set model.default wardner/Intern_Decision-4B
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use wardner/Intern_Decision-4B with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf wardner/Intern_Decision-4B
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:9931/v1 \ --custom-model-id "wardner/Intern_Decision-4B" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
- decision
|
| 13 |
+
- npu
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# Intern-Decision-4B — Rockchip RKNN 部署包
|
| 17 |
+
|
| 18 |
+
[Intern-Decision-4B](https://huggingface.co/internlm/Intern-Decision-4B) 的 **RKNN 导出**,
|
| 19 |
+
供 Rockchip 协处理器(RK1820 / RK3588)上的 NPU 推理使用。
|
| 20 |
+
|
| 21 |
+
上游是原始权重;**本仓库只包含 RKNN 量化导出后的运行期文件**,不能直接用
|
| 22 |
+
`transformers` 加载,需要通过下面的 `wdnai` SDK 加载。
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## ⚠️ 这不是对话模型
|
| 27 |
+
|
| 28 |
+
Intern-Decision **不生成文本**。它对任务里的每个「决策字段」输出 **62 个候选符号**
|
| 29 |
+
(`A-Z` + `a-z` + `0-9`)的 logits,由 CPU 侧换算成选项概率:
|
| 30 |
+
|
| 31 |
+
| 字段类型 | 语义 | 输出 |
|
| 32 |
+
|---|---|---|
|
| 33 |
+
| `choice` | 选一项 | 选项概率(**归一化**,合计为 1) |
|
| 34 |
+
| `score` | 打分 | 概率加权评分 |
|
| 35 |
+
| `noul` | 是否 | 肯定概率(**不归一化**,各项独立) |
|
| 36 |
+
|
| 37 |
+
调用方必须传**任务配置**(`task=`)。答案形如 `{"category": "account", "urgency": 0.7676}`,
|
| 38 |
+
完整概率 / logits 随文本附件一起回传。
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
## 文件说明
|
| 43 |
+
|
| 44 |
+
| 文件 | 大小 | 说明 |
|
| 45 |
+
|---|---|---|
|
| 46 |
+
| `Intern-Decision-4B-llm.rknn` | 25 MB | LLM 计算图 |
|
| 47 |
+
| `Intern-Decision-4B-llm.weight` | 2.0 GB | LLM 权重 |
|
| 48 |
+
| `Intern-Decision-4B-llm.embed.bin` | 1.2 GB | LLM embedding 表(词表 248320) |
|
| 49 |
+
| `Intern-Decision-4B-llm.tokenizer.gguf` | 11 MB | GGUF 预分词器 |
|
| 50 |
+
| `Intern-Decision-4B-vision.rknn` | 4.6 MB | 视觉编码器计算图(384×384) |
|
| 51 |
+
| `Intern-Decision-4B-vision.weight` | 651 MB | 视觉编码器权重 |
|
| 52 |
+
| `intern-decision-4b.json` | 4 KB | 模型清单(`wdnai` SDK 用) |
|
| 53 |
+
| `Intern-Decision-4B-llm_report/model_report.html` | 220 KB | LLM 转换报告(RKNX 可视化) |
|
| 54 |
+
| `Intern-Decision-4B-vision_report/model_report.html` | 84 KB | 视觉转换报告 |
|
| 55 |
+
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
## 使用
|
| 59 |
+
|
| 60 |
+
### 1. 放置目录
|
| 61 |
+
|
| 62 |
+
默认目录 `/userdata/models/Intern_Decision-4B`,也可以用环境变量指定:
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
export WDNAI_INTERN_DECISION_4B_DIR=/path/to/Intern_Decision-4B
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
### 2. 加载
|
| 69 |
+
|
| 70 |
+
```python
|
| 71 |
+
from wdnai.model import SystemLanguageModel
|
| 72 |
+
|
| 73 |
+
spec = SystemLanguageModel.intern_decision_4b()
|
| 74 |
+
session = spec.session() # LLM + 视觉编码器常驻,约 3100 MB 显存
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
### 3. 下决策任务
|
| 78 |
+
|
| 79 |
+
```python
|
| 80 |
+
from wdnai.decision import parse_decision_task
|
| 81 |
+
|
| 82 |
+
task = parse_decision_task({
|
| 83 |
+
"questions": {
|
| 84 |
+
"广告": {"type": "noul", "criteria": {"no": "没有广告", "yes": "含广告"}},
|
| 85 |
+
"诈骗": {"type": "noul", "criteria": {"no": "没有诈骗", "yes": "含诈骗"}},
|
| 86 |
+
}
|
| 87 |
+
})
|
| 88 |
+
text, attachments = session.run_prompt(
|
| 89 |
+
prompt="限时优惠,加微信领红包",
|
| 90 |
+
attachment=[image], # 可选
|
| 91 |
+
task=task,
|
| 92 |
+
)
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
---
|
| 96 |
+
|
| 97 |
+
## 实测性能(RK3588 + 1 张 1828 协卡)
|
| 98 |
+
|
| 99 |
+
**prefill-only 模型**:每个字段跑一次 `max_new_tokens=1` 的推理,解码 token 恒为 0
|
| 100 |
+
⇒ 吞吐指标是**预填充速率**(提示词处理速度),不是生成速度。
|
| 101 |
+
|
| 102 |
+
| 维度数 | 纯文本 | 图文 |
|
| 103 |
+
|---|---|---|
|
| 104 |
+
| 1 | 0.55 s | 0.94 s |
|
| 105 |
+
| 4 | 2.68 s | 3.70 s |
|
| 106 |
+
| 7 | 6.30 s | 8.04 s |
|
| 107 |
+
| 16 | 23.30 s | 26.55 s |
|
| 108 |
+
|
| 109 |
+
⚠️ **耗时随维度数呈平方增长**:字段 *i* 的 prompt 前缀包含字段 0..*i*−1 的定义
|
| 110 |
+
⇒ 总 prefill 量 ∝ *N*²。图片的 151 个视觉 token 也会被**每个字段重新 prefill 一遍**。
|
| 111 |
+
|
| 112 |
+
---
|
| 113 |
+
|
| 114 |
+
## 部署注意事项
|
| 115 |
+
|
| 116 |
+
- ⚠️ **每个字段必须换一次 LLM session**:模型有 linear-attention 层,递归状态跨调用
|
| 117 |
+
残留,`keep_history=0` 只清 KV cache 不清递归状态 ⇒ 每个字段都要
|
| 118 |
+
`recreate_llm_session()`。官方 C++ 参考实现同理(每字段
|
| 119 |
+
`rknn3_session_init/destroy`)。
|
| 120 |
+
- ⚠️ **prompt 里的 ChatML 标记是「写进文本」的,不是 chat template**:导出模型的
|
| 121 |
+
`chat_template` 是空的,C 侧必须保持 `set_chat_template("", "", "")`。完整形态是
|
| 122 |
+
`<|im_start|>system\n…<|im_end|>\n<|im_start|>user\n…<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n{骨架}<|im_end|>\n`
|
| 123 |
+
—— 少写这 6 个标记就少 66 字节 / 6 个 token,token 位置整体错位、概率明显偏移。
|
| 124 |
+
- ⚠️ **控制 token 必须是单 token**:`<decision>`=248077、`<think>`=248068、`</think>`=248069。
|
| 125 |
+
- ⚠️ **预分词正则按 GGUF 的 `tokenizer.ggml.pre` 选**,不要用 ByteLevel 自带的
|
| 126 |
+
GPT-2 正则,否则 token id 整体错位。
|
| 127 |
+
- ⚠️ **概率校准温度**按 embedding 宽度查表(4B = `1.9924182891845703`),
|
| 128 |
+
运行时从 RKNN 内嵌的 `LLM_CONFIG` 自动读取。
|
| 129 |
+
- ✅ **单卡可同驻留 LLM + vision**:实测一张 1828 协卡上 LLM(weight 2013MB +
|
| 130 |
+
internal 44MB + kvcache 297MB)与 vision(weight 651MB + internal 65MB)同时驻留。
|
| 131 |
+
- ✅ **与官方 C++ demo 逐位一致**:prompt 字节、token id 序列、原始 logits、
|
| 132 |
+
校准概率、评分、温度全部对拍通过。
|
| 133 |
+
|
| 134 |
+
---
|
| 135 |
+
|
| 136 |
+
## License
|
| 137 |
+
|
| 138 |
+
Apache-2.0 —— 与上游 [internlm/Intern-Decision-4B](https://huggingface.co/internlm/Intern-Decision-4B) 一致。
|
| 139 |
+
|
| 140 |
+
本仓库的 RKNN 导出由 `wdnai` / `wardner` 工具链生成。
|