flyingbertman commited on
Commit
96d72d8
·
verified ·
1 Parent(s): 413bced

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +40 -43
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  license: cc-by-sa-4.0
3
- pretty_name: NFCorpus (corpus.tsv re-encoding)
4
  task_categories:
5
  - sentence-similarity
6
  - text-retrieval
@@ -21,11 +21,11 @@ source_datasets:
21
  - original
22
  ---
23
 
24
- # NFCorpus — `corpus.tsv` re-encoding
25
 
26
- A re-encoding of the [NFCorpus](https://www.cl.uni-heidelberg.de/statnlpgroup/nfcorpus/) medical-IR corpus by Boteva et al. (Heidelberg StatNLP, ECIR 2016), distilled into a single gzip-compressed tab-delimited file. The 3,633 rows, integer `passage_id` column, and concatenated `text` column derive verbatim from the BEIR-reformatted [`corpus.jsonl`](https://public.ukp.informatik.tu-darmstadt.de/thakur/BEIR/datasets/nfcorpus.zip) — only the outer container differs.
27
 
28
- Re-hosted under Heliosoph for ingestion-pipeline stability — the upstream BEIR archive (`nfcorpus.zip`) wraps the corpus alongside queries and qrels in a zip, and the Heidelberg release splits docs across three per-split TSVs with overlap. Dropping the zip wrapper and unifying to one deduped TSV lets a streaming gzip CSV reader work directly against the file.
29
 
30
  Credit: Vera Boteva, Demian Gholipour, Artem Sokolov, Stefan Riezler (Heidelberg StatNLP, ECIR 2016) — corpus extracted from [NutritionFacts.org](https://nutritionfacts.org/) under CC BY-SA 4.0. BEIR-reformatted distribution by Nandan Thakur et al. (UKP, TU Darmstadt, NeurIPS 2021).
31
 
@@ -34,71 +34,68 @@ Credit: Vera Boteva, Demian Gholipour, Artem Sokolov, Stefan Riezler (Heidelberg
34
  The two upstream NFCorpus distributions both add work for an ingestion pipeline that just wants the passages:
35
 
36
  - **Heidelberg's `nfcorpus.tar.gz`** splits documents across `train.docs`, `dev.docs`, and `test.docs` with overlap — recovering the canonical 3,633 unique passages requires a union+dedup step on the doc-id column.
37
- - **BEIR's `nfcorpus.zip`** wraps the unified `corpus.jsonl` together with queries and qrels in a zip, and the `corpus.jsonl` schema (`{"_id": ..., "title": ..., "text": ..., "metadata": {}}`) needs a JSON-line reader to flatten.
38
 
39
- This mirror strips both wrappers down to a single gzipped TSV — `corpus.tsv.gz` — that any streaming CSV reader can consume directly. Title and body text are concatenated as `title + ". " + text` (the convention used by most BEIR embedder evaluations) so the file fits the canonical two-column passage-retrieval shape.
40
 
41
- The decompressed `_id` and concatenated `title + text` content matches BEIR's `corpus.jsonl` exactly for all 3,633 rows.
42
 
43
  ## What this repo contains
44
 
45
  ```
46
- corpus.tsv.gz # 3,633 rows, ~1.8 MB compressed, UTF-8, tab-delimited, no header
47
  ```
48
 
49
- One file, two columns, **no header row**:
50
 
51
- | Column | Type | Meaning |
52
  |---|---|---|
53
- | 0 | int | `passage_id` stable id from the upstream BEIR `_id` field. |
54
- | 1 | string | `text` — `title + ". " + body`, original casing + punctuation. |
 
 
55
 
56
- The `passage_id` is the join key used by the official NFCorpus / BEIR `qrels` (relevance judgments) if you intend to evaluate against the standard test split or compare against MTEB / BEIR leaderboards, keep the id intact end-to-end.
57
 
58
  ## How to use
59
 
60
- Stream the gzipped TSV directly with pandas:
61
 
62
  ```python
63
- import pandas as pd
64
-
65
- df = pd.read_csv(
66
- "corpus.tsv.gz",
67
- sep="\t",
68
- header=None,
69
- names=["passage_id", "text"],
70
- dtype={"passage_id": "string", "text": "string"},
71
- compression="gzip",
72
- )
73
- print(df.shape) # (3633, 2)
74
- print(df["text"].str.len().describe())
75
  ```
76
 
77
- Or row-by-row with the standard library (zero-memory streaming):
78
 
79
  ```python
80
- import csv, gzip
81
 
82
- with gzip.open("corpus.tsv.gz", "rt", encoding="utf-8", newline="") as f:
83
- for pid, text in csv.reader(f, delimiter="\t"):
84
- # pid: BEIR-style string id (e.g. "MED-10")
85
- # text: "<title>. <body>" — full passage, ready to embed
86
- ...
87
  ```
88
 
89
  ## Dataset specs
90
 
91
  | | Spec |
92
  |---|---|
93
- | Rows | 3,633 passages |
94
- | Distinct passages | 3,633 (passage_id is unique) |
95
  | Encoding | UTF-8 |
96
- | Delimiter | Tab (`\t`) |
97
- | Header | None first row is data |
98
- | Quoting | Minimal embedded tabs in passage text are rare; standard CSV/TSV readers handle them with double-quote escaping |
99
- | Compressed size | ~1.8 MB |
100
- | Uncompressed size | ~5.93 MB |
101
- | Average passage length | ~232 words / ~330 BERT word-piece tokens |
102
  | Max passage length | ~5,000+ tokens — exercises long-context embedders |
103
  | Language | English |
104
  | Domain | Medical / nutrition (NutritionFacts.org articles) |
@@ -110,7 +107,7 @@ with gzip.open("corpus.tsv.gz", "rt", encoding="utf-8", newline="") as f:
110
  - **Long-context embedder showcase**: the passage length tail runs into the thousands of tokens — full articles, not snippets. Embedders with 4K / 8K context (Jina v2, E5 long, BGE long) actually see passages worth more than the first 512 tokens.
111
  - **BEIR / MTEB leaderboard comparison**: NFCorpus is one of the original BEIR zero-shot retrieval benchmarks, so a fresh nDCG@10 number from your recipe is directly comparable to dozens of published embedders.
112
 
113
- For the much larger general-domain counterpart, reach for **MS MARCO Passages** — same two-column shape, 2,400× the rows, web-search vocabulary instead of medical.
114
 
115
  ## Companion splits (not in this repo)
116
 
@@ -119,7 +116,7 @@ A full NFCorpus / BEIR retrieval evaluation requires two more files from the ups
119
  - `queries.jsonl` — 3,237 natural-language health queries (`_id`, `text`).
120
  - `qrels/test.tsv` — graded (query_id, passage_id, relevance) judgments for the test split.
121
 
122
- Run a full nDCG@10 / MRR@10 evaluation by pairing this corpus with those two. A follow-up Heliosoph variant may bundle them as `queries.tsv.gz` + `qrels_test.tsv.gz`.
123
 
124
  ## License
125
 
 
1
  ---
2
  license: cc-by-sa-4.0
3
+ pretty_name: NFCorpus (corpus.jsonl re-encoding)
4
  task_categories:
5
  - sentence-similarity
6
  - text-retrieval
 
21
  - original
22
  ---
23
 
24
+ # NFCorpus — `corpus.jsonl` re-encoding
25
 
26
+ A re-encoding of the [NFCorpus](https://www.cl.uni-heidelberg.de/statnlpgroup/nfcorpus/) medical-IR corpus by Boteva et al. (Heidelberg StatNLP, ECIR 2016), distilled into a single gzip-compressed JSON-Lines file. The 3,633 rows and the four-key per-line schema (`_id`, `title`, `text`, `metadata`) match the [BEIR-reformatted](https://public.ukp.informatik.tu-darmstadt.de/thakur/BEIR/datasets/nfcorpus.zip) `corpus.jsonl` byte-for-byte — only the outer container differs.
27
 
28
+ Re-hosted under Heliosoph for ingestion-pipeline stability — the upstream BEIR archive (`nfcorpus.zip`) wraps `corpus.jsonl` alongside queries and qrels in a single zip, and the original Heidelberg release splits docs across three per-split TSVs with overlap. Dropping the zip wrapper down to a plain `corpus.jsonl.gz` lets a streaming JSON-Lines reader work directly against the file with no intermediate extraction step.
29
 
30
  Credit: Vera Boteva, Demian Gholipour, Artem Sokolov, Stefan Riezler (Heidelberg StatNLP, ECIR 2016) — corpus extracted from [NutritionFacts.org](https://nutritionfacts.org/) under CC BY-SA 4.0. BEIR-reformatted distribution by Nandan Thakur et al. (UKP, TU Darmstadt, NeurIPS 2021).
31
 
 
34
  The two upstream NFCorpus distributions both add work for an ingestion pipeline that just wants the passages:
35
 
36
  - **Heidelberg's `nfcorpus.tar.gz`** splits documents across `train.docs`, `dev.docs`, and `test.docs` with overlap — recovering the canonical 3,633 unique passages requires a union+dedup step on the doc-id column.
37
+ - **BEIR's `nfcorpus.zip`** wraps the unified `corpus.jsonl` together with queries and qrels in a zip pipelines that ingest one corpus file at a time have to either extract the zip first or know which member to seek to.
38
 
39
+ This mirror strips the zip wrapper down to a single gzipped JSON-Lines file — `corpus.jsonl.gz` — that any streaming JSONL reader can consume directly. The line-level schema is preserved verbatim, so the `_id` field can still be joined against the official BEIR `qrels/test.tsv` for nDCG@10 evaluation without translation.
40
 
41
+ The decompressed contents match BEIR's `corpus.jsonl` line-for-line, byte-for-byte.
42
 
43
  ## What this repo contains
44
 
45
  ```
46
+ corpus.jsonl.gz # 3,633 lines, ~1.9 MB compressed, UTF-8, one JSON object per line
47
  ```
48
 
49
+ One file, one JSON object per non-empty line, four keys per object:
50
 
51
+ | Key | Type | Meaning |
52
  |---|---|---|
53
+ | `_id` | string | BEIR-style passage id (e.g. `"MED-10"`). Stable join key against the official `queries.jsonl` and `qrels/test.tsv`. |
54
+ | `title` | string | Article title from NutritionFacts.org, original casing + punctuation. |
55
+ | `text` | string | Article body, original casing + punctuation. |
56
+ | `metadata` | object | `{"url": "..."}` — the source NutritionFacts.org permalink. |
57
 
58
+ Lines are not sorted by `_id` in any meaningful order; the order matches BEIR's upstream `corpus.jsonl` exactly.
59
 
60
  ## How to use
61
 
62
+ Stream the gzipped JSONL row-by-row with the standard library (zero-memory streaming, ~3,633 dict allocations):
63
 
64
  ```python
65
+ import gzip, json
66
+
67
+ with gzip.open("corpus.jsonl.gz", "rt", encoding="utf-8") as f:
68
+ for line in f:
69
+ rec = json.loads(line)
70
+ passage_id = rec["_id"]
71
+ title = rec["title"]
72
+ body = rec["text"]
73
+ # Most BEIR embedder evaluations concatenate title + body before encoding:
74
+ passage = f"{title}. {body}"
 
 
75
  ```
76
 
77
+ Or load the whole corpus into a pandas frame (fits in <50 MB RAM):
78
 
79
  ```python
80
+ import pandas as pd
81
 
82
+ df = pd.read_json("corpus.jsonl.gz", lines=True, compression="gzip")
83
+ print(df.shape) # (3633, 4)
84
+ print(df.columns.tolist()) # ['_id', 'title', 'text', 'metadata']
85
+ print(df["text"].str.len().describe())
 
86
  ```
87
 
88
  ## Dataset specs
89
 
90
  | | Spec |
91
  |---|---|
92
+ | Lines | 3,633 passages |
93
+ | Distinct passages | 3,633 (`_id` is unique) |
94
  | Encoding | UTF-8 |
95
+ | Format | JSON Lines (one JSON object per non-empty line, no enclosing array) |
96
+ | Compressed size | ~1.9 MB |
97
+ | Uncompressed size | ~5.9 MB |
98
+ | Average passage length | ~232 words / ~330 BERT word-piece tokens (title + body concatenated) |
 
 
99
  | Max passage length | ~5,000+ tokens — exercises long-context embedders |
100
  | Language | English |
101
  | Domain | Medical / nutrition (NutritionFacts.org articles) |
 
107
  - **Long-context embedder showcase**: the passage length tail runs into the thousands of tokens — full articles, not snippets. Embedders with 4K / 8K context (Jina v2, E5 long, BGE long) actually see passages worth more than the first 512 tokens.
108
  - **BEIR / MTEB leaderboard comparison**: NFCorpus is one of the original BEIR zero-shot retrieval benchmarks, so a fresh nDCG@10 number from your recipe is directly comparable to dozens of published embedders.
109
 
110
+ For the much larger general-domain counterpart, reach for **MS MARCO Passages** — passage-retrieval shape, 2,400× the rows, web-search vocabulary instead of medical.
111
 
112
  ## Companion splits (not in this repo)
113
 
 
116
  - `queries.jsonl` — 3,237 natural-language health queries (`_id`, `text`).
117
  - `qrels/test.tsv` — graded (query_id, passage_id, relevance) judgments for the test split.
118
 
119
+ Run a full nDCG@10 / MRR@10 evaluation by pairing this corpus with those two. A follow-up Heliosoph variant may bundle them.
120
 
121
  ## License
122