Ameame1002 commited on
Commit
06f4afc
·
verified ·
1 Parent(s): 54bee4e

Add OPERA 1.78M BGE-M3 retrieval corpus (index + meta + README)

Browse files
Files changed (5) hide show
  1. .gitattributes +2 -0
  2. README.md +125 -0
  3. load_example.py +60 -0
  4. opera_corpus.index +3 -0
  5. opera_corpus.meta +3 -0
.gitattributes CHANGED
@@ -58,3 +58,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ opera_corpus.index filter=lfs diff=lfs merge=lfs -text
62
+ opera_corpus.meta filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OPERA Retrieval Corpus
2
+
3
+ Prebuilt dense retrieval corpus used by the OPERA inference pipeline
4
+ (*OPERA: A Reinforcement Learning–Enhanced Orchestrated Planner-Executor
5
+ Architecture for Reasoning-Oriented Multi-Hop Retrieval*).
6
+
7
+ This release contains two files:
8
+
9
+ | File | Size | Purpose |
10
+ |---|---|---|
11
+ | `opera_corpus.index` | ~7.3 GB | FAISS `IndexFlatIP` over BGE-M3 dense embeddings |
12
+ | `opera_corpus.meta` | ~150 MB | Pickle list of `{id, title, content}` aligned 1:1 with the FAISS rows |
13
+
14
+ Total documents: **1,780,294**
15
+ Embedding model: **`BAAI/bge-m3`** (1024-dim, cosine via inner-product on L2-normalized vectors)
16
+ Index type: **FAISS `IndexFlatIP`** (exact search, no quantization)
17
+
18
+ ## Source datasets
19
+
20
+ The corpus is built from the publicly available Wikipedia paragraphs that
21
+ ship with the three multi-hop QA benchmarks evaluated in the OPERA paper:
22
+
23
+ - **HotpotQA** (Yang et al., 2018)
24
+ - **2WikiMultiHopQA** (Ho et al., 2020)
25
+ - **MuSiQue** (Trivedi et al., 2022)
26
+
27
+ For each benchmark we include the paragraphs from the splits that the
28
+ respective release distributes (dev paragraphs from HotpotQA / 2Wiki;
29
+ dev + train paragraphs from MuSiQue). All paragraphs in the corpus come
30
+ from the original benchmark distributions — no external web content was
31
+ added.
32
+
33
+ The corpus contains plain text only. We do not include benchmark labels
34
+ such as supporting-paragraph flags, decomposed sub-questions, or gold
35
+ answers; if you need those, fetch them directly from the upstream
36
+ datasets.
37
+
38
+ ## Schema
39
+
40
+ Each record in `opera_corpus.meta` is a Python dict with exactly three
41
+ keys:
42
+
43
+ ```python
44
+ {
45
+ "id": "doc_0", # sequential, stable across loads
46
+ "title": "The Big Short (film)", # source-document title
47
+ "content": "The Big Short is a 2015 American ...",
48
+ }
49
+ ```
50
+
51
+ Row `i` in `opera_corpus.meta` corresponds to row `i` of
52
+ `opera_corpus.index`. The row order has been shuffled with a fixed seed
53
+ so that the IDs `doc_0 … doc_1780293` carry no information about which
54
+ dataset a paragraph came from.
55
+
56
+ ## Chunking
57
+
58
+ Content lengths in the corpus are not uniform: most records are
59
+ paragraph-sized (a few hundred characters), while a smaller portion are
60
+ shorter sentence-window chunks (~30–150 characters) extracted from
61
+ longer paragraphs to improve recall on fine-grained reasoning
62
+ questions. This dual-granularity chunking is a deliberate design choice
63
+ of the dense-retrieval frontend and applies uniformly to the corpus.
64
+
65
+ If your downstream use case prefers a single granularity, you can
66
+ filter records by `len(record["content"])`.
67
+
68
+ ## Loading
69
+
70
+ ```python
71
+ import pickle, faiss
72
+
73
+ index = faiss.read_index("opera_corpus.index")
74
+ with open("opera_corpus.meta", "rb") as f:
75
+ meta = pickle.load(f)
76
+
77
+ assert index.ntotal == len(meta) == 1780294
78
+ print(meta[0])
79
+ ```
80
+
81
+ See `load_example.py` for an end-to-end retrieval example with BGE-M3.
82
+
83
+ ## Reproducing OPERA inference
84
+
85
+ The OPERA inference pipeline (planner agent → BGE-M3 retriever →
86
+ analysis-answer agent → rewrite agent → final synthesis) is released
87
+ separately at the OPERA repository. Point its `--index-path` and
88
+ `--metadata-path` flags at the two files in this release, or serve them
89
+ behind the persistent retriever HTTP server shipped with the pipeline.
90
+
91
+ On the standard 500-question seed42 / seed53 evaluation splits, the
92
+ inference-only pipeline against this corpus reproduces the **OPERA
93
+ (CoT)** row of Table 1 of the paper, i.e. the OPERA architecture
94
+ without MAPGRPO training:
95
+
96
+ | Split | HotpotQA EM | 2Wiki EM | MuSiQue EM |
97
+ |---|---|---|---|
98
+ | seed42 | 41.8 | 44.0 | 24.0 |
99
+ | seed53 | 42.2 | 42.2 | 20.8 |
100
+ | paper "OPERA (CoT)" | 44.9 | 42.3 | 21.2 |
101
+
102
+ Headline numbers in Table 1 of the paper (OPERA-MAPGRPO row) require
103
+ MAPGRPO training of the three agents; the training code is not part of
104
+ this release.
105
+
106
+ ## License
107
+
108
+ The retrieval index and metadata are released for research use only.
109
+ Underlying paragraph text comes from HotpotQA, 2WikiMultiHopQA and
110
+ MuSiQue and remains subject to those datasets' original licenses (each
111
+ of which is derived from Wikipedia under CC-BY-SA). When publishing
112
+ results obtained with this corpus, please cite the OPERA paper as well
113
+ as the original benchmark papers:
114
+
115
+ - Yang et al., *HotpotQA*, EMNLP 2018.
116
+ - Ho et al., *Constructing a multi-hop QA dataset for comprehensive
117
+ evaluation of reasoning steps*, COLING 2020.
118
+ - Trivedi et al., *MuSiQue: Multihop Questions via Single-hop Question
119
+ Composition*, TACL 2022.
120
+ - Chen et al., *BGE M3-Embedding*, 2024.
121
+
122
+ ## Contact
123
+
124
+ For questions about the corpus or the OPERA pipeline, please open an
125
+ issue on the OPERA GitHub repository.
load_example.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Minimal end-to-end retrieval example for the OPERA retrieval corpus.
3
+
4
+ Loads opera_corpus.index + opera_corpus.meta, encodes a query with
5
+ BGE-M3, and prints the top-5 documents.
6
+
7
+ Requirements:
8
+ pip install faiss-cpu FlagEmbedding numpy
9
+ # (or faiss-gpu if you have a CUDA build that matches your stack)
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import pickle
15
+ from pathlib import Path
16
+
17
+ import faiss
18
+ import numpy as np
19
+ from FlagEmbedding import BGEM3FlagModel
20
+
21
+ HERE = Path(__file__).resolve().parent
22
+ INDEX_PATH = HERE / "opera_corpus.index"
23
+ META_PATH = HERE / "opera_corpus.meta"
24
+
25
+ BGE_MODEL = "BAAI/bge-m3"
26
+
27
+
28
+ def main(query: str = "Who directed the film The Big Short?", top_k: int = 5) -> None:
29
+ print(f"loading FAISS index from {INDEX_PATH}")
30
+ index = faiss.read_index(str(INDEX_PATH))
31
+
32
+ print(f"loading metadata from {META_PATH}")
33
+ with open(META_PATH, "rb") as f:
34
+ meta = pickle.load(f)
35
+
36
+ assert index.ntotal == len(meta), (
37
+ f"count mismatch: index={index.ntotal} meta={len(meta)}"
38
+ )
39
+ print(f"corpus size: {index.ntotal}")
40
+
41
+ print(f"loading BGE-M3 ({BGE_MODEL})")
42
+ model = BGEM3FlagModel(BGE_MODEL, use_fp16=True)
43
+
44
+ print(f"encoding query: {query!r}")
45
+ encoded = model.encode([query], return_dense=True, return_sparse=False, return_colbert_vecs=False)
46
+ vec = np.asarray(encoded["dense_vecs"], dtype="float32")
47
+ vec /= np.linalg.norm(vec, axis=1, keepdims=True) + 1e-12
48
+
49
+ print(f"searching top-{top_k}")
50
+ scores, indices = index.search(vec, top_k)
51
+
52
+ for rank, (idx, score) in enumerate(zip(indices[0], scores[0]), start=1):
53
+ rec = meta[int(idx)]
54
+ snippet = rec["content"][:200].replace("\n", " ")
55
+ print(f" #{rank} score={score:.4f} {rec['title']!r}")
56
+ print(f" {snippet}")
57
+
58
+
59
+ if __name__ == "__main__":
60
+ main()
opera_corpus.index ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a2ea20f40ee4654c2a7ab8e94084467e411629b300cd33ab6e71237aad07cc3
3
+ size 7292084269
opera_corpus.meta ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:947da7c872a7f453ebf36bf407db7a8117d711a0566745126665dda8aca43faa
3
+ size 412567527