Skip to main content

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

Metadata

Release files for smolhub 0.6.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smolhub 0.6.8
File Size Uploaded Provenance
smolhub-0.6.8.tar.gz 15.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for smolhub 0.6.8
File Interpreter ABI Platform
smolhub-0.6.8-py3-none-any.whl Python 3 none any Details

Total release size: 35.6 kB

Release files / smolhub-0.6.8.tar.gz

Download URL smolhub-0.6.8.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
17c75624c6ff9f97cb0bfbc338d1c34a0092c2c13041c9acab8508f7659a019e
BLAKE2b-256 checksum
How to use checksums
7b3d2b59841b2030ac99d38ebd125e494eb8e072dffa6c946abfaab8c928a6b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / smolhub-0.6.8-py3-none-any.whl

Download URL smolhub-0.6.8-py3-none-any.whl
Size 20.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b2cc4e48ed85c81af21807b2ead65dd5a461b028b2040c541b4c85087693d91
BLAKE2b-256 checksum
How to use checksums
1c7cf54ee87c9629f5c77c4b99f7fe036304fc6b69b152085066d5c732c2dacf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Security for smolhub 0.6.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page