-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Add Falcon3 support and Fix issue #10875 #10883
Open
mokeddembillel
wants to merge
5
commits into
ggerganov:master
Choose a base branch
from
mokeddembillel:falcon3_integration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+31
−0
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d146334
Add Falcon3 model support
mokeddembillel fc05540
Add fix for adding bos to added special tokens
mokeddembillel b3d022a
Add comment explaining the logic behind the if statement
mokeddembillel d8d2f37
Add a log message to better track the when the following line of code…
mokeddembillel 92e41ec
Update log to only print when input and output characters are different
mokeddembillel 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -525,6 +525,13 @@ def get_vocab_base(self) -> tuple[list[str], list[int], str]: | |
else: | ||
token: str = reverse_vocab[i] | ||
if token in added_vocab: | ||
# We need to manually encode and decode the added tokens in case special characters | ||
# used for `\n` / `\t` have been manually added in the added tokens | ||
# To avoid unexpected issues - we make sure to encode single-char tokens | ||
if len(token) == 1: | ||
logger.info("Ecode-Decode special characters using AutoTokenizer") | ||
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. I was thinking about comparing the token before and after the encoding and print the log only if there is a difference. 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. that's a good idea. Done!
|
||
token = tokenizer.decode(tokenizer.encode(token, add_special_tokens=False)) | ||
|
||
if tokenizer.added_tokens_decoder[i].special or self.does_token_look_special(token): | ||
toktypes.append(gguf.TokenType.CONTROL) | ||
else: | ||
|
@@ -571,6 +578,9 @@ def get_vocab_base_pre(self, tokenizer) -> str: | |
if chkhsh == "8aeee3860c56296a157a1fe2fad249ec40aa59b1bb5709f4ade11c4e6fe652ed": | ||
# ref: https://huggingface.co/tiiuae/falcon-7b | ||
res = "falcon" | ||
if chkhsh == "9d032fcbd5501f4a38150912590928bfb36091efb5df11b8e2124b0390e3fb1e": | ||
# ref: https://huggingface.co/tiiuae/Falcon3-7B-Base | ||
res = "falcon3" | ||
if chkhsh == "0876d13b50744004aa9aeae05e7b0647eac9d801b5ba4668afc01e709c15e19f": | ||
# ref: https://huggingface.co/BAAI/bge-small-en-v1.5 | ||
res = "bert-bge" | ||
|
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
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.
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.
I'm looking at the Falcon tokenizer and I don't see any added tokens that have
\n
or\t
: https://huggingface.co/tiiuae/Falcon3-7B-Instruct/raw/main/tokenizer.jsonFor which tokens does this change make a difference?
Maybe also add some logs to know when this path is being triggered so we can spot any potential problems with other models.
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.
Chiming in here ! The added token is
(
\t
is the id 13)the only way to convert it properly to
\n
is to encode / decode using the tokenizerThere 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.
I just added a log message inside the if statement.