# gkamradt/needle-in-a-haystack

Doing simple retrieval from LLM models at various context lengths to measure accuracy

Repository: https://github.com/gkamradt/needle-in-a-haystack
Canonical: https://ross.abutalabs.com/products/needle-in-a-haystack
Language: Jupyter Notebook
License: NOASSERTION
License Family: other
Last push: 2026-06-08T18:01:12+00:00

## Health v2 (maintenance only)
Score: 72/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 86, release rhythm 54, longevity 73
- inputs: {"age_days": 1027, "days_push": 86, "days_rel": 95, "gap_med": null, "n_releases_24m": 1}
- flags: no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2375, forks 246 (observed 2026-08-28T04:06:41.998317+00:00)

## What it is
A benchmarking tool (niah / needlehaystack) that pressure-tests LLM long-context retrieval by sweeping context length x needle depth cells against configured models and scoring each response. It supports single-fact lookup, multi-fact recall, and UUID-chain multi-step reasoning tasks, writing one JSONL result row per cell.

## Use cases
- test how well an LLM retrieves a fact from a long context
- measure retrieval accuracy at different context lengths and depths
- compare long-context performance across OpenAI, Anthropic, and Cohere models
- run a needle-in-a-haystack evaluation sweep
- probe whether models miss information buried in the middle of long prompts
- evaluate multi-step reasoning over long context with UUID chains

## When to choose
- you need a reproducible, configurable sweep of context-length vs depth accuracy for LLMs
- you want to benchmark raw long-context retrieval across multiple providers
- you want scored JSONL results you can analyze, including reconstructing the exact context each cell saw

## When to avoid
- you need a general LLM evaluation harness for coding, math, or reasoning benchmarks beyond context retrieval
- you want to test a RAG pipeline's retriever rather than a model's raw context handling
- you need a production inference client - this is an evaluation tool, not a serving layer

## Facets
- artifact type: cli-tool
- maturity: active
- function: benchmarking, llm-inference, testing
- domain: large-language-models, artificial-intelligence, testing, machine-learning
- platform: python, cli
- tags: llm-evaluation, long-context, context-window, needle-in-a-haystack, lost-in-the-middle, jsonl-results, yaml-config, model-comparison, openai, anthropic, cohere, uuid-chain-reasoning

## Member repositories
- gkamradt/needle-in-a-haystack (main) score 72

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:41.998317+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:35:03.149366+00:00, confidence not recorded.
  - readme: https://github.com/gkamradt/needle-in-a-haystack (fetched 2026-08-28T04:06:41.998317+00:00, sha 2b039ddce7a7)
- Data as of 2026-08-30T08:39:29.467469+00:00.
