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

Uploaded Source

Built Distribution

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

isage_finetune-0.1.0.1-py2.py3-none-any.whl (51.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: isage_finetune-0.1.0.1.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

Hashes for isage_finetune-0.1.0.1.tar.gz
Algorithm Hash digest
SHA256 141d511e04fdb9c7c350cbcd3ccb944aa3600e667cfaff5f394826088e1455c1
MD5 25551e89af979a51777c51debb15d4f4
BLAKE2b-256 c54a1c6ddeb9f7274343860417beeaef81b6e02fbe0f7ed62d640bff30bc26f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isage_finetune-0.1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 618fd6783425266933d8261e29d460990f7d6ab1bc37e84c4c9ad14733f23f02
MD5 68c0d2871668660e9e315bf6c271f81a
BLAKE2b-256 0fef3c0fb5f89fd70845ec91bffd383676a23f8dd9a8b0b899bbc8104c9a0cf7

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