Text Generation
Transformers
Safetensors
qwen3
reinforcement-learning
score-centering
code-generation
experimental
conversational
text-generation-inference
Instructions to use Palind/Qwen3-4B-SC-CodeAgent-500Steps with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Palind/Qwen3-4B-SC-CodeAgent-500Steps with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Palind/Qwen3-4B-SC-CodeAgent-500Steps") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Palind/Qwen3-4B-SC-CodeAgent-500Steps") model = AutoModelForCausalLM.from_pretrained("Palind/Qwen3-4B-SC-CodeAgent-500Steps", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Palind/Qwen3-4B-SC-CodeAgent-500Steps with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Palind/Qwen3-4B-SC-CodeAgent-500Steps" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Palind/Qwen3-4B-SC-CodeAgent-500Steps", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Palind/Qwen3-4B-SC-CodeAgent-500Steps
- SGLang
How to use Palind/Qwen3-4B-SC-CodeAgent-500Steps 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 "Palind/Qwen3-4B-SC-CodeAgent-500Steps" \ --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": "Palind/Qwen3-4B-SC-CodeAgent-500Steps", "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 "Palind/Qwen3-4B-SC-CodeAgent-500Steps" \ --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": "Palind/Qwen3-4B-SC-CodeAgent-500Steps", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Palind/Qwen3-4B-SC-CodeAgent-500Steps with Docker Model Runner:
docker model run hf.co/Palind/Qwen3-4B-SC-CodeAgent-500Steps
|
Download README.md from Palind/Qwen3-4B-SC-CodeAgent-500Steps: direct link, hf CLI and curl.
- Browser
- Download file 5.04 kB
-
https://huggingface.co/Palind/Qwen3-4B-SC-CodeAgent-500Steps/resolve/main/README.md
- Command line
-
hf download hf://Palind/Qwen3-4B-SC-CodeAgent-500Steps/README.md
-
curl -L -o README.md https://huggingface.co/Palind/Qwen3-4B-SC-CodeAgent-500Steps/resolve/main/README.md
5.04 kB
| library_name: transformers | |
| license: apache-2.0 | |
| license_link: https://huggingface.co/Palind/Qwen3-4B-SC-CodeAgent-500Steps/blob/main/LICENSE | |
| pipeline_tag: text-generation | |
| base_model: Qwen/Qwen3-4B | |
| base_model_relation: finetune | |
| datasets: | |
| - BAAI/TACO | |
| tags: | |
| - reinforcement-learning | |
| - score-centering | |
| - code-generation | |
| - experimental | |
| - qwen3 | |
| # Qwen3-4B-SC-CodeAgent-500Steps | |
| 这是原始 **[Qwen/Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B)** 经 Score Centering(SC)异步代码任务训练得到的探索性检查点。从第 200 步训练检查点恢复模型、优化器等状态,继续训练至第 500 步,发布为 **BF16 推理权重**。[200 步版本](https://huggingface.co/Palind/Qwen3-4B-SC-CodeAgent-200Steps)保留独立仓库。 | |
| **本仓库发布的是第 500 步,不是开发集上表现最好的检查点。** 它适合复现实验和分析训练行为,目前不能据此宣称通用代码 agent 能力或 SC 算法优势。 | |
| ## 指标 | |
|  | |
| 以下均为同一固定 **256 题 TACO 开发集**上的结果。每题只采样一次:`n=1`、`temperature=0.6`、`top_p=1.0`、`top_k=-1`;每 25 步评估一次。 | |
| | 步数 | 全测试通过题数 | 题目准确率 | 逐题测试通过率均值 | 有可提取代码 | | |
| |---:|---:|---:|---:|---:| | |
| | 200 | 130/256 | 50.78% | 56.11% | 61.33% | | |
| | 350 | 133/256 | 51.95% | 61.59% | 74.61% | | |
| | 475 | 135/256 | **52.73%** | 63.57% | 89.84% | | |
| | 500 | 118/256 | 46.09% | 60.79% | **91.80%** | | |
| 第 475 步是已记录验证点中的最高准确率,**但当时没有保存权重**,不能从评估日志恢复该模型。本次发布不以第 475 步分数代表第 500 步权重。 | |
| `acc` 要求一题的最终代码通过全部保存测试;训练奖励 `pass_rate` 是该题通过测试的比例,再逐题平均。两者不同:从 200 到 500 步,平均测试通过率上升,但全对题数下降。`format_ok` 只表示末次助手回答中能提取代码,不代表代码正确。 | |
| 全程 32,000 条训练轨迹中,只有 **41 条(约 0.13%)**实际执行过工具;最终开发集工具使用率为 0。最后 50 步的训练截断率平均为 **8.34%**,第 200 步之前最后 50 步为 40.81%。格式与截断有所改善,但没有形成稳定的工具使用行为。 | |
| 完整曲线数值见[逐步指标](./metrics/metrics.jsonl)。SwanLab:[1–200 步](https://swanlab.cn/@Palind/sc-agentic-rl/runs/lijvc2qg)、[201–500 步](https://swanlab.cn/@Palind/sc-agentic-rl/runs/lncfjse1)。 | |
| ## 方法与数据 | |
| - **框架与资源**:verl 原生 `ToolAgentLoop` + 自定义、无状态的 `run_python`,8 × A100 80GB,4 张 FSDP2 训练、4 张 vLLM rollout。不是 Harbor、Terminal-Bench 或 SWE 环境。 | |
| - **目标**:REINFORCE 形式的策略损失 + top-128 近似 SC;每题 4 个回答,奖励减去组内均值,不按标准差归一化。不使用 TIS、RS、PPO clipping、critic、KL 惩罚或工具调用奖励。 | |
| - **优化**:AdamW,恒定学习率 `1e-6`,weight decay=0,梯度范数裁剪 1.0;BF16 计算、FP32 主参数。每训练步 16 题 × 4 条轨迹。 | |
| - **异步**:自然 `separate_async`,每步同步权重,`max_off_policy_threshold=4`、`drop`;不是人为给所有样本固定增加 4 步延迟。 | |
| - **长度与采样**:thinking 模式;prompt 上限 4,096、响应上限 8,192 tokens,最多 6 个助手轮次。训练使用 temperature=1.0、top-p=1.0,不启用生成 top-k 截断。SC 的 top-128 是概率记录宽度。 | |
| - **数据**:[TACO](https://huggingface.co/datasets/BAAI/TACO) 的固定训练分片 02、03、04,经标准输入/输出接口筛选、身份去重和隔离参考解校验,划分为 **2,000 题 train + 256 题 dev**。这不是官方 TACO test,也不是整个 TACO 的随机抽样。上游 revision:`d593ed0a2becbbc952230bb89be09189bf1056dc`。 | |
| 隐藏测试只供最终判题,不作为工具反馈。Python 程序在 Landlock + seccomp 隔离环境中运行,限制网络、文件和进程访问;单测试 3 秒、每题累计执行预算 90 秒,排队不计入该预算。完整参数见[配置摘要](./experiment/training_config.json)。 | |
| ## 使用范围与局限 | |
| 本仓库包含 BF16 推理权重、tokenizer、指标和配置摘要,不含优化器状态或完整 agent harness。已逐张量核验导出结果与源分片的 BF16 转换一致,并完成本地加载和短前向检查;详见[转换清单](./conversion_manifest.json)。以上分数来自训练期间评测,导出后未重新运行完整开发集。 | |
| 单次运行,没有 step-0 基线、匹配的无 SC 对照或多种子重复;开发集已被反复评估,**尚无 LiveCodeBench 分数**。不能据此判断 SC 优劣或通用 agent 能力,也不能仅凭最后一次分数下降断言稳定退化。 | |
| 参考:[Score Centering 论文](https://arxiv.org/html/2609.20807v1)、[verl](https://github.com/verl-project/verl)、[Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B)。 | |