通义智文开源QwenLong-L1: 迈向长上下文大推理模型的强化学习
🎉 动态
2025年5月26日: 🔥 我们正式发布🤗QwenLong-L1-32B——首个采用强化学习训练、专攻长文本推理的LRM模型。在七项长文本文档问答基准测试中,QwenLong-L1-32B性能超越OpenAI-o3-mini和Qwen3-235B-A22B等旗舰LRM,达到与Claude-3.7-Sonnet-Thinking持平的水准,展现了当前最先进长文本推理模型的领先实力。
2025年5月26日: 🔥 我们同步开源🤗DocQA-RL-1.6K专项强化学习数据集,包含1,600道涵盖数学演算、逻辑推理和多跳推理等领域的文档问答题目。
📚 简介
在本研究中,我们提出了QwenLong-L1,这是一种新颖的强化学习(RL)框架,旨在促进LRM从短上下文熟练度向稳健的长上下文泛化过渡。在我们的初步实验中,我们展示了短上下文和长上下文推理RL训练动态之间的差异。
我们的框架通过强化学习训练中的渐进式上下文扩展,增强了短上下文语言推理模型(LRM)的性能。该框架包含三个核心组件:用于初始化稳健策略的预热监督微调(SFT)阶段;通过课程引导的强化学习阶段实现从短上下文到长上下文的稳定适应;以及难度感知的回溯采样机制,通过动态调整各阶段训练复杂度来激励策略探索。我们整合了包括GRPO和DAPO在内的最新强化学习算法,结合基于规则和基于模型的二元结果奖励混合函数,以平衡精确率与召回率。在策略优化过程中,通过战略性利用群体相对优势,引导LRM学习对实现稳健长上下文锚定和卓越推理能力至关重要的有效推理模式。
🎯 模型发布
我们发布了🤗 QwenLong-L1-32B,这是首个通过强化学习训练、专为长文本推理设计的长上下文语言推理模型。在七项长文本文档问答基准测试中,QwenLong-L1-32B性能超越OpenAI-o3-mini和Qwen3-235B-A22B等旗舰语言推理模型,达到与Claude-3.7-Sonnet-Thinking相当的水准,展现出当前最先进语言推理模型中的领先性能。
以下是评估结果。
🛠️ 要求
# Create the conda environment
conda create -n qwenlongl1 python==3.10
conda activate qwenlongl1# Install requirements
pip3 install -r requirements.txt# Install verl
cd verl
pip3 install -e .# Install vLLM
pip3 install vllm==0.7.3 # Install flash-attn
pip3 install flash-attn --no-build-isolation
🚀 快速入门
以下是如何使用 🤗 Transformers 运行该模型:
from transformers import AutoModelForCausalLM, AutoTokenizermodel_name = "Tongyi-Zhiwen/QwenLong-L1-32B"# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name,torch_dtype="auto",device_map="auto"
)# prepare the model input
template = """Please read the following text and answer the question below.<text>
$DOC$
</text>$Q$Format your response as follows: "Therefore, the answer is (insert answer here)"."""
context = "<YOUR_CONTEXT_HERE>"
question = "<YOUR_QUESTION_HERE>"
prompt = template.replace('$DOC$', context.strip()).replace('$Q$', question.strip())
messages = [{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)# conduct text completion
generated_ids = model.generate(**model_inputs,max_new_tokens=10000,temperature=0.7,top_p=0.95
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() # parsing thinking content
try:# rindex finding 151649 (</think>)index = len(output_ids) - output_ids[::-1].index(151649)
except ValueError:index = 0thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")print("thinking content:", thinking_content)
print("content:", content)
🗂️ 数据集
为了构建一个具有挑战性的可验证长文本推理强化学习数据集,我们开发了🤗DocQA-RL-1.6K,该数据集包含跨三个推理领域的1600个文档问答问题:
(1) 数学推理:我们使用DocMath数据集中的600道问题,这些问题要求对财务报告等长专业文档进行数值推理。对于DocMath数据集,我们从其验证集中每个子集抽取75%条目用于训练,25%用于评估;
(2) 逻辑推理:我们采用DeepSeek-R1合成了600道多选题,这些问题需要对我们精选的法律、金融、保险和生产领域真实文档进行逻辑分析;
(3) 多跳推理:我们从MultiHopRAG选取200个样本,从Musique选取200个样本,重点关注跨文档推理。
请下载以下数据集并放入./datasets/
目录用于训练和评估。
强化学习训练数据:🤗DocQA-RL-1.6K
评估数据:🤗docmath、🤗frames、🤗longbench
💻 训练
我们为单阶段强化学习训练提供了基于DAPO的基础演示代码。
首先,我们应该启动一个本地验证器。
export CUDA_VISIBLE_DEVICES=0vllm serve "Qwen/Qwen2.5-1.5B-Instruct" \--host 0.0.0.0 \--port 23547
然后,我们开始使用4个节点进行强化学习训练。
export PROJ_DIR="<YOUR_PROJ_DIR_HERE>"
export MASTER_IP="<YOUR_MASTER_IP_HERE>" # ray master ip
export NNODES=4 # total GPU nodes
export NODE_RANK=${RANK} # rank of current node
export PORT=6382
export WANDB_API_KEY="<YOUR_WANDB_API_KEY_HERE>"
export WANDB_PROJECT="QwenLong-L1"
export LLM_JUDGE=Y # 'Y': LLM JUDGE, 'N': RULE BASED
export VLLM_ATTENTION_BACKEND=FLASH_ATTN
# verifier
export VERIFIER_PATH="Qwen/Qwen2.5-1.5B-Instruct"
export VERIFIER_HOST="<YOUR_VERIFIER_HOST_HERE>"
export VERIFIER_PORT="23547"ray_start_retry() {while true; doray start --address="${MASTER_IP}:${PORT}"if [ $? -eq 0 ]; thenbreakfiecho "Failed to connect to master, retrying in 5 seconds..."sleep 5done
}check_ray_status() {until ray status >/dev/null 2>&1; doecho "Waiting for Ray cluster to be ready..."sleep 5done
}if [ "$RANK" == "0" ]; thenecho "Starting HEAD node..."ray start --head --port=${PORT}check_ray_statusecho "Ray head node started successfully"elseecho "Starting WORKER node..."ray_start_retrycheck_ray_statusecho "Successfully joined Ray cluster"
fiif [ "$RANK" == "0" ]; thenbash ${PROJ_DIR}/scripts/rl_4nodes_dapo.sh 2>&1 | tee ${PROJ_DIR}/logs/rl_log_$(date +%Y%m%d_%H%M%S).txt &
elsesleep 30d
fiwait
实践演示
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfigmodel_name = "Tongyi-Zhiwen/QwenLong-L1-32B"quantization_config = BitsAndBytesConfig(load_in_4bit=True)# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name,torch_dtype="auto",device_map="auto",quantization_config=quantization_config,
)# prepare the model input
template = """Please read the following text and answer the question below.<text>
$DOC$
</text>$Q$Format your response as follows: "Therefore, the answer is (insert answer here)"."""# 填充上下文和问题
context = """
Renewable energy sources are crucial for addressing climate change and reducing dependence on fossil fuels. Solar power is one of the most abundant and widely available renewable energy sources. It converts sunlight directly into electricity using photovoltaic (PV) cells or indirectly through concentrated solar power (CSP) systems.Wind energy is another rapidly growing renewable source. Wind turbines capture the kinetic energy of moving air and convert it into electrical energy. Onshore wind farms are more common, but offshore wind farms are becoming increasingly popular due to stronger and more consistent wind resources.Hydroelectric power is generated by harnessing the energy of flowing water in rivers or dams. It is one of the oldest and most established renewable energy technologies, providing a reliable and flexible source of electricity.Biomass energy uses organic materials such as wood, agricultural waste, and dedicated energy crops to produce heat, electricity, or biofuels. It is considered renewable because the carbon dioxide released during combustion is offset by the carbon dioxide absorbed during the growth of the biomass feedstock.Geothermal energy taps into the Earth's internal heat to generate electricity or provide direct heating and cooling. It is a reliable and consistent energy source, particularly in regions with high geothermal activity.The transition to renewable energy is driven by several factors, including environmental concerns, energy security, and technological advancements. However, challenges remain, such as the intermittency of solar and wind power, high initial costs, and the need for energy storage solutions.Despite these challenges, the global renewable energy market is expanding rapidly. Many countries have set ambitious renewable energy targets, and investments in renewable energy technologies continue to grow. The International Renewable Energy Agency (IRENA) projects that renewable energy could account for up to 86% of global electricity generation by 2050 if current trends continue.
"""question = """
What are the main types of renewable energy sources mentioned in the text, and what are their respective advantages?
"""# 构建提示
prompt = template.replace('$DOC$', context.strip()).replace('$Q$', question.strip())
messages = [{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)# conduct text completion
generated_ids = model.generate(**model_inputs,max_new_tokens=10000,temperature=0.7,top_p=0.95
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() # parsing thinking content
try:# rindex finding 151649 (</think>)index = len(output_ids) - output_ids[::-1].index(151649)
except ValueError:index = 0thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")print("thinking content:", thinking_content)
print("content:", content)
输出:
thinking content: Okay, let me try to figure this out. The question is asking for the main types of renewable energy sources mentioned in the text and their respective advantages. First, I need to go through the text again to identify each renewable energy source and note down their advantages.Starting with the first paragraph, it mentions solar power. The text says solar power uses photovoltaic cells or CSP systems. The advantage here is that it's abundant and widely available. Then, wind energy is next. The text talks about onshore and offshore wind farms. The advantage for wind is that offshore farms have stronger and more consistent winds, which I think makes them more reliable.Hydroelectric power is mentioned next. It's described as one of the oldest and most established, providing reliable and flexible electricity. So the advantage here is reliability and flexibility. Biomass energy uses organic materials and is considered renewable because the CO2 released is offset by the growth of the feedstock. The advantage here is that it's renewable in terms of carbon balance.Geothermal energy is next, using the Earth's internal heat. The advantage is that it's reliable and consistent, especially in areas with high geothermal activity. Wait, the question is about the main types and their advantages. Let me list them out:1. Solar power: Abundant and widely available.
2. Wind energy: Stronger and more consistent winds offshore.
3. Hydroelectric power: Reliable and flexible.
4. Biomass energy: Carbon neutrality (offset by growth).
5. Geothermal energy: Reliable and consistent.I think that's all the main types mentioned. The text also mentions challenges like intermittency for solar and wind, but the question is about advantages, so I should focus on the positive aspects each has. I need to make sure I didn't miss any. Let me check the text again.Yes, the text lists solar, wind, hydroelectric, biomass, and geothermal. Each has their specific advantages as I noted. So the answer should list each type with their respective advantages.
</think>
content: Therefore, the answer is Solar power (abundant and widely available), wind energy (stronger and consistent offshore winds), hydroelectric power (reliable and flexible), biomass energy (carbon neutrality through growth of feedstock), and geothermal energy (reliable and consistent internal heat).
相关文章:

通义智文开源QwenLong-L1: 迈向长上下文大推理模型的强化学习
🎉 动态 2025年5月26日: 🔥 我们正式发布🤗QwenLong-L1-32B——首个采用强化学习训练、专攻长文本推理的LRM模型。在七项长文本文档问答基准测试中,QwenLong-L1-32B性能超越OpenAI-o3-mini和Qwen3-235B-A22B等旗舰LRM,…...
HTTP代理的实际用处有哪些?HTTP代理强在哪里?
嘿,小伙伴们!今天咱们来聊聊 HTTP 代理。大家可能会经常在网页上看到类似“HTTP 代理”的关键词,是不是会心生疑惑:这不就是个技术名词吗?它到底有啥用呢?别急,听我娓娓道来。 一、什么是HTTP代…...

低代码——表单生成器以form-generator为例
主要执行流程说明: 初始化阶段 : 接收表单配置对象formConf深拷贝配置,初始化表单数据和验证规则处理每个表单组件的默认值和特殊配置(如文件上传) 渲染阶段 : 通过render函数创建el-form根组件递归渲染表…...
【Vue Vapor Mode :技术突破与性能优化的可能性】
Vue Vapor Mode :技术突破与性能优化的可能性 前言 作为一名有着Vue 2经验和Vue 3经验的开发者,你一定深刻体会过Vue从Options API到Composition API的演进,也感受过Vue 3在性能上相比Vue 2的显著提升。现在,Vue团队正在开发一个…...
Parasoft C++Test软件单元测试_常见问题及处理
系列文章目录 Parasoft C++Test软件静态分析:操作指南(编码规范、质量度量)、常见问题及处理 Parasoft C++Test软件单元测试:操作指南、实例讲解、常见问题及处理 Parasoft C++Test软件集成测试:操作指南、实例讲解、常见问题及处理 进阶扩展:自动生成静态分析文档、自动…...
vue渲染数组各子项实现文本超出宽度显示tooltip
vue渲染数组各子项实现文本超出宽度显示tooltip 需求背景 vue项目中,通过v-for渲染数组,子项中均存在一行描述文字。当描述文字超出固定宽度时,显示省略号并且鼠标悬浮时显示tooltip;当描述文字不超出固定宽度时则正常显示&…...
libreoffice容器word转pdf
先说结论,市面上不花钱的,简单的效果好的就是这个种方式,在线测试下来不如命令转的效果好。AsposeWords和SpireDoc效果都不错,但是只有这个word转pdf感觉花3-5w不划算。 下载容器路径 https://docker.aityp.com/i/search?searchl…...
AI模型升级与机器人产业落地同步推进
2025年5月28日,中国AI领域迎来两项实质性进展。DeepSeek-R1模型完成小版本试升级,开源社区发布其0528版本。本次更新聚焦语义理解精准性、复杂逻辑推理和长文本处理能力的提升。在代码测试平台Live CodeBench中,开发者反馈其编程性能已接近Op…...
安全编码与AI接口权限控制
安全编码与AI接口权限控制 在AI系统中,模型服务的开放接口往往涉及敏感数据、核心算法与算力资源,如果缺乏有效的安全编码与权限控制机制,极易引发数据泄露、滥用调用或非法操作等问题。本节将从“接口安全策略”“权限验证流程”“Token管控机制”“多租户身份隔离”四个方…...

linux centos 服务器性能排查 vmstat、top等常用指令
背景:项目上经常出现系统运行缓慢,由于数据库服务器是linux服务器,记录下linux服务器性能排查常用指令 vmstat vmstat介绍 vmstat 命令报告关于内核线程、虚拟内存、磁盘、陷阱和 CPU 活动的统计信息。由 vmstat 命令生成的报告可以用于平衡系统负载活动。系统范围内的这…...
MySQL----视图的创造和使用
这里写目录标题 **创造视图****查看视图****修改视图****更新视图****删除视图** 创造视图 使用create view…创造 语法格式 create[algorithm {undefiend|merge|temptable}]view <视图名> [(<字段名1>[,……,字段名n])]as <select 语…...
c/c++的opencv伽马噪声
理解与实现 C/OpenCV 中的伽马噪声 🖼️ 噪声是大多数图像采集过程中固有的组成部分。理解和模拟不同类型的噪声对于开发鲁棒的图像处理算法至关重要,尤其是在去噪方面。虽然高斯噪声和椒盐噪声是常被讨论的类型,但伽马噪声(通常…...

LiveGBS国标视频平台收流模式:UDP、TCP被动与TCP主动传输模式之差异剖析
LiveGBS国标视频平台收流模式:UDP、TCP被动与TCP主动传输模式之差异剖析 1、背景2、信令传输3、视频流传输3.1、UDP传输模式3.2、TCP被动传输模式3.3、TCP主动传输模式 4、WEB配置流传输模式4.1、编辑模式4.2、下拉切换模式 5、搭建GB28181视频直播平台 1、背景 在…...
跳表(Skip List)查找算法详解
1、原理 跳表是一种概率型数据结构,通过多层有序链表实现高效查找,时间复杂度接近平衡树(O(log n))。其核心思想是通过层级索引加速搜索,结构类似火车时刻表的“快车-慢车”模式。 关键特性: 多层链表&a…...
React从基础入门到高级实战:React 核心技术 - React 与 TypeScript:构建类型安全的应用
React 与 TypeScript:构建类型安全的应用 在现代前端开发中,TypeScript 因其强大的类型系统和编译时错误检查功能,已成为 React 开发者的热门选择。通过为代码添加类型定义,TypeScript 能够显著提升代码的健壮性、可维护性和团队…...
Django orm详解--组成部件
Django ORM 的核心部件可分为模型系统、查询系统、数据库后端和辅助工具四大类,每个部件负责不同的职责,共同实现对象与关系数据库的映射。以下是核心部件的分层解析: 一、模型系统(Model System) 1. 模型基类&#…...

Tomcat 使用与配置全解
一、 Tomcat简介 Tomcat服务器是Apache的一个开源免费的Web容器。它实现了JavaEE平台下部分技术规范,属于轻量级应用服务器。 1. Tomcat版本 Tomcat版本 JDK版本 Servlet版本 JSP版本 10.0.X 8 and later 5.0 3.0 9.0.x 8 and later 4.0 2.3 8.0.x 7…...
Chrome 开发中的任务调度与线程模型实战指南
内容 概述 快速入门指南 核心概念线程词典 线程任务优先使用序列而不是物理线程 发布并行任务 直接发布到线程池通过 TaskRunner 发布 发布顺序任务 发布到新序列发布到当前(虚拟)主题 使用序列代替锁将多个任务发布到同一线程 发布到浏览器进程中的主线…...

aws instance store 的恢复
1: aws instance store 要在launch instance 才可以创建,而且,通过snapshot 恢复后,instance store 里面的数据会丢失。 下面是创建instance store 的过程,和通过两种方式恢复,发现/etc/fstab 不同的写法,有的不能启动: [root@ip-xx ~]# lsblk NAME MAJ:MIN RM …...
从零开始创建 Vue 3 开发环境并构建第一个 Demo
Vue 3 是目前前端开发中非常流行的渐进式 JavaScript 框架。本文将手把手带你完成从环境搭建到运行一个基础 Vue 3 示例的全过程。 📦 一、环境准备 1. 安装 Node.js Vue 项目依赖 Node.js 运行环境,请确保你的电脑已安装 Node.js(建议使用…...

EasyRTC音视频实时通话助力微信小程序:打造低延迟、高可靠的VoIP端到端呼叫解决方案
一、方案概述 在数字化通信浪潮下,端到端实时音视频能力成为刚需。依托庞大用户生态的微信小程序,是实现此类功能的优质载体。基于WebRTC的EasyRTC音视频SDK,为小程序VoIP呼叫提供轻量化解决方案,通过技术优化实现低延迟通信&a…...

STM32 SPI通信(软件)
一、SPI简介 SPI(Serial Peripheral Interface)是由Motorola公司开发的一种通用数据总线四根通信线:SCK(Serial Clock)、MOSI(Master Output Slave Input)、MISO(Master Input Slav…...

每日刷题c++
快速幂 #include <iostream> using namespace std; #define int long long int power(int a, int b, int p) {int ans 1;while (b){if (b % 2){ans * a;ans % p; // 随时取模}a * a;a % p; // 随时取模b / 2;}return ans; } signed main() {int a, b, p;cin >> a …...
(自用)Java学习-5.19(地址管理,三级联动,预支付)
1. 地址管理模块 地址展示 前端:通过 showAddress() 发起 Ajax GET 请求,动态渲染地址列表表格,使用 #{tag}、#{name} 等占位符替换真实数据。 后端: 控制器层调用 AddressService,通过 AddressMapper 查询用户地址数…...
【容器】docker使用问题处理
问题一、systemctl start docker启动报 ERROR: ZONE_CONFLICT: docker0 already bound to a zone 处理方法 firewall-cmd --permanent --zonedocker --change-interfacedocker0 systemctl restart firewalld 问题二、启动容器报 ptables failed/iptables: No chain/target/…...

ChemDraw 2023|Win英文|化学结构编辑器|安装教程
软件下载 【名称】:ChemDraw 2023 【大小】:1.34G 【语言】:英文界面 【安装环境】:Win10/Win11 【夸克网盘下载链接】(务必手机注册): https://pan.quark.cn/s/320bcb67da80 【网站下载…...
Vue3实现提示文字组件
Vue3 实现一个文字提示组件(Tooltip) 文字提示(Tooltip)是前端开发中非常常见的组件,通常用于在用户悬停某个元素时显示额外的信息。 一、需求分析 我们要实现一个 Vue3 的文字提示组件,具备以下功能&…...
JAVA与C语言之间的差异(一)
一、代码习惯以及主函数 JAVA中{在使用的时候不要换行 public static void main(String[] args) {int[] array {1, 2, 3};for(int i 0; i < array.length; i){System.out.println(array[i] " ");}} 其次,以main函数为主函数: public …...
深入剖析 C 语言中的指针数组与数组指针
资料合集下载链接: https://pan.quark.cn/s/472bbdfcd014 在C语言中,指针是其强大和灵活性的核心。然而,围绕指针的概念有很多容易混淆的地方,其中“指针数组”和“数组指针”就是一对常见的“双胞胎”概念。它们名称相似,但含义和用法却大相径庭。 本文旨在清…...

4.1.1 Spark SQL概述
Spark SQL是Apache Spark的一个模块,专门用于处理结构化数据。它引入了DataFrame这一编程抽象,DataFrame是带有Schema信息的分布式数据集合,类似于关系型数据库中的表。用户可以通过SQL、DataFrames API和Datasets API三种方式操作结构化数据…...