RIP (Rejecting Instruction Preferences) Prompts in AI

RIP judges a prompt by the answers it produces. It relies on two hypotheses

RIP (Rejecting Instruction Preferences) is a method from researchers including a team at Meta (Ping Yu et al., 2025) for finding weak prompts in AI training data. This guide explains its mathematics and shows a simple Python version.

Important: RIP is not a template for writing better chatbot prompts. It filters the prompts used to fine-tune a Large Language Model (LLM). Other projects also use the letters "RIP", such as "Resonant Identity Prompting", which is a different thing.

1. The core idea

RIP judges a prompt by the answers it produces. It relies on two hypotheses:

  1. Poor prompts tend to produce poor answers, so even the worst answer is informative.
  2. Unclear prompts tend to produce answers that vary widely in quality.

2. Mathematical formula

Step 1: Sample N responses

For each prompt x in the set X, the model M generates N answers:

{y1, y2, …, yN} ~ M(x)

Step 2: Best-vs-worst pairing

A reward function r scores each answer. The highest is "chosen" (yw) and the lowest is "rejected" (yl).

yw = argmaxyi r(yi | x)
yl = argminyi r(yi | x)

This pairing applies to model-generated answers. Datasets that already have preference pairs can use their existing pairs and scores.

Step 3: Three metrics

m1 = r(yl | x)   (rejected reward: higher is better)
m2 = len(yl)   (rejected length: higher is better)
m3 = r(yw | x) − r(yl | x)   (reward gap: lower is better)

Step 4: Selection rule

The kept set S combines a threshold Ï„ for each metric:

S = { x ∈ X : m1 ≥ Ï„1  ∧  m2 ≥ Ï„2  ∧  m3 ≤ Ï„3 }

This is a combined way of writing the paper's separate threshold conditions. The authors tested the 25th, 50th and 75th percentiles. Their best Llama 3.1-8B model on WildChat used the 50th percentile (median) for all three. These values are not guaranteed to be best for other data.

Note: length is a signal only for comparing prompts. A longer answer is not automatically a better answer.

3. Worked example

Suppose three answers score 0.92, 0.86 and 0.81. Then m1 = 0.81 and m3 = 0.92 − 0.81 = 0.11. If the 0.81 answer has 98 words, m2 = 98.

4. Python code

Requires NumPy (pip install numpy). This is an educational sketch, not the authors' official code. The responses are placeholder text and the reward scores are invented. It does not call an AI model or train one. Length is counted in words for simplicity.

import numpy as np

# Toy data: prompt -> list of (response, reward). Rewards are made up for the demo.
# In real use, sample N responses from your LLM and score them with a reward model.
def resp(words, reward):
    return (" ".join(["word"] * words), reward)

data = {
    "Explain how a rainbow forms.":           [resp(120, 0.92), resp(105, 0.86), resp(98, 0.81)],
    "Write a Python function to reverse a list.": [resp(90, 0.95), resp(75, 0.88), resp(70, 0.84)],
    "Give 5 tips for better sleep.":          [resp(130, 0.90), resp(110, 0.85), resp(95, 0.79)],
    "Compare TCP and UDP.":                   [resp(140, 0.91), resp(115, 0.83), resp(100, 0.76)],
    "fix it":                                 [resp(60, 0.55), resp(20, 0.25), resp(8, 0.10)],
    "asdf qwer zxcv":                         [resp(25, 0.30), resp(12, 0.15), resp(6, 0.08)],
    "and then he said the":                   [resp(80, 0.62), resp(30, 0.28), resp(15, 0.14)],
    "Make my code good.":                     [resp(150, 0.80), resp(40, 0.35), resp(22, 0.20)],
}

def rip_metrics(responses):
    """Best-vs-worst pairing, then the three RIP metrics."""
    chosen = max(responses, key=lambda r: r[1])    # y_w
    rejected = min(responses, key=lambda r: r[1])  # y_l
    m1 = rejected[1]                 # rejected reward
    m2 = len(rejected[0].split())    # rejected length (words, in this demo)
    m3 = chosen[1] - rejected[1]     # reward gap
    return m1, m2, m3

def rip_filter(data, q=50):
    """Keep prompts with m1 >= tau1, m2 >= tau2 and m3 <= tau3."""
    if not data:
        raise ValueError("data is empty")
    prompts = list(data)
    M = np.array([rip_metrics(data[p]) for p in prompts])
    tau = np.percentile(M, q, axis=0)
    keep = (M[:, 0] >= tau[0]) & (M[:, 1] >= tau[1]) & (M[:, 2] <= tau[2])
    return prompts, M, tau, keep

if __name__ == "__main__":
    prompts, M, tau, keep = rip_filter(data, q=50)
    print(f"Thresholds: tau1={tau[0]:.3f}  tau2={tau[1]:.1f}  tau3={tau[2]:.3f}\n")
    print(f"{'Prompt':<44}{'m1':>6}{'m2':>5}{'m3':>6}  Result")
    for p, (m1, m2, m3), k in zip(prompts, M, keep):
        print(f"{p:<44}{m1:>6.2f}{int(m2):>5}{m3:>6.2f}  {'KEEP' if k else 'REJECT'}")
    print(f"\nKept {keep.sum()} of {len(prompts)} prompts")

Output

Thresholds: tau1=0.480  tau2=46.0  tau3=0.185

Prompt                                          m1   m2    m3  Result
Explain how a rainbow forms.                  0.81   98  0.11  KEEP
Write a Python function to reverse a list.    0.84   70  0.11  KEEP
Give 5 tips for better sleep.                 0.79   95  0.11  KEEP
Compare TCP and UDP.                          0.76  100  0.15  KEEP
fix it                                        0.10    8  0.45  REJECT
asdf qwer zxcv                                0.08    6  0.22  REJECT
and then he said the                          0.14   15  0.48  REJECT
Make my code good.                            0.20   22  0.60  REJECT

Kept 4 of 8 prompts

A prompt must pass all three tests. A reasonable prompt can therefore be rejected just for falling below a median. RIP thresholds are relative to the dataset, not absolute measures of quality.

5. Self-RIP: creating new prompts

  1. Filter an initial prompt pool with RIP.
  2. Give the model 8 randomly selected kept prompts as few-shot examples, and ask for a similar new prompt.
  3. Clean the results, for example by removing near-duplicates (the paper keeps those with ROUGE-L similarity below 0.7) and certain keywords such as "image".
  4. Apply RIP again with the same threshold values, then train on what remains.

6. Reported results

Llama 3.1-8B-Instruct, trained with Direct Preference Optimization (DPO). Responses on these WildChat-based sets were scored with the ArmoRM reward model.

Training dataExamplesAlpacaEval2 LC win rate (%)Arena-HardWildBench
WildChat, no filter20,00048.437.941.5
WildChat + RIP4,53857.843.145.6
Self-RIP18,81260.242.142.5

RIP removed about 77% of the examples in this test. Self-RIP had the highest AlpacaEval2 score here, but scored lower than filtered WildChat on the other two benchmarks. These are the authors' results and were not reproduced for this article.

7. Benefits and limitations

  • Benefit: simple metrics that can reduce noisy training data.
  • Cost: generating and scoring many answers (N = 64 in the main WildChat experiments) takes computing power.
  • Limitation: results depend on the reward model and chosen thresholds.
  • Limitation: the authors note that a large reward gap does not necessarily mean a prompt is bad.
  • Safety: filtering is not a substitute for dedicated safety testing.

FAQ

Does RIP mean "prompt engineering is dead"?
No. In this paper it stands for Rejecting Instruction Preferences.

Can I use it with ChatGPT-style prompts?
You can sample and score answers to compare prompts, but that is an adaptation. The paper does not test it as a prompt-writing technique.

Reference

Yu, P. et al. (2025). R.I.P.: Better Models by Survival of the Fittest Prompts. arXiv:2501.18578

Post a Comment

0 Comments