Instructions to use Kaylee0501/SwAP-1.5B-theta0.3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Kaylee0501/SwAP-1.5B-theta0.3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Kaylee0501/SwAP-1.5B-theta0.3") 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("Kaylee0501/SwAP-1.5B-theta0.3") model = AutoModelForCausalLM.from_pretrained("Kaylee0501/SwAP-1.5B-theta0.3", 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 Kaylee0501/SwAP-1.5B-theta0.3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Kaylee0501/SwAP-1.5B-theta0.3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kaylee0501/SwAP-1.5B-theta0.3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Kaylee0501/SwAP-1.5B-theta0.3
- SGLang
How to use Kaylee0501/SwAP-1.5B-theta0.3 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 "Kaylee0501/SwAP-1.5B-theta0.3" \ --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": "Kaylee0501/SwAP-1.5B-theta0.3", "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 "Kaylee0501/SwAP-1.5B-theta0.3" \ --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": "Kaylee0501/SwAP-1.5B-theta0.3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Kaylee0501/SwAP-1.5B-theta0.3 with Docker Model Runner:
docker model run hf.co/Kaylee0501/SwAP-1.5B-theta0.3
SwAP-1.5B-theta0.3
SwAP-1.5B-theta0.3 is deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B trained with SwAP (Step-wise Adaptive Penalization), the method of the NeurIPS 2026 paper Stepwise Penalization for Length-Efficient Chain-of-Thought Reasoning.
SwAP shortens chains-of-thought by penalizing reasoning steps according to how much they contribute. The importance of each step is estimated from the model's own on-policy log-probability improvement toward the correct answer; excess length is treated as a penalty mass that is redistributed so that low-importance steps are penalized more heavily while high-importance reasoning is preserved. Training uses a unified outcome-process advantage inside group-relative policy optimization (GRPO):
A = beta * A_outcome + theta * 1[correct] * A_process
This checkpoint uses beta = 1, theta = 0.3 (theta weights the step-level process advantage, i.e. how strongly length is reduced).
Results
Accuracy (pass@1, %) / average response length (tokens). Sampling: temperature 0.8, top-p 0.95, max 16,384 new tokens, 16 samples per problem. Both rows were measured with the same evaluation script.
| Model | MATH-500 | AMC23 | AIME24 | AIME25 | GPQA-Diamond | Avg. |
|---|---|---|---|---|---|---|
| DeepSeek-R1-Distill-Qwen-1.5B | 85.0 / 4832 | 69.5 / 8055 | 26.5 / 12281 | 22.3 / 12312 | 34.5 / 9437 | 47.6 / 9383 |
| SwAP-1.5B-theta0.3 | 87.1 / 1464 | 76.6 / 2518 | 34.2 / 4975 | 22.5 / 4405 | 37.8 / 4788 | 51.6 / 3630 |
Usage
The model keeps the base model's chat template. Append the instruction below to math questions.
from vllm import LLM, SamplingParams
from transformers import AutoTokenizer
model = "Kaylee0501/SwAP-1.5B-theta0.3"
tok = AutoTokenizer.from_pretrained(model)
question = "What is the sum of all positive divisors of 36?"
prompt = tok.apply_chat_template(
[{"role": "user", "content": question + " Let's think step by step and output the final answer within \\boxed{}."}],
tokenize=False, add_generation_prompt=True)
llm = LLM(model=model)
out = llm.generate([prompt], SamplingParams(temperature=0.8, top_p=0.95, max_tokens=16384))
print(out[0].outputs[0].text)
Training details
- Base model:
deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B - Data: DeepScaleR (40K competition math problems)
- Algorithm: GRPO with the SwAP outcome-process advantage (beta = 1, theta = 0.3), 16 rollouts per prompt
- Step reward: answer log-probability gain after each ~350-token reasoning step (at most 20 steps); step reward weight 0.5, step penalty weight 0.3, length-penalty coefficient 1.0, maximum penalty per step 0.15
- Optimization: batch size 64 prompts, PPO mini-batch 32, learning rate 1e-6, KL loss 1e-3 (low-variance KL), rollout temperature 1.0, maximum response length 12,000 tokens
- Checkpoint: step 1240
- Framework: verl
Citation
@inproceedings{li2026swap,
title = {Stepwise Penalization for Length-Efficient Chain-of-Thought Reasoning},
author = {Li, Xintong and Li, Sha and Lin, Rongmei and Jin, Hongye and Li, Linwei and Cui, Hejie and Zhang, Sarah and
Chang, Chia-Yuan and Cheng, Kewei and Zhang, Yuwei and Yin, Qingyu and Shang, Jingbo and Yin, Bing},
booktitle = {Advances in Neural Information Processing Systems},
year = {2026}
}
- Downloads last month
- 252
Model tree for Kaylee0501/SwAP-1.5B-theta0.3
Base model
deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B