Skip to content

Conversation

@bbkx226
Copy link

@bbkx226 bbkx226 commented Dec 14, 2025

Resolves #7

  • Introduced LoRA (Low-Rank Adaptation) configuration in lora_config.py.
  • Updated arguments.py to include LoRA parameters.
  • Modified model.py to apply LoRA if enabled during model initialization.
  • Enhanced run.py to prepare LoRA configuration based on user arguments.
    This pull request introduces comprehensive support for LoRA (Low-Rank Adaptation) parameter-efficient fine-tuning in the F2LLM codebase, enabling users to efficiently adapt large language models with minimal computational resources. It adds LoRA configuration options, integration with the training and model initialization workflow, utilities for applying LoRA, and a full test suite to verify correct LoRA behavior. Documentation has also been updated to guide users through LoRA usage and benefits.

LoRA Integration and Configuration:

  • Added a new lora_config.py module implementing the LoRAConfig dataclass and utility functions to configure and apply LoRA adapters using the PEFT library. This includes sensible defaults for common transformer architectures and exposes all major LoRA hyperparameters.
  • Updated the F2LLM class in model.py to support LoRA-enabled initialization, including fallback for flash attention, and to apply LoRA adapters if enabled via configuration.
  • Extended the Args class in arguments.py and the training pipeline in run.py to accept and propagate LoRA-specific hyperparameters, allowing LoRA to be toggled and configured via the config file or command line. [1] [2] [3]
  • Updated model checkpoint saving logic in utils.py to save only LoRA adapter weights when using LoRA, reducing checkpoint size and storage requirements.

Testing and Validation:

  • Added a comprehensive test_lora.py test suite to validate LoRA integration, including tests for model initialization, parameter reduction, forward pass correctness, gradient flow, checkpoint saving/loading, configuration flexibility, and end-to-end training workflow.

Documentation and Usability:

  • Updated README.md with detailed instructions for enabling and configuring LoRA, explanations of LoRA parameters, usage examples, and a guide to loading LoRA fine-tuned models.
  • Added peft as a dependency in requirements.txt to support LoRA functionality.
  • Updated model references in tokenize_data_qwen.py and configs/config.json to use Hugging Face model identifiers for improved clarity and reproducibility. [1] [2]

These changes make it easy to enable, configure, and test LoRA fine-tuning for F2LLM models, providing significant improvements in efficiency and flexibility for model adaptation workflows.- Added test_lora.py for validating LoRA implementation.

  • Adjusted requirements.txt to ensure necessary dependencies are included.
  • Updated tokenizer initialization in tokenize_data_qwen.py for better model compatibility.
  • Enhanced checkpoint saving logic in utils.py for LoRA models.

- Introduced LoRA (Low-Rank Adaptation) configuration in `lora_config.py`.
- Updated `arguments.py` to include LoRA parameters.
- Modified `model.py` to apply LoRA if enabled during model initialization.
- Enhanced `run.py` to prepare LoRA configuration based on user arguments.
- Updated `README.md` with LoRA training instructions and benefits.
- Added `test_lora.py` for validating LoRA implementation.
- Adjusted `requirements.txt` to ensure necessary dependencies are included.
- Updated tokenizer initialization in `tokenize_data_qwen.py` for better model compatibility.
- Enhanced checkpoint saving logic in `utils.py` for LoRA models.
@bbkx226
Copy link
Author

bbkx226 commented Dec 14, 2025

#7

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.

[Codefuse开源轻训营] Support for LoRA PEFT methods

1 participant