Skip to content

Conversation

@000alen
Copy link
Owner

@000alen 000alen commented Jul 13, 2025

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.

000alen added 2 commits July 13, 2025 16:48
…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.
@000alen 000alen changed the title 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. feat: support frozen embeddings Jul 20, 2025
@000alen 000alen self-assigned this Jul 20, 2025
@000alen 000alen requested a review from Copilot July 20, 2025 19:13
Copy link

Copilot AI left a 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]

000alen and others added 3 commits July 20, 2025 12:14
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants