-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support frozen embeddings #2
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
base: main
Are you sure you want to change the base?
Conversation
…oading of pretrained embeddings in Trainer class. Enhance model initialization to support freezing embeddings and ensure dimensional consistency when loading embeddings.
…nedModel instead of AutoModel for improved compatibility with GPT-2 architecture. Ensure consistent handling of input embeddings during initialization.
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.
Pull Request Overview
This PR adds support for loading and optionally freezing pretrained embeddings from Hugging Face models. The implementation allows models to initialize with pretrained embeddings (like GPT-2) and freeze them during training to preserve learned representations.
- Adds embedding configuration options to TrainingConfig (freeze_embeddings, load_pretrained_embeddings, pretrained_model_name)
- Implements pretrained embedding loading with dimensional consistency checks in the Trainer class
- Reorders initialization sequence to load data first, ensuring correct vocab_size before model creation
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| train_launcher.py | Maps new embedding configuration parameters from config dict to TrainingConfig |
| secure_transformer/train.py | Implements embedding loading/freezing logic and reorders initialization sequence |
| secure_transformer/config.py | Adds new embedding-related configuration fields with defaults |
| configs/gpt2_frozen_config.yaml | Provides example configuration for using frozen GPT-2 embeddings |
Comments suppressed due to low confidence (1)
secure_transformer/train.py:76
- [nitpick] The variable name 'trainable_params' could be more descriptive. Consider renaming to 'trainable_parameters' for consistency with the logging message that mentions 'trainable params'.
trainable_params = [p for p in self.model.parameters() if p.requires_grad]
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add embedding configuration options to TrainingConfig and implement loading of pretrained embeddings in Trainer class. Enhance model initialization to support freezing embeddings and ensure dimensional consistency when loading embeddings.