-
Notifications
You must be signed in to change notification settings - Fork 102
fix Baichuan2-13B issue #37
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 all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cf87e8b
enable special model
WeiweiZhang1 4791954
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4af62b9
fix typos
WeiweiZhang1 6d09e7c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a914264
fix typos2
WeiweiZhang1 a94c571
fix typos2
WeiweiZhang1 0c1e415
add model_info file
WeiweiZhang1 d72fb8f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5a25c1b
refine variant name
WeiweiZhang1 8ab2bd8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e980716
refine code
WeiweiZhang1 62ee73c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0bf4812
fix scan issue
WeiweiZhang1 ac68374
Merge branch 'enable_baichuan2-13b-chat' of https://github.com/intel/…
WeiweiZhang1 c30e715
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4db74b3
update handler
WeiweiZhang1 93b0a59
fixtypo
WeiweiZhang1 b6dbcec
fix typos
WeiweiZhang1 ff2cd49
Merge branch 'main' into enable_baichuan2-13b-chat
WeiweiZhang1 b9bd103
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8604578
fixtypo2
WeiweiZhang1 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Copyright (c) 2023 Intel Corporation | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from .utils import logger, torch | ||
|
|
||
| share_attention_mask_tuple = ("baichuan",) | ||
| special_states_dim_tuple = ("chatglm",) | ||
|
|
||
|
|
||
| def check_share_attention_mask(model, hidden_states, attention_mask=None, **kwargs): | ||
| """Checks if the attention mask states of the hidden states are shared in the model. | ||
|
|
||
| Args: | ||
| hidden_states (torch.Tensor): The hidden states of the model. | ||
| attention_mask (torch.Tensor, optional): The attention mask tensor. Defaults to None. | ||
| **kwargs: Additional keyword arguments. | ||
|
|
||
| Returns: | ||
| bool: True if attention mask is shared in the model, False otherwise. | ||
| """ | ||
| if attention_mask is None or not isinstance(hidden_states, torch.Tensor): | ||
| return False | ||
| is_special = False | ||
| for key in share_attention_mask_tuple: | ||
| if hasattr(model, "config") and key in model.config.model_type: | ||
| is_special = True | ||
| break | ||
| return bool(is_special and attention_mask.shape[0] != hidden_states.shape[0]) | ||
|
|
||
|
|
||
| def check_hidden_state_dim(model, positional_args): | ||
| """Checks the dimensionality of the hidden states. | ||
|
|
||
| Args: | ||
| positional_args: The positional arguments. | ||
|
|
||
| Returns: | ||
| int: 1 if the model type is 'chatglm' and positional arguments are not None, 0 otherwise. | ||
| """ | ||
| is_special = False | ||
| for key in special_states_dim_tuple: | ||
| if hasattr(model, "config") and key in model.config.model_type: | ||
| is_special = True | ||
| break | ||
| return int(is_special and positional_args is not None) |
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
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.