|
--- |
|
dataset_info: |
|
features: |
|
- name: id |
|
dtype: int64 |
|
- name: haystack |
|
dtype: string |
|
- name: keys |
|
dtype: string |
|
- name: values |
|
dtype: string |
|
- name: question |
|
dtype: string |
|
- name: context_length |
|
dtype: int64 |
|
- name: num_kv_pairs |
|
dtype: int64 |
|
- name: repeat_number |
|
dtype: int64 |
|
- name: needle_depth |
|
dtype: string |
|
- name: num_needles |
|
dtype: int64 |
|
- name: needle_placement |
|
dtype: string |
|
- name: conditional_character |
|
dtype: string |
|
- name: thread_length |
|
dtype: int64 |
|
- name: thread_direction |
|
dtype: string |
|
- name: num_threads |
|
dtype: int64 |
|
splits: |
|
- name: Single_Needle |
|
num_bytes: 159048560 |
|
num_examples: 660 |
|
- name: Multiple_Needles |
|
num_bytes: 261371340 |
|
num_examples: 1080 |
|
- name: Conditional_Needles |
|
num_bytes: 260974140 |
|
num_examples: 1080 |
|
- name: Single_Threads |
|
num_bytes: 564730140 |
|
num_examples: 2340 |
|
- name: Multi_Threads |
|
num_bytes: 1391847750 |
|
num_examples: 5700 |
|
download_size: 1798326219 |
|
dataset_size: 2637971930 |
|
configs: |
|
- config_name: default |
|
data_files: |
|
- split: Single_Needle |
|
path: data/Single_Needle-* |
|
- split: Multiple_Needles |
|
path: data/Multiple_Needles-* |
|
- split: Conditional_Needles |
|
path: data/Conditional_Needles-* |
|
- split: Single_Threads |
|
path: data/Single_Threads-* |
|
- split: Multi_Threads |
|
path: data/Multi_Threads-* |
|
license: mit |
|
language: |
|
- en |
|
--- |
|
--- |
|
--- |
|
# Needle Threading: Can LLMs Follow Threads through Near-Million-Scale Haystacks? |
|
|
|
## Dataset Description |
|
|
|
- **Homepage:** [https://needle-threading.github.io](https://needle-threading.github.io) |
|
- **Paper:** [Needle Threading: Can LLMs Follow Threads through Near-Million-Scale Haystacks?](https://arxiv.org/abs/2411.05000) |
|
- **Repository** [Needle Threading](https://github.com/jonathan-roberts1/needle-threading) |
|
|
|
## Dataset Summary |
|
|
|
As the context limits of Large Language Models (LLMs) increase, the range of possible applications and downstream functions broadens. Although the development of longer context models has seen rapid gains recently, our understanding of how effectively they use their context has not kept pace. |
|
|
|
To address this, we conduct a set of retrieval experiments designed to evaluate the capabilities of 17 leading LLMs, such as their ability to follow threads of information through the context window. |
|
|
|
Strikingly, we find that many models are remarkably thread-safe: capable of simultaneously following multiple threads without significant loss in performance. Still, for many models, we find the effective context limit is significantly shorter than the supported context length, with accuracy decreasing as the context window grows. |
|
|
|
## Example Usage |
|
|
|
### Option 1: HuggingFace datasets |
|
```python |
|
from datasets import load_dataset |
|
|
|
# task splits can be downloaded separately: |
|
# splits = ['Single_Needle', 'Multi_Needle', 'Conditional_Needle', 'Single_Thread', 'Multi_Thread'] |
|
single_needle_dataset = load_dataset("jonathan-roberts1/needle-threading", split='Single_Needle') |
|
|
|
""" |
|
Dataset({ |
|
features: ['id', 'haystack', 'keys', 'values', 'question', 'context_length', 'num_kv_pairs', |
|
'repeat_number', 'needle_depth', 'num_needles', 'needle_placement', 'conditional_character', |
|
'thread_length', 'thread_direction', 'num_threads'], |
|
num_rows: 660 |
|
}) |
|
Note the units of context_length are number of characters. |
|
""" |
|
|
|
# query individual questions |
|
single_needle_dataset[5] # e.g., the 6th element |
|
""" |
|
{'id': 5, 'haystack': '{"e3e70682-c209-4cac-629f-6fbed82c07cd": "f728b4fa-4248-5e3a-0a5d-2f346baa9455", |
|
"eb1...": "964a870c-7c87-9b74-1d87-8f9f9cdf5a86"}', 'keys': '247a8333-f7b0-b7d2-cda8-056c3d15eef7', |
|
'values': '1759edc3-72ae-2244-8b01-63c1cd9d2b7d', 'question': 'Extract the value corresponding to |
|
the specified key in the JSON object. Key: "247a83...-cda8-056c3d15eef7"\n Corresponding value: ', |
|
'context_length': 2000, 'num_kv_pairs': 25, 'repeat_number': 0, 'needle_depth': '50', 'num_needles': 1, |
|
'needle_placement': 'depthwise', 'conditional_character': 'N/A', 'thread_length': 1, |
|
'thread_direction': 'N/A', 'num_threads': 0} |
|
""" |
|
``` |
|
|
|
|
|
### Option 2: Manual download |
|
|
|
Directly downloading image files and question data from the needle-threading HuggingFace repository into the ```data``` directory in this repo. |
|
``` |
|
cd data |
|
wget https://huggingface.co/datasets/jonathan-roberts1/needle-threading/resolve/main/data_json.zip |
|
unzip data_json.zip && rm data_json.zip |
|
``` |
|
#### Expected structure |
|
``` |
|
βββ data |
|
βββ json_data |
|
βββ Single_Needle.json |
|
βββ Multiple_Needles.json |
|
βββ Conditional_Needles.json |
|
βββ Single_Threads.json |
|
βββ Multi_Threads.json |
|
``` |
|
|
|
Note: ```data_json/``` needs to be downloaded. |
|
|
|
Please visit our [GitHub repository](https://github.com/jonathan-roberts1/needle-threading) for example inference code. |
|
|
|
### Dataset Curators |
|
|
|
This dataset was curated by Jonathan Roberts, Kai Han, and Samuel Albanie |
|
|
|
### Citation |
|
If you found our work useful in your own research, please consider citing our paper: |
|
```latex |
|
@article{roberts2024needle, |
|
title={Needle Threading: Can LLMs Follow Threads through Near-Million-Scale Haystacks?}, |
|
author={Roberts, Jonathan and Han, Kai and Albanie, Samuel}, |
|
journal={arXiv preprint arXiv:2411.05000}, |
|
year={2024} |
|
} |
|
``` |