Datasets:

Modalities:
Text
Formats:
json
ArXiv:
Libraries:
Datasets
Dask
License:
zhennan1 commited on
Commit
e10bdfa
Β·
verified Β·
1 Parent(s): f622e84

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +123 -3
README.md CHANGED
@@ -1,3 +1,123 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+ # ExtAgents
5
+
6
+ <p align="center">
7
+ <a href="https://github.com/THUNLP-MT/ExtAgents">🌐 Github</a> |
8
+ <a href="https://arxiv.org/abs/2505.21471">πŸ“– Paper</a> |
9
+ <a href="https://huggingface.co/datasets/zhennan1/ExtAgents">πŸ€— Data</a>
10
+ </p>
11
+
12
+ ## Introduction
13
+
14
+ ExtAgents is a framework for scaling external knowledge input beyond the context length of LLMs via multi-agent collaboration.
15
+
16
+ ## Setup
17
+
18
+ ```bash
19
+ conda create -n extagents python=3.10 -y
20
+ conda activate extagents
21
+ pip install -r requirements.txt
22
+ ```
23
+
24
+ ## Data
25
+
26
+ You can download the data with the script:
27
+
28
+ ```bash
29
+ bash scripts/download_data.sh
30
+ ```
31
+
32
+ Or you can download the data manually from one of the following links:
33
+
34
+ - [Google Drive](https://drive.google.com/drive/folders/1FQSojqgF1VdumXxSh1UbIoE6lQ2E_xJn?usp=sharing)
35
+ - [Tsinghua Cloud](https://cloud.tsinghua.edu.cn/d/b8aab568cf5c4785b457/)
36
+
37
+ The data should be organized as follows:
38
+
39
+ ```bash
40
+ ./
41
+ └── data/
42
+ β”œβ”€β”€ sampled_hotpot_questions.json
43
+ β”œβ”€β”€ rag_1000k.jsonl
44
+ β”œβ”€β”€ longbook_qa_eng.jsonl
45
+ └── longbook_qa_chn.jsonl
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ ### Generation
51
+
52
+ We currently support three tasks: RAG, En.QA, Zh.QA.
53
+
54
+ The RAG task is a question answering task, where the input is a question and a context. The question and answer are sampled from the [HotpotQA](https://github.com/hotpotqa/hotpot). The context is a long text, which is the concatenation of documents retrieved from Wikipedia using BM25 embedding. We use [KILT knowledge source](http://dl.fbaipublicfiles.com/KILT/kilt_knowledgesource.json) as our knowledge source. It is based on the [2019/08/01 Wikipedia dump](http://dl.fbaipublicfiles.com/BLINK/enwiki-pages-articles.xml.bz2). We have provided the context in the `data/rag_1000k.jsonl` file.
55
+
56
+ The En.QA and Zh.QA tasks are question answering tasks, where the input is a question and a context. The question, answer and context are from the [InfiniteBench](https://github.com/OpenBMB/InfiniteBench).
57
+
58
+ Here is an example command to generate predictions for RAG task:
59
+
60
+ ```bash
61
+ python main.py \
62
+ --task rag \
63
+ --output_dir results_rag \
64
+ --chunk_length 8000 \
65
+ --input_length 128000 \
66
+ --api_url "YOUR_API_URL" \
67
+ --api_key "YOUR_API_KEY" \
68
+ --model "gpt-4o-mini-2024-07-18" \
69
+ --num_workers 8 \
70
+ > rag.log
71
+ ```
72
+
73
+ The generated predictions will be saved in the `results_rag` directory.
74
+
75
+ - `--task`: Task, can be `rag`, `en`, `zh`.
76
+ - `--output_dir`: Directory to save the generated predictions.
77
+ - `--chunk_length`: Chunk length.
78
+ - `--input_length`: Input length.
79
+ - `--model`: Model to use, default is `gpt-4o-mini-2024-07-18`.
80
+ - `--api_url`: Your API URL, default is os.getenv("OPENAI_BASE_URL").
81
+ - `--api_key`: Your API Key, default is os.getenv("OPENAI_API_KEY").
82
+ - `--num_workers`: Number of workers, each worker will process one example.
83
+
84
+ You can also set the environment variables `OPENAI_BASE_URL` and `OPENAI_API_KEY` to avoid typing them in the command line.
85
+
86
+ ```bash
87
+ export OPENAI_BASE_URL="YOUR_API_URL"
88
+ export OPENAI_API_KEY="YOUR_API_KEY"
89
+ ```
90
+
91
+ ### Evaluation
92
+
93
+ We provide a script to evaluate the generated predictions. For RAG task, the evaluation is based on the [HotpotQA](https://github.com/hotpotqa/hotpot). For En.QA and Zh.QA task, the evaluation is based on the [InfiniteBench](https://github.com/OpenBMB/InfiniteBench).
94
+
95
+ For RAG task:
96
+
97
+ ```bash
98
+ bash scripts/eval_rag.sh /path/to/your/output_dir
99
+ ```
100
+
101
+ For En.QA task:
102
+
103
+ ```bash
104
+ bash scripts/eval_en.sh /path/to/your/output_dir
105
+ ```
106
+
107
+ For Zh.QA task:
108
+
109
+ ```bash
110
+ bash scripts/eval_zh.sh /path/to/your/output_dir
111
+ ```
112
+
113
+ ## Citation
114
+
115
+ If you find this project helpful, please cite it as follows:
116
+
117
+ ```bibtex
118
+ @article{liu2025extagents,
119
+ title={Scaling External Knowledge Input Beyond The Context Length of LLMs via Multi-Agent Collaboration},
120
+ author={Zijun Liu and Zhennan Wan and Peng Li and Ming Yan and Ji Zhang and Fei Huang and Yang Liu},
121
+ year={2025}
122
+ }
123
+ ```