BeaverTails: Improving safety alignment of large language models through a human preference datasetBeaverTails: Towards Improved Safety Alignment of LLM via a Human-Preference Dataset
The authors release the BeaverTails safety alignment dataset: safety meta-labels for 333,963 QA pairs and 361,903 separated helpfulness/harmlessness preference rankings, and demonstrate its use in content moderation and Safe RLHF.
- LLM safety alignment relies on large-scale human feedback, but existing preference data mostly mixes helpfulness and harmlessness into a single score, which the authors argue is insufficient to support fine-grained safety alignment training and content moderation.
- The authors build BeaverTails: starting from red-team prompts, they use Alpaca-7B to generate answers, obtain safety meta-labels for 14 harm categories through two-stage annotation, and separately rank preferences for helpfulness and harmlessness; then they use the data to train QA-moderation, reward/cost models and perform Safe RLHF.
- Reward model test accuracy 78.13%, cost model sign accuracy 95.62%; after Safe-RLHF fine-tuning, Alpaca-7B under GPT-4 evaluation achieves an 85.57% helpfulness win rate and an 82.57% harmlessness win rate against the original model, both higher than all ablation baselines.
- The authors note that the annotation team's demographic diversity is relatively limited, the 14 harm categories overlap, and some categories have imbalanced samples; the experiments are based on models generated and fine-tuned from Alpaca-7B, the safety evaluation uses 140 QA pairs per model, and the paper does not report agreement values between GPT-4 evaluation and humans.
- Evaluated models
- Alpaca-7BAlpaca-13BVicuna-7bgpt-3.5-turboSafe-RLHFPPOL-classifier-maxPPOL-classifier-meanHH-PPOPPOQA-moderation modelReward ModelCost Model
- Benchmarks
- BeaverTails-30kBeaverTails-330kHH Red-TeamSafety-PromptsHH-RLHF
- Metrics
- safe meta-label 比例evaluator agreement ratioreward model accuracycost model sign accuracycost model preference accuracywin rate (GPT-4 评审)
The Peking University team released the BeaverTails dataset, which decouples helpfulness and harmlessness preference annotations for question-answer pairs, for research on safety alignment of large language models. The dataset provides safety meta-labels for 333,963 question-answer pairs covering 14 categories of potential harm, and separately collects 361,903 pairs of expert comparison data along the two dimensions of helpfulness and harmlessness, with questions drawn from more than 16,000 red-teaming prompts. The team trained a QA moderation model and compared its agreement with prompted GPT-4, and also trained reward and cost models, using PPO-Lagrangian to fine-tune Alpaca-7B with Safe RLHF; after fine-tuning, the cost distribution shifted left and the reward distribution shifted right, with both harmlessness and helpfulness improving. Ablation experiments showed that decoupled preferences outperformed mixed single-preference annotation, and that the ranking-based cost model outperformed the classifier approach. The dataset is open-sourced under the CC BY-NC 4.0 license, and the project page is https://sites.google.com/view/pku-beavertails。
Why it was selectedThe dataset decouples helpfulness and harmlessness preference annotations, contains more than 330,000 QA safety labels and more than 360,000 expert comparisons, and can be directly reused for safety alignment training.
Related events and news
1 events · 3 news mentions
News that mentions this paper
Jev 网关提示注入检测器基准测试
- Cisconames the paperJev 决策模型在内容安全任务上的对比评测:与传统分类器及 LLM 判官谁更强
Jev came closest to our model on BeaverTails and PolygloToxicityPrompts, and edged ahead on raw AUC for XSTest;
- Anthropic Alignment Sciencecites the paper's id or linkAnthropic 研究:自动化对齐研究者在小模型上缓解十类对齐失败
of LLM via a Human-Preference Dataset.” arXiv Preprint arXiv:2307.04657.
- Microsoft PyRIT 版本发布names the paperMicrosoft PyRIT v0.12.0 发布:GUI、CLI 与框架三种交互方式全部可用
Added 8 new dataset loaders: CBT-Bench (#1411), PromptIntel (#1400), SimpleSafetyTests (#1426), SALAD-Bench (#1425), OR-Bench (#1423), BeaverTails (#1424), ToxicChat (#1422), HarmfulQA (#1421)
Paper analysis
What problem does this paper attempt to solve?
The authors constructed BeaverTails, a QA preference dataset with separate helpfulness and harmlessness annotations, to support LLM safety alignment research and content moderation.
Core problem: LLM safety alignment lacks large-scale human preference data that labels helpfulness and harmlessness separately.
- Problem setting: The authors argue that unconstrained LLMs may amplify misinformation and promote harmful content; alignment techniques such as red teaming and RLHF both rely on large-scale, costly human annotation feedback.
- Shortcomings of existing data: The authors state that existing preference datasets typically aggregate multiple preferences into a single score; merging helpfulness and harmlessness into one-dimensional data introduces ambiguity, bias, and inconsistency (Sec. 4.4).
- Core design: The dataset defines harmlessness as a QA pair being "risk-neutral" across all 14 harm categories, judged from the whole QA pair rather than from single-sentence toxicity; helpfulness and harmlessness are ranked independently. The authors claim this is the first dataset to decouple harmlessness and helpfulness from human preference scores.
- Paper outputs: Two dataset versions (BeaverTails-30k and 330k), and three application experiments: QA-moderation content moderation, reward/cost model training, and Safe RLHF fine-tuning based on PPO-Lagrangian.
- Data scale: Safety meta-labels for 333,963 QA pairs (16,851 unique prompts), and 361,903 expert comparison pairs on helpfulness and harmlessness (abstract).
What related research exists?
Related work falls into four groups: QA datasets with human preferences, LLM toxicity evaluation, automated content moderation, and RLHF; this paper's data is based on Anthropic red-team prompts.
QA datasets with human preference annotations
- BAD (MetaAI) — a dialogue dataset in which annotators use unsafe utterances to induce a chatbot to produce unsafe behavior; all utterances are labeled offensive or safe.
- RealToxicityPrompts — 100k sentences, annotated with toxicity scores using the Perspective API; SHP — 385k collective human preferences on the helpfulness of responses, covering 18 disciplines.
- Anthropic (2022) — contributed human preference datasets and red-team datasets for helpfulness and harmlessness; the prompts in this paper's dataset are based on Anthropic red-team data.
LLM toxicity evaluation
- Multiple works propose pipelines and guidelines for evaluating the harmfulness and toxicity of LLM outputs; TruthfulQA uses 817 human-written questions to evaluate the truthfulness of answers.
- BBQ — examines social bias against various identity groups in QA tasks, contains nine categories of bias labels, and covers ambiguous and disambiguated contexts.
Automated content moderation
- Perspective API (Google Jigsaw) — gives scores on 8 dimensions (Toxicity, Insult, Threat, etc.) for input text.
- OpenAI Moderation API — flags content as harmful if any of seven harm categories exceeds a preset probability threshold. The paper empirically tests these two APIs in Appendix E and compares them with this paper's QA-moderation (see Question 4).
RLHF
- RLHF aims to optimize language models toward the "helpful, honest, harmless" objectives and has been used for text summarization, instruction following, and reducing harmful outputs; a typical approach is to train a ranking model with human feedback to obtain a reward function, then train with RL methods such as PPO.
Baselines and comparison setup: The comparison methods for the downstream fine-tuning experiments are PPOL-classifier-mean, PPOL-classifier-max, HH-PPO (based on the HH-RLHF dataset), and PPO (based on mixed preference data), all using Alpaca-7B as the base model (Table 2).
Author positioning: This paper's dataset decouples harmlessness from helpfulness in preference scores, provides ranking data separately for each, and determines harmlessness based on the risk-neutrality of the QA pair as a whole rather than the toxicity of a single sentence.
How does the paper address this problem?
Red-team prompts + Alpaca-7B generated responses, two-stage crowdsourced annotation yields 14 categories of safety meta-labels and decoupled preference rankings, then moderation and reward/cost models are trained.
Overall approach: starting from red-team prompts, generate QA pairs, use a two-stage annotation process to produce safety meta-labels and separated helpfulness/harmlessness preference rankings, then use this data to train a QA-moderation model, reward model, and cost model, and perform Safe RLHF fine-tuning with PPO-Lagrangian.
Data Generation
- Prompt sources: Over 28k red-team prompts from the HH Red-Team dataset and Safety-Prompts ([56]), taking the first question that starts the interaction in each conversation; overly short or incomplete questions are supplemented with context during preprocessing. Prompts average 13.61 words.
- Answer generation: Alpaca-7B generates multiple answers for each of the 7.7k questions in the 30k version; sampling parameters temperature 1.5, maximum token length 512, top_k 30, top_p 0.95; answers average 61.38 words.
Two-Stage Annotation Process
- Stage one: Annotators perform multi-class classification of QA pairs across 14 harm categories, assigning a safe meta-label only if all categories are risk-neutral; judgments are made from a risk neutralization perspective rather than single-sentence toxicity.
- Stage two: Annotators are given a prompt and multiple answers already carrying safety labels, and rank them separately by harmlessness and helpfulness; the harmlessness ranking enforces a logical constraint—harmless answers must be ranked before harmful ones. Annotators can flag answers they believe are mislabeled, which the research team reviews.
- Annotation team and quality control: More than 70 crowdsourced annotators with at least a college education and English proficiency, selected from about 200 candidates (test accuracy must reach 90%); the AIJet quality-control team and the research team both spot-check, sampling at least 10% of each batch and accepting only at 90% agreement; annotators also give a confidence score from 0–3 (Appendix D).
Harm Taxonomy
- 14 categories: hate speech/offensive language, discrimination/stereotyping/injustice, violence/incitement/instigation, financial crime/property crime/theft, privacy violation, drug abuse/weapons/contraband, non-violent unethical behavior, sexually explicit content, controversial topics/politics, misinformation related to ethics, law, or safety, terrorism/organized crime, self-harm, animal abuse, child abuse.
- Categories are not mutually exclusive: A QA pair can belong to multiple categories; the authors report a correlation coefficient of 0.408 between "discrimination/stereotyping/injustice" and "hate speech/offensive language," and no correlation between "animal abuse" and the "misinformation" category (Sec. 3.3, Figure 3).
Preference Definitions
- Harmlessness: The QA pair is risk-neutral across all 14 categories, i.e., does not contribute to any harmful outcome.
- Helpfulness: How effectively the answer responds to the prompt, independent of harmlessness; the authors give the example that a detailed harmful operational answer can be "helpful" while the QA pair is still harmful.
Downstream Model Training
- Reward/cost model: Fine-tuned from Alpaca-7B with a linear head, outputting a scalar at the last EOS token of the QA pair; uses Bradley-Terry preference modeling with a negative log-likelihood training objective: LR(ϕ; DR) = −E[log σ(Rϕ(τw) − Rϕ(τl))], i.e., making the reward of the preferred answer higher than that of the non-preferred one; the cost model adds a sign term, with the sign function returning −1 for safe text and +1 for unsafe.
- Safe RLHF: Fine-tunes Alpaca-7B with PPO-Lagrangian, with the objective minθ maxλ ≥ 0 E[−Rϕ(τ) + λ · Cψ(τ)], i.e., maximizing reward and minimizing cost, with λ adaptively updated by gradient descent in the cost direction; algorithm details are in the Safe-RLHF paper [26].
- QA-moderation: Takes a (prompt, answer) pair as input and judges harmful/harmless by degree of risk neutrality; the authors state it can support multi-turn rejection sampling rather than directly rejecting the prompt (Figure 4).
What experiments did the paper conduct?
Three groups of experiments: agreement of QA-moderation with GPT-4/humans, reward/cost model training, and Safe RLHF fine-tuning and ablations; all downstream experiments are based on BeaverTails-30k.
Experimental Setup
- Models evaluated: The safety evaluation covers four models: Alpaca-7B, Alpaca-13B, Vicuna-7b, and gpt-3.5-turbo; downstream fine-tuning and ablations all use Alpaca-7B as the base model.
- Data: Downstream experiments (all of Sec. 4) use BeaverTails-30k; reward/cost model training splits train/test sets 9:1.
- Safety evaluation protocol: 140 red-team prompts (10 for each of 14 categories), each model generates 140 QA pairs, and harmlessness is assessed by three parties: the QA-moderation model, prompted GPT-4, and humans (the original data annotation team).
- Ablation comparison methods: Safe-RLHF, PPOL-classifier-max, PPOL-classifier-mean (an ensemble of 14 binary classifiers replacing the cost model, taking max/mean probability respectively), HH-PPO (trained on the HH-RLHF dataset), PPO (trained on mixed preference data).
- Evaluation method: Ablation experiments use prompted GPT-4 to evaluate each method's win rate against Alpaca-7B; the evaluation system prompt is in Appendix G.
- Number of repetitions: Not reported in the paper.
Main Results
Ablations: win rate of each method against Alpaca-7B (prompted GPT-4 evaluation, per Table 2)
Swipe horizontally to read the table
Metric Safe-RLHF PPOL-classifier-max PPOL-classifier-mean HH-PPO PPO Helpfulness 85.57% 74.00% 69.43% 64.93% 65.07% Harmlessness 82.57% 64.50% 59.07% 66.21% 68.64% - RQ1: The authors state that ranking-based cost outperforms classifier-ensemble cost; the mean variant is worse than the max variant, which the authors suggest may be because the number of flagged categories is not linearly related to the degree of harmlessness.
- RQ2: The authors state that decoupled preferences bring gains, and that the disadvantage of mixed preferences (PPO) may stem from the ambiguity introduced by aggregating multi-dimensional preferences into one dimension during annotation.
- RQ3: The authors state that Safe-RLHF outperforming HH-PPO shows the dataset is a meaningful extension of existing work; the HH-PPO model often refuses to answer or gives answers lacking detail.
Consistency Between Safety Evaluation and Moderation Models (Figure 5)
- What was measured: 140 QA pairs for each of the four models, comparing the proportion of safe QA pairs judged by the three evaluators and the pairwise agreement rates.
- Results: The authors state that Alpaca-7B and Alpaca-13B have lower safe proportions, while Vicuna-7b and gpt-3.5-turbo are comparable; the three evaluators have high agreement, with GPT-4 agreeing with humans more than QA-moderation agrees with humans; evaluator disagreement is larger on models with insufficient safety alignment. The specific values of the bar heights and curves are unreadable in the text conversion.
Reward and Cost Model Performance (Table 1, Figure 6)
- What was measured: Accuracy and score distributions of the reward model and cost model on the BeaverTails-30k test set.
- Results: Reward model accuracy 78.13%; cost model sign accuracy 95.62%, preference accuracy 74.37% (Table 1). In Figure 6, the safe and unsafe distributions of cost scores are clearly separated, which the authors state constitutes validation; the reward distribution shows no clear correlation with safe meta-labels.
Safe RLHF Fine-Tuning Effects (Figure 7, Table 3, Appendix H)
- What was measured: Using static cost/reward models to evaluate distribution changes in Alpaca-7B before and after fine-tuning, plus qualitative comparison.
- Results: In Figure 7, after fine-tuning the cost distribution shifts left and the reward distribution shifts right, which the authors state correspond to improved harmlessness and improved helpfulness respectively; in the Table 3 examples, the Safe-RLHF model refuses malicious requests and provides guidance on legal risks or public welfare.
- Failure cases: Appendix H reports that under high-temperature sampling (T = 1.0) the PPO-Lag model still produces unsafe answers; the authors state from experience that lowering the temperature to T = 0.001 can improve safety performance.
Other Ablations and Analyses
- Comparison with existing moderation APIs (Appendix E): The authors state that the Perspective API relies on keywords and has limited contextual understanding, making it unsuitable for QA moderation; the OpenAI Moderation API has some contextual understanding, but on multiple categories for Alpaca-7B/13B it missed QA pairs unanimously judged harmful by the three parties, and mislabeled 10% and 20% of safe answers for gpt-3.5-turbo and Vicuna-7b respectively ("Sexually Explicit, Adult Content" category).
- Annotation agreement (Sec. 3.1): BeaverTails-330k inter-annotator agreement: safety meta-labels 81.68%, helpfulness preference 62.39%, harmlessness 60.91%.
- Gains from the two-stage process (Appendix D): After switching from single-stage to two-stage annotation, quality-control test agreement rose by about 15%; within two months, batch agreement rose from 60%–70% to 88%–92%.
What are some points that can be further explored?
The authors list two limitations—annotation team diversity and the harm taxonomy—along with expansion plans; experiments are concentrated on the Alpaca series and the 30k data.
Limitations and future directions noted by the authors
- Limited diversity of the annotation team (Sec. 5.2): the 70 annotators have similar cultural backgrounds, which the authors believe may make the human preferences in the data narrowly representative; they plan to recruit more diverse annotators through platforms such as Amazon MTurk and Upwork.
- The harm taxonomy can be improved (Sec. 5.2): the 14 categories may not cover all harm types, and some categories overlap; the authors believe this may affect the performance of the QA-moderation model.
- Class imbalance (Sec. 5.2): categories such as "Child Abuse" and "Animal Abuse" have low sample proportions and are underrepresented; they plan to refine the taxonomy, add categories if necessary, and supplement data for underrepresented categories.
- Data expansion plan (Sec. 5.2): the authors plan to accumulate one million human preference ranking data points, with responses generated by a variety of publicly available LLMs.
- The model is not yet complete (Sec. 4.5): the authors state that the Safe-RLHF model cannot yet withstand all malicious prompts, and Appendix H gives failure cases under high-temperature sampling.
Scope of experimental coverage
- The safety evaluation covers 4 models (Alpaca-7B, Alpaca-13B, Vicuna-7b, gpt-3.5-turbo), with 140 QA pairs per model (Figure 5).
- Downstream training and ablations all use Alpaca-7B as the base model and BeaverTails-30k; the ablations include 5 methods (Table 2).
- Evaluation of fine-tuning effects is done by prompted GPT-4; the paper does not report a numerical agreement between GPT-4 evaluation and human evaluation on the win-rate experiment.
- The paper does not report the number of repetitions or variance of the experiments.
- The comparison with existing moderation systems (Appendix E) covers the OpenAI Moderation API and Perspective API, with results placed in the supplementary materials as a worksheet.
Summarize the main content of the paper
BeaverTails: a large-scale safety alignment dataset with decoupled helpfulness/harmlessness annotation, validating its use in content moderation and Safe RLHF.
A NeurIPS 2023 Datasets and Benchmarks paper that releases the safety alignment dataset BeaverTails and demonstrates three downstream applications.
- Problem addressed: The authors argue that existing preference data mixes helpfulness and harmlessness into a single score, which is insufficient to support fine-grained safety alignment; traditional content moderation judges by single-sentence toxicity, which easily leads to mass refusals and harms usability.
- Data construction: Red-team prompts are taken from HH Red-Team and Safety-Prompts, and answers are generated with Alpaca-7B; 70 selected crowdsourced annotators label via a two-stage process: first judging whether a QA pair is risk-neutral across 14 harm categories and assigning a safe/unsafe meta-label, then separately ranking answers by helpfulness and harmlessness. The 330k version contains meta-labels for 333,963 QA pairs and 361,903 preference comparison pairs, with inter-annotator agreement of 81.68% (meta-labels), 62.39% (helpfulness), and 60.91% (harmlessness) respectively.
- Application one: Training a QA-moderation model, compared on an evaluation set of 140 red-team prompts against prompted GPT-4 and human evaluation; the authors state the three parties have high agreement, with GPT-4 closer to humans.
- Application two: Training a reward model (test accuracy 78.13%) and a cost model (sign accuracy 95.62%, preference accuracy 74.37%), with the safe/unsafe distributions of cost scores clearly separated.
- Application three: Fine-tuning Alpaca-7B with PPO-Lagrangian; under GPT-4 evaluation, the helpfulness win rate against the original model is 85.57% and the harmlessness win rate is 82.57%, higher than ablation baselines such as classifier cost, HH-PPO, and mixed-preference PPO; the authors state this supports the conclusion that "decoupled preferences are beneficial."
- Authors' conclusions and boundaries: The authors believe the dataset can provide a resource for safety alignment research; they also acknowledge limited annotation team diversity, overlapping harm categories, and imbalanced categories, and report that under high-temperature sampling the fine-tuned model still outputs unsafe content.