Commit c54996a
Summary:
Pull Request resolved: #17569
* [FEAT] Add prepend normalizer
This commit introduces prepend normalizer, similiar to hugging faces's
rust implementation.
* [FEAT] Add "skip_special_tokens" parameter to the decode function
Added decode function parameter, to optionaly skip decoding special
tokens. Similiary to the HF Rust implementaiton. This change should be
agnostic unless set to true.
* [FEAT] Add funciton "piece_to_id"
This commit introduces public member function that converts string to
token id. This function is reverse of already existing 'id_to_piece'
* [FEAT] Add handling of null pretokenizer and bytefallback json fields
Added:
- Handling of pretokenizer field explicitly set to null
- Handling of bytefallback field along with encode logic
* [FIX] Changed decode API to work on vectors instead of singular tokens
* [REFACTOR] Changed tests to reflect new decode API
* [FIX] Change decoders to work on vectors
* [FEAT] Make postprocessing a separte step
Postprocessing is now separate, configurable step similiar to normalization, pretokenization or decoding.
* Revert "[FIX] Changed decode API to work on vectors instead of singular tokens"
This reverts commit 08e1b399e4fafcecc78c1941b6331782f7d65469.
* [REFACTOR] Split loading function of HFTokenizer
* Revert tests as there's no longer vectorized decode api
* [FIX] Fix handling of unknown tokens in bpm
* [FIX] Added FuseDecoder implementation
* Fix python bindings
* [FIX] post_processor, remove silent fails
This commit, removes BertProcessor and RobertaProcessor skeleton
classes.
* chore: Add test cases
This commit adds test cases for:
- PieceToId logic
- skip_special_tokens logic
- PrependNormalizer
* chore: add python binding for batch decode
* chore: add post_processor to BUCK file
* chore: fix formatting in token_decoder.h, remove placeholder code in post_processor.h
* chore: change copyright handle to SWM
* feat: add tests requested in review
* chore: Unify logs in piece_to_id definitions
* chore: fix tests to ensure parity with rust implementaiton outputs
* chore: add python test for batch_decode
Differential Revision: D93019471
1 parent a398a96 commit c54996a
2 files changed
Lines changed: 16 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
| 34 | + | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
| 44 | + | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| |||
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
131 | | - | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
139 | | - | |
140 | | - | |
141 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
142 | 144 | | |
143 | 145 | | |
144 | 146 | | |
| |||
Submodule tokenizers updated 43 files
- .github/workflows/pull.yml+2-2
- .gitignore+1
- BUCK+7
- CMakeLists.txt+1
- include/pytorch/tokenizers/bpe_tokenizer_base.h+6-38
- include/pytorch/tokenizers/hf_tokenizer.h+32
- include/pytorch/tokenizers/llama2c_tokenizer.h+5-2
- include/pytorch/tokenizers/normalizer.h+25
- include/pytorch/tokenizers/pcre2_regex.h+1-1
- include/pytorch/tokenizers/post_processor.h+177
- include/pytorch/tokenizers/sentencepiece.h+5-2
- include/pytorch/tokenizers/string_integer_map.h+178-63
- include/pytorch/tokenizers/tiktoken.h+1-1
- include/pytorch/tokenizers/token_decoder.h+35-6
- include/pytorch/tokenizers/tokenizer.h+20-3
- pytorch_tokenizers/llama2c.py+3-3
- pytorch_tokenizers/tiktoken.py+1-2
- setup.py+1-1
- src/bpe_tokenizer_base.cpp+36-11
- src/hf_tokenizer.cpp+384-327
- src/llama2c_tokenizer.cpp+18-2
- src/normalizer.cpp+26-2
- src/pcre2_regex.cpp+45-7
- src/post_processor.cpp+302
- src/python_bindings.cpp+36-21
- src/sentencepiece.cpp+25-2
- src/std_regex.cpp+17-6
- src/tekken.cpp+5-1
- src/tiktoken.cpp+12-6
- src/token_decoder.cpp+155-52
- test/test_hf_tokenizer.cpp+284-4
- test/test_hf_tokenizer.py+16-3
- test/test_llama2c_tokenizer.cpp+52
- test/test_normalizer.cpp+32
- test/test_post_processor.cpp+265
- test/test_pre_tokenizer.cpp+102-86
- test/test_regex.cpp+22
- test/test_sentencepiece.cpp+56-1
- test/test_string_integer_map.cpp+43-4
- test/test_tekken.cpp+65
- test/test_tekken_python.py+4-4
- test/test_tiktoken.cpp+45
- test/test_token_decoder.cpp+164-43
0 commit comments