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

feat: FromPretrained to load tokenizer directly from HF #27

Merged
merged 10 commits into from
Nov 7, 2024

Conversation

berkayersoyy
Copy link
Contributor

Benchmark benchmarks/eafe2ce1db50dcd78b3b7157bf2c669109f4e322.txt benchmarks/867b67eeade51e570d5150cebddab679b855e885.txt Change
sec/op
EncodeNTimes-10 12.75µ ± 2% 12.60µ ± 1% -1.18% (p=0.015 n=6)
EncodeNChars-10 0.3629n ± 19% 0.3589n ± 8% ~ (p=1.000 n=6)
DecodeNTimes-10 4.433µ ± 1% 4.481µ ± 1% +1.08% (p=0.011 n=6)
DecodeNTokens-10 660.5n ± 2% 662.0n ± 5% ~ (p=0.485 n=6)
Geomean 341.2n 340.3n -0.25%
Benchmark benchmarks/eafe2ce1db50dcd78b3b7157bf2c669109f4e322.txt benchmarks/867b67eeade51e570d5150cebddab679b855e885.txt Change
B/op
EncodeNTimes-10 232.0 ± 0% 232.0 ± 0% ~ (p=1.000 n=6)¹
EncodeNChars-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=6)¹
DecodeNTimes-10 96.00 ± 0% 96.00 ± 0% ~ (p=1.000 n=6)¹
DecodeNTokens-10 7.000 ± 0% 7.000 ± 0% ~ (p=1.000 n=6)¹
Geomean +0.00%²
Benchmark benchmarks/eafe2ce1db50dcd78b3b7157bf2c669109f4e322.txt benchmarks/867b67eeade51e570d5150cebddab679b855e885.txt Change
allocs/op
EncodeNTimes-10 12.00 ± 0% 12.00 ± 0% ~ (p=1.000 n=6)¹
EncodeNChars-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=6)¹
DecodeNTimes-10 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=6)¹
DecodeNTokens-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=6)¹
Geomean +0.00%²

¹ All samples are equal
² Summaries must be >0 to compute geomean

@berkayersoyy
Copy link
Contributor Author

I added a few things so that the tokenizer can be loaded directly from huggingface, if you could review it that would be great @daulet 🙏

tokenizer.go Outdated Show resolved Hide resolved
tokenizer.go Outdated Show resolved Hide resolved
tokenizer.go Outdated Show resolved Hide resolved
tokenizer.go Outdated Show resolved Hide resolved
tokenizer.go Outdated Show resolved Hide resolved
Copy link
Owner

@daulet daulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! In principle looks good, let's just iron out concurrency stuff.

@berkayersoyy
Copy link
Contributor Author

I made the changes you mentioned, can you review them again? 🙏

tokenizer.go Outdated Show resolved Hide resolved
@daulet
Copy link
Owner

daulet commented Nov 5, 2024

@berkayersoyy I've made few changes instead of PR comments, lets just add tests and we are good to go

@berkayersoyy
Copy link
Contributor Author

looks good 🙏 , I added the tests @daulet

tokenizer_test.go Outdated Show resolved Hide resolved
tokenizer_test.go Outdated Show resolved Hide resolved
tokenizer_test.go Outdated Show resolved Hide resolved
tokenizer_test.go Outdated Show resolved Hide resolved
Copy link
Owner

@daulet daulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left comments

@berkayersoyy
Copy link
Contributor Author

updated the tests 🙏 @daulet

@daulet daulet changed the title add LoadTokenizerFromHuggingFace function to load tokenizer directly … feat: FromPretrained to load tokenizer directly from HF Nov 7, 2024
@daulet daulet merged commit 9c972d9 into daulet:main Nov 7, 2024
1 check passed
@daulet
Copy link
Owner

daulet commented Nov 7, 2024

Thank you @berkayersoyy for your contribution!

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.

2 participants