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.0.tar.gz (13.3 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.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fatg-0.1.0.tar.gz
  • Upload date:
  • Size: 13.3 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.0.tar.gz
Algorithm Hash digest
SHA256 56ed82f333005db79cd043635a687fa9eeb3a6af96cb30d82d2150bd80b64874
MD5 9cc7c5fcbf4e88c1db74f132b4e2c656
BLAKE2b-256 3d1d24c435c75e150349064783a68b00c60c07ebe03bdc6ad4c25f53bcfd1250

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fatg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2078cda24dcd139c799fecf31bbd922bd4d56f7f76605cc2c661c78774673db8
MD5 a4e2cd593b450ef61906ba5b9b49e151
BLAKE2b-256 48dfacc668025ed9bee868e0009defa5bab32ceebb405c534b0395335df2c320

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