Text Generation
Transformers
Safetensors
qwen3
finance
quantitative-trading
alpha-factor
reinforcement-learning
grpo
qlib
conversational
text-generation-inference
Instructions to use FinStep/Alpha-R1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FinStep/Alpha-R1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FinStep/Alpha-R1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("FinStep/Alpha-R1") model = AutoModelForCausalLM.from_pretrained("FinStep/Alpha-R1", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use FinStep/Alpha-R1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FinStep/Alpha-R1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FinStep/Alpha-R1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/FinStep/Alpha-R1
- SGLang
How to use FinStep/Alpha-R1 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 "FinStep/Alpha-R1" \ --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": "FinStep/Alpha-R1", "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 "FinStep/Alpha-R1" \ --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": "FinStep/Alpha-R1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use FinStep/Alpha-R1 with Docker Model Runner:
docker model run hf.co/FinStep/Alpha-R1
File size: 6,658 Bytes
85d1222 f163935 85d1222 ba755e1 85d1222 ba755e1 85d1222 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | ---
license: mit
base_model: Qwen/Qwen3-8B
pipeline_tag: text-generation
library_name: transformers
tags:
- finance
- quantitative-trading
- alpha-factor
- reinforcement-learning
- grpo
- qlib
---
# Alpha-R1: Alpha Screening with LLM Reasoning via Reinforcement Learning
<p align="center">
<img src="assets/Alpha-R1.png" alt="Alpha-R1" style="width: 100%; height: auto;">
</p>
<p align="center">
<a href="https://huggingface.co/FinStep/Alpha-R1/blob/main/README_en.md">English</a> | <a href="https://huggingface.co/FinStep/Alpha-R1/blob/main/README.md">中文</a>
</p>
**Alpha-R1** 是一个面向量化 Alpha 筛选的推理增强型 LLM:基于 Qwen3-8B,通过 GRPO 强化学习([verl](https://github.com/volcengine/verl))以市场反馈奖励训练。它阅读 Alpha101 因子的**语义化描述**——每个因子如何起作用、何时有效、何时失效——并针对当前市场环境筛选出最值得激活的因子组合。
- 📄 Paper: [arXiv:2512.23515](https://arxiv.org/abs/2512.23515)
- 💻 Code: [FinStep-AI/Alpha-R1](https://github.com/FinStep-AI/Alpha-R1)(推理管线 / qlib 回测 / 训练配置)
- 📜 License: MIT
## 模型概览 (Model Overview)
<p align="center">
<img src="assets/framework.png" alt="Alpha-R1 framework overview" style="width: 100%;">
</p>
| 项目 | 内容 |
|---|---|
| Base model | [Qwen/Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B) |
| 训练方法 | GRPO(verl),市场反馈奖励 |
| 输入 | 决策上下文 prompt:拼接的因子语义描述 `α_des` |
| 输出 | `<alpha_list>` 中列出的选中因子 |
| 候选因子池 | 82 个 Alpha101 因子(论文筛选后) |
| 推荐解码 | temperature=0(greedy),top_p=0.7,max_new_tokens=4096 |
## 快速开始 (Quick Start)
### transformers
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "FinStep/Alpha-R1"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="bfloat16", device_map="auto")
prompt = "<decision context: concatenated factor descriptions>" # see the GitHub repo for the prompt builder
inputs = tokenizer.apply_chat_template(
[{"role": "user", "content": prompt}],
add_generation_prompt=True, return_tensors="pt",
).to(model.device)
# paper setting: temperature=0 (greedy), top_p=0.7
out = model.generate(inputs, max_new_tokens=4096, do_sample=False)
print(tokenizer.decode(out[0][inputs.shape[1]:], skip_special_tokens=True))
```
### vLLM
```python
from vllm import LLM, SamplingParams
llm = LLM(model="FinStep/Alpha-R1")
params = SamplingParams(temperature=0.0, top_p=0.7, max_tokens=4096)
outputs = llm.chat([[{"role": "user", "content": prompt}]], params)
```
完整的端到端管线(因子描述生成 → Alpha-R1 推理 → 输出解析 → qlib 策略回测)见 [GitHub 仓库](https://github.com/FinStep-AI/Alpha-R1)。
## 输出契约 (Output Contract)
模型在 `<alpha_list>...</alpha_list>` 中输出选中的因子 id,例如:
```
<alpha_list>alpha001, alpha021, alpha053</alpha_list>
```
GitHub 仓库的 `src/alpha_r1/parsing/` 提供了配套的校验与解析脚本。
## 表现 (Performance)
12 个月样本外测试(2025-01-01 ~ 2025-12-31,论文 Table 1):
<p align="center">
<img src="assets/main_results.png" alt="Backtest NAV comparison on S&P 500 (left) and CSI 300 (right)" style="width: 100%;">
</p>
<table>
<thead>
<tr>
<th rowspan="2">类型</th>
<th rowspan="2" width="160">方法</th>
<th colspan="3">S&P 500</th>
<th colspan="3">CSI 300</th>
</tr>
<tr>
<th>AR (%)</th>
<th>SR</th>
<th>MDD (%)</th>
<th>AR (%)</th>
<th>SR</th>
<th>MDD (%)</th>
</tr>
</thead>
<tbody>
<tr><td rowspan="9">Non-LLM</td><td>Buy & Hold</td><td>19.34</td><td>0.80</td><td>18.75</td><td>22.16</td><td>1.31</td><td>10.49</td></tr>
<tr><td>PCA</td><td>7.98</td><td>0.27</td><td>17.30</td><td>2.93</td><td>0.17</td><td>14.46</td></tr>
<tr><td>XGBoost</td><td>3.49</td><td>0.03</td><td>18.45</td><td>8.99</td><td>0.50</td><td>16.26</td></tr>
<tr><td>LightGBM</td><td>-5.42</td><td>-0.43</td><td>20.93</td><td>18.44</td><td>1.05</td><td>14.92</td></tr>
<tr><td>A2C</td><td>10.82</td><td>0.40</td><td>17.70</td><td>22.96</td><td>1.20</td><td>14.86</td></tr>
<tr><td>PPO</td><td>7.68</td><td>0.25</td><td>14.97</td><td>14.96</td><td>0.81</td><td>12.95</td></tr>
<tr><td>DDPG</td><td>2.53</td><td>-0.02</td><td>15.04</td><td>1.97</td><td>0.12</td><td>16.54</td></tr>
<tr><td>TD3</td><td>5.54</td><td>0.14</td><td>16.58</td><td>8.66</td><td>0.52</td><td>10.26</td></tr>
<tr><td>SAC</td><td>37.60</td><td>1.44</td><td>15.18</td><td>9.77</td><td>0.56</td><td>11.68</td></tr>
<tr><td rowspan="5">LLM</td><td>Gemini 2.5 Pro</td><td>14.23</td><td>0.55</td><td>17.01</td><td>16.29</td><td>0.90</td><td>14.01</td></tr>
<tr><td>Claude 3.7 Sonnet</td><td>10.92</td><td>0.40</td><td>18.88</td><td>10.13</td><td>0.57</td><td>14.49</td></tr>
<tr><td>DeepSeek‑R1</td><td>21.94</td><td>0.93</td><td><b>14.36</b></td><td>14.66</td><td>0.81</td><td>14.60</td></tr>
<tr><td>Qwen3‑8B</td><td>12.85</td><td>0.47</td><td>19.52</td><td>15.44</td><td>0.79</td><td>14.38</td></tr>
<tr><td><b>Alpha‑R1 (Ours)</b></td><td><b>47.87</b></td><td><b>1.62</b></td><td>16.91</td><td><b>40.57</b></td><td><b>2.23</b></td><td><b>6.58</b></td></tr>
</tbody>
</table>
域外泛化(无需重训,论文 Table 2):Russell 2000 上 80.54% AR(SR 2.46),CSI 1000 上 73.52% AR(SR 2.80)。AR = 年化收益,SR = 超额夏普比率,MDD = 最大回撤。
## 训练 (Training)
基于 Qwen3-8B,使用 verl 进行 GRPO 训练,奖励为市场反馈奖励(`R_final = R_adjusted - P_structural`,论文 §3.4)。训练配置与参考奖励实现见 GitHub 仓库的 `training/` 目录。
## 局限性 (Limitations)
- 本模型面向学术研究场景,输出不构成任何投资建议。
- 因子筛选依赖上游的描述生成与回测管线(见 GitHub 仓库),模型本身不直接产出可交易信号。
## 引用 (Citation)
```bibtex
@article{jiang2025alphar1,
title={Alpha-R1: Alpha Screening with LLM Reasoning via Reinforcement Learning},
author={Jiang, Zuoyou and Zhao, Li and Sun, Rui and Sun, Ruohan and Li, Zhongjian and Li, Jing and Jiang, Daxin and Bai, Zuo and Hua, Cheng},
journal={arXiv preprint arXiv:2512.23515},
year={2025}
}
```
## License
本项目基于 [MIT License](https://opensource.org/licenses/MIT) 发布。
|