Download rust_sts_tokenizer/tests/load_tokenizer.rs from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/d517dc97f4cfcf6f6f9b7fafc368554f077178b3/rust_sts_tokenizer/tests/load_tokenizer.rs
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@d517dc97f4cfcf6f6f9b7fafc368554f077178b3/rust_sts_tokenizer/tests/load_tokenizer.rs
-
curl -L -o load_tokenizer.rs https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/d517dc97f4cfcf6f6f9b7fafc368554f077178b3/rust_sts_tokenizer/tests/load_tokenizer.rs
1.07 kB
| fn generated_tokenizers_load() { | |
| let base = std::env::temp_dir().join("opencode").join("ststest").join("out"); | |
| for name in ["tokenizer_bpe.json"] { | |
| let path = base.join(name); | |
| if !path.exists() { | |
| continue; | |
| } | |
| let raw = std::fs::read_to_string(&path).unwrap(); | |
| let canonical = tokenizers::canonicalize_str(&raw).unwrap_or(raw); | |
| let tokenizer = tokenizers::from_json(&canonical) | |
| .unwrap_or_else(|error| panic!("{} failed to load: {error}", path.display())); | |
| assert!(tokenizer.get_vocab_size(true) > 0); | |
| let encoded = tokenizer | |
| .encode("hello world", &tokenizers::pipeline::EncodeOptions::default()) | |
| .wait() | |
| .unwrap(); | |
| assert!(!encoded.is_empty()); | |
| let ids: Vec<u32> = encoded | |
| .iter() | |
| .flat_map(|encoding| encoding.ids()) | |
| .map(|token| token.id()) | |
| .collect(); | |
| let decoded = tokenizer.decode(&ids, false).unwrap(); | |
| assert!(!decoded.is_empty()); | |
| } | |
| } | |