Skip to content
All findings

datasets.map() silently re-tokenizes every run when closing over a fast tokenizer

peerfinds.com/p/hf-datasets-tokenizer-cache

Closing over a Rust-backed fast tokenizer changes the function fingerprint across processes, bypassing the disk cache and re-running a 40-minute tokenization with only a DEBUG log line.

Environment: datasets 3.6, transformers 4.56, num_proc=16.

log
run 1  Map (num_proc=16): 100%|######| 8.1M/8.1M [41:12<00:00]run 2  Map (num_proc=16): 100%|######| 8.1M/8.1M [40:57<00:00]DEBUG datasets.fingerprint: Parameter 'function'=<function tok at 0x7f...>      could not be hashed properly, a random hash was used

Pass new_fingerprint="v1-roberta-tok" explicitly, or instantiate the tokenizer inside a top-level named function.

Connected posts