abliteration.org
Get the app

Two ways to read this site

Technical mode is the default: exact terms and codes, for engineers, researchers, journalists and companies. Simple mode gives the same facts in plain words, for anyone who wants a model that runs on their own computer. You can switch at any time at the top of the page.

technical
MLX weights for Apple silicon (M1 or later), usually quantized to 4 or 8 bits.
simple
Made for Macs with Apple silicon (M1 or newer), usually compressed to 4 or 8 bits.

lefft/needleif-bench

published by @lefft

Safety benchmarks, over-refusal tests, and guard-model data.Safety tests and tests for refusing harmless requests.

task_categories:text-generationlanguage:enlicense:apache-2.0modality:textregion:uslong-contextinstruction-followingifeval +3 more
Lifetime downloads
1.3K
Last 30 days
413
Likes
-
Size
54.0 MB

Description

needleif-bench

A judge-free, NIAH-style long-context control benchmark with hidden verifiable

instructions. The "needle" (lifted from IFEval)

is hidden inside long distractor prose (the "haystack"). The model must find the

instruction and follow it — testing long-context retrieval and instruction

following at once, with deterministic, model-free scoring.

It exists to measure capability regression (catastrophic forgetting) after

task-specific fine-tuning: run it on a model before… See the full description on the dataset page: https://huggingface.co/datasets/lefft/needleif-bench.

Structure 1 config · from the README front matter1 subset, from the author's description

default default
Data files
test data/full/test.jsonl
train data/full/train.jsonl
val data/full/val.jsonl

Used by uncensored models none yet

No abliterated models in our catalog have declared this dataset in their YAML metadata yet. This can mean the dataset is used but not declared, is used outside abliteration workflows, or is new. The link will populate automatically as models are indexed.No model in our catalog lists this dataset yet. It may be used without being listed, used for other work, or simply be new. The list fills in by itself as models are added.

MetadataDetails

License
apache-2.0
Language
en
Created on HFCreated
2026-06-30 · 5 months ago
ModalitiesData types
text

Related datasets same stage · Evaluatesame step · Testing

Read further

Total size
54.0 MB
Files
36
Formats
py, jsonl, json
Head
b22f13f
Last updated on HFLast updated
2026-07-10

Download the dataset

Copy any of these snippets into your notebook or terminal. All three fetch directly from Hugging Face using your own credentials.Each of these lines of code downloads the dataset straight from Hugging Face, with your own Hugging Face login.

Recommended: datasets library (Python)
from datasets import load_dataset
ds = load_dataset("lefft/needleif-bench")
Raw snapshot (Python)All files (Python)
from huggingface_hub import snapshot_download
snapshot_download(repo_id="lefft/needleif-bench", repo_type="dataset")
git clone (requires git-lfs)With git (needs git-lfs)
git clone https://huggingface.co/datasets/lefft/needleif-bench

Files by folder from our last crawlfrom our last check

top level 11 files 67.2 KB
.gitattributes 2.7 KB file download
.gitignore 185 B file download
CLAUDE.md 8.2 KB md download
generate.py 15.7 KB py download
LICENSE 11.3 KB file download
pyproject.toml 1.2 KB toml download
README.md 14.0 KB md download
requirements.txt 342 B txt download
run_model.py 5.1 KB py download
RUNBOOK.md 5.7 KB md download
score.py 2.9 KB py download
configs/ 1 file 1.8 KB
full.yaml 1.8 KB yaml download
data/ 4 files 53.9 MB
full/test.jsonl 17.9 MB jsonl download
full/train.jsonl 27.0 MB jsonl download
full/val.jsonl 8.8 MB jsonl download
needles_ifeval.json 123.2 KB json download
needleif/ 6 files 21.2 KB
__init__.py 235 B py download
checks.py 5.5 KB py download
haystack.py 5.2 KB py download
io_utils.py 886 B py download
scoring.py 6.4 KB py download
sizing.py 2.9 KB py download
scripts/ 5 files 12.7 KB
add_responses.py 5.0 KB py download
dataset_stats.py 2.3 KB py download
fetch_needles.py 2.4 KB py download
push_to_hf.py 1.4 KB py download
results_table.py 1.6 KB py download
tests/ 9 files 34.2 KB
data/needles_fixture.json 1.7 KB json download
test_add_responses.py 3.9 KB py download
test_budget.py 4.3 KB py download
test_checks.py 10.4 KB py download
test_determinism.py 1.7 KB py download
test_insertion.py 1.7 KB py download
test_providers.py 4.6 KB py download
test_scoring.py 3.7 KB py download
test_sizing.py 2.0 KB py download

READMEAuthor's description current version from Hugging Faceas it is now on Hugging Face

needleif-bench

A judge-free, NIAH-style long-context control benchmark with hidden verifiable
instructions. The "needle" (lifted from IFEval)
is hidden inside long distractor prose (the "haystack"). The model must find the
instruction and follow it
— testing long-context retrieval and instruction
following at once, with deterministic, model-free scoring.

It exists to measure capability regression (catastrophic forgetting) after
task-specific fine-tuning: run it on a model before and after unrelated FT and
watch the score move. Most useful for small open-weight models.

from datasets import load_dataset
ds = load_dataset("lefft/needleif-bench", split="test")  # "test" | "train" | "val"
ds_128k = ds.filter(lambda r: r["metadata"]["size_bucket"] == "128k")

Task

Every needle is presented in two conditions that differ only in the
presence of the document, so the haystack is the sole variable:

  • bare — the instruction alone: "Follow it. Reply with ONLY the output…"
  • haystack — the same instruction buried in long prose: "Hidden somewhere in
    this document is exactly one instruction. Find it and follow it. Reply with
    ONLY the output…"

Metrics

A response passes a needle when it satisfies all of that needle's
instructions (prompt-level). Each pass is scored two ways: strict (exact)
and loose (forgives a stray preamble line or stray markdown); unless noted,
tables use loose prompt-level pass@1 — one sample at temperature 0. pass@k is
also supported.

From each bare/haystack pair we compute:

  • baseline (bare) accuracy — fraction of needles the model follows given the
    instruction alone.
  • long-context (haystack) accuracy — fraction it still follows when the
    instruction is buried in the haystack. (This is the "long-context loose
    prompt@1" column in the tables.)
  • distraction regression = #(passes bare ∧ fails haystack) / #(passes bare) —
    of the needles the model can follow in isolation, the fraction the haystack
    causes it to fail. This is the primary number: it divides out raw
    instruction-following ability to isolate the long-context effect.
  • net penalty = baseline − long-context accuracy.

All are broken down by haystack size, needle depth, and instruction complexity.

Results

Stale: the tables below were measured on the pre-2026-07-10 data
(cl100k-sized buckets, no per-bucket budgets). Rankings are unlikely to
change materially, but rerun run_model.py + score.py to refresh.

A few models on the full test split (100 pairs) — a small illustrative set, not a leaderboard; loose prompt-level pass@1, seed=666.

Model baseline (bare) long-context (haystack) distraction regression ↓ net penalty
Gemma4-31B (reasoning on) 98.0% 97.0% 3.1% 1.0%
Gemma4-31B (reasoning off) 98.0% 91.0% 8.2% 7.0%
Claude Haiku 4.5 92.0% 84.0% 10.9% 8.0%
Qwen3.5-9B (reasoning on) 88.0% 65.0% 34.1% 23.0%
Qwen3.5-9B (reasoning off) 93.0% 46.0% 52.7% 47.0%
Qwen2.5-7B-Instruct-Turbo 77.0% 17.0% 79.2% 60.0%

Long-context (haystack) accuracy by size:

Model 2k 4k 8k 16k 32k 64k 128k
Gemma4-31B (reasoning on) 100% 100% 100% 100% 95% 100% 90%
Gemma4-31B (reasoning off) 90% 100% 100% 100% 100% 90% 70%
Claude Haiku 4.5 100% 100% 80% 90% 75% 90% 70%
Qwen3.5-9B (reasoning on) 90% 60% 80% 80% 70% 45% 55%
Qwen3.5-9B (reasoning off) 90% 40% 50% 30% 60% 30% 35%
Qwen2.5-7B-Instruct-Turbo 60% 50% 50% 10% — — —

Dataset statistics

300 needles → 600 records across three splits with disjoint needle pools (no
leakage across splits), seed=666. Per-split, per-size needle (pair) counts —
smaller sizes are sampled less so the long-context tail stays well-represented:

split pairs records complex / simple 2k 4k 8k 16k 32k 64k 128k
test 100 200 33 / 67 10 10 10 10 20 20 20
train 150 300 50 / 100 15 15 15 15 30 30 30
val 50 100 17 / 33 5 5 5 5 10 10 10

Each needle also appears in a bare condition (the instruction alone). Train
and val records carry a verified assistant turn (see Record schema below);
test records are user-only. Each size
bucket is a context window: the chat-templated conversation — prompt plus
the assistant turn (train/val) or the reserved generation budget (test, =
output_reserve_tokens) — fits within 95% of the bucket, as measured by the
pinned Gemma 4 tokenizer used for sizing. Training at seq_len == bucket or
evaluating a bucket-context model therefore needs no filtering. ~1/3 of needles are complex
(2–3 instructions), the rest simple (1) — bounded by the IFEval-derived pool
(209 simple / 106 complex). Depths {10%, 50%, 90%} cycle within each size bucket.
Regenerate stats with python3 scripts/dataset_stats.py --records data/full/<split>.jsonl.

Record schema

One JSON object per line. messages opens with a single user turn — a fixed
find-the-instruction meta-instruction followed by the document. Scoring never
uses a gold response: it applies the metadata spec (instruction_id_list +
kwargs) to the model's answer, and metadata is never shown to the model.

In train and val, each record additionally ends with an assistant
turn so those splits are directly usable as SFT data. Responses were generated
from the bare prompt (both records of a pair share the same response — the
checks are response-only, so the correct output is identical for both
conditions) and every one is verified to pass its needle's strict checks
(google/gemma-4-31B-it, stragglers filled by
meta-llama/Llama-3.3-70B-Instruct-Turbo; see scripts/add_responses.py).
The test split stays user-only: the eval is deterministic and needs no
reference answer.

{
  "id": "f00d…-hay",
  "pair_id": "f00d…",
  "messages": [
    {"role": "user", "content": "…fixed find-the-instruction preamble…\n\n----- BEGIN DOCUMENT -----\n…prose … the needle instruction … prose…\n----- END DOCUMENT -----"}
  ],
  "metadata": {
    "condition": "haystack",                     // or "bare"
    "instruction_id_list": ["detectable_format:title"],
    "kwargs": [{}],
    "needle_text": "the IFEval instruction, verbatim",
    "needle_source": "ifeval", "needle_source_key": 1357,
    "haystack_source": "pg19",
    "haystack_target_tokens": 8192, "haystack_actual_tokens": 5637, "size_bucket": "8k",
    "total_prompt_tokens": 5702, "prompt_token_budget": 5718, "output_reserve_tokens": 2048,
    "reference_tokenizer": "hf:google/gemma-4-E4B-it@a4c2d58be94dda072b918d9db64ee85c8ed34e3f",
    "depth_percent": 50.0, "needle_char_offset": 19342,  // offset into the document body
    "complexity": "simple", "num_instructions": 1,
    "split": "test", "seed": 666, "needle_marker": null
  }
}

Usage

See RUNBOOK.md for the full walkthrough (auth, loading via datasets, regenerating the data, reasoning models). The short version:

# get the benchmark (this repo holds both the data and the code) and install
git clone https://huggingface.co/datasets/lefft/needleif-bench && cd needleif-bench
pip install -r requirements.txt

# run a model on the test split (Anthropic, or any OpenAI-compatible endpoint)
python3 run_model.py \
    --records data/full/test.jsonl \
    --provider anthropic \
    --model claude-haiku-4-5-20251001 \
    --out responses.jsonl

# score (judge-free; responses JSONL is {"id","response"} or {"id","responses":[...]})
python3 score.py \
    --records data/full/test.jsonl \
    --responses responses.jsonl \
    --out-results results.jsonl \
    --out-summary summary.json

Scoring

We adopt a simplified, self-contained version of IFEval's scoring: each supported
instruction type has a deterministic check run against the model's answer only (no
model-as-judge). The 17 checks live in needleif/checks.py, which — like
score.py — is pure standard library, so the published dataset can be scored with
nothing installed.

Worked example — the needle "Answer with at least 3 bullet points and finish with
the exact phrase: Any other questions?"
carries two checks, number_bullet_lists (≥3) and end_checker ("Any other questions?"); the answer passes the needle iff
both hold on the response text.

Notes & caveats

  • Token sizes are measured in the pinned Gemma 4 tokenizer (see
    reference_tokenizer); the per-bucket fit guarantee holds exactly for that
    tokenizer and, via the 5% headroom, for tokenizers within ~5% of it on
    English prose (most recent open models). Sizing never affects pass/fail.
    Regenerate with --tokenizer hf:<model>[@rev] to retarget another family.
  • output_reserve_tokens is the eval generation budget: run the test split
    with max_tokens equal to the record's reserve and the request can never
    overflow a bucket-sized window.
  • Deterministic. generate.py is a pure function of its config + seed
    (byte-identical output); scoring is deterministic.
  • Haystack source. Default is PG19 (Apache-2.0, redistributable). A
    zero-dependency programmatic provider exists for offline use.

Repository structure

needleif-bench/
├── needleif/               # library (the scoring path is stdlib-only)
│   ├── checks.py           # 17 IFEval checks + whitelist — the judge-free scoring core
│   ├── scoring.py          # per-record + paired distraction metrics, pass@k
│   ├── haystack.py         # PG19 + programmatic distractor providers
│   ├── sizing.py           # tokenizer abstraction (tiktoken | hf:<model> | words)
│   └── io_utils.py         # jsonl I/O, stable ids, seeded RNG
├── generate.py             # CLI: build the dataset (config, needle pool, wrappers)
├── score.py                # CLI: judge-free scoring
├── run_model.py            # CLI: run a model (Anthropic | OpenAI-compatible)
├── scripts/                # fetch_needles · add_responses · dataset_stats · results_table · push_to_hf
├── configs/                # generation grids
├── data/                   # needles_ifeval.json (needle pool) + generated splits
├── tests/                  # pytest, network-free  (run: python3 -m pytest)
├── CLAUDE.md  RUNBOOK.md   # contributor notes  ·  step-by-step eval walkthrough
├── README.md  LICENSE
└── pyproject.toml  requirements.txt

See CLAUDE.md for the module map + contributor notes, and RUNBOOK.md to run an eval end-to-end.

  • LIFBench — Wu et al. (2025), ACL 2025. Instruction-following accuracy and stability under long-context inputs — the closest sibling, though it scales context around the instruction rather than hiding a single verifiable needle.
  • RULER — Hsieh et al. (2024), COLM 2024. Generalizes needle-in-a-haystack with configurable needles plus multi-hop and aggregation tasks to probe a model's effective context length.
  • BABILong — Kuratov et al. (2024), NeurIPS 2024 Datasets & Benchmarks. Hides bAbI reasoning facts in PG19 background text — the same task-in-PG19-noise construction used here — but targets multi-fact reasoning rather than instruction-following.
  • IFEval — Zhou et al. (2023), arXiv preprint. ~500 prompts with programmatically verifiable instructions scored by deterministic code (no LLM judge); needleif-bench reuses its prompts as needles and reimplements the checks.
  • MMMT-IF — Epstein et al. (2024), arXiv preprint. Disperses code-verifiable instructions across long multi-turn multimodal dialogues, scored by a judge-free Programmatic Instruction Following (PIF) metric.
  • Needle in a Haystack — Kamradt (2023), open-source project. The original retrieval-at-depth pressure test (one fact in long filler across depths and lengths); needleif-bench swaps the retrievable fact for a followable instruction.

License & attribution

Apache-2.0 (see LICENSE). Built entirely from open-source artifacts:


TODO

  • Iterate on the prompt wrappers and the bare-condition framing.
  • Add a needle-length filter and tune the complex-needle instruction mix.
  • Handle reasoning models more gracefully (answer extraction, token-budget guidance).
  • Once the format is frozen, wipe the test suite (CLAUDE.md documents how to regenerate coverage).
  • (research, not practical) Fix a needle and sweep the haystack size to find
    the context length at which instruction-following breaks down — and whether that
    threshold varies by base model, shifts before/after fine-tuning, or depends on
    needle complexity.

README historyEdit history latest 20 of 29 revisionslatest 20 of 29 edits

Every night we snapshot the README of every dataset in the catalog. When the SHA changes we archive the new version and diff it against the last. This is the evolving thought record of the alignment-data field: what the author decided to say about the corpus, and how that framing shifted over time.Every night we save the author's description of every dataset in the catalog. When it changes, we keep the new text and compare it with the one before. This shows what each author chose to say about their dataset, and how that changed over time.

  1. 2026-07-10 Per-bucket context budgets sized in the Gemma 4 tokenizer (train/eval-ready b... b22f13f 13.6 KB
    Loading...
  2. 2026-07-08 Simplify code paths; add verified assistant turns to train/val (SFT-ready) 1414171 12.8 KB
    Loading...
  3. 2026-07-07 Add scripts/results_table.py (was silently excluded from Hub pushes by push_t... 35b7412 12.4 KB
    Loading...
  4. 2026-07-07 Cap full prompt at max_prompt_tokens=124928 so 128k-bucket records fit a 1310... c828eed 12.4 KB
    Loading...
  5. 2026-07-01 Reword scoring-core principle (drop agent-memory reference) 7f5b161 12.4 KB
    Loading...
  6. 2026-07-01 Reword headline (NIAH-style, hidden verifiable instructions) d95a618 12.4 KB
    Loading...
  7. 2026-07-01 Add size_bucket metadata field; Gemma4-31B (reasoning on) results; filter by ... 191310b 12.4 KB
    Loading...
  8. 2026-07-01 Add context-length filter example to load snippet 37eedd9 12.4 KB
    Loading...
  9. 2026-07-01 Rename val split; add Gemma4-31B (reasoning off) results 7fba52a 12.2 KB
    Loading...
  10. 2026-07-01 Rename validation split to val 4e761e2 12.1 KB
    Loading...
  11. 2026-07-01 Results: drop footnote, use — for errored cells d3452b5 12.1 KB
    Loading...
  12. 2026-07-01 Move load snippet to top; trim results commentary 5d7d183 12.3 KB
    Loading...
  13. 2026-07-01 Add Qwen3.5-9B reasoning-on results; integer per-size %; bash Usage 0a4d8dc 12.3 KB
    Loading...
  14. 2026-07-01 Add Related benchmarks section 959bd44 12 KB
    Loading...
  15. 2026-07-01 Full-test results (3 models) + README revisions e879294 10.6 KB
    Loading...
  16. 2026-07-01 Delete configs/v0.yaml with huggingface_hub 346e1e0 9.7 KB
    Loading...
  17. 2026-07-01 Delete NOTICE with huggingface_hub a8fb17a 9.7 KB
    Loading...
  18. 2026-07-01 Delete test.jsonl with huggingface_hub 8328941 9.7 KB
    Loading...
  19. 2026-07-01 Full benchmark: test/train/validation splits (sizes 2k-128k), README + code u... 2f2e7cc 9.7 KB
    Loading...
  20. 2026-06-30 Upload folder using huggingface_hub 11e976e 10.9 KB
    Loading...

Community discussions 1 thread · 1 open · 1 comments

Threads posted by the community on Hugging Face: bug reports, questions about usage, pull requests on the README, licence clarifications. Click any thread to expand and read the full conversation inline. Newest first.Conversations people started on Hugging Face: bug reports, questions about using the data, suggested changes to the author's description, questions about the licence. Open a thread to read it here. Newest first.

  1. 2026-07-02 [bot] Conversion to Parquet open 1 💬 #1
    Loading...
Download from Hugging Face

lefft/needleif-bench

Catalog is the map. Apps are the tools.

Run models on your own machine, not in the cloud.

Every GGUF model page has an "Open in Abliteration" button that lets you pick a file, then opens it in the desktop app. No API keys, no subscription, no prompt leakage.Each model page in the format the app uses has an "Open in Abliteration" button to open a file in the desktop app. No API keys, no subscription, your requests stay on your computer.

Open in Abliteration