Pre-Built Token Generators
Cerebras Model Zoo provides a comprehensive suite of pre-built token generators tailored to support various stages and tasks in the development of LLMs. The initialization of these token generators is dependent on themode parameter that is specified in the config file (refer to Modes.
Flags Supported by Pre-Built Token Generators
Pretraining Parameters
Pretraining Parameters
This section lists parameters that can be used for
PretrainingTokenGenerator.In this case, it also uses all the config paramaters that are used by
PretrainingTokenGenerator, in addition to the ones specified below.VSL Finetuning Token Generator Parameters
VSL Finetuning Token Generator Parameters
This section lists down parameters that can be used for
VSLFineTuningTokenGenerator.VSLFineTuningTokenGenerator also uses the config paramaters that are used by FineTuningTokenGenerator, in addition to the ones specified below.NoteIncreasing the read chunk size will increase the packing factor of VSL. So, the user needs to figure out the tradeoff between higher packing and processing time depending on the dataset’s packing factor.
VSL Pretraining Token Generator Parameters
VSL Pretraining Token Generator Parameters
This section lists down parameters that can be used for
VSLPretrainingTokenGenerator. use_vsl needs to be set to True in the train_input or eval_input section of the model config.VSLPretrainingTokenGenerator also uses the config paramaters that are used by PretrainingTokenGenerator, in addition to the ones specified below.DPO Token Generator Parameters
DPO Token Generator Parameters
This section lists down parameters that can be used for
DPOTokenGenerator.Multimodal Pretraining Token Generator Parameters
Multimodal Pretraining Token Generator Parameters
This section lists down parameters that can be used for
MultiModalPretrainingTokenGenerator.Multimodal Token Generator Parameters
Multimodal Token Generator Parameters
This section lists down parameters that can be used for multimodal token generators.
Supported Token Generators - Pretraining Mode
-
PretrainingTokenGenerator: General-purpose pretraining on large text corpora. Whentraining_objectiveis set tomlm, it does MLM task processing. For multimodal pretraining,is_multimodalis set to True. -
FIMTokenGenerator: Designed for fill-in-the-middle tasks. Initialized whentraining_objectiveis set tofimin the config file. -
VSLPretrainingTokenGenerator: For visual and language pretraining. Initialized whenuse_vslis set toTruein the config file.
Supported Token Generators - Finetuning Mode
-
FinetuningTokenGenerator: General-purpose fine-tuning. For multimodal finetuning,is_multimodalis set to True. -
VSLFinetuningTokenGenerator: Fine-tuning for visual and language tasks. Initialized whenuse_vslis set toTruein the config file.
Other Supported Token Generators
-
DPOTokenGenerator: Focused on direct preference optimization (DPO) during token generation. Initialized whenmodeis set todpo. -
NLGTokenGenerator: Optimized for natural language generation tasks. Initialized whenmodeis set tonlg.
Custom Token Generators
In addition to pre-built token generators, the Model Zoo allows users to implement custom token generators. This enables arbitrary transformations of the input data before tokenization. To use custom token generators, ensure the configuration file is properly set up. Follow these steps: 1. Ensure that themode param is set to custom, in order to be able to specify your own token generator.
2. Specify the path to the custom token generator class in the config file, in the token_generator param, within the setup section. This would look like:
The
token_generator path should be specified with the class name being separated with a colon : from the module name, for the custom token generator be instantiated correctly.Class Implementation Guidelines
The custom token generator must adhere to the following guidelines: 1. The constructor’s signature must be as follows:encode method, which tokenizes and encodes the data according to the user definition. For more examples on how the encode method looks like, refer to the code of pre-built token generators that are present in Model Zoo.
3. The signature of the encode method is given below, where it takes in a semantic_data_array: