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"
File size: 5,232 Bytes
3c7a2db | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | ---
base_model: internlm/Intern-Decision-4B
license: apache-2.0
pipeline_tag: image-text-to-text
tags:
- rknn
- rockchip
- rk3588
- rk1820
- intern-decision
- multimodal
- decision
- npu
---
# Intern-Decision-4B — Rockchip RKNN 部署包
[Intern-Decision-4B](https://huggingface.co/internlm/Intern-Decision-4B) 的 **RKNN 导出**,
供 Rockchip 协处理器(RK1820 / RK3588)上的 NPU 推理使用。
上游是原始权重;**本仓库只包含 RKNN 量化导出后的运行期文件**,不能直接用
`transformers` 加载,需要通过下面的 `wdnai` SDK 加载。
---
## ⚠️ 这不是对话模型
Intern-Decision **不生成文本**。它对任务里的每个「决策字段」输出 **62 个候选符号**
(`A-Z` + `a-z` + `0-9`)的 logits,由 CPU 侧换算成选项概率:
| 字段类型 | 语义 | 输出 |
|---|---|---|
| `choice` | 选一项 | 选项概率(**归一化**,合计为 1) |
| `score` | 打分 | 概率加权评分 |
| `noul` | 是否 | 肯定概率(**不归一化**,各项独立) |
调用方必须传**任务配置**(`task=`)。答案形如 `{"category": "account", "urgency": 0.7676}`,
完整概率 / logits 随文本附件一起回传。
---
## 文件说明
| 文件 | 大小 | 说明 |
|---|---|---|
| `Intern-Decision-4B-llm.rknn` | 25 MB | LLM 计算图 |
| `Intern-Decision-4B-llm.weight` | 2.0 GB | LLM 权重 |
| `Intern-Decision-4B-llm.embed.bin` | 1.2 GB | LLM embedding 表(词表 248320) |
| `Intern-Decision-4B-llm.tokenizer.gguf` | 11 MB | GGUF 预分词器 |
| `Intern-Decision-4B-vision.rknn` | 4.6 MB | 视觉编码器计算图(384×384) |
| `Intern-Decision-4B-vision.weight` | 651 MB | 视觉编码器权重 |
| `intern-decision-4b.json` | 4 KB | 模型清单(`wdnai` SDK 用) |
| `Intern-Decision-4B-llm_report/model_report.html` | 220 KB | LLM 转换报告(RKNX 可视化) |
| `Intern-Decision-4B-vision_report/model_report.html` | 84 KB | 视觉转换报告 |
---
## 使用
### 1. 放置目录
默认目录 `/userdata/models/Intern_Decision-4B`,也可以用环境变量指定:
```bash
export WDNAI_INTERN_DECISION_4B_DIR=/path/to/Intern_Decision-4B
```
### 2. 加载
```python
from wdnai.model import SystemLanguageModel
spec = SystemLanguageModel.intern_decision_4b()
session = spec.session() # LLM + 视觉编码器常驻,约 3100 MB 显存
```
### 3. 下决策任务
```python
from wdnai.decision import parse_decision_task
task = parse_decision_task({
"questions": {
"广告": {"type": "noul", "criteria": {"no": "没有广告", "yes": "含广告"}},
"诈骗": {"type": "noul", "criteria": {"no": "没有诈骗", "yes": "含诈骗"}},
}
})
text, attachments = session.run_prompt(
prompt="限时优惠,加微信领红包",
attachment=[image], # 可选
task=task,
)
```
---
## 实测性能(RK3588 + 1 张 1828 协卡)
**prefill-only 模型**:每个字段跑一次 `max_new_tokens=1` 的推理,解码 token 恒为 0
⇒ 吞吐指标是**预填充速率**(提示词处理速度),不是生成速度。
| 维度数 | 纯文本 | 图文 |
|---|---|---|
| 1 | 0.55 s | 0.94 s |
| 4 | 2.68 s | 3.70 s |
| 7 | 6.30 s | 8.04 s |
| 16 | 23.30 s | 26.55 s |
⚠️ **耗时随维度数呈平方增长**:字段 *i* 的 prompt 前缀包含字段 0..*i*−1 的定义
⇒ 总 prefill 量 ∝ *N*²。图片的 151 个视觉 token 也会被**每个字段重新 prefill 一遍**。
---
## 部署注意事项
- ⚠️ **每个字段必须换一次 LLM session**:模型有 linear-attention 层,递归状态跨调用
残留,`keep_history=0` 只清 KV cache 不清递归状态 ⇒ 每个字段都要
`recreate_llm_session()`。官方 C++ 参考实现同理(每字段
`rknn3_session_init/destroy`)。
- ⚠️ **prompt 里的 ChatML 标记是「写进文本」的,不是 chat template**:导出模型的
`chat_template` 是空的,C 侧必须保持 `set_chat_template("", "", "")`。完整形态是
`<|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`
—— 少写这 6 个标记就少 66 字节 / 6 个 token,token 位置整体错位、概率明显偏移。
- ⚠️ **控制 token 必须是单 token**:`<decision>`=248077、`<think>`=248068、`</think>`=248069。
- ⚠️ **预分词正则按 GGUF 的 `tokenizer.ggml.pre` 选**,不要用 ByteLevel 自带的
GPT-2 正则,否则 token id 整体错位。
- ⚠️ **概率校准温度**按 embedding 宽度查表(4B = `1.9924182891845703`),
运行时从 RKNN 内嵌的 `LLM_CONFIG` 自动读取。
- ✅ **单卡可同驻留 LLM + vision**:实测一张 1828 协卡上 LLM(weight 2013MB +
internal 44MB + kvcache 297MB)与 vision(weight 651MB + internal 65MB)同时驻留。
- ✅ **与官方 C++ demo 逐位一致**:prompt 字节、token id 序列、原始 logits、
校准概率、评分、温度全部对拍通过。
---
## License
Apache-2.0 —— 与上游 [internlm/Intern-Decision-4B](https://huggingface.co/internlm/Intern-Decision-4B) 一致。
本仓库的 RKNN 导出由 `wdnai` / `wardner` 工具链生成。
|