Skip to content
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

support tiktoken #7

Merged
merged 7 commits into from
Oct 7, 2023
Merged

support tiktoken #7

merged 7 commits into from
Oct 7, 2023

Conversation

chengchingwen
Copy link
Owner

Support the tokenizers provided by tiktoken. The tokenizer files are re-host on my gist due to Artifacts.jl lacking support for lazy artifact without unpacking.

cc @ztangent

@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (ad9d33b) 80.20% compared to head (e2efa4e) 83.63%.

❗ Current head e2efa4e differs from pull request most recent head 3c2b05e. Consider uploading reports for the commit 3c2b05e to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master       #7      +/-   ##
==========================================
+ Coverage   80.20%   83.63%   +3.43%     
==========================================
  Files           8        9       +1     
  Lines         389      495     +106     
==========================================
+ Hits          312      414     +102     
- Misses         77       81       +4     
Files Coverage Δ
src/BytePairEncoding.jl 100.00% <ø> (ø)
src/bpe.jl 91.97% <100.00%> (+0.92%) ⬆️
src/bytefallback.jl 0.00% <ø> (ø)
src/gpt2_utils.jl 100.00% <100.00%> (ø)
src/tokenization.jl 77.77% <100.00%> (+6.34%) ⬆️
src/tiktoken.jl 94.62% <94.62%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chengchingwen chengchingwen marked this pull request as ready for review October 6, 2023 13:24
@chengchingwen
Copy link
Owner Author

julia> using BytePairEncoding, TextEncodeBase

julia> tkr = BytePairEncoding.load_tiktoken("cl100k_base")
FlatTokenizer(MatchTokenization(BPETokenization(Cl100kBaseTokenization, bpe = TikTokenBPE(100256 merges)), 5 patterns))

julia> tkr(TextEncodeBase.Sentence("hello world aaaaaaaaaaaa"))
5-element Vector{TextEncodeBase.TokenStage}:
 Token("hello", (ismatch = false,))
 Token(" world", (ismatch = false,))
 Token(" a", (ismatch = false,))
 Token("aaaaaaaa", (ismatch = false,))
 Token("aaa", (ismatch = false,))

@chengchingwen chengchingwen merged commit 3c2b05e into master Oct 7, 2023
0 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant