Comments (3)
Any news on this? Training from token counts would be very nice.
For instance, in my use case original data is processed in Spark so obtaining word counts is easy while dumping all of the strings into files would be very slow
from tokenizers.
I'm really not sure giving the ability to feed word counts is a good idea because the PreTokenizer
is in charge of doing the pre-tokenization and it would introduce potential discrepancies between training and tokenization. Also, this trainer API is subject to change in the future, and may not be compatible with word counts anymore.
What about being able to stream raw strings instead?
from tokenizers.
That would be useful too albeit more cumbersome.
Would you mind expanding on the discrepancies you foresee? Currently, I use a custom loop using tfds subwordtextencoder methods that takes in word counts -> iterates over words, tokenizes them -> for each token increments token counter by the source word count -> builds encoder vocab using token counter.
code_count = events.groupby("event_code").count().collect()
print("Starting indexing")
tokenizer = text_encoder.Tokenizer(
alphanum_only=False, reserved_tokens=[_UNDERSCORE_REPLACEMENT]
)
token_counts= defaultdict(int)
for row in code_count:
tokens = tokenizer.tokenize(row["event_code"])
tokens = _prepare_tokens_for_encode(tokens)
for token in tokens:
token_counts[token] += row["count"]
encoder = tfds.features.text.SubwordTextEncoder._build_from_token_counts(
token_counts, min_count,[],4, 40
)
encoder.save_to_file(os.path.join(output_path, "tensorflow_vocabulary_file"))
But this is a) really slow when encoding b) ugly and hard to customize since it uses hidden method
from tokenizers.
Related Issues (20)
- [BUG]Might be a bug in Unigram Trainer HOT 1
- Training HuggingFace tokenizer - ignore_merges HOT 2
- Memory leak for large strings HOT 8
- Deserializing BPE tokenizer failure HOT 4
- llama3 tokenizer doesn't round trip HOT 4
- [BUG] Fast tokenizer does not deal with AddedTokens properly(no problem in Transformers python tokenizer impl.) HOT 6
- How can I get the mapping relationship between byte values and Unicode characters of the fast tokenizer? HOT 5
- "Solution" to memory hogging in train_new_from_iterator with a hack HOT 7
- How to use `TokenizerBuilder`? HOT 4
- [Bug?] Modifying normalizer for pretrained tokenizers don't consistently work HOT 2
- Llama-3 offset-mapping needs fixing HOT 6
- `Encoding` object stub doesn't include `__len__` HOT 4
- Progress bar doesn't show in log file. HOT 3
- Unable to Load Custom GPT2 Tokenizer - " data did not match any variant of untagged enum ModelWrapper at line 1 column 3193814" Error
- Unable to sSet `use_regex=False` in BPE decoder & post_processor?
- Decode regression HOT 8
- documentation of the `pattern` parameter in `pre_tokenizers.Split` is incorrect HOT 1
- Custom fast PreTokenizer, ported via PyO3 to Python
- Tokenizer.from_bytes() not available in python bindings HOT 3
- BPE Split pretokenization rule is not reflected in the vocabulary HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokenizers.