Skip to main content

No project description provided

Project description

SmolHub

A lightweight and efficient package for training language models using Low-Rank Adaptation (LoRA). Designed for easy experimentation and research with minimal boilerplate.

Features

  • 🚀 Multiple Training Paradigms:
    • Supervised Fine-tuning (SFT)
    • Pretraining
    • Preference Alignment (RLHF-style training)
  • 📦 Easy Integration with Hugging Face models
  • Efficient Training with LoRA
  • 📊 WandB Integration for experiment tracking
  • 🔄 Automatic Dataset Handling

Installation

pip install smolhub

Quickstart

from smolhub.scripts.finetune import SFTTrainer
from smolhub.scripts.lora import LoRAModel
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

# Load model and tokenizer
model_id = "openai-community/gpt2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)

# Setup LoRA
lora_model = LoRAModel(model)

# Train with minimal setup
trainer = SFTTrainer(
    model=lora_model,
    dataset_path="your_dataset",  # HF dataset or local file
    tokenizer=tokenizer
)
trainer.train()

Configuration

SmolHub uses a YAML configuration file for experiment settings. A default config is created in your project directory:

project:
  name: SFTrainer
  author: Yuvraj Singh
  version: 1.0

LoRA:
  rank: 4
  alpha: 8

Preference:
  beta: 0.1
  
Dataset:
    use_hf_dataset: True
    dataset_path: trl-lib/ultrafeedback_binarized
    max_length: 512
    batch_size:  16
    num_workers:  4
    shuffle:  True
    drop_last: True
    pin_memory:  True
    persistent_workers:  True
    type: "classification" #TODO Add Chat style and Instruction 
   
huggingface:
  hf_token: "..."

Training: 
  type: 'preference'

Model:
 
  epochs: 1
  eval_iters: 10
  eval_steps: 0
  save_model_path: "saved_model"
  saved_model_name: 'model.pt'


MAP:
  use_bfloat16:  False
  use_float16: False

Optimizations:
  use_compile: False


wandb:
  project_name: "SFTrainer"
  

Training Modes

Supervised Fine-tuning

trainer = SFTTrainer(model, dataset_path="classification_dataset")

Pretraining

from smolhub.scripts.pretrain import PreTrainer
trainer = PreTrainer(model, dataset_path="text_corpus")

Preference Alignment

from smolhub.scripts.align import PreferenceTrainer
trainer = PreferenceTrainer(model, dataset_path="preference_pairs")

Documentation

For detailed documentation and examples, visit our documentation.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License

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

smolhub-0.6.6.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

smolhub-0.6.6-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file smolhub-0.6.6.tar.gz.

File metadata

  • Download URL: smolhub-0.6.6.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for smolhub-0.6.6.tar.gz
Algorithm Hash digest
SHA256 9d394e8f013914043343adddc0c8a2aa57e0215be9571d865b508edcb70c2eb5
MD5 374f469041f3f4459f3b440cc59260bf
BLAKE2b-256 66aa3273773fbacc3a5689588e8199d713c162b671c2b3d366560be5c84d4bf1

See more details on using hashes here.

File details

Details for the file smolhub-0.6.6-py3-none-any.whl.

File metadata

  • Download URL: smolhub-0.6.6-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for smolhub-0.6.6-py3-none-any.whl
Algorithm Hash digest
SHA256 05744fc5f1fc23abf9277c42ae6b05ec56daf0586e23794f64089ce226ee388e
MD5 8661d9c474844a656282ae61d340facf
BLAKE2b-256 c5d542a8113d2c3add267f7d0e0918d0b9145b72f16f070a18ef6074bd5fceb7

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