AI Dictionary › Prompting

Needle in a Haystack

Definition

Needle in a haystack is an evaluation test measuring a model's ability to retrieve a single specific piece of information ("the needle") hidden inside a very long context ("the haystack"). You insert a target sentence at an arbitrary point in a text of tens of thousands of tokens and ask the model to recover it. Example: inside a long novel you hide "the secret code is ORANGE-7" at 60% of the text, then ask "what is the secret code?". The test checks whether the model finds it regardless of position, revealing blind spots (often tied to the lost-in-the-middle effect).

Use it to assess a model's or a RAG pipeline's reliability on long contexts before production. A good score gives you confidence the model will not "lose" critical data buried in extended documents.

Definizione (italiano)

Il needle in a haystack è un test di valutazione che misura la capacità di un modello di ritrovare una singola informazione specifica ("l'ago") nascosta all'interno di un contesto molto lungo ("il pagliaio"). Si inserisce una frase-bersaglio in un punto arbitrario di un testo di decine di migliaia di token e si chiede al modello di recuperarla. Esempio: dentro un lungo romanzo si nasconde "il codice segreto è ARANCIO-7" al 60% del testo, poi si chiede "qual è il codice segreto?". Il test verifica se il modello lo trova indipendentemente dalla posizione, rivelando eventuali punti ciechi (spesso legati al fenomeno lost in the middle).

Usalo per valutare l'affidabilità di un modello o di una pipeline RAG su contesti lunghi prima di metterla in produzione. Un buon punteggio ti dà fiducia che il modello non "perda" dati critici sepolti in documenti estesi.

Related terms

More in Prompting

From our network

AGORÀ Intelligence — Enterprise AI Governance Platform

Govern AI at scale: policies, adoption and measurable results on your data. Built for boards and C-suite.

Visit agora-intelligence.com →

From the Agora Intelligence blog

More on agora-intelligence.com →

📱 Download the Android app (beta) iOS coming soon

Say what you mean. Get what you need.

Grace Certified — the AI coach that trains and certifies your prompt engineering — by Agora Intelligence.