-
Notifications
You must be signed in to change notification settings - Fork 12k
llama : more tokenizer fixes #2810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5cad62b
tests : write a Python tokenizer test (wip)
ggerganov 5d0ffb6
llama : prefix input text for tokenization with whitespace
ggerganov 9668aa1
llama : distinguish pieces from decoded text + fix detokenization
ggerganov 1e7a033
common : add comments
ggerganov dfa058e
examples : no longer manually add leading space when tokenizing
ggerganov 70005bd
tests : use Python to generate tokenizer tests for C++
ggerganov e4324cb
tests : add option to tokenize text files
ggerganov eb8b326
tests : add test-tokenizer-1.py
ggerganov c767746
Merge branch 'master' into fix-tokenizer
ggerganov ab3ba64
llama.cpp : fix LF token
klosax dbcf470
hellaswag : move the concat space for clarity
ggerganov 3bb0f84
tests : add falcon tests (py + cpp, currently do not pass Unicode)
ggerganov 841983f
common : temporary separate llama_detokenize calls for SPM and BPE
ggerganov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import os | ||
import sys | ||
import argparse | ||
|
||
from sentencepiece import SentencePieceProcessor | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("dir_tokenizer", help="directory containing 'tokenizer.model' file") | ||
args = parser.parse_args() | ||
|
||
dir_tokenizer = args.dir_tokenizer | ||
|
||
tokenizer = SentencePieceProcessor(dir_tokenizer + '/tokenizer.model') | ||
|
||
tests = [ | ||
"" | ||
" ", | ||
" ", | ||
" ", | ||
"\t", | ||
"\n", | ||
"\t\n", | ||
"Hello world", | ||
" Hello world", | ||
"Hello World", | ||
" Hello World", | ||
" Hello World!", | ||
"Hello, world!", | ||
" Hello, world!", | ||
" this is 🦙.cpp", | ||
"w048 7tuijk dsdfhu", | ||
"нещо на Български", | ||
"កាន់តែពិសេសអាចខលចេញ", | ||
"🚀 (normal) 😶🌫️ (multiple emojis concatenated) ✅ (only emoji that has its own token)", | ||
"Hello", | ||
" Hello", | ||
" Hello", | ||
" Hello", | ||
" Hello", | ||
" Hello\n Hello", | ||
] | ||
|
||
|
||
for text in tests: | ||
print('text: ', text) | ||
print('\nwith bos:') | ||
print(tokenizer.encode(text, add_bos=True)) | ||
print(tokenizer.decode(tokenizer.encode(text, add_bos=True))) | ||
print('\nwithout bos:') | ||
print(tokenizer.encode(text, add_bos=False)) | ||
print(tokenizer.decode(tokenizer.encode(text, add_bos=False))) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.