--- license: apache-2.0 library_name: transformers base_model: Qwen/Qwen3.5-2B base_model_relation: finetune pipeline_tag: image-text-to-text language: [en, fr, es, sw, yo, ha, wo, ln, xh, af, rw, ny, sg] tags: [document-parsing, ocr, layout-analysis, table-recognition, vision-language, african-languages, handwriting] --- # Soma-1X Lite **A 2B Model for Document Intelligence** ![Soma-1X Lite by Amini](assets/hero.png) Soma-1X Lite is a 2-billion-parameter vision-language model developed by [Amini](https://amini.ai) for document parsing. It transforms document images into structured, machine-readable representations, preserving textual content, semantic elements, spatial information and reading order. The model combines competitive document parsing performance, multilingual transcription and efficient inference, with the flexibility to run on private infrastructure. ## Highlights - **Structured document understanding:** Joint extraction of content, semantic elements, bounding boxes and reading order, with tables in HTML and mathematical expressions in LaTeX. - **Competitive public benchmarks:** Soma-1X Lite scores 84.7 on olmOCR-Bench and 84.37 on OmniParse-Bench (OPB) in our reported evaluations. With a multi-pass inference harness that selectively reprocesses challenging document regions, the OPB score increases to 86.53. - **Multilingual transcription:** 2.90% mean character error rate across ten evaluated African languages. - **Open weights:** Released under the Apache 2.0 licence. - **Runs locally:** [GGUF builds](https://huggingface.co/AminiTech/Soma-1X-lite-GGUF) for llama.cpp and Ollama run on a single GPU or a CPU. ## Quick Start For the default system prompt and instruction, refer to [`system_prompt.txt`](system_prompt.txt) and [`user_prompt.txt`](user_prompt.txt) in this repository. ### Installation ```bash pip install -U torch torchvision transformers accelerate pillow pymupdf huggingface_hub ``` ### Inference with Hugging Face Transformers ```python import torch from PIL import Image from huggingface_hub import hf_hub_download from transformers import AutoProcessor, Qwen3_5ForConditionalGeneration MODEL_ID = "AminiTech/Soma-1X-lite" # Initialise model and processor model = Qwen3_5ForConditionalGeneration.from_pretrained( MODEL_ID, torch_dtype=torch.bfloat16, device_map="auto", ).eval() processor = AutoProcessor.from_pretrained(MODEL_ID) # The prompts the model was trained with def read_prompt(name): with open(hf_hub_download(MODEL_ID, name), encoding="utf-8") as f: return f.read() SYSTEM_PROMPT = read_prompt("system_prompt.txt") USER_PROMPT = read_prompt("user_prompt.txt") # Load a document image image = Image.open("document.png").convert("RGB") messages = [ {"role": "system", "content": SYSTEM_PROMPT}, { "role": "user", "content": [ {"type": "image", "image": image}, {"type": "text", "text": USER_PROMPT}, ], }, ] # Prepare model inputs inputs = processor.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, enable_thinking=False, return_dict=True, return_tensors="pt", ).to(model.device) # Generate structured document output with torch.inference_mode(): output_ids = model.generate( **inputs, max_new_tokens=16384, do_sample=False, ) # Decode generated tokens generated_ids = output_ids[:, inputs.input_ids.shape[1]:] output = processor.batch_decode( generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False, )[0] print(output) ``` The output is one `` per page element, in reading order: ```text FICHE D'ETAT MENSUEL Station : LOEKA - BUMBA ……
DateMax.
``` Boxes are `x0 y0 x1 y1` on a 0–1000 grid over the page image. Labels: `text`, `heading`, `caption`, `footnote`, `page_header`, `page_footer`, `annotation`, `image`, `chart`, `diagram`, `map`, `stamp`, `signature`, `table`, `equation`. ### Processing PDF Documents PDF pages can be rendered into images using PyMuPDF. ```python import fitz from PIL import Image def render_pdf_page(pdf_path, page_number=0, long_edge=1792): with fitz.open(pdf_path) as pdf: page = pdf[page_number] scale = long_edge / max( page.rect.width, page.rect.height, ) pixmap = page.get_pixmap( matrix=fitz.Matrix(scale, scale), colorspace=fitz.csRGB, alpha=False, ) return Image.frombytes( "RGB", (pixmap.width, pixmap.height), pixmap.samples, ) image = render_pdf_page("document.pdf", page_number=0) ``` ### Serving with vLLM Soma-1X Lite can be served through an OpenAI-compatible API using vLLM. ```bash pip install -U vllm openai huggingface_hub ``` Launch the inference server: ```bash vllm serve AminiTech/Soma-1X-lite \ --served-model-name soma-1x-lite \ --host 127.0.0.1 \ --port 8000 \ --dtype bfloat16 \ --tensor-parallel-size 1 \ --max-model-len 32768 \ --gpu-memory-utilization 0.90 \ --default-chat-template-kwargs '{"enable_thinking": false}' ``` Send a document parsing request using the OpenAI Python SDK: ```python import base64 from huggingface_hub import hf_hub_download from openai import OpenAI MODEL_ID = "AminiTech/Soma-1X-lite" client = OpenAI( base_url="http://localhost:8000/v1", api_key="EMPTY", ) # The prompts the model was trained with def read_prompt(name): with open(hf_hub_download(MODEL_ID, name), encoding="utf-8") as f: return f.read() SYSTEM_PROMPT = read_prompt("system_prompt.txt") USER_PROMPT = read_prompt("user_prompt.txt") with open("document.png", "rb") as f: image_base64 = base64.b64encode(f.read()).decode("utf-8") response = client.chat.completions.create( model="soma-1x-lite", messages=[ {"role": "system", "content": SYSTEM_PROMPT}, { "role": "user", "content": [ { "type": "image_url", "image_url": { "url": f"data:image/png;base64,{image_base64}" }, }, { "type": "text", "text": USER_PROMPT, }, ], }, ], temperature=0.0, max_tokens=16384, ) print(response.choices[0].message.content) ``` ### Running Locally with llama.cpp and Ollama GGUF builds of Soma-1X Lite for [llama.cpp](https://github.com/ggml-org/llama.cpp) and [Ollama](https://ollama.com), which run on a single GPU or on a CPU, are available at [AminiTech/Soma-1X-lite-GGUF](https://huggingface.co/AminiTech/Soma-1X-lite-GGUF), with setup instructions. ## Benchmark Performance We evaluated Soma-1X Lite on two public document-understanding benchmarks, olmOCR-Bench and OmniParse-Bench (OPB), alongside internal evaluations focused on multilingual transcription and inference efficiency. These evaluations assess the model's ability to accurately recognize document content, preserve complex structures and process diverse document types. ### olmOCR-Bench Soma-1X Lite scores **84.7** overall on olmOCR-Bench, which evaluates document transcription across tables, mathematical content, multi-column layouts, historical scans, and other challenging document types. ![Bar chart of olmOCR-Bench overall scores: Soma-1X Lite 84.7 among open-weight OCR models and frontier API models](assets/olmocr_bench.png) *Figure 2. Soma-1X Lite scores 84.7 on olmOCR-Bench, demonstrating competitive performance among leading open-weight OCR systems and general-purpose AI models.* *Sources: Open-weight model scores are sourced from the olmOCR-Bench leaderboard on Hugging Face. API model scores are drawn from published evaluations by Unsiloed AI (GPT-5.5), Interfaze (Claude Sonnet 5 and Gemini 3.8 Flash), and Nanonets IDP Leaderboard (GPT-5.4, Gemini 3 Pro and Claude Opus 4.6).* ### OmniParse-Bench (OPB) Soma-1X Lite scores **84.37** overall on OmniParse-Bench (OPB), which evaluates document parsing across text, table structure, and layout understanding. With a multi-pass inference harness that selectively reprocesses challenging document regions, including complex tables and rotated pages, the overall score increases to **86.53**. ![OmniParse-Bench text, tables and layout scores: raw output + benchmark adapter (80.8, 78.4, 93.9) and + multi-pass harness (81.8, 83.4, 94.4)](assets/opb_multipass.png) *Figure 3. Multi-pass inference lifts Soma-1X Lite from 84.37 to 86.53 on OmniParse-Bench, with the largest gain on tables (+5.0).* ![OmniParse-Bench overall scores: Soma-1X Lite 84.4 and Soma-1X Lite multi-pass 86.5, compared with open-weight and proprietary models](assets/opb_comparison.png) *Figure 4. Soma-1X Lite performance on OmniParse-Bench compared with open-weight and proprietary models.* ### African-language Transcription An important focus in developing Soma-1X Lite has been improving transcription across underrepresented languages, particularly those with characters and diacritics that existing document-parsing models may struggle to preserve. For example, Yoruba uses dotted letters such as ẹ, ọ and ṣ; Hausa uses hooked letters including ɓ, ɗ and ƙ; and Lingala uses open vowels ɛ and ɔ. Accurately preserving these characters is essential for faithful document transcription. We evaluated Soma-1X Lite alongside four other open-weight document-parsing models on an internal test set spanning ten African languages. Soma-1X Lite achieved the lowest mean character error rate of **2.90%**, recording the best performance among the evaluated models in seven of the ten languages. ![Character error rate across ten African languages for five models; Soma-1X Lite mean 2.90%](assets/african_cer.png) *Figure 5. Character error rate (CER) across ten African languages on 435 held-out document pages. The overall score is the mean CER across the ten languages. Lower is better.* Beyond overall transcription accuracy, we evaluated how reliably each model preserves language-specific characters. | Character category | Soma-1X Lite | dots.mocr | LightOnOCR-3-4B | Chandra 2 | Surya 2.5 | |---|---:|---:|---:|---:|---:| | Hausa hooked letters | **93%** | 0% | 5% | 43% | 60% | | Yoruba dots below | **99%** | 58% | 69% | 31% | 35% | | Lingala open vowels | **87%** | 25% | 13% | 7% | 0.2% | *Table 1. Percentage of language-specific characters correctly retained in the evaluated pages. Higher is better.* ## Structured Document Representation Soma-1X Lite jointly models the textual, spatial and semantic properties of documents within a unified representation. Each document element is associated with a semantic label, spatial coordinates and its corresponding content, while preserving reading order. *[Original document, annotated layout and structured output]* ## Training Methodology Soma-1X Lite is developed through a multi-stage training process combining supervised fine-tuning (SFT) and reinforcement learning with verifiable rewards (RLVR) using Group Relative Policy Optimisation (GRPO). Our training approach emphasises joint spatial-semantic representation, transcription fidelity and structural accuracy. To complement real-world document collections, we developed **Soma-Sim**, a programmable document generation engine that enables targeted generation of diverse document layouts, multilingual content, complex structures and challenging visual conditions with precise ground-truth annotations. ![Soma-1X Lite training pipeline: real-world documents and Soma-Sim data feed a joint spatial-semantic representation; supervised fine-tuning of the base VLM, then reinforcement learning (RLVR / GRPO) with verifiable rewards on output quality, with continuous evaluation and real-world feedback into Soma-Sim](assets/training_pipeline.png) *Overview of the Soma-1X Lite training and continuous improvement pipeline.* ## Examples Each example shows the page with numbered, colour-coded layout blocks (left) and the model's structured output for those blocks (right). ### Historical administrative records: Gold Coast Survey, 1928 Soma-1X Lite reconstructs the document's reading order and identifies typed text, handwritten annotations, stamps and signatures, preserving their positions within the original record. ![Gold Coast Survey memorandum, 1928, with detected blocks and output](assets/example_gold_coast_1928.png) *Structured document extraction from a 1928 Gold Coast administrative record. Source: British Library, Endangered Archives Programme, [EAP541](https://eap.bl.uk/project/EAP541).* ### Handwritten correspondence: government correspondence, 1927 Soma-1X Lite identifies handwritten text, administrative stamps and signatures, capturing both document content and its spatial organisation. ![Handwritten government correspondence, 1927, with detected text, stamps and signatures](assets/example_correspondence_1927.png) *Handwritten correspondence with detected text and document elements. Source: British Library, Endangered Archives Programme, [EAP541](https://eap.bl.uk/project/EAP541).* ### Printed law in Kinyarwanda: Rwanda, 1977 ![Page from Rwanda's Decree-Law No. 02/77 in Kinyarwanda, with detected blocks and output](assets/example_kinyarwanda_1977.png) *Page from Rwanda's Decree-Law No. 02/77 of 5 January 1977, printed in Kinyarwanda.* ### Colonial administrative correspondence: French Equatorial Africa, 1932 ![Covering letter from the Agence Économique de l'AEF, May 1932, with detected blocks and output](assets/example_aef_covering_letter_1932.png) *Covering letter from the Agence Économique de l'AEF to the Governor-General in Brazzaville, May 1932, with stamps and handwritten annotations. Source: Archives de l'Afrique Équatoriale Française (Brazzaville), dossier GG 535, Prospection pétrole (1932–1934).* ![Typewritten report, Paris, 24 May 1932, with detected blocks and output](assets/example_french_report_1932.png) *Typewritten report, Paris, 24 May 1932, on the publication of a 1:50,000 map of the Pointe-Noire region. Source: Archives de l'Afrique Équatoriale Française (Brazzaville), dossier GG 535, Prospection pétrole (1932–1934).* ### Newspaper: Die Afrikaanse Patriot, 1876 ![Front page of Die Afrikaanse Patriot, 1876, with detected blocks and output](assets/example_afrikaans_newspaper_1876.png) *Front page of the first issue of Die Afrikaanse Patriot, 15 January 1876, an early Afrikaans-language newspaper. Source: Genootskap van Regte Afrikaners, public domain, via [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Afrikaanse_Patriot.jpg).* ## Licence Soma-1X Lite is released under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ## Citation ```bibtex @misc{soma1xlite2026, title = {Soma-1X Lite: A 2B Model for Document Intelligence}, author = {{Amini}}, year = {2026}, url = {https://huggingface.co/AminiTech/Soma-1X-lite} } ```