kacperwikiel commited on
Commit
ccfa260
·
1 Parent(s): 575452c

Add quick tokenizer judging columns

Browse files
Files changed (3) hide show
  1. README.md +11 -0
  2. build_parquet.py +57 -0
  3. data/train-00000-of-00001.parquet +2 -2
README.md CHANGED
@@ -23,8 +23,14 @@ filter, and compare the tokenizers without navigating contributor folders.
23
  - `author`: contributor's exact GitHub username, resolved from the source repository's pull-request history.
24
  - `size`: tokenizer vocabulary size.
25
  - `name`: original filename.
 
 
26
  - `format`: normalized artifact-format classification.
27
  - `model_type`: tokenizer model type reported by the source.
 
 
 
 
28
  - `metadata`: normalized metadata encoded as a JSON string.
29
  - `tokenizer_json`: complete, lossless original JSON file contents.
30
  - `source_path`: original path in the source repository.
@@ -42,3 +48,8 @@ filter, and compare the tokenizers without navigating contributor folders.
42
  All source files were parsed as valid JSON. A file being valid JSON does not
43
  imply it implements the Hugging Face Tokenizers serialization schema; check the
44
  `format` column before loading `tokenizer_json`.
 
 
 
 
 
 
23
  - `author`: contributor's exact GitHub username, resolved from the source repository's pull-request history.
24
  - `size`: tokenizer vocabulary size.
25
  - `name`: original filename.
26
+ - `quick_status`: whether the artifact is ready to load or needs custom conversion.
27
+ - `hf_loadable`: whether it loads directly with `tokenizers.Tokenizer.from_file(...)`.
28
  - `format`: normalized artifact-format classification.
29
  - `model_type`: tokenizer model type reported by the source.
30
+ - `merge_count`: number of BPE merge rules when available.
31
+ - `normalizer`, `pre_tokenizer`, `decoder`: quick configuration summary.
32
+ - `unk_token`, `added_tokens_count`: special-token readiness indicators.
33
+ - `reported_metrics`: evaluation numbers reported by the author, encoded as JSON.
34
  - `metadata`: normalized metadata encoded as a JSON string.
35
  - `tokenizer_json`: complete, lossless original JSON file contents.
36
  - `source_path`: original path in the source repository.
 
48
  All source files were parsed as valid JSON. A file being valid JSON does not
49
  imply it implements the Hugging Face Tokenizers serialization schema; check the
50
  `format` column before loading `tokenizer_json`.
51
+
52
+ Reported metrics were produced with different texts and procedures, so they are
53
+ useful for inspecting an individual submission but not for ranking authors. A
54
+ fair quality ranking requires running every compatible tokenizer against the
55
+ same held-out Polish evaluation corpus.
build_parquet.py CHANGED
@@ -46,6 +46,42 @@ def extract_metadata(document: dict) -> dict:
46
  return metadata
47
 
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  def main() -> None:
50
  parser = argparse.ArgumentParser()
51
  parser.add_argument("--source-root", type=Path, default=Path("."))
@@ -59,13 +95,25 @@ def main() -> None:
59
  source_path = item["source_path"]
60
  raw_json = (args.source_root / source_path).read_text(encoding="utf-8")
61
  document = json.loads(raw_json)
 
 
 
62
  rows.append(
63
  {
64
  "author": GITHUB_AUTHORS[item["contributor"]],
65
  "size": int(item["vocab_size"]),
66
  "name": Path(source_path).name,
 
 
67
  "format": item["format"],
68
  "model_type": item["model_type"],
 
 
 
 
 
 
 
69
  "metadata": json.dumps(
70
  extract_metadata(document), ensure_ascii=False, sort_keys=True
71
  ),
@@ -82,8 +130,17 @@ def main() -> None:
82
  ("author", pa.string()),
83
  ("size", pa.int64()),
84
  ("name", pa.string()),
 
 
85
  ("format", pa.string()),
86
  ("model_type", pa.string()),
 
 
 
 
 
 
 
87
  ("metadata", pa.string()),
88
  ("tokenizer_json", pa.large_string()),
89
  ("source_path", pa.string()),
 
46
  return metadata
47
 
48
 
49
+ def component_name(value) -> str:
50
+ if value is None:
51
+ return "none"
52
+ if isinstance(value, dict):
53
+ return str(value.get("type", "configured"))
54
+ return str(value)
55
+
56
+
57
+ def merge_count(document: dict) -> int | None:
58
+ model = document.get("model")
59
+ candidates = []
60
+ if isinstance(model, dict):
61
+ candidates.append(model.get("merges"))
62
+ candidates.extend((document.get("merges"), document.get("reguly_merge")))
63
+ for value in candidates:
64
+ if isinstance(value, (list, dict)):
65
+ return len(value)
66
+ for key in ("liczba_regul_merge", "n_merges"):
67
+ if isinstance(document.get(key), int):
68
+ return document[key]
69
+ return None
70
+
71
+
72
+ def extract_reported_metrics(document: dict) -> dict:
73
+ markers = ("eval", "metr", "fert", "znaki_na_token", "tokens_per_word", "sweep", "compression")
74
+ metrics = {}
75
+ for key, value in document.items():
76
+ if any(marker in key.lower() for marker in markers):
77
+ metrics[key] = value
78
+ if isinstance(document.get("meta"), dict):
79
+ for key, value in document["meta"].items():
80
+ if any(marker in key.lower() for marker in markers):
81
+ metrics[f"meta.{key}"] = value
82
+ return metrics
83
+
84
+
85
  def main() -> None:
86
  parser = argparse.ArgumentParser()
87
  parser.add_argument("--source-root", type=Path, default=Path("."))
 
95
  source_path = item["source_path"]
96
  raw_json = (args.source_root / source_path).read_text(encoding="utf-8")
97
  document = json.loads(raw_json)
98
+ model = document.get("model") if isinstance(document.get("model"), dict) else {}
99
+ metrics = extract_reported_metrics(document)
100
+ hf_loadable = item["format"] == "hf_tokenizers"
101
  rows.append(
102
  {
103
  "author": GITHUB_AUTHORS[item["contributor"]],
104
  "size": int(item["vocab_size"]),
105
  "name": Path(source_path).name,
106
+ "quick_status": "ready_hf_tokenizers" if hf_loadable else "custom_conversion_required",
107
+ "hf_loadable": hf_loadable,
108
  "format": item["format"],
109
  "model_type": item["model_type"],
110
+ "merge_count": merge_count(document),
111
+ "normalizer": component_name(document.get("normalizer")),
112
+ "pre_tokenizer": component_name(document.get("pre_tokenizer")),
113
+ "decoder": component_name(document.get("decoder")),
114
+ "unk_token": str(model.get("unk_token") or ""),
115
+ "added_tokens_count": len(document.get("added_tokens", [])),
116
+ "reported_metrics": json.dumps(metrics, ensure_ascii=False, sort_keys=True),
117
  "metadata": json.dumps(
118
  extract_metadata(document), ensure_ascii=False, sort_keys=True
119
  ),
 
130
  ("author", pa.string()),
131
  ("size", pa.int64()),
132
  ("name", pa.string()),
133
+ ("quick_status", pa.string()),
134
+ ("hf_loadable", pa.bool_()),
135
  ("format", pa.string()),
136
  ("model_type", pa.string()),
137
+ ("merge_count", pa.int64()),
138
+ ("normalizer", pa.string()),
139
+ ("pre_tokenizer", pa.string()),
140
+ ("decoder", pa.string()),
141
+ ("unk_token", pa.string()),
142
+ ("added_tokens_count", pa.int64()),
143
+ ("reported_metrics", pa.string()),
144
  ("metadata", pa.string()),
145
  ("tokenizer_json", pa.large_string()),
146
  ("source_path", pa.string()),
data/train-00000-of-00001.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:41aaae73e4a924dad689ea6bf87142abb937157b90781205b228d98a2abde415
3
- size 16487708
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2763c94cfaeb582062ad428d600015d9e6f0646a61081a190a8505e3a2243bf0
3
+ size 16491254