~4m11:15
Ray Codes

Ternary Bonsai 2: New 0.4GB Vision AI With 310 Tokens/Sec Speed!

Oct 17, 2026

Read: ~4m · You save: 7 min

Ternary Bonsai 2: New Compact Visual AI Model 0.4 GB at 310 Tokens/s

A tiny 0.4 GB AI model runs offline, reads receipts and invoices, hides personal data, and generates 310 tokens per second. We test it on real documents.

The Tencent n 1 CI2 model, released by the Prisma LM team, is available in three versions: 2, 4, and 9 billion parameters. The versions are designed to run on consumer systems. The article examines how the model processes document images, removes personal data, and passes the cleaned data on to the downstream processing pipeline.

Key Model Characteristics

ParameterValue (per the source material)
Versions2B, 4B, 9B parameters
Working memoryless than 0.5 GB, which is 9 times less than uncompressed local versions
Context window sizemore than 250,000 tokens
Attention architecturehybrid
Generation speedmore than 300 tokens per second, up to 310 tokens per second on consumer laptops
Numerical weight statesthree
Reasoning capability retentionabout 95%
Size of quantized filesless than 1 GB

The model accepts text queries and images. The system uses flexible visual data processors to analyze all visual content.

Loading the Model

Model files are published on the official Hugging Face page. The choice of version depends on the hardware configuration:

  • for a graphics card with 2 GB of memory, the GGML files of the 2-billion-parameter version are suitable;
  • systems with greater resources can use larger versions.

In testing, 2-bit quantization was used. Additionally, the vision module file was downloaded. The download was performed in the Google Antigravity development environment using hf download commands into the local models folder.

Registering the Model in Ollama

GGML files are registered with the Ollama service using a simple custom model file. The model is given the name ternary bonsai two. To interact with it, the ollama.chat command is used with the specified model name. To install Ollama, download the free software from ollama.com/download.

Operating Mechanism

Architecture and Computation

  • Three numerical states. The model stores its full knowledge base in three values. Compressed data is not decompressed: computations are performed directly in GPU memory.
  • Addition instead of multiplication. Resource-intensive multiplication logic is excluded from the core. Computations rely on simple addition, which reduces the load on computing resources.
  • Hybrid attention architecture. Layers of standard and linear attention enable high-speed processing of long inputs.
  • Mathematical smoothing. A dedicated smoothing process handles extreme values and preserves output quality during compression.

Image Processing Module

The image processing module remains inactive until it is needed. Even when active, it occupies a small amount of memory. For text queries, the module is bypassed. The model supports dense documents and recognizes small text, numbers, and handwritten data.

Document Processing Pipeline

The script main.py performs the following actions:

  1. Reads all images from the inputs folder.
  2. Passes the images and the recognized text to Ollama along with the model name.
  3. Saves the JSON response to the outputs folder.

Request Requirements

The model is given the following task:

  • find personal data: names, contact numbers, email addresses;
  • identify payment amounts and sensitive financial data;
  • produce a response in the specified format, including:
    • a document summary;
    • a list of the redacted text indicating the hidden information;
    • a classification of all data by entity type;
    • an audit log.

Test Data

The test set included five documents:

  1. A hotel receipt.
  2. A café receipt.
  3. A company business card.
  4. A complex invoice with handwritten text and signatures.
  5. A medical prescription in a non-English language.

Результаты тестирования

Аппаратные показатели

  • Использовано 0,8 ГБ памяти видеокарты из 4 ГБ доступных.
  • Обработка пяти документов заняла 30 секунд, примерно 6 секунд на документ.

Документ 1: чек отеля

  • Отображены название отеля и адрес.
  • Имя владельца скрыто.
  • Выведены стоимость позиций, итоговая сумма и налог 7,6%. Значения 54,5 и 7,6% указаны корректно.
  • Скрыты имя сотрудника, телефон, факс и адрес электронной почты.
  • Предоставлен полный журнал скрытых данных.

Документ 2: чек кафе

  • Скрыты имена и фискальный идентификатор.
  • Указаны позиции и их стоимость.
  • Промежуточная сумма отсутствует в чеке. Модель рассчитала ее самостоятельно: 1,8 + 1,8 = 3,6, итог 3,6.
  • Идентификатор счета скрыт.
  • Предоставлен журнал аудита.

Документ 3: визитная карточка

  • Название: Sleepy Hollow Farm, специализация: морские минералы и сельское хозяйство.
  • Скрыты имена обоих владельцев и их мобильные номера.

Документ 4: исторический счет

  • Модель определила документ как счет ювелирной компании Imperial 1900 года, выставленный императору Николаю II.
  • Извлечены адрес головного офиса и сведения о частных казначейских счетах.
  • Указаны магазины компании: Санкт-Петербург, Москва и Одесса.
  • Скрыты имя клиента и номер счета.
  • Дата: 10 мая 1902 года.
  • Итоговая сумма: около 14 800 рублей.
  • Основные позиции извлечены корректно.
  • Модель пропустила часть подписей и имен.

Документ 5: медицинский рецепт

  • Модель определила документ как итальянский документ туберкулезного диспансера, описывающий протоколы госпитализации детей.
  • Название извлечено корректно.
  • Имя пациента и идентификатор протокола скрыты.
  • Дата отображена как 10 10 61. В итоговом извлечении эта дата отсутствует.
  • Текст печати извлечен, подпись скрыта.
  • Модель пропустила часть числовых данных.

Общая оценка

Модель в целом справилась с задачей. На сложных документах фиксируются пропуски отдельных данных. Обработка каждого документа заняла 5–10 секунд при полностью локальном запуске.

Benchmark Results

According to the material, the model showed the following results:

  • higher results in standard tests on elementary-school-level mathematical problems;
  • a 66% increase compared to the base model Q1;
  • retention of the ability to call external functions and system tools;
  • a significant increase in generation speed on modern laptop processors;
  • lower battery charge consumption;
  • retention of most of its capabilities for complex mathematical reasoning;
  • superiority over the base model in basic mathematics, instruction following, and programming tests;
  • retention of about 98% of the base model's intellectual capabilities in tool-calling and multimodal analysis tasks.

These results are presented in the material without independent verification.

Use Cases

  • Data anonymization. Developers use the model to remove confidential information from documents. The model runs fully offline, so customer data and details never leave the system.
  • Interactive voice response systems (IVR). The model can be used in such systems.
  • Operation on low-power hardware. The model runs on efficient processors without overheating and requires low power consumption.
  • Mobile devices. The model can read screen content and interact with applications without an internet connection.
  • Edge devices with limited memory. Quantized versions under 1 GB are suitable for standard laptops, phones, and resource-constrained devices.
  • Vision tasks. For image processing, a separate vision module is connected to the model.

Advantages and Limitations

Advantages

  • Runs on low-power hardware, including older laptops, without crashes or freezes.
  • Processes documents without cloud servers, with full control over personal data.
  • Generation speed of up to 310 tokens per second on consumer laptops.

Limitations

  • The model may produce lengthy internal reasoning. For quick answers, it is recommended to switch the model to fast-response mode.
  • The generation temperature should be set to deterministic values. This reduces the risk of repetitions and logical loops.
  • For maximum performance, a separate backend based on the llama.cpp runtime is used.
  • On complex documents, data may be omitted, including numbers, signatures, and some names.

Introduction and Model Characteristics

Presents the Ternary Bonsai 2 model and its main characteristics: small memory footprint, large context, and high speed.

  • The Tencent Ternary Bonsai 2 model was released by the PrismML team and is available in 2, 4, and 9 billion parameter versions
  • It works with multimedia input data and uses just under half a GB of working memory, roughly 9 times less than uncompressed local versions
  • The context window exceeds 250,000 tokens, and a hybrid attention scheme is used
  • Generation speed is more than 300 tokens per second
  • Only three basic numerical states are used; according to the claim, 95% of reasoning capabilities are retained

Download and Installation

Downloading a model from Hugging Face, choosing quantization, and running it via Ollama and Google Antigravity.

  • The model is downloaded from the official Hugging Face page; the choice of version depends on the hardware
  • With 2 GB of VRAM, the 2 billion parameter version in GGML format is recommended
  • The author chose 2-bit quantization and a separate file for visual capabilities
  • Downloading is done with simple HF download commands into the models folder in the Google Antigravity environment
  • The files are registered in Ollama via a simple custom model file under the name ternary bonsai two; Ollama is available for free at ollama.com/download

Architecture and Compression Mechanism

Description of the compression mechanisms and model operation: ternary weights, addition instead of multiplication, image module.

  • Heavy computations are replaced by simple addition instead of complex multiplication
  • A hybrid architecture combines standard and linear layers, which speeds up processing of long prompts
  • Computations are performed directly in the graphics card memory without unpacking compressed data
  • According to the claim, 95% of the base model's intelligence is retained while memory consumption is reduced by 88%
  • The image processing module remains inactive during text queries and takes up little space when activated

Testing on Documents

Testing the model on a set of documents: receipts, a café receipt, a business card, a complex invoice, and a prescription, with the task of removing personal data.

  • Test documents: a hotel receipt, a café receipt, a company business card, a complex invoice with handwritten signatures, and a medical prescription in a non-English language
  • Task: extract PII (names, phone numbers, emails, payment amounts, and financial data) and return the result in JSON format
  • The response includes a document summary, a list of hidden fragments, and entity categories
  • Files are read from the inputs folder and results are saved to the outputs folder via the main.py script

Results and Analysis

Analysis of the processing results for each document and comparison with the source data.

  • About 0.8 GB of VRAM used out of 4 GB available; five documents processed in about 30 seconds (around 6 seconds per document)
  • Hotel: name and address are visible, owner's name is hidden; amounts such as 54.5 and 7.6% tax were extracted correctly
  • Cafe: names and fiscal ID are hidden; the total of 3.6 was obtained by summing 1.8 and the second item
  • Business card of Sleepy Hollow Farm (sea minerals and agriculture): owners' names and mobile numbers are hidden
  • 1900 invoice from Imperial Jewelry, issued to Nicholas II: client and invoice number are hidden, date 10 May 1902, total about 14,800 rubles; signatures and some names are omitted
  • Recipe from an Italian tuberculosis sanatorium: some numbers are omitted (10 10 61), signature is hidden; the model handled it overall but not all details

Pros, Cons, and Recommendations

Summary: advantages of running locally and the model's limitations when handling long reasoning and generation settings.

  • The model can run on older laptops and smartphones; the size of quantized files is less than 1 GB
  • Documents are processed without cloud servers, which provides full control over personal data
  • The model tends to produce long internal reasoning; for quick answers, it is recommended to disable the reasoning mode
  • To prevent looping, a low temperature is recommended; for maximum speed, the llama.cpp backend can be used