Comments (6)
Sounds good! Thanks for the prompt responses on this, I find this work very impressive, and will spread the word.
from tokenizers.
We are actually using rayon
to encode multiple sequences in parallel, see https://github.com/huggingface/tokenizers/blob/master/tokenizers/src/tokenizer/mod.rs#L357.
Otherwise, we don't make any assumption on the type of content that we are going to process. According to your choice of PreTokenizer
and Model
, there isn't necessarily a concept of word, and thus parallelization at this level isn't really possible, at least not trivially.
from tokenizers.
Thanks for the response! I am new to NLP, so I did not know that this concept is not generic. Also I had missed this call to par_iter(), so thanks for pointing that out.
On an unrelated note, could you please point me to a time/throughput comparison with WordPiece tokenizer in python that is used for the BERT model? It would help me push the case for switching to this tokenizer at my workplace.
from tokenizers.
Hey @smr97, you can have a look at this file: https://github.com/huggingface/tokenizers/blob/master/bindings/python/examples/example.py
It provides an example of processing between the Python tokenizer which is available in transformers
and the one provided by this library. You can process a large enough file, like one of the wiki-text-raw to see the difference.
If you need to download a vocabulary for BERT, all the links are available here: https://github.com/huggingface/transformers/blob/master/src/transformers/tokenization_bert.py#L32
from tokenizers.
Thanks for the useful example, that is exactly what I wanted. I ran this with the wiki-text-raw-train file (541MB) and saw a pretty amazing speedup (MacBook 2017)!
Just FYI though, there seems to be a bug in the script, it throws this error as shown in the figure. I checked the rust source and it seems that the decode_batch
function indeed has two positional arguments (so the error is un-called for). I have not worked with python bindings to Rust, so am not sure where the bug really is.
from tokenizers.
@smr97 It should be fixed on master now :)
from tokenizers.
Related Issues (20)
- tokenizers-linux-x64-musl is not found when running inside node apline docker
- `BertWordPieceTokenizer` not saving with `sep_token` marked HOT 2
- error: casting `&T` to `&mut T` is undefined behavior HOT 1
- Is it possible to pass a tokenizer from Python into Rust?
- Discrepancy Between GitHub Release and NPM Package Version & Missing Dependencies HOT 1
- Deepseeker model completely loses performance after using tokenizer.add_tokens(special_tokens)
- Unsound use of unsafe in `src/utils/parallelism.rs`
- LLamaTokenizer with `use_fast=True` / and `use_fast=False` causing memory leak when used with multiprocessing / `dataset.map(num_proc)` HOT 1
- StripAccents doesn't work
- Issue in installing rudalle on google colab, !pip install rudalle
- Extended vocab tokenizer merging text into a single string without spaces while decoding
- offline installation HOT 1
- Failing to build bindings with 0.19.1 HOT 1
- Python Binding: Tokenizer.from_file() cannot parse JSON file of tokens HOT 1
- Treatment of hyphenated words
- Cross-compilation fails for custom target
- Breaking changes in v0.19.1 for tiktoken/llama3 HOT 3
- BPE Trainer doesn't respect the `vocab_size` parameter when dataset size is increased HOT 1
- UnigramTrainer: byte_fallback is false.
- Tokens Removed from Trained Custom BPE Tokenizer
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.