lora
diapason.learning.training.lora
¶
LoRATrainer — fine-tune local models via LoRA/QLoRA from trace-derived SFT pairs.
All torch, transformers, and peft imports are guarded so the
module can be imported without GPU dependencies. The :class:LoRATrainingConfig
dataclass works without any optional deps; :class:LoRATrainer raises
ImportError at construction time when torch is unavailable.
LoRATrainer
¶
Fine-tune a local causal LM with LoRA (or QLoRA) adapters.
Parameters¶
config:
LoRA training configuration.
model_name:
HuggingFace model identifier or local path.
device:
PyTorch device string. None auto-detects (cuda > mps > cpu).
Raises¶
ImportError
If torch is not installed.
prepare_dataset(pairs)
¶
Convert SFT pairs to tokenized examples.
Each returned dict contains input_ids, attention_mask,
and text (the raw formatted string before tokenization).
Parameters¶
pairs:
List of dicts with at least input and output keys,
as produced by :class:TrainingDataMiner.extract_sft_pairs.
LoRATrainingConfig
dataclass
¶
Configuration for LoRA / QLoRA fine-tuning.