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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smolhub-0.6.7.tar.gz.
File metadata
- Download URL: smolhub-0.6.7.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82daacec31fec867dd92d14b0ca875470b01087da02c35ff5c941832510478fc
|
|
| MD5 |
89350be0e5a816afe72dbdf02747901c
|
|
| BLAKE2b-256 |
32878e91f7056d37714844f5b85436fd79eaf0369abe655044a2c171010e45b1
|
File details
Details for the file smolhub-0.6.7-py3-none-any.whl.
File metadata
- Download URL: smolhub-0.6.7-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1068c95e7f9eef3f5decc033d6e56eadc9759f2ca4d5cc7a2f503dbf0dc6732
|
|
| MD5 |
8025ed144ddfaa8aa44beba73cb74615
|
|
| BLAKE2b-256 |
cf11e45d4d9398477373b4b894f9e5277dea6ef1351536329cf348ebd2e30340
|