Update README.md
Browse filesupdated — the critical enable_thinking requirement and the robot: prefix issue should be documented.

README.md
CHANGED
|
@@ -1,135 +1,176 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
library_name: rkllm
|
| 4 |
-
base_model: Qwen/Qwen3-1.7B
|
| 5 |
-
tags:
|
| 6 |
-
- rkllm
|
| 7 |
-
- rk3588
|
| 8 |
-
- npu
|
| 9 |
-
- rockchip
|
| 10 |
-
- qwen3
|
| 11 |
-
- thinking
|
| 12 |
-
- reasoning
|
| 13 |
-
- quantized
|
| 14 |
-
- edge-ai
|
| 15 |
-
- orange-pi
|
| 16 |
-
model_name: Qwen3-1.7B-RKLLM-v1.2.3
|
| 17 |
-
pipeline_tag: text-generation
|
| 18 |
-
language:
|
| 19 |
-
- en
|
| 20 |
-
- zh
|
| 21 |
-
---
|
| 22 |
-
|
| 23 |
-
# Qwen3-1.7B — RKLLM v1.2.3 (w8a8, RK3588)
|
| 24 |
-
|
| 25 |
-
RKLLM conversion of [Qwen/Qwen3-1.7B](https://huggingface.co/Qwen/Qwen3-1.7B) for Rockchip RK3588 NPU inference.
|
| 26 |
-
|
| 27 |
-
Converted with **RKLLM Toolkit v1.2.3**, which includes full **thinking mode support** — the model produces `<think>…</think>` reasoning blocks when used with compatible runtimes.
|
| 28 |
-
|
| 29 |
-
## Key Details
|
| 30 |
-
|
| 31 |
-
| Property | Value |
|
| 32 |
-
|---|---|
|
| 33 |
-
| **Base Model** | [Qwen/Qwen3-1.7B](https://huggingface.co/Qwen/Qwen3-1.7B) |
|
| 34 |
-
| **Toolkit Version** | RKLLM Toolkit v1.2.3 |
|
| 35 |
-
| **Runtime Version** | RKLLM Runtime ≥ v1.2.1 (v1.2.3 recommended) |
|
| 36 |
-
| **Quantization** | w8a8 (8-bit weights, 8-bit activations) |
|
| 37 |
-
| **Quantization Algorithm** | normal |
|
| 38 |
-
| **Target Platform** | RK3588 |
|
| 39 |
-
| **NPU Cores** | 3 |
|
| 40 |
-
| **Max Context Length** | 4096 tokens |
|
| 41 |
-
| **Optimization Level** | 1 |
|
| 42 |
-
| **Thinking Mode** | ✅ Supported |
|
| 43 |
-
| **Languages** | English, Chinese (+ others inherited from Qwen3) |
|
| 44 |
-
|
| 45 |
-
## Why This Conversion?
|
| 46 |
-
|
| 47 |
-
Previous Qwen3-1.7B RKLLM conversions on HuggingFace were built with **Toolkit v1.2.0**, which predates thinking mode support (added in v1.2.1). The chat template baked into those `.rkllm` files does not include the `<think>` trigger, so the model never produces reasoning output.
|
| 48 |
-
|
| 49 |
-
This conversion uses **Toolkit v1.2.3**, which correctly embeds the thinking-enabled chat template into the model file.
|
| 50 |
-
|
| 51 |
-
## Thinking Mode
|
| 52 |
-
|
| 53 |
-
Qwen3-1.7B is a hybrid thinking model. When served through an OpenAI-compatible API that parses `<think>` tags, reasoning content appears separately from the final answer — enabling UIs like Open WebUI to show a collapsible "Thinking…" section.
|
| 54 |
-
|
| 55 |
-
Example raw output:
|
| 56 |
-
```
|
| 57 |
-
<think>
|
| 58 |
-
The user is asking about the capital of France. This is a straightforward geography question.
|
| 59 |
-
</think>
|
| 60 |
-
The capital of France is Paris.
|
| 61 |
-
```
|
| 62 |
-
|
| 63 |
-
## Hardware Tested
|
| 64 |
-
|
| 65 |
-
- **Orange Pi 5 Plus** — RK3588, 16GB RAM, Armbian Linux
|
| 66 |
-
- RKNPU driver 0.9.8
|
| 67 |
-
- RKLLM Runtime v1.2.3
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: rkllm
|
| 4 |
+
base_model: Qwen/Qwen3-1.7B
|
| 5 |
+
tags:
|
| 6 |
+
- rkllm
|
| 7 |
+
- rk3588
|
| 8 |
+
- npu
|
| 9 |
+
- rockchip
|
| 10 |
+
- qwen3
|
| 11 |
+
- thinking
|
| 12 |
+
- reasoning
|
| 13 |
+
- quantized
|
| 14 |
+
- edge-ai
|
| 15 |
+
- orange-pi
|
| 16 |
+
model_name: Qwen3-1.7B-RKLLM-v1.2.3
|
| 17 |
+
pipeline_tag: text-generation
|
| 18 |
+
language:
|
| 19 |
+
- en
|
| 20 |
+
- zh
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
# Qwen3-1.7B — RKLLM v1.2.3 (w8a8, RK3588)
|
| 24 |
+
|
| 25 |
+
RKLLM conversion of [Qwen/Qwen3-1.7B](https://huggingface.co/Qwen/Qwen3-1.7B) for Rockchip RK3588 NPU inference.
|
| 26 |
+
|
| 27 |
+
Converted with **RKLLM Toolkit v1.2.3**, which includes full **thinking mode support** — the model produces `<think>…</think>` reasoning blocks when used with compatible runtimes.
|
| 28 |
+
|
| 29 |
+
## Key Details
|
| 30 |
+
|
| 31 |
+
| Property | Value |
|
| 32 |
+
|---|---|
|
| 33 |
+
| **Base Model** | [Qwen/Qwen3-1.7B](https://huggingface.co/Qwen/Qwen3-1.7B) |
|
| 34 |
+
| **Toolkit Version** | RKLLM Toolkit v1.2.3 |
|
| 35 |
+
| **Runtime Version** | RKLLM Runtime ≥ v1.2.1 (v1.2.3 recommended) |
|
| 36 |
+
| **Quantization** | w8a8 (8-bit weights, 8-bit activations) |
|
| 37 |
+
| **Quantization Algorithm** | normal |
|
| 38 |
+
| **Target Platform** | RK3588 |
|
| 39 |
+
| **NPU Cores** | 3 |
|
| 40 |
+
| **Max Context Length** | 4096 tokens |
|
| 41 |
+
| **Optimization Level** | 1 |
|
| 42 |
+
| **Thinking Mode** | ✅ Supported |
|
| 43 |
+
| **Languages** | English, Chinese (+ others inherited from Qwen3) |
|
| 44 |
+
|
| 45 |
+
## Why This Conversion?
|
| 46 |
+
|
| 47 |
+
Previous Qwen3-1.7B RKLLM conversions on HuggingFace were built with **Toolkit v1.2.0**, which predates thinking mode support (added in v1.2.1). The chat template baked into those `.rkllm` files does not include the `<think>` trigger, so the model never produces reasoning output.
|
| 48 |
+
|
| 49 |
+
This conversion uses **Toolkit v1.2.3**, which correctly embeds the thinking-enabled chat template into the model file.
|
| 50 |
+
|
| 51 |
+
## Thinking Mode
|
| 52 |
+
|
| 53 |
+
Qwen3-1.7B is a hybrid thinking model. When served through an OpenAI-compatible API that parses `<think>` tags, reasoning content appears separately from the final answer — enabling UIs like Open WebUI to show a collapsible "Thinking…" section.
|
| 54 |
+
|
| 55 |
+
Example raw output:
|
| 56 |
+
```
|
| 57 |
+
<think>
|
| 58 |
+
The user is asking about the capital of France. This is a straightforward geography question.
|
| 59 |
+
</think>
|
| 60 |
+
The capital of France is Paris.
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## Hardware Tested
|
| 64 |
+
|
| 65 |
+
- **Orange Pi 5 Plus** — RK3588, 16GB RAM, Armbian Linux
|
| 66 |
+
- RKNPU driver 0.9.8
|
| 67 |
+
- RKLLM Runtime v1.2.3
|
| 68 |
+
|
| 69 |
+
## Important: Enabling Thinking Mode
|
| 70 |
+
|
| 71 |
+
The RKLLM runtime requires **two things** for thinking mode to work:
|
| 72 |
+
|
| 73 |
+
### 1. Set `enable_thinking = true` in the C++ demo
|
| 74 |
+
|
| 75 |
+
The stock `llm_demo.cpp` uses `memset(&rkllm_input, 0, ...)` which defaults `enable_thinking` to `false`. You **must** add one line:
|
| 76 |
+
|
| 77 |
+
```cpp
|
| 78 |
+
rkllm_input.input_type = RKLLM_INPUT_PROMPT;
|
| 79 |
+
rkllm_input.enable_thinking = true; // ← ADD THIS LINE
|
| 80 |
+
rkllm_input.role = "user";
|
| 81 |
+
rkllm_input.prompt_input = (char *)input_str.c_str();
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
If using the Python ctypes API (`flask_server.py` / `gradio_server.py`), set it on the `RKLLMInput` struct:
|
| 85 |
+
```python
|
| 86 |
+
rkllm_input.enable_thinking = ctypes.c_bool(True)
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
Without this, the runtime never triggers the thinking chat template and the model won't produce `<think>` tags.
|
| 90 |
+
|
| 91 |
+
### 2. Handle the `robot: ` output prefix
|
| 92 |
+
|
| 93 |
+
The compiled `llm_demo` binary outputs `robot: ` before the model's actual response text. If your server uses a timing-based guard to discard residual stdout data, the `<think>` tag may arrive fast enough to be incorrectly discarded along with the prefix. Make sure your output parser:
|
| 94 |
+
|
| 95 |
+
- Strips the `robot: ` prefix (in addition to any `LLM: ` prefix)
|
| 96 |
+
- Does **not** discard data containing `<think>` even if it arrives quickly after the prompt is sent
|
| 97 |
+
|
| 98 |
+
### Compiling natively on aarch64
|
| 99 |
+
|
| 100 |
+
If building directly on the board (not cross-compiling), ignore `build-linux.sh` and compile natively:
|
| 101 |
+
|
| 102 |
+
```bash
|
| 103 |
+
cd ~/rknn-llm/examples/rkllm_api_demo/deploy
|
| 104 |
+
g++ -O2 -o llm_demo src/llm_demo.cpp \
|
| 105 |
+
-I../../../rkllm-runtime/Linux/librkllm_api/include \
|
| 106 |
+
-L../../../rkllm-runtime/Linux/librkllm_api/aarch64 \
|
| 107 |
+
-lrkllmrt -lpthread
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
## Usage
|
| 111 |
+
|
| 112 |
+
### With the official RKLLM API demo
|
| 113 |
+
|
| 114 |
+
```bash
|
| 115 |
+
# Clone the runtime
|
| 116 |
+
git clone https://github.com/airockchip/rknn-llm.git
|
| 117 |
+
cd rknn-llm/examples/rkllm_api_demo
|
| 118 |
+
|
| 119 |
+
# Run (aarch64)
|
| 120 |
+
./build/rkllm_api_demo /path/to/Qwen3-1.7B-w8a8-rk3588.rkllm 2048 4096
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
### With a custom OpenAI-compatible server
|
| 124 |
+
|
| 125 |
+
Any server that launches the RKLLM binary and parses `<think>` tags from the output stream will work. The model responds to standard chat completion requests.
|
| 126 |
+
|
| 127 |
+
## Conversion Script
|
| 128 |
+
|
| 129 |
+
```python
|
| 130 |
+
from rkllm.api import RKLLM
|
| 131 |
+
|
| 132 |
+
model_path = "Qwen/Qwen3-1.7B" # or local path
|
| 133 |
+
output_path = "./Qwen3-1.7B-w8a8-rk3588.rkllm"
|
| 134 |
+
dataset_path = "./data_quant.json" # calibration data
|
| 135 |
+
|
| 136 |
+
# Load
|
| 137 |
+
llm = RKLLM()
|
| 138 |
+
llm.load_huggingface(model=model_path, model_lora=None, device="cpu")
|
| 139 |
+
|
| 140 |
+
# Build
|
| 141 |
+
llm.build(
|
| 142 |
+
do_quantization=True,
|
| 143 |
+
optimization_level=1,
|
| 144 |
+
quantized_dtype="w8a8",
|
| 145 |
+
quantized_algorithm="normal",
|
| 146 |
+
target_platform="rk3588",
|
| 147 |
+
num_npu_core=3,
|
| 148 |
+
extra_qparams=None,
|
| 149 |
+
dataset=dataset_path,
|
| 150 |
+
max_context=4096,
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
# Export
|
| 154 |
+
llm.export_rkllm(output_path)
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
Calibration dataset: 21 diverse prompt/completion pairs (English + Chinese) generated with `generate_data_quant.py` from the [rknn-llm examples](https://github.com/airockchip/rknn-llm/tree/main/examples/rkllm_api_demo/export).
|
| 158 |
+
|
| 159 |
+
## File Listing
|
| 160 |
+
|
| 161 |
+
| File | Description |
|
| 162 |
+
|---|---|
|
| 163 |
+
| `Qwen3-1.7B-w8a8-rk3588.rkllm` | Quantized model for RK3588 NPU |
|
| 164 |
+
|
| 165 |
+
## Compatibility Notes
|
| 166 |
+
|
| 167 |
+
- **Minimum runtime**: RKLLM Runtime v1.2.1 (for thinking mode). v1.2.3 recommended.
|
| 168 |
+
- **RKNPU driver**: ≥ 0.9.6
|
| 169 |
+
- **SoCs**: RK3588 / RK3588S (3 NPU cores). Not compatible with RK3576 (2 cores) without reconversion.
|
| 170 |
+
- **RAM**: ~2GB loaded. Runs comfortably on 8GB+ boards.
|
| 171 |
+
|
| 172 |
+
## Acknowledgements
|
| 173 |
+
|
| 174 |
+
- [Qwen Team](https://huggingface.co/Qwen) for the base model
|
| 175 |
+
- [Rockchip / airockchip](https://github.com/airockchip/rknn-llm) for the RKLLM toolkit and runtime
|
| 176 |
+
- Converted by [GatekeeperZA](https://huggingface.co/GatekeeperZA)
|