本文全面梳理大模型领域相关的开源数据集,涵盖预训练语料、指令微调数据、偏好对齐数据、评测基准数据 四大类,提供下载地址、使用方法和最佳实践。
目录
一、数据集全景图
1.1 数据集分类体系
┌─────────────────────────────────────────────────────────────────┐
│ 大模型数据集分类 │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1. 预训练语料(海量无标注文本) │
│ ├── 通用网页数据: Common Crawl, C4, RefinedWeb │
│ ├── 代码数据: The Stack, StarCoder Data │
│ ├── 学术论文: arXiv, S2ORC │
│ ├── 书籍: Books3, Gutenberg │
│ └── 百科: Wikipedia │
│ │
│ 2. 指令微调数据(输入→输出对) │
│ ├── 通用指令: Alpaca, ShareGPT, OpenAssistant │
│ ├── 中文指令: BELLE, Firefly, COIG │
│ ├── 代码指令: CodeAlpaca, Magicoder │
│ └── 数学指令: MetaMath, WizardMath │
│ │
│ 3. 偏好对齐数据(chosen/rejected 对) │
│ ├── DPO 数据: UltraFeedback, Nectar │
│ ├── RLHF 数据: Anthropic HH, OpenAI Summarize │
│ └── 安全对齐: SafeRLHF, BeaverTails │
│ │
│ 4. 评测基准数据(标准化测试) │
│ ├── 知识: MMLU, ARC, C-Eval │
│ ├── 推理: GSM8K, MATH, BBH │
│ ├── 代码: HumanEval, MBPP │
│ ├── 对话: MT-Bench, AlpacaEval │
│ └── 安全: TruthfulQA, ToxicChat │
│ │
└─────────────────────────────────────────────────────────────────┘
1.2 数据集速查表
数据集 类型 规模 语言 用途 下载 C4 预训练 750GB 英文 通用预训练 c4RefinedWeb 预训练 5TB 英文 高质量网页 tiiuae/refinedwebThe Stack v2 预训练 67TB 多语言 代码预训练 bigcode/the-stack-v2Wikipedia 预训练 20GB 多语言 百科知识 wikimedia/wikipediaAlpaca 微调 52K 英文 通用指令 tatsu-lab/alpacaShareGPT 微调 90K 多语言 对话数据 anon8231489123/ShareGPTBELLE 微调 3.5M 中文 中文指令 BelleGroup/train_3.5M_CNFirefly 微调 1.1M 中文 中文多任务 YeungNLP/firefly-train-1.1MUltraChat 微调 1.5M 英文 高质量对话 stingning/ultrachatUltraFeedback 偏好 64K 英文 DPO训练 openbmb/UltraFeedbackAnthropic HH 偏好 170K 英文 安全对齐 Anthropic/hh-rlhfMMLU 评测 14K 英文 知识评估 cais/mmluGSM8K 评测 8.5K 英文 数学推理 openai/gsm8kHumanEval 评测 164 英文 代码生成 openai/openai_humanevalC-Eval 评测 14K 中文 中文知识 ceval/ceval-examCMMLU 评测 12K 中文 中文知识 haonan-li/cmmlu
二、预训练语料数据集
2.1 通用网页数据
Common Crawl
属性 值 规模 PB 级网页数据 更新频率 每月更新 网址 commoncrawl.org 使用方式 需要大量清洗
C4 (Colossal Clean Crawled Corpus)
属性 值 规模 750GB 纯文本 来源 Common Crawl 清洗版 语言 主要英文 HuggingFace datasets.load_dataset("c4", "en")用途 T5、LLaMA 等预训练
from datasets import load_dataset
dataset = load_dataset( "c4" , "en" , split= "train" , streaming= True )
for item in dataset. take( 5 ) :
print ( item[ "text" ] [ : 200 ] )
RefinedWeb (Falcon 使用)
属性 值 规模 5TB 高质量文本 特点 严格去重和过滤 HuggingFace tiiuae/refinedweb用途 Falcon 模型预训练
RedPajama v2
属性 值 规模 100B+ 文档,30TB+ 文本 特点 完整开源,包含质量信号 HuggingFace togethercomputer/RedPajama-Data-V2用途 LLaMA 复现
FineWeb (HuggingFace)
属性 值 规模 15TB,1000亿文档 特点 HuggingFace 精心清洗 HuggingFace HuggingFaceFW/fineweb用途 高质量预训练
from datasets import load_dataset
dataset = load_dataset( "HuggingFaceFW/fineweb" , name= "sample-10BT" , split= "train" )
中文预训练语料
数据集 规模 HuggingFace Wudao 200GB shibing624/nli_zhChinese Web 1.42TB building-chinese-corpusCLUECorpus 100GB cluecorpussmall
2.2 代码数据
The Stack v2 (BigCode)
属性 值 规模 67TB,600+ 编程语言 特点 最大的开源代码数据集 HuggingFace bigcode/the-stack-v2用途 StarCoder2 预训练
from datasets import load_dataset
dataset = load_dataset( "bigcode/the-stack-v2" , split= "train" , streaming= True )
StarCoder Data
属性 值 规模 783GB,86种语言 HuggingFace bigcode/starcoderdata用途 StarCoder 预训练
CodeSearchNet
属性 值 规模 600万函数 语言 Go/Java/JS/PHP/Python/Ruby HuggingFace code_search_net用途 代码理解训练
2.3 学术论文数据
数据集 规模 来源 HuggingFace arXiv 200万+论文 arxiv.org gfissore/arxiv-abstracts-2021S2ORC 1.3亿学术记录 Semantic Scholar allenai/s2orcPubMed 3600万引用 PubMed pubmedSemantic Scholar 2亿+论文 AI2 allenai/peS2o
2.4 书籍数据
数据集 规模 说明 Books3 19万本书 The Pile 的一部分 Gutenberg 6万+免费书 公版书籍 BookCorpus 1.1万本 BERT 训练使用
2.5 百科知识数据
from datasets import load_dataset
wiki = load_dataset( "wikimedia/wikipedia" , "20231101.en" , split= "train" )
print ( f"Wikipedia 条目数: { len ( wiki) } " )
wiki_zh = load_dataset( "wikimedia/wikipedia" , "20231101.zh" , split= "train" )
2.6 预训练数据集处理工具
from datatrove. pipeline. readers import JsonlReader
from datatrove. pipeline. filters import GopherRepetitionFilter
from datatrove. pipeline. writers import JsonlWriter
pipeline = [
JsonlReader( "raw_data/" ) ,
GopherRepetitionFilter( ) ,
JsonlWriter( "cleaned_data/" )
]
三、指令微调数据集
3.1 英文指令数据
Alpaca (斯坦福)
属性 值 规模 52K 指令 来源 GPT-3.5 生成 HuggingFace tatsu-lab/alpaca格式 instruction/input/output
from datasets import load_dataset
dataset = load_dataset( "tatsu-lab/alpaca" , split= "train" )
print ( dataset[ 0 ] )
ShareGPT / Vicuna
属性 值 规模 90K+ 对话 来源 用户分享的 ChatGPT 对话 HuggingFace anon8231489123/ShareGPT_Vicuna_unfiltered格式 conversations
OpenAssistant (OASST2)
属性 值 规模 66K 对话树 特点 人工标注,多语言 HuggingFace OpenAssistant/oasst2
UltraChat
属性 值 规模 150万对话 特点 高质量多轮对话 HuggingFace stingning/ultrachat
SlimOrca
属性 值 规模 518K 特点 经过严格过滤的高质量数据 HuggingFace Open-Orca/SlimOrca
LIMA
属性 值 规模 1K(仅1000条!) 特点 证明数据质量 > 数量 HuggingFace GAIR/lima
Capybara
属性 值 规模 16K 多轮对话 特点 高质量,深度推理 HuggingFace LDJnr/Capybara
3.2 中文指令数据
BELLE
属性 值 规模 3.5M 中文指令 来源 ChatGPT 生成 HuggingFace BelleGroup/train_3.5M_CN
from datasets import load_dataset
dataset = load_dataset( "BelleGroup/train_3.5M_CN" , split= "train" )
Firefly
属性 值 规模 1.1M,23种中文任务 特点 任务类型丰富 HuggingFace YeungNLP/firefly-train-1.1M
COIG (Chinese Open Instruction Generalist)
属性 值 规模 多个子集 HuggingFace BAAI/COIG-PC-core
Alpaca-GPT4-Chinese
属性 值 规模 48K 特点 GPT-4 生成的中文指令 HuggingFace shibing624/alpaca-zh
MOSS-SFT
属性 值 规模 1.1M 来源 复旦 MOSS 项目 HuggingFace fnlp/moss-003-sft-data
Infinity-Instruct
属性 值 规模 1000万+ 特点 最大规模中文指令集 HuggingFace BAAI/Infinity-Instruct
3.3 代码指令数据
数据集 规模 HuggingFace 特点 CodeAlpaca 20K sahil2801/CodeAlpaca-20k代码指令 Magicoder-OSS-Instruct 75K ise-uiuc/Magicoder-OSS-Instruct-75K开源代码指令 Code-Feedback 67K m-a-p/Code-Feedback代码反馈 StarCoder-Self-Instruct 22K codeparrot/self-instruct-starcoder自指令 Evol-Instruct-Code 80K nickrosh/Evol-Instruct-Code-80k-v1进化指令 Python Code Instructions 18K iamtarun/python_code_instructions_18kPython专用
3.4 数学指令数据
数据集 规模 HuggingFace 特点 MetaMathQA 400K meta-math/MetaMathQA数学推理增强 WizardMath 96K WizardLM/WizardMath数学进化指令 MathInstruct 262K TIGER-Lab/MathInstruct多样数学指令 GSM8K-RFT 180K gsm8k_rftGSM8K 增强 Camel Math 50K camel-ai/math数学对话 NuminaMath-CoT 860K AI-MO/NuminaMath-CoT数学推理链
3.5 指令数据生成工具
Self-Instruct
git clone https://github.com/yizhongw/self-instruct.git
cd self-instruct
python self_instruct.py --num_instructions 10000
Evol-Instruct (WizardLM)
git clone https://github.com/nlpxucan/WizardLM.git
cd WizardLM/Evol-Instruct
python evolve.py --output_file evol_instructions.json
Alpaca-Evol
pip install alpaca-evol
alpaca_evol generate --num 10000 --output alpaca_evol.json
四、偏好对齐数据集(RLHF/DPO)
4.1 英文偏好数据
UltraFeedback
属性 值 规模 64K prompts,256K responses 特点 GPT-4 评分的多维度反馈 HuggingFace openbmb/UltraFeedback用途 DPO 训练首选
from datasets import load_dataset
dataset = load_dataset( "openbmb/UltraFeedback" , split= "train" )
Anthropic HH-RLHF
属性 值 规模 170K 对话 特点 安全对齐数据 HuggingFace Anthropic/hh-rlhf
Nectar
属性 值 规模 183K 特点 GPT-4 排序的偏好数据 HuggingFace berkeley-nest/Nectar
SHP (Stanford Human Preferences)
属性 值 规模 385K HuggingFace stanfordnlp/SHP
HelpSteer2 (NVIDIA)
属性 值 规模 21K 特点 多维度评分 HuggingFace nvidia/HelpSteer2
Distilabel-Capybara-DPO
属性 值 规模 10K HuggingFace argilla/distilabel-capybara-dpo-7k-binarized
4.2 中文偏好数据
数据集 规模 HuggingFace 特点 CValues 145K CValue/Comparison中文安全对齐 COIG-Pair 50K BAAI/COIG-Pair中文偏好对 SafeRLHF 40K PKU-Alignment/SafeRLHF安全偏好 Zhihu-RLHF 50K m-a-p/zhihu_rlhf_3k知乎风格偏好
4.3 偏好数据构建方法
"""使用 GPT-4 构建 DPO 数据"""
import openai
client = openai. OpenAI( )
def generate_preference_pair ( question: str ) - > dict :
"""生成偏好对"""
responses = [ ]
for temp in [ 0.3 , 0.7 , 1.0 ] :
resp = client. chat. completions. create(
model= "gpt-4o" ,
messages= [ { "role" : "user" , "content" : question} ] ,
temperature= temp
)
responses. append( resp. choices[ 0 ] . message. content)
eval_prompt = f"""请对以下回答排序(1=最好,3=最差):
问题: { question}
回答A: { responses[ 0 ] }
回答B: { responses[ 1 ] }
回答C: { responses[ 2 ] }
输出格式:A排名X,B排名Y,C排名Z"""
eval_resp = client. chat. completions. create(
model= "gpt-4o" ,
messages= [ { "role" : "user" , "content" : eval_prompt} ] ,
temperature= 0
)
return {
"prompt" : question,
"chosen" : responses[ 0 ] ,
"rejected" : responses[ 2 ]
}
五、评测基准数据集
5.1 综合知识评测
MMLU (Massive Multitask Language Understanding)
属性 值 规模 14K 题目,57个学科 任务 多选题 HuggingFace cais/mmlu难度 高中到研究生级别
from datasets import load_dataset
mmlu = load_dataset( "cais/mmlu" , "all" , split= "test" )
C-Eval (中文评测)
属性 值 规模 14K,52个学科 语言 中文 HuggingFace ceval/ceval-exam
CMMLU (中文多任务)
属性 值 规模 12K,67个任务 语言 中文 HuggingFace haonan-li/cmmlu
5.2 数学推理评测
GSM8K
属性 值 规模 8.5K 小学数学题 特点 需要多步推理 HuggingFace openai/gsm8k
from datasets import load_dataset
gsm8k = load_dataset( "openai/gsm8k" , "main" , split= "test" )
MATH
属性 值 规模 12.5K 高等数学 难度 高中竞赛级别 HuggingFace hendrycks/competition_math
GSM8K-Platinum
属性 值 规模 8.5K(修正版) 特点 修复了原始GSM8K的错误 HuggingFace TAUR-Lab/GSM8K-Platinum
5.3 代码评测
HumanEval
属性 值 规模 164 Python 编程题 评测 pass@1, pass@10 HuggingFace openai/openai_humaneval
from datasets import load_dataset
humaneval = load_dataset( "openai/openai_humaneval" , split= "test" )
MBPP
属性 值 规模 974 Python 编程题 HuggingFace google-research-datasets/mbpp
MultiPL-E
属性 值 规模 HumanEval 的多语言版本 语言 18种编程语言 HuggingFace nuprl/MultiPL-E
5.4 推理评测
ARC (AI2 Reasoning Challenge)
属性 值 规模 7.7K 科学题 HuggingFace allenai/ai2_arc
HellaSwag
属性 值 规模 10K 常识推理 HuggingFace Rowan/hellaswag
BBH (BIG-Bench Hard)
属性 值 规模 6.5K,23个任务 特点 困难推理任务 HuggingFace lukaemon/bbh
GPQA
属性 值 规模 448 研究生级问题 特点 非常困难 HuggingFace Idavidrein/gpqa
5.5 对话评测
MT-Bench
属性 值 规模 80 个多轮对话 评测 GPT-4 评分 (1-10) 下载 github.com/lm-sys/FastChat
AlpacaEval
属性 值 规模 805 指令 评测 与 GPT-4 对比胜率 下载 github.com/tatsu-lab/alpaca_eval
Arena-Hard-Auto
属性 值 规模 500 困难问题 评测 自动评估 下载 github.com/lm-sys/arena-hard-auto
5.6 安全评测
数据集 规模 HuggingFace 评测内容 TruthfulQA 817 truthfulqa/truthful_qa真实性 ToxicChat 10K lmsys/toxic-chat毒性检测 BBQ 58K heegyu/bbq偏见检测 HarmBench 8K walledai/HarmBench安全性
5.7 基准测试速查
类别 基准 模型预期分数(7B级) 知识 MMLU 60-70% 中文 C-Eval 55-65% 数学 GSM8K 50-80% 数学 MATH 15-30% 代码 HumanEval 30-60% 代码 MBPP 40-60% 推理 ARC-Challenge 60-75% 常识 HellaSwag 75-85% 对话 MT-Bench 6-8 分 安全 TruthfulQA 40-60%
六、领域专用数据集
6.1 医疗健康
数据集 规模 HuggingFace 用途 MedMCQA 194K openlifescienceai/medmcqa医学问答 PubMedQA 1K qiaojin/PubMedQA医学问答 MedQA 12K bigbio/med_qa医学考试 HealthCareMagic 200K wangrongsheng/HealthCareMagic-100k-en医疗对话 cMedQA2 108K zhangtao23/cMedQA2中文医疗QA
6.2 金融
数据集 规模 HuggingFace 用途 FinQA 8K TheFinAI/finqa金融问答 ConvFinQA 3K TheFinAI/convfinqa金融对话 FIQASA 1.7K pauri32/fiqasa金融情感
6.3 法律
数据集 规模 HuggingFace 用途 LegalBench 17K nguha/legalbench法律推理 CUAD 510 theatticusproject/cuad合同分析 CaseHOLD 53K casehold/casehold法律引用
6.4 教育
数据集 规模 HuggingFace 用途 ARC 7.7K allenai/ai2_arc科学问答 SciQ 13.7K allenai/sciq科学问答 MMLU-STEM 3K cais/mmlu (STEM子集)STEM知识
七、多模态数据集
7.1 图文数据
数据集 规模 HuggingFace 用途 LAION-5B 50亿图文对 laion/laion2B-enCLIP训练 COYO 7亿图文对 kakaobrain/coyo-700m图文预训练 CC3M 330万 google-research-datasets/conceptual_captions图文预训练 CC12M 1200万 pixparse/cc12m-wds图文预训练 ShareGPT4V 100K Lin-Chen/ShareGPT4V视觉指令
7.2 视频数据
数据集 规模 HuggingFace 用途 WebVid 1070万 temporalwebvideos/webvid-10m视频文本 VideoChat 11K OpenGVLab/VideoChat2-IT视频对话 ActivityNet 20K视频 lmms-lab/ActivityNetQA视频理解
7.3 语音数据
数据集 规模 HuggingFace 用途 LibriSpeech 1000小时 librispeech_asr语音识别 Common Voice 2500小时 mozilla-foundation/common_voice_17_0多语言ASR GigaSpeech 1万小时 speechcolab/gigaspeech语音识别
八、数据集使用最佳实践
8.1 数据下载与加载
from datasets import load_dataset
dataset = load_dataset( "tatsu-lab/alpaca" , split= "train" )
dataset = load_dataset( "HuggingFaceFW/fineweb" , split= "train" , streaming= True )
dataset = load_dataset( "openai/gsm8k" , cache_dir= "./data/cache" )
dataset = load_dataset( "json" , data_files= "my_data.json" )
dataset = load_dataset( "csv" , data_files= "my_data.csv" )
from modelscope. msdatasets import MsDataset
dataset = MsDataset. load( "chinese_alpaca_sft" )
8.2 数据处理 Pipeline
from datasets import load_dataset
raw = load_dataset( "tatsu-lab/alpaca" , split= "train" )
def clean ( example) :
if not example[ "instruction" ] or not example[ "output" ] :
return False
if len ( example[ "output" ] ) < 10 :
return False
return True
filtered = raw. filter ( clean)
def format_chatml ( example) :
return {
"messages" : [
{ "role" : "user" , "content" : example[ "instruction" ] + example. get( "input" , "" ) } ,
{ "role" : "assistant" , "content" : example[ "output" ] }
]
}
formatted = filtered. map ( format_chatml)
split = formatted. train_test_split( test_size= 0.1 , seed= 42 )
train_set = split[ "train" ]
val_set = split[ "test" ]
train_set. to_json( "train_processed.json" )
val_set. to_json( "val_processed.json" )
8.3 数据混合策略
"""混合多个数据集"""
from datasets import concatenate_datasets, interleave_datasets
alpaca = load_dataset( "tatsu-lab/alpaca" , split= "train" )
sharegpt = load_dataset( "anon8231489123/ShareGPT_Vicuna_unfiltered" , split= "train" )
code = load_dataset( "sahil2801/CodeAlpaca-20k" , split= "train" )
mixed = concatenate_datasets( [ alpaca, sharegpt, code] )
mixed = interleave_datasets(
[ alpaca, sharegpt, code] ,
probabilities= [ 0.5 , 0.3 , 0.2 ] ,
seed= 42
)
print ( f"混合数据集大小: { len ( mixed) } " )
8.4 数据质量检查
"""数据质量检查清单"""
def quality_check ( dataset) :
stats = {
"total" : len ( dataset) ,
"empty" : 0 ,
"too_short" : 0 ,
"too_long" : 0 ,
"duplicates" : 0
}
seen = set ( )
for item in dataset:
text = item. get( "text" , "" ) or str ( item)
if not text. strip( ) :
stats[ "empty" ] += 1
elif len ( text) < 20 :
stats[ "too_short" ] += 1
elif len ( text) > 10000 :
stats[ "too_long" ] += 1
if text in seen:
stats[ "duplicates" ] += 1
seen. add( text)
print ( f"总样本: { stats[ 'total' ] } " )
print ( f"空样本: { stats[ 'empty' ] } " )
print ( f"过短: { stats[ 'too_short' ] } " )
print ( f"过长: { stats[ 'too_long' ] } " )
print ( f"重复: { stats[ 'duplicates' ] } " )
return stats
quality_check( dataset)
8.5 数据集大小参考
训练类型 推荐数据量 说明 LoRA 微调 1K-100K 少量高质量数据即可 Full 微调 100K-1M 需要更多数据避免过拟合 DPO 对齐 10K-100K 偏好对数据 预训练 100B+ tokens 海量数据
8.6 数据许可证注意事项
许可证 说明 可商用 Apache 2.0 宽松许可 ✅ MIT 最宽松 ✅ CC BY 4.0 署名即可 ✅ CC BY-NC 4.0 非商用 ❌ CC BY-SA 4.0 相同方式共享 ✅(需同许可) GPL 开源义务 ✅(需开源)