codelion/ellora

Enhancing LLMs with LoRA

Jupyter Notebook

227

22 commits

updated Oct 20, 2025

See the code

README

๐ŸŽฏ Ellora: Enhancing LLMs with LoRA

GitHub Models

Ellora (Enhancing LLMs with LoRA) is a collection of standardized, high-quality LoRA recipes for enhancing Large Language Model capabilities. Instead of building new frameworks, we focus on creating reproducible training methodologies that work with existing infrastructure.

๐ŸŒŸ Philosophy

The LLM ecosystem has amazing infrastructure (LoRAX, PEFT, vLLM), but lacks standardized, high-quality capability adapters. Ellora bridges this gap by providing:

  • ๐Ÿ“‹ Recipes, not frameworks - Reproducible training methodologies
  • ๐ŸŽฏ Quality-first approach - Rigorous evaluation and benchmarking
  • ๐Ÿ”„ Self-supervised data generation - No dependency on external datasets
  • ๐Ÿ—๏ธ Infrastructure agnostic - Works with existing tools (PEFT, LoRAX, etc.)
  • ๐ŸŒ Community-driven - Open recipes for the ecosystem

๐Ÿ“š Recipe Collection

RecipePurposeKey AchievementJump to
#1: Accuracy RecoveryRestore quantized model performance<5% degradation from FP16Details
#2: Reasoning EnhancementAdd structured thinking with <think> tags60% thinking usage, 75% quality boostDetails
#3: Tool CallingEnable effective development tool usage80% success rate on complex tasksDetails
#4: Context ExtensionExpand from 32K to 2M tokens61x context increase for full reposDetails
#5: Secure Code GenerationTrain models to write secure code by default97% vulnerability reductionDetails
#6: Execution World ModelAdd execution awareness to thinking models33% state prediction accuracyDetails

๐Ÿณ Available Recipes

Recipe #1: Accuracy Recovery LoRA

Problem: Quantized models (INT4/INT8) lose accuracy compared to FP16 versions
Solution: Self-distillation LoRA adapter using Magpie-generated data

  • ๐ŸŽฏ Goal: <5% performance degradation from FP16 baseline
  • ๐Ÿ’พ Memory: ~75% reduction in model size
  • โšก Speed: 2-3x faster inference than FP16
  • ๐Ÿ“Š Method: Teacher (FP16) โ†’ Student (INT4+LoRA) distillation

Open In Colab

Key Innovation: Uses Magpie self-data generation for perfect domain alignment - no external datasets needed!

Quick Start

from transformers import AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel

# Load quantized model
model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen3-0.6B",
    quantization_config=BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4")
)

# Load accuracy recovery adapter
model = PeftModel.from_pretrained(model, "codelion/Qwen3-0.6B-accuracy-recovery-lora")

# Use normally - now with recovered accuracy!

Results

ModelPerplexityMemorySpeedStatus
FP16 Baseline1.971.0GB1.0xโœ…
INT4 Raw2.40 (+21.8%)0.25GB3.2xโš ๏ธ
INT4 + Ellora2.09 (+5.7%)0.28GB3.0xโœ…

Recipe #2: Reasoning LoRA with GRPO

Problem: LLMs often lack structured thinking patterns for complex reasoning
Solution: GRPO-trained adapter that teaches chain-of-thought with <think></think> tags

  • ๐Ÿง  Goal: Enhance reasoning capabilities through preference learning
  • ๐Ÿ“ Method: GRPO (Group Relative Policy Optimization) with self-rewarding
  • ๐ŸŽฏ Feature: Teaches structured thinking with clear reasoning steps
  • ๐Ÿ’ก Output: Models that show their reasoning process transparently

Open In Colab

Key Innovation: Self-generated preference data with automated quality scoring - no need for human annotations or external preference datasets!

Quick Start

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# Load base model
model = AutoModelForCausalLM.from_pretrained("google/gemma-3-1b-it")
tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-1b-it")

# Load reasoning adapter
model = PeftModel.from_pretrained(model, "codelion/gemma-3-1b-it-reasoning-grpo-lora")

# Use with thinking prompt
prompt = '''Think step by step and use <think></think> tags to show your reasoning process.

Problem: If a train travels 120 miles in 2 hours, then increases its speed by 30 mph for the next hour, how many total miles does it travel?

Response:'''

inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.2)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)

Results

ModelThinking UsageQuality ScoreTraining MethodStatus
Gemma-3-1B Base0%3.2-โš ๏ธ
Gemma-3-1B + Ellora60%5.6GRPOโœ…

Recipe #3: Tool Calling LoRA

Problem: LLMs struggle with effective tool usage for code exploration
Solution: Hybrid training with Magpie scenarios + real tool execution results

  • ๐Ÿ› ๏ธ Goal: Teach models to use development tools effectively
  • ๐Ÿ”„ Method: Generate scenarios with Magpie, execute on real codebases
  • ๐ŸŽฏ Feature: OpenAI-compatible function calling format
  • ๐Ÿ’ป Tools: File operations, search, code navigation, and more

Open In Colab

Key Innovation: Combines synthetic scenario diversity with real execution feedback - ensuring models learn authentic tool usage patterns!

Recipe #4: Progressive Context Extension LoRA

Problem: Base models limited to 32K context, need 2M tokens for large repositories
Solution: Progressive curriculum learning with vLLM + Unsloth hybrid approach

  • ๐Ÿ“ˆ Goal: Extend context from 32K to 2M tokens (61x increase)
  • ๐ŸŽ“ Method: Curriculum learning across 4 stages (32K โ†’ 128K โ†’ 512K โ†’ 2M)
  • โšก Innovation: vLLM for fast data generation, Unsloth for memory-efficient training
  • ๐Ÿ” Feature: Single LoRA adapter progressively learns longer contexts

Open In Colab

Key Innovation: Hybrid optimization combining vLLM's inference speed with Unsloth's training efficiency - achieving 61x context extension with minimal compute!

Quick Start

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# Load base model
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct")

# Load progressive context adapter
model = PeftModel.from_pretrained(model, "codelion/qwen2-5-coder-0-5b-instruct-progressive-2000k-lora")

# Use with 2M token context - perfect for large repositories!
long_context_prompt = "Analyze this entire repository..." # Up to 2M tokens
inputs = tokenizer(long_context_prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=1024)

Results

ModelContext LimitMax FilesUse CaseStatus
Qwen2.5-Coder Base32K tokens~10-20 filesSmall projectsโš ๏ธ
+ Stage 0 LoRA32K tokens~10-20 filesSingle module analysisโœ…
+ Stage 1 LoRA128K tokens~50-100 filesMedium repositoriesโœ…
+ Stage 2 LoRA512K tokens~200-500 filesLarge codebasesโœ…
+ Stage 3 LoRA2M tokens~1000+ filesEntire repositoriesโœ…

Recipe #5: Secure Code Generation LoRA

Problem: LLMs frequently generate code with security vulnerabilities (SQL injection, etc.)
Solution: GRPO training with automated Semgrep analysis for security scoring

  • ๐Ÿ”’ Goal: Generate secure code by default without explicit prompting
  • ๐Ÿ›ก๏ธ Method: Self-supervised training with automatic vulnerability detection
  • ๐Ÿ“Š Scoring: Partial credit system (40% functionality, 40% patterns, 20% vulnerabilities)
  • โœ… Results: 97% reduction in vulnerabilities, 100% functional code

Open In Colab

Key Innovation: Automated security analysis replaces manual curation - teaching secure patterns without labeled datasets!

Quick Start

from transformers import AutoModelForCausalLM
from peft import PeftModel

# Load base model
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct")

# Load security adapter
model = PeftModel.from_pretrained(model, "codelion/qwen2.5-coder-security-grpo-lora")

# Generate secure code by default
prompt = "Create a function to search for products by name in a database"
# Model will automatically use parameterized queries!

Results

MetricBase Model+ Security LoRAImprovement
Vulnerability Score12.30.40-97%
Functional Code95%100%+5%
Partial Credit Score-61.2/100-
Uses Secure Patterns5%76%+1420%

Recipe #6: Execution World Model Thinking LoRA

Problem: LLMs can generate and reason about code, but lack execution awareness - understanding how code behaves at runtime, predicting variable states, and comprehending dynamic program behavior Solution: GRPO-trained adapter combining Qwen3's native thinking with real execution traces, inspired by Meta's CWM (Code World Model)

  • ๐Ÿง  Goal: Add execution awareness to thinking models
  • ๐Ÿ” Method: Hybrid Magpie-style generation + real Python execution tracing
  • ๐Ÿ“Š Feature: Predict program states, debug with execution understanding
  • ๐Ÿ’ก Model: Built on Qwen3-4B-Thinking-2507 with 262K context

Open In Colab

Key Innovation: Combines Qwen3's thinking capabilities with real execution traces captured via Python's trace module - creating a "neural debugger" that understands both logic AND runtime behavior!

Quick Start

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# Load base model
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B-Thinking-2507")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-4B-Thinking-2507")

# Load execution world model adapter
model = PeftModel.from_pretrained(model, "codelion/Qwen3-4B-execution-world-model-lora")

# Analyze code with execution awareness
code = """
x = 10
y = x * 2
z = x + y
"""

prompt = f"Analyze this code and predict its execution trace step by step:\n\n```python\n{code}\n```"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.1)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Model will predict variable states at each line!

Results

MetricValueTraining DataStatus
Overall Accuracy20.0%298 samples๐Ÿšง
Mean State Accuracy33.3%Self-generated๐Ÿšง
Base ModelQwen3-4B-Thinking262K contextโœ…
Training MethodGRPOExecution tracesโœ…

๐Ÿ† Model Zoo

All models trained using Ellora recipes are available on HuggingFace:

Models

๐Ÿ”ฌ Research & Citations

If you use Ellora recipes in your research, please cite:

@misc{ellora2024,
  title={Ellora: Enhancing LLMs with LoRA - Standardized Recipes for Capability Enhancement},
  author={Asankhaya Sharma},
  year={2024},
  url={https://github.com/codelion/ellora}
}

Key Papers & Inspirations

accuracy-analysis
chain-of-thought
chain-of-thought-reasoning
data-generation
distillation
fine-tune
fine-tuning
finetuning
fine-tuning-llm
finetuning-llms
lora
qlora
quantization
quantization-aware-training
reasoning
reinforcement-learning
self-correction
self-distillation
supervised-finetuning
training

Contributors

codelion

22 commits

codelion/ellora

Enhancing LLMs with LoRA

Jupyter Notebook

227

22 commits

updated Oct 20, 2025

See the code

README

๐ŸŽฏ Ellora: Enhancing LLMs with LoRA

GitHub Models

Ellora (Enhancing LLMs with LoRA) is a collection of standardized, high-quality LoRA recipes for enhancing Large Language Model capabilities. Instead of building new frameworks, we focus on creating reproducible training methodologies that work with existing infrastructure.

๐ŸŒŸ Philosophy

The LLM ecosystem has amazing infrastructure (LoRAX, PEFT, vLLM), but lacks standardized, high-quality capability adapters. Ellora bridges this gap by providing:

  • ๐Ÿ“‹ Recipes, not frameworks - Reproducible training methodologies
  • ๐ŸŽฏ Quality-first approach - Rigorous evaluation and benchmarking
  • ๐Ÿ”„ Self-supervised data generation - No dependency on external datasets
  • ๐Ÿ—๏ธ Infrastructure agnostic - Works with existing tools (PEFT, LoRAX, etc.)
  • ๐ŸŒ Community-driven - Open recipes for the ecosystem

๐Ÿ“š Recipe Collection

RecipePurposeKey AchievementJump to
#1: Accuracy RecoveryRestore quantized model performance<5% degradation from FP16Details
#2: Reasoning EnhancementAdd structured thinking with <think> tags60% thinking usage, 75% quality boostDetails
#3: Tool CallingEnable effective development tool usage80% success rate on complex tasksDetails
#4: Context ExtensionExpand from 32K to 2M tokens61x context increase for full reposDetails
#5: Secure Code GenerationTrain models to write secure code by default97% vulnerability reductionDetails
#6: Execution World ModelAdd execution awareness to thinking models33% state prediction accuracyDetails

๐Ÿณ Available Recipes

Recipe #1: Accuracy Recovery LoRA

Problem: Quantized models (INT4/INT8) lose accuracy compared to FP16 versions
Solution: Self-distillation LoRA adapter using Magpie-generated data

  • ๐ŸŽฏ Goal: <5% performance degradation from FP16 baseline
  • ๐Ÿ’พ Memory: ~75% reduction in model size
  • โšก Speed: 2-3x faster inference than FP16
  • ๐Ÿ“Š Method: Teacher (FP16) โ†’ Student (INT4+LoRA) distillation

Open In Colab

Key Innovation: Uses Magpie self-data generation for perfect domain alignment - no external datasets needed!

Quick Start

from transformers import AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel

# Load quantized model
model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen3-0.6B",
    quantization_config=BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4")
)

# Load accuracy recovery adapter
model = PeftModel.from_pretrained(model, "codelion/Qwen3-0.6B-accuracy-recovery-lora")

# Use normally - now with recovered accuracy!

Results

ModelPerplexityMemorySpeedStatus
FP16 Baseline1.971.0GB1.0xโœ…
INT4 Raw2.40 (+21.8%)0.25GB3.2xโš ๏ธ
INT4 + Ellora2.09 (+5.7%)0.28GB3.0xโœ…

Recipe #2: Reasoning LoRA with GRPO

Problem: LLMs often lack structured thinking patterns for complex reasoning
Solution: GRPO-trained adapter that teaches chain-of-thought with <think></think> tags

  • ๐Ÿง  Goal: Enhance reasoning capabilities through preference learning
  • ๐Ÿ“ Method: GRPO (Group Relative Policy Optimization) with self-rewarding
  • ๐ŸŽฏ Feature: Teaches structured thinking with clear reasoning steps
  • ๐Ÿ’ก Output: Models that show their reasoning process transparently

Open In Colab

Key Innovation: Self-generated preference data with automated quality scoring - no need for human annotations or external preference datasets!

Quick Start

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# Load base model
model = AutoModelForCausalLM.from_pretrained("google/gemma-3-1b-it")
tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-1b-it")

# Load reasoning adapter
model = PeftModel.from_pretrained(model, "codelion/gemma-3-1b-it-reasoning-grpo-lora")

# Use with thinking prompt
prompt = '''Think step by step and use <think></think> tags to show your reasoning process.

Problem: If a train travels 120 miles in 2 hours, then increases its speed by 30 mph for the next hour, how many total miles does it travel?

Response:'''

inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.2)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)

Results

ModelThinking UsageQuality ScoreTraining MethodStatus
Gemma-3-1B Base0%3.2-โš ๏ธ
Gemma-3-1B + Ellora60%5.6GRPOโœ…

Recipe #3: Tool Calling LoRA

Problem: LLMs struggle with effective tool usage for code exploration
Solution: Hybrid training with Magpie scenarios + real tool execution results

  • ๐Ÿ› ๏ธ Goal: Teach models to use development tools effectively
  • ๐Ÿ”„ Method: Generate scenarios with Magpie, execute on real codebases
  • ๐ŸŽฏ Feature: OpenAI-compatible function calling format
  • ๐Ÿ’ป Tools: File operations, search, code navigation, and more

Open In Colab

Key Innovation: Combines synthetic scenario diversity with real execution feedback - ensuring models learn authentic tool usage patterns!

Recipe #4: Progressive Context Extension LoRA

Problem: Base models limited to 32K context, need 2M tokens for large repositories
Solution: Progressive curriculum learning with vLLM + Unsloth hybrid approach

  • ๐Ÿ“ˆ Goal: Extend context from 32K to 2M tokens (61x increase)
  • ๐ŸŽ“ Method: Curriculum learning across 4 stages (32K โ†’ 128K โ†’ 512K โ†’ 2M)
  • โšก Innovation: vLLM for fast data generation, Unsloth for memory-efficient training
  • ๐Ÿ” Feature: Single LoRA adapter progressively learns longer contexts

Open In Colab

Key Innovation: Hybrid optimization combining vLLM's inference speed with Unsloth's training efficiency - achieving 61x context extension with minimal compute!

Quick Start

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# Load base model
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct")

# Load progressive context adapter
model = PeftModel.from_pretrained(model, "codelion/qwen2-5-coder-0-5b-instruct-progressive-2000k-lora")

# Use with 2M token context - perfect for large repositories!
long_context_prompt = "Analyze this entire repository..." # Up to 2M tokens
inputs = tokenizer(long_context_prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=1024)

Results

ModelContext LimitMax FilesUse CaseStatus
Qwen2.5-Coder Base32K tokens~10-20 filesSmall projectsโš ๏ธ
+ Stage 0 LoRA32K tokens~10-20 filesSingle module analysisโœ…
+ Stage 1 LoRA128K tokens~50-100 filesMedium repositoriesโœ…
+ Stage 2 LoRA512K tokens~200-500 filesLarge codebasesโœ…
+ Stage 3 LoRA2M tokens~1000+ filesEntire repositoriesโœ…

Recipe #5: Secure Code Generation LoRA

Problem: LLMs frequently generate code with security vulnerabilities (SQL injection, etc.)
Solution: GRPO training with automated Semgrep analysis for security scoring

  • ๐Ÿ”’ Goal: Generate secure code by default without explicit prompting
  • ๐Ÿ›ก๏ธ Method: Self-supervised training with automatic vulnerability detection
  • ๐Ÿ“Š Scoring: Partial credit system (40% functionality, 40% patterns, 20% vulnerabilities)
  • โœ… Results: 97% reduction in vulnerabilities, 100% functional code

Open In Colab

Key Innovation: Automated security analysis replaces manual curation - teaching secure patterns without labeled datasets!

Quick Start

from transformers import AutoModelForCausalLM
from peft import PeftModel

# Load base model
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct")

# Load security adapter
model = PeftModel.from_pretrained(model, "codelion/qwen2.5-coder-security-grpo-lora")

# Generate secure code by default
prompt = "Create a function to search for products by name in a database"
# Model will automatically use parameterized queries!

Results

MetricBase Model+ Security LoRAImprovement
Vulnerability Score12.30.40-97%
Functional Code95%100%+5%
Partial Credit Score-61.2/100-
Uses Secure Patterns5%76%+1420%

Recipe #6: Execution World Model Thinking LoRA

Problem: LLMs can generate and reason about code, but lack execution awareness - understanding how code behaves at runtime, predicting variable states, and comprehending dynamic program behavior Solution: GRPO-trained adapter combining Qwen3's native thinking with real execution traces, inspired by Meta's CWM (Code World Model)

  • ๐Ÿง  Goal: Add execution awareness to thinking models
  • ๐Ÿ” Method: Hybrid Magpie-style generation + real Python execution tracing
  • ๐Ÿ“Š Feature: Predict program states, debug with execution understanding
  • ๐Ÿ’ก Model: Built on Qwen3-4B-Thinking-2507 with 262K context

Open In Colab

Key Innovation: Combines Qwen3's thinking capabilities with real execution traces captured via Python's trace module - creating a "neural debugger" that understands both logic AND runtime behavior!

Quick Start

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# Load base model
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B-Thinking-2507")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-4B-Thinking-2507")

# Load execution world model adapter
model = PeftModel.from_pretrained(model, "codelion/Qwen3-4B-execution-world-model-lora")

# Analyze code with execution awareness
code = """
x = 10
y = x * 2
z = x + y
"""

prompt = f"Analyze this code and predict its execution trace step by step:\n\n```python\n{code}\n```"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.1)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Model will predict variable states at each line!

Results

MetricValueTraining DataStatus
Overall Accuracy20.0%298 samples๐Ÿšง
Mean State Accuracy33.3%Self-generated๐Ÿšง
Base ModelQwen3-4B-Thinking262K contextโœ…
Training MethodGRPOExecution tracesโœ…

๐Ÿ† Model Zoo

All models trained using Ellora recipes are available on HuggingFace:

Models

๐Ÿ”ฌ Research & Citations

If you use Ellora recipes in your research, please cite:

@misc{ellora2024,
  title={Ellora: Enhancing LLMs with LoRA - Standardized Recipes for Capability Enhancement},
  author={Asankhaya Sharma},
  year={2024},
  url={https://github.com/codelion/ellora}
}

Key Papers & Inspirations

accuracy-analysis
chain-of-thought
chain-of-thought-reasoning
data-generation
distillation
fine-tune
fine-tuning
finetuning
fine-tuning-llm
finetuning-llms
lora
qlora
quantization
quantization-aware-training
reasoning
reinforcement-learning
self-correction
self-distillation
supervised-finetuning
training

Contributors

codelion

22 commits

Languages

Jupyter Notebook

100.0%