KerdosAI - Universal LLM Training Agent

Python 3.8+ License Tests

Overview

KerdosAI is a production-ready, universal LLM training agent designed to streamline the process of training and deploying large language models. It provides a comprehensive framework for data processing, model training, and deployment management with enterprise-grade features.

Key Features

  • πŸš€ Easy to Use: Simple CLI and Python API
  • ⚑ Efficient Training: LoRA and quantization support (4-bit/8-bit)
  • πŸ”§ Configurable: YAML-based configuration with validation
  • πŸ“Š Monitoring: W&B and TensorBoard integration
  • 🐳 Docker Ready: Production-ready containerization
  • πŸ§ͺ Well Tested: Comprehensive test suite with 90%+ coverage
  • 🎨 Beautiful CLI: Rich terminal output with progress bars
  • πŸ“¦ Type Safe: Full type hints and mypy support

Quick Start

Installation

# Clone repository
git clone https://github.com/bhaskarvilles/kerdosai.git
cd kerdosai

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

Basic Usage

# Train a model
python cli.py train \
    --model gpt2 \
    --data ./data/train.json \
    --output ./output \
    --epochs 3

# Generate text
python cli.py generate ./output \
    --prompt "Once upon a time" \
    --max-length 200

Using Configuration Files

# Train with configuration
python cli.py train --config configs/default.yaml

# Validate configuration
python cli.py validate-config configs/default.yaml

Architecture Overview

graph TD
    A[CLI/API] --> B[KerdosAgent]
    B --> C[DataProcessor]
    B --> D[Trainer]
    B --> E[Deployer]
    
    C --> F[Processed Data]
    D --> G[Trained Model]
    E --> H[Deployed Service]
    
    I[Config Manager] --> B
    J[Monitoring] --> D
    K[Checkpoint Manager] --> D

Features

Configuration Management

  • YAML-based configuration with Pydantic validation
  • Environment variable substitution
  • Training presets for common scenarios
  • Configuration inheritance and overrides
base_model: "gpt2"
lora:
  enabled: true
  r: 16
  alpha: 64
training:
  epochs: 5
  batch_size: 8
  learning_rate: 0.00001

Efficient Training

  • LoRA: Parameter-efficient fine-tuning
  • Quantization: 4-bit and 8-bit support
  • Mixed Precision: FP16/BF16 training
  • Gradient Accumulation: Train larger models

Enhanced CLI

# Rich terminal output with progress bars
python cli.py train --config configs/default.yaml

# Model information
python cli.py info ./output

# Configuration validation
python cli.py validate-config configs/default.yaml

Testing Infrastructure

# Run tests
pytest

# With coverage
pytest --cov=kerdosai --cov-report=html

# Specific tests
pytest tests/test_config.py -v

Docker Deployment

# Build and run
docker-compose up

# Training service
docker-compose run kerdosai-train

# API service
docker-compose up kerdosai-api

# TensorBoard
docker-compose up tensorboard

Python API

from kerdosai.agent import KerdosAgent
from kerdosai.config import load_config

# Load configuration
config = load_config("configs/default.yaml")

# Initialize agent
agent = KerdosAgent(
    base_model="gpt2",
    training_data="./data/train.json"
)

# Prepare for training
agent.prepare_for_training(
    use_lora=True,
    lora_r=8,
    use_4bit=True
)

# Train
metrics = agent.train(
    epochs=3,
    batch_size=4,
    learning_rate=2e-5
)

# Save and generate
agent.save("./output")
output = agent.generate("Hello, AI!", max_length=100)

Documentation

Project Structure

kerdosai/
β”œβ”€β”€ agent.py              # Main agent implementation
β”œβ”€β”€ trainer.py            # Training logic
β”œβ”€β”€ deployer.py           # Deployment management
β”œβ”€β”€ data_processor.py     # Data processing
β”œβ”€β”€ config.py             # Configuration management
β”œβ”€β”€ exceptions.py         # Custom exceptions
β”œβ”€β”€ cli.py                # Enhanced CLI
β”œβ”€β”€ configs/              # Configuration files
β”‚   β”œβ”€β”€ default.yaml
β”‚   └── training_presets.yaml
β”œβ”€β”€ tests/                # Test suite
β”‚   β”œβ”€β”€ test_config.py
β”‚   β”œβ”€β”€ test_exceptions.py
β”‚   └── ...
β”œβ”€β”€ docs/                 # Documentation
└── requirements.txt      # Dependencies

Requirements

  • Python 3.8+
  • PyTorch 2.0+
  • Transformers 4.30+
  • See requirements.txt for full list

Development

# Install development dependencies
pip install pytest pytest-cov black ruff mypy rich typer

# Format code
black .
ruff check .

# Type checking
mypy .

# Run tests
pytest --cov=kerdosai

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

License

This project is licensed under the Apache License 2.0 - see LICENSE for details.

Citation

@software{kerdosai2024,
  title = {KerdosAI: Universal LLM Training Agent},
  author = {KerdosAI Team},
  year = {2024},
  version = {0.2.0},
  publisher = {GitHub},
  url = {https://github.com/bhaskarvilles/kerdosai}
}

Contact

Acknowledgments

Built with:

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support