hung-k-nguyen commited on
Commit
eb65bfd
·
0 Parent(s):

Release snapshot

Browse files
Files changed (6) hide show
  1. .gitattributes +60 -0
  2. README.md +78 -0
  3. SUBMISSION.md +17 -0
  4. manifest.json +16 -0
  5. our200/test-00000-of-00001.parquet +3 -0
  6. score.py +90 -0
.gitattributes ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.avro filter=lfs diff=lfs merge=lfs -text
4
+ *.bin filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
7
+ *.ftz filter=lfs diff=lfs merge=lfs -text
8
+ *.gz filter=lfs diff=lfs merge=lfs -text
9
+ *.h5 filter=lfs diff=lfs merge=lfs -text
10
+ *.joblib filter=lfs diff=lfs merge=lfs -text
11
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
13
+ *.mds filter=lfs diff=lfs merge=lfs -text
14
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
15
+ *.model filter=lfs diff=lfs merge=lfs -text
16
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
17
+ *.npy filter=lfs diff=lfs merge=lfs -text
18
+ *.npz filter=lfs diff=lfs merge=lfs -text
19
+ *.onnx filter=lfs diff=lfs merge=lfs -text
20
+ *.ot filter=lfs diff=lfs merge=lfs -text
21
+ *.parquet filter=lfs diff=lfs merge=lfs -text
22
+ *.pb filter=lfs diff=lfs merge=lfs -text
23
+ *.pickle filter=lfs diff=lfs merge=lfs -text
24
+ *.pkl filter=lfs diff=lfs merge=lfs -text
25
+ *.pt filter=lfs diff=lfs merge=lfs -text
26
+ *.pth filter=lfs diff=lfs merge=lfs -text
27
+ *.rar filter=lfs diff=lfs merge=lfs -text
28
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
29
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
31
+ *.tar filter=lfs diff=lfs merge=lfs -text
32
+ *.tflite filter=lfs diff=lfs merge=lfs -text
33
+ *.tgz filter=lfs diff=lfs merge=lfs -text
34
+ *.wasm filter=lfs diff=lfs merge=lfs -text
35
+ *.xz filter=lfs diff=lfs merge=lfs -text
36
+ *.zip filter=lfs diff=lfs merge=lfs -text
37
+ *.zst filter=lfs diff=lfs merge=lfs -text
38
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
39
+ # Audio files - uncompressed
40
+ *.pcm filter=lfs diff=lfs merge=lfs -text
41
+ *.sam filter=lfs diff=lfs merge=lfs -text
42
+ *.raw filter=lfs diff=lfs merge=lfs -text
43
+ # Audio files - compressed
44
+ *.aac filter=lfs diff=lfs merge=lfs -text
45
+ *.flac filter=lfs diff=lfs merge=lfs -text
46
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
47
+ *.ogg filter=lfs diff=lfs merge=lfs -text
48
+ *.wav filter=lfs diff=lfs merge=lfs -text
49
+ # Image files - uncompressed
50
+ *.bmp filter=lfs diff=lfs merge=lfs -text
51
+ *.gif filter=lfs diff=lfs merge=lfs -text
52
+ *.png filter=lfs diff=lfs merge=lfs -text
53
+ *.tiff filter=lfs diff=lfs merge=lfs -text
54
+ # Image files - compressed
55
+ *.jpg filter=lfs diff=lfs merge=lfs -text
56
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
57
+ *.webp 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
README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-sa-4.0
3
+ pretty_name: Doc-Split Benchmark (page-stream segmentation)
4
+ task_categories: [image-classification, text-classification]
5
+ language: [multilingual]
6
+ tags: [page-stream-segmentation, document-boundary-detection, document-ai, benchmark]
7
+ size_categories: [1K<n<10K]
8
+ configs:
9
+ - config_name: our200
10
+ data_files: [{split: test, path: our200/test-*.parquet}]
11
+ ---
12
+
13
+ # Doc-Split Benchmark
14
+
15
+ The **evaluation slice** for page-stream segmentation — the exact set behind the
16
+ [leaderboard](https://huggingface.co/spaces/nutrientdocs/doc-split-leaderboard) and the cloud-VLM
17
+ comparison. Self-contained (page images embedded), with a reference scorer so results are reproducible.
18
+ This is the *benchmark*, not the training corpus (which stays private).
19
+
20
+ - 🏆 **Leaderboard:** [doc-split-leaderboard](https://huggingface.co/spaces/nutrientdocs/doc-split-leaderboard)
21
+ - 🎯 **Demo:** [doc-split-demo](https://huggingface.co/spaces/nutrientdocs/doc-split-demo)
22
+ - 🟢 **Model:** [doc-split-mini-e5](https://huggingface.co/nutrientdocs/doc-split-mini-e5) (open weights)
23
+ - 🌍 **OpenPSS cuts:** [openpss-mirror](https://huggingface.co/datasets/nutrientdocs/openpss-mirror) (SHORT/LONG, self-contained)
24
+
25
+ ## Cuts
26
+
27
+ | Cut | Where | Notes |
28
+ |---|---|---|
29
+ | **our-200** | this repo (`our200` config) | 200 license-clean synthetic-concat streams, ~78% boundary rate |
30
+ | **OpenPSS short / long** | [openpss-mirror](https://huggingface.co/datasets/nutrientdocs/openpss-mirror) | Dutch; sparse- & dense-boundary regimes |
31
+ | TABME++ / Tobacco800 | upstream (not redistributed) | reported for reference; licenses/gating prevent re-hosting |
32
+
33
+ ## Load
34
+
35
+ ```python
36
+ from datasets import load_dataset
37
+ ds = load_dataset("nutrientdocs/doc-split-benchmark", "our200", split="test")
38
+ # one row = one page; group by stream_id, order by position.
39
+ ```
40
+
41
+ ## Schema
42
+
43
+ | Field | Type | Meaning |
44
+ |---|---|---|
45
+ | `stream_id` | string | groups pages into one ordered stream |
46
+ | `position` | int | page index within the stream (0-based) |
47
+ | `boundary` | int | **1 = starts a new document** (position 0 always 1) |
48
+ | `page_text` | string | page OCR text (may be empty) |
49
+ | `image` | image | page image (512px) |
50
+ | `source` | string | provenance |
51
+
52
+ ## How to score
53
+
54
+ Metric: **boundary page-F1** (internal positions, page 0 forced) + Cohen's **κ**, WindowDiff, Pk.
55
+ The reference scorer ships in this repo:
56
+
57
+ ```bash
58
+ python score.py --pred your_preds.json # preds: {stream_id: [0/1 per page]}
59
+ ```
60
+
61
+ `score.py` uses `docsplit.eval.metrics.aggregate` (bundled). κ is reported because a degenerate
62
+ predict-none/all can look fine on F1 but scores κ ≈ 0 on the sparse cuts. See `SUBMISSION.md` to add a row to
63
+ the leaderboard.
64
+
65
+ `manifest.json` records provenance (per-source stream/page counts, boundary rates, seed).
66
+
67
+ ## License & attribution
68
+
69
+ CC-BY-SA-4.0 for the our-200 packaging (Nutrient-generated synthetic concatenations). OpenPSS cuts are in
70
+ `openpss-mirror` under their upstream terms. TABME++/Tobacco800 are referenced, not redistributed.
71
+
72
+ ## About the author
73
+
74
+ <a href="https://nutrient.io/">
75
+ <img src="https://avatars2.githubusercontent.com/u/1527679?v=3&s=200" height="80" />
76
+ </a>
77
+
78
+ This project is maintained and funded by [Nutrient](https://nutrient.io/) - The #1 PDF SDK library for viewing, editing, eSigning, and more.
SUBMISSION.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Submit to the Doc-Split leaderboard
2
+
3
+ 1. **Predict** boundaries for every stream in each cut: `{stream_id: [0/1 per page, in position order]}`
4
+ (1 = page starts a new document; page 0 is a forced boundary). Cuts: `our200` (this repo) and the
5
+ OpenPSS SHORT/LONG cuts from [`openpss-mirror`](https://huggingface.co/datasets/nutrientdocs/openpss-mirror).
6
+ 2. **Score** per cut: `python score.py --pred preds.json --config our200` → `{f1, kappa, windowdiff, pk, ...}`.
7
+ 3. **Open a PR** on the [leaderboard Space](https://huggingface.co/spaces/nutrientdocs/doc-split-leaderboard)
8
+ adding `results/<model>-<cut>.json`:
9
+
10
+ ```json
11
+ { "name": "your-model", "model": "org/your-model", "cut": "openpss_short",
12
+ "open": true, "n": 108, "f1": 0.00, "kappa": 0.00,
13
+ "hardware": "A100", "inputs": "image+text" }
14
+ ```
15
+
16
+ Report **κ alongside F1** — on the sparse cuts a degenerate predict-none/all scores κ ≈ 0 despite a
17
+ misleading F1. Note whether your model saw these domains in training (in-domain vs zero-shot).
manifest.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cut": "our200",
3
+ "streams": 200,
4
+ "pages": 894,
5
+ "boundaries": 702,
6
+ "boundary_rate": 0.7852,
7
+ "by_source": {
8
+ "openpss_short": 71,
9
+ "doclayout-render": 565,
10
+ "commonforms-synth": 170,
11
+ "cord-v2": 24,
12
+ "idl-wds": 22,
13
+ "pdfa-eng-wds": 14,
14
+ "sroie": 28
15
+ }
16
+ }
our200/test-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e26fedbe482c3d4c7e21e9a0ce8f7848e5e1d1443722b63a62422e85d9be7010
3
+ size 282433884
score.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Reference scorer for the Doc-Split Benchmark — self-contained (only needs `datasets`).
2
+
3
+ Boundary page-F1 (internal positions, page 0 forced) + Cohen's kappa + WindowDiff + Pk.
4
+
5
+ Usage:
6
+ python score.py --pred preds.json [--config our200]
7
+ preds.json = {stream_id: [0/1, ...]} (one label per page, in position order; index 0 may be omitted/ignored)
8
+ """
9
+ import argparse, json
10
+ from collections import defaultdict
11
+
12
+
13
+ def _counts(gold, pred):
14
+ tp = fp = fn = tn = 0
15
+ for g, p in zip(gold[1:], pred[1:]): # skip page 0 (forced boundary for both)
16
+ if g and p: tp += 1
17
+ elif p and not g: fp += 1
18
+ elif g and not p: fn += 1
19
+ else: tn += 1
20
+ return tp, fp, fn, tn
21
+
22
+
23
+ def _seg(b):
24
+ out, c = [], 0
25
+ for x in b:
26
+ c += 1 if x else 0; out.append(c)
27
+ return out
28
+
29
+
30
+ def _k(ref):
31
+ n = len(ref); ns = max(1, sum(ref)); return max(1, round((n / ns) / 2))
32
+
33
+
34
+ def windowdiff(g, p):
35
+ gg, pp = g[1:], p[1:]; m = len(gg)
36
+ if m == 0: return 0.0
37
+ k = min(_k(g), m); n = m - k + 1
38
+ if n <= 0: return float(sum(gg) != sum(pp))
39
+ return sum(1 for i in range(n) if sum(gg[i:i+k]) != sum(pp[i:i+k])) / n
40
+
41
+
42
+ def pk(g, p):
43
+ n = len(g)
44
+ if n < 2: return 0.0
45
+ k = min(_k(g), n - 1); sg, sp = _seg(g), _seg(p); t = n - k
46
+ if t <= 0: return 0.0
47
+ return sum(1 for i in range(t) if (sg[i] == sg[i+k]) != (sp[i] == sp[i+k])) / t
48
+
49
+
50
+ def aggregate(streams):
51
+ TP = FP = FN = TN = 0; em = wd = pkv = 0.0; n = len(streams)
52
+ for s in streams:
53
+ g, p = s["gold"], s["pred"]
54
+ tp, fp, fn, tn = _counts(g, p); TP += tp; FP += fp; FN += fn; TN += tn
55
+ em += 1.0 if list(g[1:]) == list(p[1:]) else 0.0
56
+ wd += windowdiff(g, p); pkv += pk(g, p)
57
+ prec = TP / (TP + FP) if TP + FP else 1.0
58
+ rec = TP / (TP + FN) if TP + FN else 1.0
59
+ f1 = 2 * prec * rec / (prec + rec) if prec + rec else 0.0
60
+ tot = TP + FP + FN + TN
61
+ po = (TP + TN) / tot if tot else 0.0
62
+ pe = ((TP + FP) / tot) * ((TP + FN) / tot) + ((FN + TN) / tot) * ((FP + TN) / tot) if tot else 0.0
63
+ kappa = (po - pe) / (1 - pe) if (1 - pe) > 1e-12 else 0.0
64
+ return {"f1": round(f1, 4), "precision": round(prec, 4), "recall": round(rec, 4),
65
+ "kappa": round(kappa, 4), "windowdiff": round(wd / n, 4), "pk": round(pkv / n, 4),
66
+ "exact_match": round(em / n, 4), "n_streams": n}
67
+
68
+
69
+ def main():
70
+ ap = argparse.ArgumentParser()
71
+ ap.add_argument("--pred", required=True); ap.add_argument("--config", default="our200")
72
+ a = ap.parse_args()
73
+ from datasets import load_dataset
74
+ ds = load_dataset("nutrientdocs/doc-split-benchmark", a.config, split="test")
75
+ gold = defaultdict(list)
76
+ for r in ds:
77
+ gold[r["stream_id"]].append((r["position"], int(r["boundary"])))
78
+ preds = json.load(open(a.pred))
79
+ streams = []
80
+ for sid, pg in gold.items():
81
+ g = [b for _, b in sorted(pg)]
82
+ p = preds.get(sid)
83
+ if p is None:
84
+ p = [1] + [0] * (len(g) - 1) # missing prediction -> forced page-0 only
85
+ streams.append({"gold": g, "pred": list(p)[:len(g)]})
86
+ print(json.dumps(aggregate(streams), indent=2))
87
+
88
+
89
+ if __name__ == "__main__":
90
+ main()