Skip to main content

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


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.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

isage_finetune-0.1.0.0-py2.py3-none-any.whl (15.5 kB view details)

Uploaded Python 2Python 3

isage_finetune-0.1.0.0-cp311-none-any.whl (10.7 kB view details)

Uploaded CPython 3.11

File details

Details for the file isage_finetune-0.1.0.0.tar.gz.

File metadata

  • Download URL: isage_finetune-0.1.0.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for isage_finetune-0.1.0.0.tar.gz
Algorithm Hash digest
SHA256 0f3dfcdc43514238e9e0a95243be38503889cf2f1a5105ace0778856491cba64
MD5 49d4a9a9b62ea97610a81114162bf2fb
BLAKE2b-256 a34315663a86f641d94152f49de43167b1a168fc59b35537122bc5ce1e5e0359

See more details on using hashes here.

File details

Details for the file isage_finetune-0.1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for isage_finetune-0.1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3532b0f2d7f3bcf1ad10a541cae841ac995a2ac3a6c517823582383b0a702dd1
MD5 9f12915a3ebb0edf117240a93f8357fc
BLAKE2b-256 cbdbfd08d1546bf64ea8f2bcb30e61553db1ae5db75dbb7e8f9974b9b3304b0f

See more details on using hashes here.

File details

Details for the file isage_finetune-0.1.0.0-cp311-none-any.whl.

File metadata

File hashes

Hashes for isage_finetune-0.1.0.0-cp311-none-any.whl
Algorithm Hash digest
SHA256 579977806826b7b25cd34cf1ceab2ce15104cd5272c95eec4c4d52fdcce70d00
MD5 64ddc2a8869f8ec8ce36416b5aac3fbb
BLAKE2b-256 e5b14493c88e039c8af686bda495a1bfbf22520fc2501412ea99e0d5473d41f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page