-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to wikitext-103 input pipeline to enable specifying alternati…
…ve tokenizers: - add args to specify tokenizer and vocab path - change signature of Wikitext word `Tokenizer.tokenize` such that its arg is a tensor instead of a dataset. This allows us to use the `tf Dataset.map` method to tokenize the dataset, consistent w the typical use of other tokenizers like SentencePiece. - offload flattening of dataset (to prepare for dividing into sequences) from the Wikitext word piece tokenizer PiperOrigin-RevId: 706822231
- Loading branch information
1 parent
43d6a8f
commit 15ba961
Showing
6 changed files
with
155 additions
and
43 deletions.
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# coding=utf-8 | ||
# Copyright 2024 The init2winit 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 | ||
# | ||
# 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. | ||
|
||
"""Module containing hyperparameters, metadata and dataset getter for Wikitext-103 dataset.""" | ||
|
||
|
||
from init2winit.dataset_lib import wikitext103 | ||
from init2winit.dataset_lib import wikitext103_input_pipeline | ||
from ml_collections.config_dict import config_dict | ||
|
||
SPM_TOKENIZER_VOCAB_SIZE = wikitext103_input_pipeline.SPM_TOKENIZER_VOCAB_SIZE | ||
SPM_TOKENIZER_VOCAB_PATH = wikitext103_input_pipeline.SPM_TOKENIZER_VOCAB_PATH | ||
|
||
get_wikitext103 = wikitext103.get_wikitext103 | ||
|
||
DEFAULT_HPARAMS = config_dict.ConfigDict( | ||
dict( | ||
sequence_length=128, | ||
max_target_length=128, | ||
max_eval_target_length=128, | ||
eval_sequence_length=128, | ||
input_shape=(128,), | ||
output_shape=(SPM_TOKENIZER_VOCAB_SIZE,), | ||
tokenizer='sentencepiece', | ||
tokenizer_vocab_path=SPM_TOKENIZER_VOCAB_PATH, | ||
vocab_size=SPM_TOKENIZER_VOCAB_SIZE, | ||
train_size=800210, # TODO(kasimbeg): Update this | ||
) | ||
) | ||
|
||
|
||
METADATA = { | ||
'apply_one_hot_in_loss': True, | ||
'shift_inputs': True, | ||
'causal': True, | ||
'pad_token': -1, | ||
} |
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