[Paper Review] LLM In-Context Recall is Prompt Dependent
This paper investigates in-context recall performance of large language models (LLMs) using the needle-in-a-haystack method, demonstrating that recall is highly prompt-dependent and influenced by factors like needle placement, haystack length, and model fine-tuning. Key findings show that model architecture, training strategy, and fine-tuning significantly impact recall accuracy, with fine-tuned models like WizardLM and GPT-3.5 Turbo 0125 outperforming base models despite similar parameter counts.
The proliferation of Large Language Models (LLMs) highlights the critical importance of conducting thorough evaluations to discern their comparative advantages, limitations, and optimal use cases. Particularly important is assessing their capacity to accurately retrieve information included in a given prompt. A model's ability to do this significantly influences how effectively it can utilize contextual details, thus impacting its practical efficacy and dependability in real-world applications. Our research analyzes the in-context recall performance of various LLMs using the needle-in-a-haystack method. In this approach, a factoid (the "needle") is embedded within a block of filler text (the "haystack"), which the model is asked to retrieve. We assess the recall performance of each model across various haystack lengths and with varying needle placements to identify performance patterns. This study demonstrates that an LLM's recall capability is not only contingent upon the prompt's content but also may be compromised by biases in its training data. Conversely, adjustments to model architecture, training strategy, or fine-tuning can improve performance. Our analysis provides insight into LLM behavior, offering direction for the development of more effective applications of LLMs.
Motivation & Objective
- To evaluate how reliably LLMs can retrieve specific facts embedded in long context windows using the needle-in-a-haystack method.
- To investigate whether prompt structure—such as needle placement and haystack length—affects in-context recall performance.
- To analyze the impact of model architecture, training strategy, and fine-tuning on recall accuracy across diverse LLMs.
- To identify systematic biases or anomalies in evaluation scoring that may distort perceived model performance.
- To provide actionable insights for selecting and optimizing LLMs based on their retrieval capabilities in real-world applications.
Proposed method
- Conducted needle-in-a-haystack tests using three distinct factoid-question pairs (e.g., PistachioAI, San Francisco, Thornfield Hollow) to evaluate in-context recall.
- Evaluated nine LLMs with varying context window sizes, including Llama 2, GPT-3.5 Turbo, Mistral, Mixtral, and GPT-4 Turbo, across multiple haystack lengths and needle placements.
- Used GPT-4 Turbo as a judge to score model responses against a predefined criteria (Table 4), reducing human evaluation cost and time.
- Generated heatmaps to visualize recall performance across different haystack depths and lengths, enabling comparative analysis of model behavior.
- Analyzed performance differences between base models and their fine-tuned variants (e.g., WizardLM vs. Llama 2 70B) to isolate the impact of fine-tuning.
- Identified and documented scoring anomalies caused by prompt artifacts, such as irrelevant context altering response interpretation despite correct factual recall.

Experimental results
Research questions
- RQ1How does the position of a fact (needle) within a long context (haystack) affect an LLM’s ability to recall it?
- RQ2To what extent does the length of the haystack influence in-context recall performance across different LLMs?
- RQ3How do architectural differences, parameter count, and attention mechanisms impact recall accuracy?
- RQ4Does fine-tuning improve in-context recall, and if so, by how much compared to base models?
- RQ5What role do training data biases and prompt artifacts play in distorting evaluation results, particularly in automated scoring?
Key findings
- In-context recall performance is highly sensitive to prompt design, with significant variation observed based on needle placement and haystack length.
- Fine-tuned models such as WizardLM 70B outperformed their base counterparts (Llama 2 70B) across all tests, demonstrating a clear performance gain from instruction tuning.
- GPT-3.5 Turbo 0125 showed a measurable improvement over GPT-3.5 Turbo 1106, attributed to an updated fine-tuning strategy, with higher recall scores across all three tests.
- Mistral 7B v0.2 and Mixtral 8x7B achieved high recall (96.7% and 95.8%, respectively), indicating that architectural improvements and increased parameter count enhance retrieval performance.
- Scoring anomalies occurred when irrelevant context altered the meaning of the prompt, causing correct factual responses to be incorrectly scored low by GPT-4 Turbo.
- The study revealed that a single needle-in-a-haystack test is insufficient to represent a model’s true recall capability due to strong prompt dependency.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.