Image-Text-to-Text
Transformers
Safetensors
English
qwen2_5_vl
text-generation-inference
unsloth
conversational
Run this model with HF Jobs
Run cernis-intelligence/cernis-thinking on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/cernis-intelligence/cernis-thinking. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/cernis-intelligence/cernis-thinking on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/cernis-intelligence/cernis-thinking. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/cernis-intelligence/cernis-thinking. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use cernis-intelligence/cernis-thinking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cernis-intelligence/cernis-thinking with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="cernis-intelligence/cernis-thinking") 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("cernis-intelligence/cernis-thinking") model = AutoModelForMultimodalLM.from_pretrained("cernis-intelligence/cernis-thinking", 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 cernis-intelligence/cernis-thinking with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cernis-intelligence/cernis-thinking" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cernis-intelligence/cernis-thinking", "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/cernis-intelligence/cernis-thinking
- SGLang
How to use cernis-intelligence/cernis-thinking 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 "cernis-intelligence/cernis-thinking" \ --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": "cernis-intelligence/cernis-thinking", "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 "cernis-intelligence/cernis-thinking" \ --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": "cernis-intelligence/cernis-thinking", "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" } } ] } ] }' - Unsloth Desktop
- Docker Model Runner
How to use cernis-intelligence/cernis-thinking with Docker Model Runner:
docker model run hf.co/cernis-intelligence/cernis-thinking
Update README.md
Browse files7 unmodified lines891011121314151617181920217 unmodified lineslicense: apache-2.0language:- en---# Uploaded finetuned model- **Developed by:** coolAI- **License:** apache-2.0- **Finetuned from model :** unsloth/qwen2.5-vl-7b-instruct-unsloth-bnb-4bitThis qwen2_5_vl model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)7 unmodified lines891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182197 unmodified lineslicense: apache-2.0language:- endatasets:- AI4Math/MathVista- unsloth/LaTeX_OCR- mychen76/invoices-and-receipts_ocr_v1- corto-ai/handwritten-text---# Cernis-Thinking: Multi-Task Vision Language Model for Document Understanding**Cernis-Thinking** is a reasoning-capable vision language model fine-tuned with reinforcement learning (GRPO/GSPO) for document understanding tasks. Built on Qwen2.5-VL-7B, it excels at mathematical reasoning, LaTeX OCR, invoice extraction, and handwriting transcription.## Model Details- **Base Model**: [Qwen2.5-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct)- **Training Method**: Group Relative Policy Optimization (GRPO) with GSPO extensions- **Training Data**: ~2,000 samples across 4 document understanding tasks- **Model Size**: 7B parameters- **License**: Apache 2.0## CapabilitiesCernis-Thinking is trained on four distinct document understanding tasks:1. **Mathematical Reasoning** - Solves math problems from images with step-by-step reasoning2. **LaTeX OCR** - Converts mathematical notation images to LaTeX code3. **Invoice Extraction** - Extracts structured information from invoices and receipts4. **Handwriting Transcription** - Transcribes handwritten text from images## Training Details### Datasets- [AI4Math/MathVista](https://huggingface.co/datasets/AI4Math/MathVista) - Mathematical reasoning (filtered for numeric answers)- [unsloth/LaTeX_OCR](https://huggingface.co/datasets/unsloth/LaTeX_OCR) - LaTeX formula recognition- [mychen76/invoices-and-receipts_ocr_v1](https://huggingface.co/datasets/mychen76/invoices-and-receipts_ocr_v1) - Invoice extraction- [corto-ai/handwritten-text](https://huggingface.co/datasets/corto-ai/handwritten-text) - Handwriting transcription### Reinforcement Learning ApproachThe model was trained using GRPO (Group Relative Policy Optimization) with custom reward functions:**1. Formatting Reward Function**- Rewards proper use of `<REASONING>` and `<SOLUTION>` tags- Penalizes malformed outputs (e.g., excessive "addCriterion" artifacts)- Encourages structured, parseable responses**2. Task-Specific Correctness Reward**- **Math**: Exact numeric matching (2.0 points)- **LaTeX/Handwriting**: String similarity with word overlap scoring (0.75-2.0 points)- **Invoices**: Partial credit for extracting key information (1.5 points)**3. ROUGE-like Word Overlap**- For text-heavy tasks, rewards based on word overlap ratio:- >50% overlap: 1.5 points- >30% overlap: 0.75 points- Prevents wasted training on completely wrong outputs### Training Configuration```pythontraining_args = GRPOConfig(learning_rate = 5e-6,num_train_epochs = 0.5,per_device_train_batch_size = 1,gradient_accumulation_steps = 2,num_generations = 4,max_prompt_length = 1024,max_completion_length = 1024,# GSPO settingsimportance_sampling_level = "sequence",loss_type = "dr_grpo",)```## Usage### With Transformers```pythonfrom transformers import Qwen2VLForConditionalGeneration, AutoProcessorfrom PIL import Image# Load model and processormodel = Qwen2VLForConditionalGeneration.from_pretrained("coolAI/cernis-thinking",torch_dtype="auto",device_map="auto")processor = AutoProcessor.from_pretrained("coolAI/cernis-thinking")# Prepare image and promptimage = Image.open("document.jpg")messages = [{"role": "user","content": [{"type": "image"},{"type": "text", "text": "Extract the key information from this invoice. First provide your reasoning between <REASONING> and </REASONING>, then your answer between <SOLUTION> and </SOLUTION>"}]}]# Prepare inputstext = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = processor(text=[text], images=[image], return_tensors="pt", padding=True).to(model.device)# Generateoutput_ids = model.generate(**inputs, max_new_tokens=1024)generated_text = processor.batch_decode(output_ids, skip_special_tokens=True)print(generated_text[0])```### With vLLM (Recommended for Production)```pythonfrom vllm import LLM, SamplingParamsfrom vllm.assets.image import ImageAsset# Initialize vLLMllm = LLM(model="coolAI/cernis-thinking",max_model_len=16384,gpu_memory_utilization=0.8)# Prepare promptprompt = "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>What is the LaTeX code shown in this image? Provide your answer between <SOLUTION> and </SOLUTION><|im_end|>\n<|im_start|>assistant\n"# Sampling parameterssampling_params = SamplingParams(temperature=0.7,top_k=50,max_tokens=1024)# Generateoutputs = llm.generate({"prompt": prompt,"multi_modal_data": {"image": ImageAsset("formula.png").pil_image}},sampling_params=sampling_params)print(outputs[0].outputs[0].text)```## Example Outputs### Mathematical Reasoning**Input**: Image of geometry problem**Output**:```<REASONING>To solve this parallelogram problem, I need to use the properties:1. Opposite sides are equal in a parallelogram2. Angle bisectors create specific relationships...</REASONING><SOLUTION>42</SOLUTION>```### LaTeX OCR**Input**: Image of mathematical formula**Output**:```<SOLUTION>\frac{2}{3} < a^{2} \alpha^{2} \leq 1</SOLUTION>```### Invoice Extraction**Input**: Invoice image**Output**:```<SOLUTION>Invoice No: 53553822Date: 07/24/2012Vendor: Leo BrownSeller Address: 082 Christopher Club Apt. 771 Thomasberg, OH 42949Seller Tax ID: 926-74-9803Total: $247.50</SOLUTION>```## Citation```bibtex@misc{cernis-thinking-2025,title={Cernis-Thinking: Multi-Task Vision Language Model for Document Understanding},author={Your Name},year={2025},publisher={HuggingFace},howpublished={\url{https://huggingface.co/coolAI/cernis-thinking}}}```## Acknowledgments- Built with [Unsloth](https://github.com/unslothai/unsloth) for efficient VLM training- Base model: [Qwen2.5-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct)- Training datasets: AI4Math, Unsloth, mychen76, corto-ai## LicenseApache 2.0 - Free for commercial and research use
README.md+204-6