RLAIF Preference Labeling
Use this skill when a recovery or implementation needs to convert two candidate responses into the soft AI preference label used by RLAIF. It is appropriate for summarization, helpful-dialogue, or harmless-dialogue pairwise comparisons where an LLM or deterministic scorer can return logits for displayed labels 1 and 2.
Do not use this skill to train a reward model, score a single generation from 1 to 10, or update a policy. Those are separate RLAIF mechanisms.
Inputs
task: one of summarization, helpful_dialogue, or harmless_dialogue.
context: source post or dialogue history.
response1, response2: candidate responses in the original order.
- A labeler that returns logits for displayed labels
1 and 2; in tests this is a deterministic fake.
- Optional flags for detailed preamble, chain-of-thought rationale, and swapped-order scoring.
Outputs
- A normalized preference
[p_response1, p_response2] over the original response order.
- Prompt and scoring records that identify displayed order, logits, rationale text, and remapped probabilities.
- No reward-model parameters, direct reward, policy update, or evaluation decision.
Workflow
- Build a pairwise prompt from the task preamble, context, response fields, and label ending.
- If chain-of-thought is enabled, first request a rationale and append it before final label scoring.
- Convert label logits for
1 and 2 to probabilities with stable softmax.
- If position-bias mitigation is enabled, repeat scoring with the two responses swapped.
- Remap swapped probabilities back to the original response identities.
- Average original-order and remapped swapped-order preferences.
- Return records that make the displayed-order mapping auditable.
Validation
Run:
python scripts/preference_labeling.py --smoke
python tests/test_preference_labeling.py
The tests verify softmax conversion, swapped-order remapping, chain-of-thought prompt metadata, and the module boundary that preference labels must not contain reward or policy fields.
Limitations
This skill can emulate the paper's label-token API, but it does not provide a real PaLM 2 labeler. Full paper-scale labeling requires an external LLM endpoint and the original preference datasets.
1---2name: rlaif-preference-labeling3description: Build RLAIF pairwise AI-feedback labels from label-token logits, optional chain-of-thought rationales, and swapped-order position-bias mitigation.4metadata:5 source: https://skillmd.com/skills/yzj623/rlaif-preference-labeling6---78# RLAIF Preference Labeling910Use this skill when a recovery or implementation needs to convert two candidate responses into the soft AI preference label used by RLAIF. It is appropriate for summarization, helpful-dialogue, or harmless-dialogue pairwise comparisons where an LLM or deterministic scorer can return logits for displayed labels `1` and `2`.1112Do not use this skill to train a reward model, score a single generation from 1 to 10, or update a policy. Those are separate RLAIF mechanisms.1314## Inputs1516- `task`: one of `summarization`, `helpful_dialogue`, or `harmless_dialogue`.17- `context`: source post or dialogue history.18- `response1`, `response2`: candidate responses in the original order.19- A labeler that returns logits for displayed labels `1` and `2`; in tests this is a deterministic fake.20- Optional flags for detailed preamble, chain-of-thought rationale, and swapped-order scoring.2122## Outputs2324- A normalized preference `[p_response1, p_response2]` over the original response order.25- Prompt and scoring records that identify displayed order, logits, rationale text, and remapped probabilities.26- No reward-model parameters, direct reward, policy update, or evaluation decision.2728## Workflow29301. Build a pairwise prompt from the task preamble, context, response fields, and label ending.312. If chain-of-thought is enabled, first request a rationale and append it before final label scoring.323. Convert label logits for `1` and `2` to probabilities with stable softmax.334. If position-bias mitigation is enabled, repeat scoring with the two responses swapped.345. Remap swapped probabilities back to the original response identities.356. Average original-order and remapped swapped-order preferences.367. Return records that make the displayed-order mapping auditable.3738## Validation3940Run:4142```bash43python scripts/preference_labeling.py --smoke44python tests/test_preference_labeling.py45```4647The tests verify softmax conversion, swapped-order remapping, chain-of-thought prompt metadata, and the module boundary that preference labels must not contain reward or policy fields.4849## Limitations5051This skill can emulate the paper's label-token API, but it does not provide a real PaLM 2 labeler. Full paper-scale labeling requires an external LLM endpoint and the original preference datasets.