Rennart
/

Rennart Freakz3z commited on
Commit
6cf1fa5
·
0 Parent(s):

Duplicate from Freakz3z/Qwen-JSON

Browse files

Co-authored-by: HU RUIKE <Freakz3z@users.noreply.huggingface.co>

Files changed (4) hide show
  1. .gitattributes +36 -0
  2. Qwen-JSON_Q4_K_M.gguf +3 -0
  3. README.md +57 -0
  4. 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%** |