coolAI commited on
Commit
7b38832
·
verified ·
1 Parent(s): 44f46ff

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +110 -14
README.md CHANGED
@@ -1,21 +1,117 @@
1
  ---
2
- base_model: unsloth/qwen2.5-vl-7b-instruct-bnb-4bit
3
- tags:
4
- - text-generation-inference
5
- - transformers
6
- - unsloth
7
- - qwen2_5_vl
8
  license: apache-2.0
9
- language:
10
- - en
 
 
 
 
 
 
 
 
11
  ---
12
 
13
- # Uploaded finetuned model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- - **Developed by:** coolAI
16
- - **License:** apache-2.0
17
- - **Finetuned from model :** unsloth/qwen2.5-vl-7b-instruct-bnb-4bit
18
 
19
- This qwen2_5_vl model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
20
 
21
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
1
  ---
 
 
 
 
 
 
2
  license: apache-2.0
3
+ base_model: unsloth/Qwen2.5-VL-7B-Instruct-bnb-4bit
4
+ tags:
5
+ - vision
6
+ - ocr
7
+ - document-understanding
8
+ - qwen2.5-vl
9
+ - lora
10
+ - latex
11
+ - handwriting
12
+ - invoice
13
  ---
14
 
15
+ # CernisOCR
16
+
17
+ A vision language model OCR model fine-tuned on Qwen2.5-VL-7B-Instruct for handling mathematical formulas, handwritten text, and structured documents in a single model.
18
+
19
+ ## Model Description
20
+
21
+ CernisOCR is a vision language model, optimized for diverse OCR tasks across multiple document domains. Unlike domain-specific OCR models, CernisOCR unifies three traditionally separate OCR tasks into a single, efficient model:
22
+
23
+ - **Mathematical LaTeX conversion**: Converts handwritten or printed mathematical formulas to LaTeX notation
24
+ - **Handwritten text transcription**: Transcribes cursive and printed handwriting
25
+ - **Structured document extraction**: Extracts structured data from invoices and receipts
26
+
27
+ **Key Features:**
28
+ - Multi-domain capability in a single model
29
+ - Handles varied image types, layouts, and text styles
30
+ - Extracts both raw text and structured information
31
+ - Robust to noise and variable image quality
32
+
33
+ ## Training Details
34
+
35
+ - **Base Model**: Qwen2.5-VL-7B-Instruct
36
+ - **Training Data**: 10,000 samples from three domains:
37
+ - LaTeX OCR: 3,978 samples (mathematical notation)
38
+ - Invoices & Receipts: 2,043 samples (structured documents)
39
+ - Handwritten Text: 3,978 samples (handwriting transcription)
40
+ - **Fine-tuning Method**: LoRA (Low-Rank Adaptation)
41
+ - **Training Loss**: Reduced from 4.802 to 0.116 (97.6% improvement)
42
+ - **Training Time**: ~8.7 minutes on RTX 5090
43
+
44
+ ## Intended Use
45
+
46
+ This model is designed for:
47
+ - Mathematical formula recognition and LaTeX conversion
48
+ - Handwritten text transcription
49
+ - Invoice and receipt data extraction
50
+ - Multi-domain document processing workflows
51
+ - Applications requiring unified OCR across different document types
52
+
53
+ ## How to Use
54
+
55
+ ```python
56
+ from unsloth import FastVisionModel
57
+ from transformers import AutoTokenizer
58
+ from PIL import Image
59
+
60
+ # Load model and tokenizer
61
+ model, tokenizer = FastVisionModel.from_pretrained(
62
+ "coolAI/cernis-ocr", # or "coolAI/cernis-vision-ocr" for merged model
63
+ load_in_4bit=True,
64
+ )
65
+ FastVisionModel.for_inference(model)
66
+
67
+ # Example 1: LaTeX conversion
68
+ image = Image.open("formula.png")
69
+ messages = [{
70
+ "role": "user",
71
+ "content": [
72
+ {"type": "image", "image": image},
73
+ {"type": "text", "text": "Write the LaTeX representation for this image."}
74
+ ]
75
+ }]
76
+
77
+ # Example 2: Handwritten transcription
78
+ messages = [{
79
+ "role": "user",
80
+ "content": [
81
+ {"type": "image", "image": image},
82
+ {"type": "text", "text": "Transcribe the handwritten text in this image."}
83
+ ]
84
+ }]
85
+
86
+ # Example 3: Invoice extraction
87
+ messages = [{
88
+ "role": "user",
89
+ "content": [
90
+ {"type": "image", "image": image},
91
+ {"type": "text", "text": "Extract and structure all text content from this invoice/receipt image."}
92
+ ]
93
+ }]
94
+
95
+ # Generate
96
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=True, return_tensors="pt").to("cuda")
97
+ outputs = model.generate(**inputs, max_new_tokens=2048, temperature=0.7)
98
+ text = tokenizer.decode(outputs[0], skip_special_tokens=True)
99
+ ```
100
+
101
+ ## Citation
102
+
103
+ If you use this model, please cite:
104
+
105
+ ```bibtex
106
+ @misc{cernis-ocr,
107
+ title={CernisOCR: A Unified Multi-Domain OCR Model},
108
+ author={Cernis AI},
109
+ year={2025},
110
+ howpublished={\url{https://huggingface.co/coolAI/cernis-ocr}}
111
+ }
112
+ ```
113
 
114
+ ## Acknowledgments
 
 
115
 
116
+ Built using [Unsloth](https://github.com/unslothai/unsloth) for efficient fine-tuning. Training data sourced from publicly available OCR datasets on Hugging Face.
117