Skip to main content
Atuna Logo

A tasty layer on top of Unsloth for Large Language Model fine-tuning

Atuna: A fine-tuning assistant for large language models with built-in hyperparameter optimization.

Features

  • Easy fine-tuning with Unsloth integration for efficient training
  • Hyperparameter optimization with Optuna for automated tuning
  • Built-in evaluation and monitoring capabilities
  • TensorBoard integration for training visualization

Installation

From source (development)

git clone https://github.com/mapa17/atuna.git
cd atuna
uv sync
uv pip install -e .

Using the library

pip install atuna  # When published to PyPI

Quick Start

Basic Fine-tuning

from tuna import Tuna, TunaConfig, TrainingConfig, model_registry

# Configure your model
model = model_registry["unsloth/Qwen3-4B-Instruct-2507"]
config = TunaConfig(
    model_cfg=model,
    dataset_path="./data/training_set.csv",
    max_seq_length=2048,
    precision=16,  # Use 16-bit precision
)

# Create trainer
tuna = Tuna(config=config)

# Configure training
training_config = TrainingConfig(
    num_train_epochs=3,
    batch_size=1,
    learning_rate=5e-5,
    eval_epochs=1.0,
    enable_early_stopping=True,
)

# Train the model
result = tuna.train(config=training_config)
print(f"Training completed: {result.stop_reason}")

Hyperparameter Optimization

from tuna import Tuna, TunaConfig, TrainingConfig, HyperparpamConfig, model_registry

# Setup configuration
model = model_registry["unsloth/Qwen3-4B-Instruct-2507"]
config = TunaConfig(
    model_cfg=model,
    dataset_path="./data/training_set.csv",
    max_seq_length=2048,
    precision=4,  # Use 4-bit quantization for efficiency
)

tuna = Tuna(config=config)

# Configure training
training_config = TrainingConfig(
    num_train_epochs=2,
    eval_epochs=0.25,
    batch_size=1,
    data_sample=0.3,  # Use subset for faster experimentation
)

# Configure hyperparameter search
hyper_config = HyperparpamConfig(
    n_trials=10,
    learning_rate=[1e-5, 5e-5, 7e-5, 1e-4],
    weight_decay=[0.001, 0.01, 0.1],
    peft_r=[16, 32],
    lora_alpha=[32, 50, 64],
    enable_slora=True,
)

# Run optimization
study = tuna.hyperparam_tune(
    study_name="MyOptimization",
    train_config=training_config,
    hyper_config=hyper_config,
)

print(f"Best parameters: {study.best_trial.params}")

Model Evaluation

# Evaluate trained model
responses = tuna.evaluate_prompts([
    "What is machine learning?",
    "Explain fine-tuning in simple terms.",
])

for response in responses:
    print(f"Response: {response}")

CLI Usage

# Show version
tuna --version

# List available models
tuna --list-models

Data Format

Your training data should be a CSV file with request and response columns:

request,response
"What is Python?","Python is a programming language..."
"How does machine learning work?","Machine learning works by..."

Monitoring and Visualization

Optuna Dashboard

# View hyperparameter optimization results
optuna-dashboard sqlite:///./atuna_workspace/optuna_studies.db

TensorBoard

# View training metrics
tensorboard --logdir ./atuna_workspace/logs

Supported Models

  • unsloth/Qwen3-4B-Instruct-2507
  • unsloth/Qwen3-0.6B-GGUF

More models can be easily added to the model_registry.

Configuration Options

TunaConfig

  • model_cfg: Model configuration from registry
  • dataset_path: Path to training CSV file
  • max_seq_length: Maximum sequence length (default: 2048)
  • precision: Training precision - 4, 8, or 16 bit (default: 16)
  • peft_r: LoRA rank parameter (default: 32)
  • workspace: Working directory (default: "./atuna_workspace")

TrainingConfig

  • learning_rate: Learning rate (default: 2e-5)
  • batch_size: Batch size (default: 1)
  • num_train_epochs: Number of training epochs (default: 1.0)
  • eval_epochs: Evaluation frequency in epochs
  • enable_early_stopping: Enable early stopping (default: True)
  • data_sample: Fraction of data to use (default: 1.0)

HyperparpamConfig

  • n_trials: Number of optimization trials
  • learning_rate: List of learning rates to try
  • peft_r: List of LoRA rank values to try
  • lora_alpha: List of LoRA alpha values to try
  • weight_decay: List of weight decay values to try

Examples

See the examples/ directory for complete usage examples:

  • examples/basic_finetuning.py - Basic fine-tuning workflow
  • examples/hyperparameter_search.py - Hyperparameter optimization

Requirements

  • Python 3.12+
  • CUDA-capable GPU
  • See pyproject.toml for full dependency list

Development

# Clone repository
git clone https://github.com/mapa17/atuna.git
cd atuna

# Install development dependencies
uv sync --group dev

# Install pre-commit hooks
pre-commit install

# Run tests
pytest

# Build package
uv build

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Metadata

Release files for atuna 0.3.0

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

Source distribution (sdist)

Source distribution for atuna 0.3.0
File Size Uploaded Provenance Actions
atuna-0.3.0.tar.gz 14.8 kB With provenance Details for atuna-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 19.1 kB

Release files / atuna-0.3.0.tar.gz

Download URL atuna-0.3.0.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
36baa3678cd02f5a40a2f4bd8665627a97daaaa7cbc40594cfa785e6258397df
BLAKE2b-256 checksum
How to use checksums
cd91441a529eaaa6835a9a97d115f879d24ff59a05c9d1cdd2cf20975668639b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2025.

Transparency log

Release files / atuna-0.3.0-py3-none-any.whl

Download URL atuna-0.3.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f613ee6e5ed8001c2014db58b2aa4a9a3ee449732cbdb44286684dd565ddb27
BLAKE2b-256 checksum
How to use checksums
078b60d06263ad7860df787f2eaedf4c2d0cb24ee65a66951f4d7f971d5902eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2025.

Transparency log

Security for atuna 0.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for atuna-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2025.

Transparency log

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