Download runtime/web/tokenize_check.mjs from islomov/gapi-uz-gapiring-v1: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/islomov/gapi-uz-gapiring-v1/resolve/main/runtime/web/tokenize_check.mjs
- Command line
-
hf download hf://islomov/gapi-uz-gapiring-v1/runtime/web/tokenize_check.mjs
-
curl -L -o tokenize_check.mjs https://huggingface.co/islomov/gapi-uz-gapiring-v1/resolve/main/runtime/web/tokenize_check.mjs
1.05 kB
| // node tokenize_check.mjs tokenizer.json cases.jsonl -> mismatches against the Python tokenizer's ids | |
| import fs from "node:fs"; | |
| import readline from "node:readline"; | |
| import { UnigramTokenizer, pocketText } from "./pocket_text.js"; | |
| const tok = new UnigramTokenizer(JSON.parse(fs.readFileSync(process.argv[2], "utf8"))); | |
| let n = 0, bad = 0, badText = 0; | |
| const rl = readline.createInterface({ input: fs.createReadStream(process.argv[3]) }); | |
| for await (const line of rl) { | |
| const r = JSON.parse(line); n++; | |
| const t = pocketText(r.raw, r.tags); | |
| if (t !== r.text) { badText++; if (badText <= 3) console.log("TEXT", JSON.stringify(r.raw).slice(0, 80), "|", JSON.stringify(t).slice(0, 80), "|", JSON.stringify(r.text).slice(0, 80)); } | |
| const ids = tok.encode(r.text); | |
| if (ids.join(",") !== r.ids.join(",")) { bad++; if (bad <= 5) console.log("IDS", JSON.stringify(r.text).slice(0, 70), ids.slice(0, 12).join(","), "|", r.ids.slice(0, 12).join(",")); } | |
| } | |
| console.log(JSON.stringify({ cases: n, pocket_text_mismatch: badText, ids_mismatch: bad })); | |