SAGE Fine-tuning Framework - Trainers and data loaders for LLM fine-tuning
Project description
sage-finetune
Fine-tuning implementations for the SAGE AI data processing framework.
Installation
pip install isage-finetune
For LoRA training:
pip install isage-finetune[peft]
Features
- LoRA Trainer: Parameter-efficient fine-tuning with Low-Rank Adaptation
- Mock Trainer: Testing trainer for pipeline validation
- JSON/JSONL Loader: Flexible data loading for instruction and chat formats
Quick Start
from sage_finetune import MockTrainer, JSONDatasetLoader
# Load training data
loader = JSONDatasetLoader()
train_data = loader.load("train.jsonl")
# Train (mock for testing)
trainer = MockTrainer()
result = trainer.train(train_data)
print(f"Loss: {result['train_loss']:.4f}")
LoRA Fine-tuning
from sage_finetune import LoRATrainer, LoRAConfig
trainer = LoRATrainer(
model_name="gpt2",
lora_config=LoRAConfig(r=8, lora_alpha=16),
)
result = trainer.train(train_dataset)
trainer.save_model("./my_lora_model")
Data Formats
Instruction Format
{"instruction": "Summarize this text", "input": "Long text...", "output": "Summary..."}
Chat Format
{"messages": [{"role": "user", "content": "Hello"}, {"role": "assistant", "content": "Hi"}]}
Integration with SAGE
When SAGE is installed, components auto-register with the framework:
from sage.libs.finetune import create_trainer
trainer = create_trainer("lora", model_name="gpt2")
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
isage_finetune-0.1.0.2.tar.gz
(37.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file isage_finetune-0.1.0.2.tar.gz.
File metadata
- Download URL: isage_finetune-0.1.0.2.tar.gz
- Upload date:
- Size: 37.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59bbc174f579f0b964d90a2d4e1b6472982b295e6e7a2dae784dcad67a772b27
|
|
| MD5 |
209d855bf2b8a8761b9d8246a1d92234
|
|
| BLAKE2b-256 |
f920705ebc9a2dea4cd850a0c588d9fe5b662c214a5c7dad6333ba9f22e5bd53
|
File details
Details for the file isage_finetune-0.1.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: isage_finetune-0.1.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 51.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93cdc3f8ca31a8a0f130f52a64ff188b198b88987fda4f99c25882ec9ad80d9c
|
|
| MD5 |
9aeda6bb3611a5b2c6a9165601c6e382
|
|
| BLAKE2b-256 |
afdeecaaaa4af1ab76bed17a37e9793c31f7971baaea4146232e2e8d903a8100
|