Image-Text-to-Text
Transformers
Safetensors
qwen3_5
document-parsing
ocr
layout-analysis
table-recognition
vision-language
african-languages
handwriting
conversational
Instructions to use AminiTech/Soma-1X-lite with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AminiTech/Soma-1X-lite with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="AminiTech/Soma-1X-lite") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("AminiTech/Soma-1X-lite") model = AutoModelForMultimodalLM.from_pretrained("AminiTech/Soma-1X-lite", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AminiTech/Soma-1X-lite with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AminiTech/Soma-1X-lite" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AminiTech/Soma-1X-lite", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/AminiTech/Soma-1X-lite
- SGLang
How to use AminiTech/Soma-1X-lite with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "AminiTech/Soma-1X-lite" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AminiTech/Soma-1X-lite", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "AminiTech/Soma-1X-lite" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AminiTech/Soma-1X-lite", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use AminiTech/Soma-1X-lite with Docker Model Runner:
docker model run hf.co/AminiTech/Soma-1X-lite
|
Download README.md from AminiTech/Soma-1X-lite: direct link, hf CLI and curl.
- Browser
- Download file 15.3 kB
-
https://huggingface.co/AminiTech/Soma-1X-lite/resolve/main/README.md
- Command line
-
hf download hf://AminiTech/Soma-1X-lite/README.md
-
curl -L -o README.md https://huggingface.co/AminiTech/Soma-1X-lite/resolve/main/README.md
15.3 kB
| 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 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 `<block>` per page element, in reading order: | |
| ```text | |
| <block label="heading" box="405 29 571 43">FICHE D'ETAT MENSUEL</block> | |
| <block label="text" box="783 25 916 39">Station : LOEKA - BUMBA</block> | |
| <block label="table" box="58 82 943 942"><table><tr><th>Date</th><th>Max.</th>…</tr>…</table></block> | |
| <block label="signature" box="829 944 871 965"></block> | |
| ``` | |
| 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. | |
|  | |
| *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**. | |
|  | |
| *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).* | |
|  | |
| *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. | |
|  | |
| *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. | |
|  | |
| *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. | |
|  | |
| *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 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 of 5 January 1977, printed in Kinyarwanda.* | |
| ### Colonial administrative correspondence: French Equatorial Africa, 1932 | |
|  | |
| *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, 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 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} | |
| } | |
| ``` | |