-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
GGUF: Fix llama 3 GGUF #31358
Merged
younesbelkada
merged 18 commits into
huggingface:main
from
younesbelkada:fix-llama-3-gguf-2
Jun 20, 2024
Merged
GGUF: Fix llama 3 GGUF #31358
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
91c72e7
Create push-important-models.yml
younesbelkada 580c7f8
merge
younesbelkada 7bc0e6c
llama3 support for GGUF
younesbelkada b6ae58b
fixup
younesbelkada 74d607e
Update src/transformers/integrations/ggml.py
younesbelkada 9074572
Merge remote-tracking branch 'origin/main' into fix-llama-3-gguf-2
younesbelkada a51e3dc
Merge branch 'fix-llama-3-gguf-2' of https://github.com/younesbelkada…
younesbelkada dc9719f
fix pre-tokenizer
younesbelkada fbd2d4b
Merge remote-tracking branch 'origin/main' into fix-llama-3-gguf-2
younesbelkada 80ea9c8
Merge branch 'fix-llama-3-gguf-2' of https://github.com/younesbelkada…
younesbelkada 11f41cc
fix
younesbelkada bc4b0c3
fix
younesbelkada 795681d
fix
younesbelkada 72633a1
fix
younesbelkada ead5a92
fix
younesbelkada c711b0a
fix
younesbelkada 71105c0
address final comment
younesbelkada b8aa283
handle special tokens + add tests
younesbelkada 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 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 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 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 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 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 |
---|---|---|
|
@@ -32,6 +32,7 @@ class GgufIntegrationTests(unittest.TestCase): | |
model_id = "TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF" | ||
mistral_model_id = "TheBloke/Mistral-7B-Instruct-v0.2-GGUF" | ||
qwen2_model_id = "Qwen/Qwen1.5-0.5B-Chat-GGUF" | ||
llama3_model_id = "NousResearch/Meta-Llama-3-8B-GGUF" | ||
|
||
q4_0_gguf_model_id = "tinyllama-1.1b-chat-v1.0.Q4_0.gguf" | ||
q4_k_gguf_model_id = "tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf" | ||
|
@@ -43,6 +44,7 @@ class GgufIntegrationTests(unittest.TestCase): | |
|
||
q4_0_mistral_model_id = "mistral-7b-instruct-v0.2.Q4_0.gguf" | ||
q4_0_qwen2_model_id = "qwen1_5-0_5b-chat-q4_0.gguf" | ||
q4_llama3_model_id = "Meta-Llama-3-8B-Q4_K_M.gguf" | ||
|
||
example_text = "Hello" | ||
|
||
|
@@ -171,6 +173,25 @@ def test_qwen2_q4_0(self): | |
EXPECTED_TEXT = "Hello.jsoup\n\nI am a beginner" | ||
self.assertEqual(tokenizer.decode(out[0], skip_special_tokens=True), EXPECTED_TEXT) | ||
|
||
def test_llama3_q4_0_tokenizer(self): | ||
tokenizer_gguf = AutoTokenizer.from_pretrained(self.llama3_model_id, gguf_file=self.q4_llama3_model_id) | ||
special_sentence = "สวัสดี" | ||
predicted_text = tokenizer_gguf.decode(tokenizer_gguf.encode(special_sentence, return_tensors="pt")[0]) | ||
self.assertEqual(predicted_text, "<|begin_of_text|>" + special_sentence) | ||
|
||
def test_llama3_q4_0(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The string that you are testing could be improved! Specifically to take into account the special tokens and etc. |
||
tokenizer = AutoTokenizer.from_pretrained(self.llama3_model_id, gguf_file=self.q4_llama3_model_id) | ||
model = AutoModelForCausalLM.from_pretrained( | ||
self.llama3_model_id, gguf_file=self.q4_llama3_model_id, device_map="auto", torch_dtype=torch.float16 | ||
) | ||
|
||
text = tokenizer(self.example_text, return_tensors="pt").to(torch_device) | ||
out = model.generate(**text, max_new_tokens=10) | ||
|
||
EXPECTED_TEXT = "Hello, I am new to this forum. I am" | ||
|
||
self.assertEqual(tokenizer.decode(out[0], skip_special_tokens=True), EXPECTED_TEXT) | ||
|
||
def test_tokenization_xnli(self): | ||
import tqdm | ||
from datasets import load_dataset | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah sound good to me TBH