Text Generation
Transformers
GGUF
English
unsloth
trl
grpo
reinforcement-learning
json
recipe
conversational
Instructions to use Rennart/Qwen-JSON with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Rennart/Qwen-JSON with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Rennart/Qwen-JSON")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Rennart/Qwen-JSON", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Rennart/Qwen-JSON 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 Rennart/Qwen-JSON:Q4_K_M # Run inference directly in the terminal: llama cli -hf Rennart/Qwen-JSON:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Rennart/Qwen-JSON:Q4_K_M # Run inference directly in the terminal: llama cli -hf Rennart/Qwen-JSON:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Rennart/Qwen-JSON:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Rennart/Qwen-JSON:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Rennart/Qwen-JSON:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Rennart/Qwen-JSON:Q4_K_M
Use Docker
docker model run hf.co/Rennart/Qwen-JSON:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Rennart/Qwen-JSON with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Rennart/Qwen-JSON" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rennart/Qwen-JSON", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Rennart/Qwen-JSON:Q4_K_M
- SGLang
How to use Rennart/Qwen-JSON with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Rennart/Qwen-JSON" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rennart/Qwen-JSON", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Rennart/Qwen-JSON" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rennart/Qwen-JSON", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use Rennart/Qwen-JSON with Ollama:
ollama run hf.co/Rennart/Qwen-JSON:Q4_K_M
- Unsloth Desktop
- Pi
How to use Rennart/Qwen-JSON with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Rennart/Qwen-JSON:Q4_K_M
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:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Rennart/Qwen-JSON:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use Rennart/Qwen-JSON with Docker Model Runner:
docker model run hf.co/Rennart/Qwen-JSON:Q4_K_M
- Lemonade
How to use Rennart/Qwen-JSON with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Rennart/Qwen-JSON:Q4_K_M
Run and chat with the model
lemonade run user.Qwen-JSON-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use Rennart/Qwen-JSON with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Rennart/Qwen-JSON:Q4_K_M
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 Rennart/Qwen-JSON:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Rennart/Qwen-JSON with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Rennart/Qwen-JSON:Q4_K_M
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 "Rennart/Qwen-JSON:Q4_K_M" \ --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"
Duplicate from Freakz3z/Qwen-JSON
Browse filesCo-authored-by: HU RUIKE <Freakz3z@users.noreply.huggingface.co>
- .gitattributes +36 -0
- Qwen-JSON_Q4_K_M.gguf +3 -0
- README.md +57 -0
- README_CN.md +43 -0
.gitattributes
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
Qwen-JSON_Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
Qwen-JSON_Q4_K_M.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ec43272bc26ffe0405ef4f7b132ac6d77809666755e57fd0b35d004287374fd
|
| 3 |
+
size 2497280224
|
README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: Qwen/Qwen3-4B-Instruct-2507
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
model_name: qwen-json
|
| 8 |
+
pipeline_tag: text-generation
|
| 9 |
+
tags:
|
| 10 |
+
- unsloth
|
| 11 |
+
- trl
|
| 12 |
+
- grpo
|
| 13 |
+
- reinforcement-learning
|
| 14 |
+
- json
|
| 15 |
+
- recipe
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# RL-Struct: Bridging the Structure Gap
|
| 19 |
+
|
| 20 |
+
[中文版本](./README_CN.md) | [📚 Paper](https://huggingface.co/papers/2512.00319)
|
| 21 |
+
|
| 22 |
+
We introduce **RL-Struct**, a lightweight Reinforcement Learning framework designed to solve the "Structure Gap"—the tension between probabilistic token generation and deterministic structured formats (e.g., JSON). By leveraging **GRPO (Gradient Regularized Policy Optimization)** and a **Multi-dimensional Reward Function**, our model achieves superior structural reliability without the high inference latency of constrained decoding.
|
| 23 |
+
|
| 24 |
+
## 🚀 Key Features
|
| 25 |
+
|
| 26 |
+
- **Multi-dimensional Reward Function**: Decomposes the objective into Structure, Format, Validity, Correctness, and Length.
|
| 27 |
+
- **Efficient Training**: Uses GRPO to eliminate the critic network, reducing VRAM usage by ~40% compared to PPO.
|
| 28 |
+
- **Emergent Curriculum**: The model spontaneously learns syntax (how to speak) before semantics (what to say).
|
| 29 |
+
- **High Performance**: Achieves **89.7% Structural Accuracy** and **92.1% JSON Validity** on complex recipe generation, outperforming LLaMA-3-8B and GPT-3.5.
|
| 30 |
+
|
| 31 |
+
## 📊 Model Details
|
| 32 |
+
|
| 33 |
+
- **Base Model:** [Qwen/Qwen3-4B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507)
|
| 34 |
+
- **Training Method:** GRPO (Reinforcement Learning) + LoRA
|
| 35 |
+
- **Task:** Structured Output Generation (JSON Recipes, GSM8K-JSON, ToolUse)
|
| 36 |
+
- **License:** Apache-2.0
|
| 37 |
+
|
| 38 |
+
## 🛠️ Usage
|
| 39 |
+
|
| 40 |
+
The following is the system prompt:
|
| 41 |
+
|
| 42 |
+
```text
|
| 43 |
+
You are a precise recipe assistant. Always respond in the following JSON format:
|
| 44 |
+
{
|
| 45 |
+
"reasoning": "Your step-by-step reasoning here...",
|
| 46 |
+
"answer": "{\"name\": \"Recipe Name\", \"nutrition\": \"Calories: ..., Protein: ..., Fat: ...\"}"
|
| 47 |
+
}
|
| 48 |
+
Do not include any other text, explanations, or markdown. Only output valid JSON.
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
## 📈 Performance
|
| 52 |
+
|
| 53 |
+
| Method | Structural Acc. | JSON Validity | Content Acc. |
|
| 54 |
+
| :--- | :---: | :---: | :---: |
|
| 55 |
+
| GPT-3.5 (Zero-shot) | 45.5% | 82.1% | 88.0% |
|
| 56 |
+
| LLaMA-3-8B (SFT) | 78.2% | 85.4% | 86.0% |
|
| 57 |
+
| **RL-Struct (Ours)** | **89.7%** | **92.1%** | **84.5%** |
|
README_CN.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RL-Struct: 弥合结构鸿沟
|
| 2 |
+
|
| 3 |
+
[English Version](./README.md)
|
| 4 |
+
|
| 5 |
+
本仓库包含论文 **"Bridging the Structure Gap: A Lightweight RL Framework for Reliable Structured Output Generation in LLMs"** 的模型和代码。
|
| 6 |
+
|
| 7 |
+
我们提出了 **RL-Struct**,这是一个轻量级的强化学习框架,旨在解决“结构鸿沟”问题——即概率性 Token 生成与确定性结构化格式(如 JSON)之间的矛盾。通过利用 **GRPO(梯度正则化策略优化)** 和新颖的 **多维奖励函数**,我们的模型在无需高延迟约束解码的情况下,实现了卓越的结构可靠性。
|
| 8 |
+
|
| 9 |
+
## 🚀 核心特性
|
| 10 |
+
|
| 11 |
+
- **多维奖励函数**:将目标分解为结构(Structure)、格式(Format)、有效性(Validity)、正确性(Correctness)和长度(Length)。
|
| 12 |
+
- **高效训练**:使用 GRPO 消除 Critic 网络,相比 PPO 减少约 40% 的显存占用。
|
| 13 |
+
- **涌现课程学习**:模型自发地先学习语法(如何说),再学习语义(说什么)。
|
| 14 |
+
- **高性能**:在复杂的食谱生成任务上实现了 **89.7% 的结构准确率** 和 **92.1% 的 JSON 有效性**,优于 LLaMA-3-8B 和 GPT-3.5。
|
| 15 |
+
|
| 16 |
+
## 📊 模型详情
|
| 17 |
+
|
| 18 |
+
- **基座模型:** [Qwen/Qwen3-4B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507)
|
| 19 |
+
- **训练方法:** GRPO (强化学习) + LoRA
|
| 20 |
+
- **任务:** 结构化输出生成 (JSON 食谱, GSM8K-JSON, ToolUse)
|
| 21 |
+
- **协议:** Apache-2.0
|
| 22 |
+
|
| 23 |
+
## 🛠️ 使用方法
|
| 24 |
+
|
| 25 |
+
### 系统提示词 (System Prompt)
|
| 26 |
+
为确保正确的 JSON 输出,请使用以下系统提示词:
|
| 27 |
+
|
| 28 |
+
```text
|
| 29 |
+
You are a precise recipe assistant. Always respond in the following JSON format:
|
| 30 |
+
{
|
| 31 |
+
"reasoning": "Your step-by-step reasoning here...",
|
| 32 |
+
"answer": "{\"name\": \"Recipe Name\", \"nutrition\": \"Calories: ..., Protein: ..., Fat: ...\"}"
|
| 33 |
+
}
|
| 34 |
+
Do not include any other text, explanations, or markdown. Only output valid JSON.
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
## 📈 性能表现
|
| 38 |
+
|
| 39 |
+
| 方法 | 结构准确率 | JSON 有效性 | 内容准确率 |
|
| 40 |
+
| :--- | :---: | :---: | :---: |
|
| 41 |
+
| GPT-3.5 (Zero-shot) | 45.5% | 82.1% | 88.0% |
|
| 42 |
+
| LLaMA-3-8B (SFT) | 78.2% | 85.4% | 86.0% |
|
| 43 |
+
| **RL-Struct (Ours)** | **89.7%** | **92.1%** | **84.5%** |
|