Update README.md
Browse files
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-sa-4.0
|
| 3 |
-
pretty_name: NFCorpus (corpus.
|
| 4 |
task_categories:
|
| 5 |
- sentence-similarity
|
| 6 |
- text-retrieval
|
|
@@ -21,11 +21,11 @@ source_datasets:
|
|
| 21 |
- original
|
| 22 |
---
|
| 23 |
|
| 24 |
-
# NFCorpus — `corpus.
|
| 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
|
| 27 |
|
| 28 |
-
Re-hosted under Heliosoph for ingestion-pipeline stability — the upstream BEIR archive (`nfcorpus.zip`) wraps
|
| 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
|
| 38 |
|
| 39 |
-
This mirror strips
|
| 40 |
|
| 41 |
-
The decompressed
|
| 42 |
|
| 43 |
## What this repo contains
|
| 44 |
|
| 45 |
```
|
| 46 |
-
corpus.
|
| 47 |
```
|
| 48 |
|
| 49 |
-
One file,
|
| 50 |
|
| 51 |
-
|
|
| 52 |
|---|---|---|
|
| 53 |
-
|
|
| 54 |
-
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
## How to use
|
| 59 |
|
| 60 |
-
Stream the gzipped
|
| 61 |
|
| 62 |
```python
|
| 63 |
-
import
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
print(df.shape) # (3633, 2)
|
| 74 |
-
print(df["text"].str.len().describe())
|
| 75 |
```
|
| 76 |
|
| 77 |
-
Or
|
| 78 |
|
| 79 |
```python
|
| 80 |
-
import
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
...
|
| 87 |
```
|
| 88 |
|
| 89 |
## Dataset specs
|
| 90 |
|
| 91 |
| | Spec |
|
| 92 |
|---|---|
|
| 93 |
-
|
|
| 94 |
-
| Distinct passages | 3,633 (
|
| 95 |
| Encoding | UTF-8 |
|
| 96 |
-
|
|
| 97 |
-
|
|
| 98 |
-
|
|
| 99 |
-
|
|
| 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** —
|
| 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
|
| 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 |
|