Skip to content

Conversation

@OneZero-Y
Copy link
Contributor

What type of PR is this?
Fix LoRA Model Training Configuration and Data Balance

What this PR does / why we need it:

Fixed critical configuration and data balance issues in LoRA training scripts that were causing model accuracy problems and training instability.

Key Issues Resolved

  1. Enhanced Target Modules Configuration
  • Improved attention learning: Added attention.self.key to BERT/RoBERTa target modules
  • Better error handling: Added target modules verification and clear error messages
  1. Advanced Dataset Balancing
  • Intent Classification: Enhanced category balance category validation
  • PII Detection: Implemented entity-type balanced sampling with negative examples
  • Security Detection: Added strict 1:1 jailbreak/benign balance with distribution verification

Files Modified

  • common_lora_utils.py - Core LoRA configuration and model validation
  • ft_linear_lora.py - Intent classification with enhanced category balancing
  • pii_bert_finetuning_lora.py - PII detection with entity-type balancing
  • jailbreak_bert_finetuning_lora.py - Security detection with strict 1:1 balance

@netlify
Copy link

netlify bot commented Sep 26, 2025

Deploy Preview for vllm-semantic-router ready!

Name Link
🔨 Latest commit 989b376
🔍 Latest deploy log https://app.netlify.com/projects/vllm-semantic-router/deploys/68d7fa656fad0800083d3119
😎 Deploy Preview https://deploy-preview-233--vllm-semantic-router.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link

github-actions bot commented Sep 26, 2025

👥 vLLM Semantic Team Notification

The following members have been identified for the changed files in this PR and have been automatically assigned:

📁 src

Owners: @rootfs, @Xunzhuo, @wangchen615
Files changed:

  • src/training/training_lora/OWNER
  • src/training/training_lora/classifier_model_fine_tuning_lora/ft_linear_lora.py
  • src/training/training_lora/classifier_model_fine_tuning_lora/ft_linear_lora_verifier.go
  • src/training/training_lora/classifier_model_fine_tuning_lora/train_cpu_optimized.sh
  • src/training/training_lora/common_lora_utils.py
  • src/training/training_lora/pii_model_fine_tuning_lora/pii_bert_finetuning_lora.py
  • src/training/training_lora/pii_model_fine_tuning_lora/pii_bert_finetuning_lora_verifier.go
  • src/training/training_lora/pii_model_fine_tuning_lora/train_cpu_optimized.sh
  • src/training/training_lora/prompt_guard_fine_tuning_lora/jailbreak_bert_finetuning_lora.py
  • src/training/training_lora/prompt_guard_fine_tuning_lora/jailbreak_bert_finetuning_lora_verifier.go
  • src/training/training_lora/prompt_guard_fine_tuning_lora/train_cpu_optimized.sh

vLLM

🎉 Thanks for your contributions!

This comment was automatically generated based on the OWNER files in the repository.

@OneZero-Y OneZero-Y changed the title Fix LoRA Model Training Configuration and Data Balance fix: LoRA Model Training Configuration and Data Balance Sep 26, 2025
@OneZero-Y OneZero-Y force-pushed the fix/lora-model-training branch from 715b5c9 to 1262ea5 Compare September 26, 2025 13:15
@rootfs
Copy link
Collaborator

rootfs commented Sep 26, 2025

@OneZero-Y Thanks for the idea. For jailbreak 1:1 mapping, is it necessary? Would that bias towards jailbreak in evaluation?

validate_lora_config,
)

# Setup logging
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you add OWNER file in the training_lora directory and add you there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I added it.

@rootfs rootfs added this to the v0.1 milestone Sep 26, 2025
Signed-off-by: OneZero-Y <[email protected]>

Fix LoRA Model Training Configuration and Data Balance

Signed-off-by: OneZero-Y <[email protected]>
@OneZero-Y
Copy link
Contributor Author

@rootfs
According to latest LLM Guard and Guardrails documentation :

  • LLM Guard: 1:1 balanced datasets are recommended for binary security classifiers
    • Source: github.com/protectai/llm-guard/blob/main/docs/tutorials/notebooks/langchain_rag.ipynb (multi-layer detection)
    • Source: github.com/protectai/llm-guard/blob/main/docs/output_scanners/ban_topics.md (threshold tuning)
    • Source: github.com/protectai/llm-guard/blob/main/docs/output_scanners/emotion_detection.md (binary classification thresholds)
  • Guardrails AI: Supports balanced training with threshold tuning for optimization
    • Source: github.com/guardrails-ai/guardrails/tree/main/docs/how_to_guides/custom_validators.md (threshold configuration)
    • Source: github.com/guardrails-ai/guardrails/tree/main/docs/examples/provenance.ipynb (validation_method="sentence")
    • Source: github.com/guardrails-ai/guardrails/tree/main/docs/examples/toxic_language.ipynb (multi-validator strategy)
  • Prevent model bias toward majority class, ensure equal sensitivity to attack/benign patterns

@OneZero-Y OneZero-Y force-pushed the fix/lora-model-training branch from 1262ea5 to 17c38ae Compare September 27, 2025 07:49
Signed-off-by: OneZero-Y <[email protected]>

fix:LoRA Model Training Configuration and Data Balance

Signed-off-by: OneZero-Y <[email protected]>
@OneZero-Y OneZero-Y force-pushed the fix/lora-model-training branch from 17c38ae to 36ec9ff Compare September 27, 2025 13:14
@rootfs
Copy link
Collaborator

rootfs commented Sep 27, 2025

@OneZero-Y thank you for the references! They are very helpful!

@rootfs
Copy link
Collaborator

rootfs commented Sep 27, 2025

@OneZero-Y I am still catching up on the LoRA training. This is beyond my working experience :D

Merging the PR now

@rootfs rootfs merged commit 56cdc08 into vllm-project:main Sep 27, 2025
4 checks passed
@OneZero-Y OneZero-Y deleted the fix/lora-model-training branch September 30, 2025 08:35
Aias00 pushed a commit to Aias00/semantic-router that referenced this pull request Oct 4, 2025
…#233)

* Fix LoRA Model Training Configuration and Data Balance

Signed-off-by: OneZero-Y <[email protected]>

Fix LoRA Model Training Configuration and Data Balance

Signed-off-by: OneZero-Y <[email protected]>

* fix:LoRA Model Training Configuration and Data Balance

Signed-off-by: OneZero-Y <[email protected]>

fix:LoRA Model Training Configuration and Data Balance

Signed-off-by: OneZero-Y <[email protected]>

---------

Signed-off-by: OneZero-Y <[email protected]>
Co-authored-by: Huamin Chen <[email protected]>
Signed-off-by: liuhy <[email protected]>
yossiovadia pushed a commit to yossiovadia/semantic-router that referenced this pull request Oct 8, 2025
…#233)

* Fix LoRA Model Training Configuration and Data Balance

Signed-off-by: OneZero-Y <[email protected]>

Fix LoRA Model Training Configuration and Data Balance

Signed-off-by: OneZero-Y <[email protected]>

* fix:LoRA Model Training Configuration and Data Balance

Signed-off-by: OneZero-Y <[email protected]>

fix:LoRA Model Training Configuration and Data Balance

Signed-off-by: OneZero-Y <[email protected]>

---------

Signed-off-by: OneZero-Y <[email protected]>
Co-authored-by: Huamin Chen <[email protected]>
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.

4 participants