Skip to main content

Finnish Adaptive Tiered Generation — hardware-adaptive LLM inference for Finnish language learning content

Project description

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 — no cloud, no API keys, no cost.

Built for Lingo Deck — 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 running locally (ollama serve)

Install

pip install fatg

With voikko support (recommended for production):

pip install fatg[voikko]
# macOS: brew install libvoikko
# Ubuntu: sudo apt install libvoikko-dev voikko-fi

Quick Start

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)

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fatg-0.1.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fatg-0.1.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file fatg-0.1.1.tar.gz.

File metadata

  • Download URL: fatg-0.1.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for fatg-0.1.1.tar.gz
Algorithm Hash digest
SHA256 465eefb5fe169f3a0570c1c64de990d96593d48ad1b19368d9fa93054d855d2e
MD5 d48fd25bb7c05fdf34e5588fd7ae2c00
BLAKE2b-256 e4c7208bc8f24a5cabc0d37c742619db217f73cc544e2b36b51f3ed8eed0797d

See more details on using hashes here.

File details

Details for the file fatg-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fatg-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for fatg-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fbb52ac6f7dd2cb16043d786ed05a4fd99b36835a1c472390825f5bdb64d27e0
MD5 fb4456a4d9889150340c40bb727018c1
BLAKE2b-256 0d8b993d8b8e817808695d0de7f18e8a251ca6efa97d5ed07d27a40927801d57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page