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.8.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.8-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: smolhub-0.6.8.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.8.tar.gz
Algorithm Hash digest
SHA256 17c75624c6ff9f97cb0bfbc338d1c34a0092c2c13041c9acab8508f7659a019e
MD5 fa464ffcca1c50b7723d82992d143d90
BLAKE2b-256 7b3d2b59841b2030ac99d38ebd125e494eb8e072dffa6c946abfaab8c928a6b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smolhub-0.6.8-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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6b2cc4e48ed85c81af21807b2ead65dd5a461b028b2040c541b4c85087693d91
MD5 bcca943bd3afeafa15125bfff8d8de49
BLAKE2b-256 1c7cf54ee87c9629f5c77c4b99f7fe036304fc6b69b152085066d5c732c2dacf

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