Spaces:
Running
Running
Download src/tokenizer/format-detection.test.ts from Orion-zhen/tokenize-it: direct link, hf CLI and curl.
- Browser
- Download file 683 Bytes
-
https://huggingface.co/spaces/Orion-zhen/tokenize-it/resolve/main/src/tokenizer/format-detection.test.ts
- Command line
-
hf download hf://spaces/Orion-zhen/tokenize-it/src/tokenizer/format-detection.test.ts
-
curl -L -o format-detection.test.ts https://huggingface.co/spaces/Orion-zhen/tokenize-it/resolve/main/src/tokenizer/format-detection.test.ts
683 Bytes
| import { describe, expect, it } from "vitest"; | |
| import { refineTokenizerFormat } from "./format-detection"; | |
| const encoder = new TextEncoder(); | |
| describe("refineTokenizerFormat", () => { | |
| it("recognizes tiktoken rank files named tokenizer.model", () => { | |
| expect( | |
| refineTokenizerFormat( | |
| "sentencepiece", | |
| "tokenizer.model", | |
| encoder.encode("IQ== 0\nIg== 1\n"), | |
| ), | |
| ).toBe("tiktoken"); | |
| }); | |
| it("keeps binary tokenizer.model files as sentencepiece", () => { | |
| expect( | |
| refineTokenizerFormat( | |
| "sentencepiece", | |
| "tokenizer.model", | |
| new Uint8Array([10, 7, 0, 255]), | |
| ), | |
| ).toBe("sentencepiece"); | |
| }); | |
| }); | |