-
Notifications
You must be signed in to change notification settings - Fork 301
T5 checkpoint conversion with HF #1277
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
17 commits
Select commit
Hold shift + click to select a range
3557373
Change TF ops to Keras Core ops
nkovela1 13ea25a
Fix formatting
nkovela1 ae48725
Sync with master after test refactoring
nkovela1 90dcf7d
Remove build override
nkovela1 c629dd4
Fix formatting and remove unneeded function
nkovela1 c239bd0
Copy over diff from T5 conversion script PR
nkovela1 387d4e3
Merge branch 't5' into t5_convert
nkovela1 312a37a
Add T5 checkpoint conversion logic
nkovela1 02aaf17
Fix output check script
nkovela1 c95c318
Add transposes for t5 checkpoints
nkovela1 a31872c
Add relative attention bias
nkovela1 5f94250
Fix formatting and imports
nkovela1 bae5f4a
Add flow for no gated activation
nkovela1 4cbd284
Merge branch 'master' into t5_convert
nkovela1 eb24e76
Add flan and t5 to checkpoint conversion script and presets
nkovela1 4a84280
Add key_value_dim to self and config
nkovela1 1b0cd0c
Add new gelu approximate standard fn
nkovela1 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# Copyright 2023 The KerasNLP Authors | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
"""XLM-RoBERTa model preset configurations.""" | ||
|
||
backbone_presets = { | ||
"t5_small_multi": { | ||
"metadata": { | ||
"description": ( | ||
"8-layer T5 model. Trained on the Colossal Clean Crawled " | ||
"Corpus (C4)." | ||
), | ||
"params": 0, | ||
"official_name": "T5", | ||
"path": "t5", | ||
"model_card": "https://github.com/google-research/text-to-text-transfer-transformer/blob/main/README.md", | ||
}, | ||
"config": { | ||
"vocabulary_size": 32128, | ||
"num_layers": 6, | ||
"num_heads": 8, | ||
"hidden_dim": 512, | ||
"intermediate_dim": 2048, | ||
"key_value_dim": 64, | ||
"dropout": 0.1, | ||
"activation": "relu", | ||
"use_gated_activation": False, | ||
"layer_norm_epsilon": 1e-06, | ||
}, | ||
"preprocessor_config": {}, | ||
}, | ||
"t5_base_multi": { | ||
"metadata": { | ||
"description": ( | ||
"12-layer T5 model. Trained on the Colossal Clean Crawled " | ||
"Corpus (C4)." | ||
), | ||
"params": 0, | ||
"official_name": "T5", | ||
"path": "t5", | ||
"model_card": "https://github.com/google-research/text-to-text-transfer-transformer/blob/main/README.md", | ||
}, | ||
"config": { | ||
"vocabulary_size": 32128, | ||
"num_layers": 12, | ||
"num_heads": 12, | ||
"hidden_dim": 768, | ||
"intermediate_dim": 3072, | ||
"dropout": 0.1, | ||
"activation": "relu", | ||
"use_gated_activation": False, | ||
"layer_norm_epsilon": 1e-06, | ||
}, | ||
"preprocessor_config": {}, | ||
}, | ||
"t5_large_multi": { | ||
"metadata": { | ||
"description": ( | ||
"24-layer T5 model. Trained on the Colossal Clean Crawled " | ||
"Corpus (C4)." | ||
), | ||
"params": 0, | ||
"official_name": "T5", | ||
"path": "t5", | ||
"model_card": "https://github.com/google-research/text-to-text-transfer-transformer/blob/main/README.md", | ||
}, | ||
"config": { | ||
"vocabulary_size": 32128, | ||
"num_layers": 24, | ||
"num_heads": 16, | ||
"hidden_dim": 1024, | ||
"intermediate_dim": 4096, | ||
"dropout": 0.1, | ||
"activation": "relu", | ||
"use_gated_activation": False, | ||
"layer_norm_epsilon": 1e-06, | ||
}, | ||
"preprocessor_config": {}, | ||
}, | ||
"flan_small_multi": { | ||
"metadata": { | ||
"description": ( | ||
"8-layer T5 model. Trained on the Colossal Clean Crawled " | ||
"Corpus (C4)." | ||
), | ||
"params": 0, | ||
"official_name": "T5", | ||
"path": "t5", | ||
"model_card": "https://github.com/google-research/text-to-text-transfer-transformer/blob/main/README.md", | ||
}, | ||
"config": { | ||
"vocabulary_size": 32128, | ||
"num_layers": 8, | ||
"num_heads": 6, | ||
"hidden_dim": 512, | ||
"intermediate_dim": 1024, | ||
"key_value_dim": 64, | ||
"dropout": 0.1, | ||
"activation": "gelu", | ||
"use_gated_activation": True, | ||
"layer_norm_epsilon": 1e-06, | ||
}, | ||
"preprocessor_config": {}, | ||
}, | ||
"flan_base_multi": { | ||
"metadata": { | ||
"description": ( | ||
"12-layer T5 model. Trained on the Colossal Clean Crawled " | ||
"Corpus (C4)." | ||
), | ||
"params": 0, | ||
"official_name": "T5", | ||
"path": "t5", | ||
"model_card": "https://github.com/google-research/text-to-text-transfer-transformer/blob/main/README.md", | ||
}, | ||
"config": { | ||
"vocabulary_size": 32128, | ||
"num_layers": 12, | ||
"num_heads": 12, | ||
"hidden_dim": 768, | ||
"intermediate_dim": 2048, | ||
"dropout": 0.1, | ||
"activation": "gelu", | ||
"use_gated_activation": True, | ||
"layer_norm_epsilon": 1e-06, | ||
}, | ||
"preprocessor_config": {}, | ||
}, | ||
"flan_large_multi": { | ||
"metadata": { | ||
"description": ( | ||
"24-layer T5 model. Trained on the Colossal Clean Crawled " | ||
"Corpus (C4)." | ||
), | ||
"params": 0, | ||
"official_name": "T5", | ||
"path": "t5", | ||
"model_card": "https://github.com/google-research/text-to-text-transfer-transformer/blob/main/README.md", | ||
}, | ||
"config": { | ||
"vocabulary_size": 32128, | ||
"num_layers": 24, | ||
"num_heads": 16, | ||
"hidden_dim": 1024, | ||
"intermediate_dim": 2816, | ||
"dropout": 0.1, | ||
"activation": "gelu", | ||
"use_gated_activation": True, | ||
"layer_norm_epsilon": 1e-06, | ||
}, | ||
"preprocessor_config": {}, | ||
}, | ||
} |
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
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.
Uh oh!
There was an error while loading. Please reload this page.