Metadata-Version: 2.4
Name: fatg
Version: 0.1.1
Summary: Finnish Adaptive Tiered Generation — hardware-adaptive LLM inference for Finnish language learning content
Project-URL: Homepage, https://github.com/Misha-17/fatg
Project-URL: Repository, https://github.com/Misha-17/fatg
Project-URL: Issues, https://github.com/Misha-17/fatg/issues
Author-email: Shivansh Singh <shivansh@example.com>
License: MIT License
        
        Copyright (c) 2026 Shivansh Singh
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: adaptive,apple-silicon,finnish,inference,language-learning,llm,nlp,ollama
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27.0
Provides-Extra: all
Requires-Dist: libvoikko>=3.0; extra == 'all'
Requires-Dist: psutil>=5.9.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: hatch>=1.9; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Provides-Extra: psutil
Requires-Dist: psutil>=5.9.0; extra == 'psutil'
Provides-Extra: voikko
Requires-Dist: libvoikko>=3.0; extra == 'voikko'
Description-Content-Type: text/markdown

# FATG — Finnish Adaptive Tiered Generation

Hardware-adaptive LLM inference framework for Finnish language learning content.
Runs on **Apple Silicon** (M1/M2/M3), **NVIDIA GPUs**, and **CPU-only** machines
via [Ollama](https://ollama.com) — no cloud, no API keys, no cost.

Built for [Lingo Deck](https://github.com/Wirlaa/LingoDeck) — a Finnish language
learning card game.

## Features

- **Auto hardware detection** — detects M1/NVIDIA/CPU and picks the right model
- **Tiered generation** — tiny model for simple content, medium model for complex
- **Finnish morphological validation** — catches hallucinated inflections before they reach users
- **Structured JSON output** — Ollama's JSON mode ensures parseable responses every time
- **Optional voikko integration** — full spell/grammar checking if libvoikko is installed
- **Zero cloud dependency** — everything runs locally

## Requirements

- Python 3.10+
- [Ollama](https://ollama.com) running locally (`ollama serve`)

## Install

```bash
pip install fatg
```

With voikko support (recommended for production):
```bash
pip install fatg[voikko]
# macOS: brew install libvoikko
# Ubuntu: sudo apt install libvoikko-dev voikko-fi
```

## Quick Start

```python
import asyncio
from fatg import FATGEngine

async def main():
    # Auto-detects hardware, pulls model if needed
    engine = await FATGEngine.create()

    # See what hardware was detected
    print(engine.hardware)
    # Backend: apple_silicon | RAM: 16.0GB | Recommended: qwen2.5:7b (medium)

    # Generate a quest question
    q = await engine.generate_quest_question(
        target_word="kahvia",
        scenario="cafe_order",
        difficulty=0.1,
    )

    print(q.question_fi)
    # "Haluaisin kupillisen ...., kiitos."

    print(q.question_en)
    # "I would like a cup of ...., please."

    print(q.options)
    # ["kahvia", "teetä", "vettä", "maitoa"]  (shuffled)

    print(q.validation.score)
    # 0.9

asyncio.run(main())
```

## KELA Boss Fight (LLM-generated questions from deck)

```python
deck = [
    {"word_fi": "tukea"},
    {"word_fi": "hakemusta"},
    {"word_fi": "liitteitä"},
]

questions = await engine.generate_kela_questions(deck)
for q in questions:
    print(q.question_fi)
    print(q.options)
```

## Hardware Performance

| Hardware | Model | Speed | 100-token response |
|---|---|---|---|
| M1 Air 8GB | phi3.5:3.8b | ~25 tok/s | ~4s |
| M1 Air 16GB | qwen2.5:7b | ~14 tok/s | ~7s |
| RTX 3060 6GB | phi3.5:3.8b | ~35 tok/s | ~3s |
| RTX 3060 8GB | qwen2.5:7b | ~45 tok/s | ~2s |
| CPU only | qwen2.5:1.5b | ~8 tok/s | ~12s |

## Config

```python
from fatg import FATGEngine, FATGConfig

config = FATGConfig(
    ollama_host="http://localhost:11434",
    verify_model="phi3.5:3.8b",   # override auto-selection
    temperature=0.7,
    max_retries=3,
    enable_finnish_validation=True,
)

engine = await FATGEngine.create(config=config)
```

## Scenarios

| Scenario | Description |
|---|---|
| `cafe_order` | Ordering at a Finnish café |
| `job_interview` | Job interview in Finnish |
| `asking_directions` | Asking for directions |
| `kela_boss` | KELA bureaucratic Finnish (hardest) |
| `general` | No specific context |

## License

MIT
