Overview

Get started with SLM Builder in under 5 minutes.

Table of contents

  1. Installation
  2. Your First Model
    1. 1. Import and Initialize
    2. 2. Load Data
    3. 3. Train the Model
    4. 4. Evaluate
    5. 5. Use Your Model
    6. 6. Export
  3. Complete Example
  4. What’s Next?
    1. Learn More About Features
    2. Try More Examples
    3. Configure Your Project
  5. Common Issues
    1. Import Error
    2. CUDA Out of Memory
    3. Model Download Fails
  6. 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']:.3f}")

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

Configure Your Project


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?


Back to top

Copyright © 2025 SLM Builder. Distributed under the MIT License.