Skip to content

Full Control

For full control over training and inference, use the lower-level Python classes.

import pmetal
# Configure training components
lora_config = pmetal.LoraConfig(r=16, alpha=32.0)
training_config = pmetal.TrainingConfig(
learning_rate=2e-4,
num_epochs=3,
batch_size=4,
max_seq_len=2048,
)
# Create trainer
trainer = pmetal.Trainer(
model_id="Qwen/Qwen3-0.6B",
lora_config=lora_config,
training_config=training_config,
dataset_path="train.jsonl",
)
# Add callbacks
trainer.add_callback(pmetal.ProgressCallback())
trainer.add_callback(pmetal.LoggingCallback())
# Train
result = trainer.train()
# Load model
model = pmetal.Model.load("Qwen/Qwen3-0.6B")
# Generate
output = model.generate("Hello world", temperature=0.7)
print(output)
ClassDescription
pmetal.LoraConfigLoRA rank, alpha, target modules
pmetal.TrainingConfigLearning rate, epochs, batch size, scheduler
pmetal.GenerationConfigTemperature, top-k, top-p, max tokens
pmetal.DataLoaderConfigDataset format, sequence packing
CallbackDescription
pmetal.ProgressCallback()Progress bar display
pmetal.LoggingCallback()Console logging
pmetal.MetricsJsonCallback(path)JSONL metrics file
CustomSubclass with on_step_end(step, loss)
# Download a model
pmetal.download_model("Qwen/Qwen3-0.6B")
# Download a specific file
pmetal.download_file("Qwen/Qwen3-0.6B", "config.json")
tokenizer = pmetal.Tokenizer("Qwen/Qwen3-0.6B")
tokens = tokenizer.encode("Hello world")
text = tokenizer.decode(tokens)