ailia LLM

A library for running local LLMs. It can load GGUF and easily implement chat functionality. It also supports NPUs (QNN) for fast inference on the NPU.

Getting Started

Choose your platform and run your first local chat completion.

1

Install

Install the ailia LLM Python package from PyPI.

pip3 install ailia_llm

Haven't installed Python or git yet? Start with Setting up your Python environment (Windows / Mac / Linux).

View on PyPI
2

Run a Sample

Download example.py from ailia-models and run it. The script downloads the Gemma 4 E2B GGUF file on first run and streams a chat completion. For image input, audio input, function calling, or MTP (Multi-Token Prediction), fetch example_vlm.py, example_alm.py, example_tool_use.py, or example_mtp.py from the same folder instead.

wget https://raw.githubusercontent.com/ailia-ai/ailia-models/master/large_language_model/gemma4/example.py
python3 example.py

On Windows, use python instead of python3.

example.py example_vlm.py (image input) example_alm.py (audio input) example_tool_use.py (function calling) example_mtp.py (MTP)

System Requirements

ailia LLM runs local language models on desktop and mobile platforms. Memory requirements scale with model size and quantization.

Operating Systems

  • Windows 10 / 11
  • macOS 11 or later
  • Linux (Ubuntu 20.04+)
  • iOS 13+ / Android 7+

Languages & Compilers

  • Python 3.6+, Dart / Flutter 3.19+
  • C++17 (VS 2019+ / Xcode 14.2+ / clang)
  • C# / Unity 2021.3.10f1+
  • GPU: Metal (iOS / macOS), Vulkan (Windows)

Model Format

  • GGUF (llama.cpp compatible)
  • Llama / Gemma / Mistral / Qwen
  • Phi / DeepSeek and more
  • Q4 / Q5 / Q8 quantization

Memory Guidance

  • 2B Q4: ~2 GB RAM
  • 7B Q4: ~5 GB RAM
  • 13B Q4: ~9 GB RAM
  • Streaming token-by-token output

Use the API in Your Project

Minimal examples for streaming a chat completion in your own application.

import ailia_llm

model = ailia_llm.AiliaLLM()
model.open("gemma-4-E2B-it-Q4_K_M.gguf")

messages = [{"role": "user", "content": "あなたの名前は何ですか?"}]
for delta in model.generate(messages):
    print(delta, end="")

Advanced Usage

Guides for NPU inference, tool use, and image and audio input.

API Reference by Platform

Python

C++

Unity

Flutter

JNI

FAQ

Common questions about ailia LLM.

What model formats are supported?

ailia LLM loads GGUF files, the format used by llama.cpp. You can convert Hugging Face checkpoints to GGUF with the convert_hf_to_gguf.py script bundled with llama.cpp, or download pre-converted GGUF weights from Hugging Face.

Which model architectures are supported?

Llama, Gemma, Mistral, Qwen, Phi, DeepSeek, and other architectures supported by llama.cpp. Compatibility tracks the upstream llama.cpp project.

How do I stream tokens as they are generated?

model.generate(messages) returns an iterator that yields delta strings as the model decodes each token. Iterate over it and append to a buffer (or print directly) for streaming UX.

How much memory do I need?

Memory usage roughly equals the GGUF file size plus the KV cache and intermediate tensors. As a rule of thumb at Q4 quantization: 2B models ≈ 2 GB, 7B ≈ 5 GB, 13B ≈ 9 GB. Use smaller models or higher quantization (Q4 → Q3) on memory-constrained devices.

Does it support GPU acceleration?

Yes. ailia LLM uses Metal on iOS and macOS, and Vulkan on Windows. (Unlike ailia SDK / Speech / Voice, ailia LLM does not require cuDNN.) Inference falls back to CPU when no GPU is available. See the Vulkan Setup Guide for details.

Does it support NPU acceleration?

Yes. On supported Android and Windows on Arm devices, the QNN backend runs inference on the Hexagon NPU. A GGUF file is converted into an SoC-specific QNN Model on a PC and executed on the device. Gemma 4 E2B / E4B support text, image, and audio input, depending on the SoC. See the ailia LLM NPU (QNN) Guide for details.

Does it support VLM / ALM?

Yes. ailia LLM supports VLMs with image input and ALMs with audio input. Load a compatible model and multimodal projector, then pass images or audio with ailiaLLMSetMultimodalPrompt or ailiaLLMSetPromptJson. Check the model's capabilities with ailiaLLMGetMultimodalCapabilities. See the Multimodal Guide for details.

Does it support tool use (function calling)?

Yes. ailia LLM 1.5.0 and later support Gemma 4 function calling. Define tools with ailiaLLMSetTools and pass the JSON history with ailiaLLMSetPromptJson. After generation, retrieve the response containing tool_calls with ailiaLLMGetResponseJson, then return each result as a message with the tool role. See the ailia LLM Tool Use Guide for details.

Materials

Related Articles

Model deep dives, release notes, and tutorials from the ailia tech blog.

ailia LLM: Implement LLM on edge devices
tech.ailia.ai
Gemma 3: Local LLM with multimodal support
tech.ailia.ai
Qwen2-VL: A vision-language model that runs locally
tech.ailia.ai
Qwen-Audio: Text generation from audio input
tech.ailia.ai
KVCache: Speed up attention via caching
tech.ailia.ai
Flash Attention: Improve transformer efficiency
tech.ailia.ai