Image-Text-to-Text
Transformers
Safetensors
English
Thai
qwen2_5_vl
OCR
vision-language
document-understanding
multilingual
conversational
text-generation-inference
Instructions to use typhoon-ai/typhoon-ocr-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use typhoon-ai/typhoon-ocr-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="typhoon-ai/typhoon-ocr-7b") 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("typhoon-ai/typhoon-ocr-7b") model = AutoModelForMultimodalLM.from_pretrained("typhoon-ai/typhoon-ocr-7b", 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 typhoon-ai/typhoon-ocr-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "typhoon-ai/typhoon-ocr-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "typhoon-ai/typhoon-ocr-7b", "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/typhoon-ai/typhoon-ocr-7b
- SGLang
How to use typhoon-ai/typhoon-ocr-7b 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 "typhoon-ai/typhoon-ocr-7b" \ --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": "typhoon-ai/typhoon-ocr-7b", "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 "typhoon-ai/typhoon-ocr-7b" \ --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": "typhoon-ai/typhoon-ocr-7b", "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 typhoon-ai/typhoon-ocr-7b with Docker Model Runner:
docker model run hf.co/typhoon-ai/typhoon-ocr-7b
update_readme2
Browse files4 unmodified lines567891011121314151617181920212223242526274 unmodified lines- thbase_model:- Qwen/Qwen2.5-VL-7B-Instruct---Typhoon OCR is an open-source, bilingual document parsing model built specifically for real-world documents in Thai and English. Inspired by models like olmOCR, Typhoon OCR introduces a redesigned architecture that is:Robust to noisy inputs and complex, irregular layoutsMultilingual, with dedicated support for both Thai and EnglishLayout-aware, preserving the document’s structural integrity in its outputUnlike conventional OCR tools, Typhoon OCR doesn't just extract raw text—it produces semantic, structured, and layout-preserving outputs that are optimized for downstream tasks such as:Retrieval-Augmented Generation (RAG)Comprehensive document parsing and understandingAccurate interpretation of tables, charts, and forms4 unmodified lines567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768694 unmodified lines- thbase_model:- Qwen/Qwen2.5-VL-7B-Instructtags:- OCR---**Typhoon-OCR-7B**: A bilingual document parsing model built specifically for real-world documents in Thai and English inspired by models like olmOCR.## **Model Description**- **Model type**: A 7B Vision-Language Models (VLMs) model based on Qwen2.5-VL-Instruction.- **Requirement**: transformers 4.50.0 or newer.- **Primary Language(s)**: Thai 🇹🇭 and English 🇬🇧- **License**:## **Real-World Document Support****1. Structured Documents**: Financial reports, Academic papers, Books, Government forms**Output format**:- Markdown for general text- HTML for tables (including merged cells and complex layouts)- Figures, charts, and diagrams are represented using figure tags for structured visual understanding**Each figure undergoes multi-layered interpretation**:- **Observation**: Detects elements like landscapes, buildings, people, logos, and embedded text- **Context Analysis**: Infers context such as location, event, or document section- **Text Recognition**: Extracts and interprets embedded text (e.g., chart labels, captions) in Thai or English- **Artistic & Structural Analysis**: Captures layout style, diagram type, or design choices contributing to document tone- **Final Summary**: Combines all insights into a structured figure description for tasks like summarization and retrieval**2. Layout-Heavy & Informal Documents**: Receipts, Menus papers, Tickets, Infographics**Output format**:- Markdown with embedded tables and layout-aware structures## Summary of FindingsTyphoon OCR outperforms both GPT-4o and Gemini 2.5 Flash in Thai document understanding, particularly on documents with complex layouts and mixed-language content.However, in the Thai books benchmark, performance slightly declined due to the high frequency and diversity of embedded figures. These images vary significantly in type and structure, which poses challenges for our current figure tag parsing. This highlights a potential area for future improvement—specifically, in enhancing the model's image understanding capabilities.For this version, our primary focus has been on achieving high-quality OCR for both English and Thai text. Future releases may extend support to more advanced image analysis and figure interpretation.## Usage Example## **Citation**- If you find Typhoon2 useful for your work, please cite it using:```@misc{typhoon2,title={Typhoon 2: A Family of Open Text and Multimodal Thai Large Language Models},author={Kunat Pipatanakul and Potsawee Manakul and Natapong Nitarach and Warit Sirichotedumrong and Surapon Nonesung and Teetouch Jaknamon and Parinthapat Pengpun and Pittawat Taveekitworachai and Adisai Na-Thalang and Sittipong Sripaisarnmongkol and Krisanapong Jirayoot and Kasima Tharnpipitchai},year={2024},eprint={2412.13702},archivePrefix={arXiv},primaryClass={cs.CL},url={https://arxiv.org/abs/2412.13702},}```
README.md+50-8