Overview
Get started with SLM Builder in under 5 minutes.
Table of contents
Installation
Your First Model
1. Import and Initialize
2. Load Data
3. Train the Model
4. Evaluate
5. Use Your Model
6. Export
Complete Example
What’s Next?
Learn More About Features
Try More Examples
Configure Your Project
Common Issues
Import Error
CUDA Out of Memory
Model Download Fails
Need Help?
Installation
1
pip install slm-builder
For specific features:
1
2
3
4
5
# Database support
pip install slm-builder[db]
# All features
pip install slm-builder[all]
Your First Model
1. Import and Initialize
1
2
3
4
5
6
from slm_builder import SLMBuilder
builder = SLMBuilder (
project_name = "my-first-model" ,
base_model = "google/flan-t5-small"
)
2. Load Data
From a CSV file:
1
builder . load_data_from_csv ( "training_data.csv" )
Your CSV should have these columns:
question or input
answer or output
3. Train the Model
1
2
3
4
5
builder . train (
epochs = 3 ,
learning_rate = 2e-5 ,
method = "lora" # Efficient fine-tuning
)
4. Evaluate
1
2
3
metrics = builder . evaluate ()
print ( f "Accuracy: { metrics [ 'accuracy' ] : . 2 % } " )
print ( f "F1 Score: { metrics [ 'f1' ] : . 3 f } " )
5. Use Your Model
1
2
response = builder . generate ( "What is machine learning?" )
print ( response )
6. Export
1
2
3
4
5
# Export to HuggingFace format
builder . export_model ( "./output" , format = "huggingface" )
# Or export to ONNX
builder . export_model ( "./output" , format = "onnx" )
Complete Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from slm_builder import SLMBuilder
# Initialize
builder = SLMBuilder (
project_name = "qa-bot" ,
base_model = "google/flan-t5-small"
)
# Load data
builder . load_data_from_csv ( "qa_data.csv" )
# Train
builder . train (
epochs = 3 ,
learning_rate = 2e-5 ,
method = "lora" ,
batch_size = 8
)
# Evaluate
metrics = builder . evaluate ()
print ( f "✅ Model trained! Accuracy: { metrics [ 'accuracy' ] : . 2 % } " )
# Test
response = builder . generate ( "How do I install Python?" )
print ( f "Bot: { response } " )
# Export
builder . export_model ( "./qa-bot-model" , format = "huggingface" )
What’s Next?
Learn More About Features
Try More Examples
Common Issues
Import Error
1
ModuleNotFoundError : No module named 'slm_builder'
Solution : Make sure you’ve installed the package:
1
pip install slm-builder
CUDA Out of Memory
1
RuntimeError: CUDA out of memory
Solution : Reduce batch size or use CPU:
1
builder . train ( batch_size = 4 , device = "cpu" )
Model Download Fails
1
ConnectionError: Failed to download model
Solution : Check your internet connection or use a local model:
1
builder = SLMBuilder ( base_model = "/path/to/local/model" )
Need Help?