Update README.md
Browse files
README.md
CHANGED
|
@@ -24,12 +24,12 @@ tags:
|
|
| 24 |
---
|
| 25 |
|
| 26 |
<div align="center">
|
| 27 |
-
<img src="lightonocr-banner.png" alt="LightOnOCR-2-1B
|
| 28 |
</div>
|
| 29 |
|
| 30 |
-
# LightOnOCR-2-1B
|
| 31 |
|
| 32 |
-
**
|
| 33 |
|
| 34 |
## Highlights
|
| 35 |
|
|
@@ -84,8 +84,8 @@ from transformers import LightOnOcrForConditionalGeneration, LightOnOcrProcessor
|
|
| 84 |
device = "mps" if torch.backends.mps.is_available() else "cuda" if torch.cuda.is_available() else "cpu"
|
| 85 |
dtype = torch.float32 if device == "mps" else torch.bfloat16
|
| 86 |
|
| 87 |
-
model = LightOnOcrForConditionalGeneration.from_pretrained("lightonai/LightOnOCR-2-1B
|
| 88 |
-
processor = LightOnOcrProcessor.from_pretrained("lightonai/LightOnOCR-2-1B
|
| 89 |
|
| 90 |
url = "https://huggingface.co/datasets/hf-internal-testing/fixtures_ocr/resolve/main/SROIE-receipt.jpeg"
|
| 91 |
|
|
@@ -111,7 +111,7 @@ print(output_text)
|
|
| 111 |
## Usage with vLLM
|
| 112 |
|
| 113 |
```bash
|
| 114 |
-
vllm serve lightonai/LightOnOCR-2-1B
|
| 115 |
--limit-mm-per-prompt '{"image": 1}' --mm-processor-cache-gb 0 --no-enable-prefix-caching
|
| 116 |
```
|
| 117 |
|
|
@@ -122,7 +122,7 @@ import pypdfium2 as pdfium
|
|
| 122 |
import io
|
| 123 |
|
| 124 |
ENDPOINT = "http://localhost:8000/v1/chat/completions"
|
| 125 |
-
MODEL = "lightonai/LightOnOCR-2-1B
|
| 126 |
|
| 127 |
# Download PDF from arXiv
|
| 128 |
pdf_url = "https://arxiv.org/pdf/2412.13663"
|
|
@@ -171,12 +171,13 @@ print(text)
|
|
| 171 |
|
| 172 |
## Fine-tuning
|
| 173 |
|
| 174 |
-
LightOnOCR-2
|
| 175 |
|
| 176 |
* LoRA fine-tuning
|
| 177 |
* Domain adaptation (receipts, scientific articles, forms, etc.)
|
| 178 |
* Multilingual fine-tuning with task-specific corpora
|
| 179 |
-
|
|
|
|
| 180 |
|
| 181 |
---
|
| 182 |
|
|
|
|
| 24 |
---
|
| 25 |
|
| 26 |
<div align="center">
|
| 27 |
+
<img src="lightonocr-banner.png" alt="LightOnOCR-2-1B Banner" width="600"/>
|
| 28 |
</div>
|
| 29 |
|
| 30 |
+
# LightOnOCR-2-1B
|
| 31 |
|
| 32 |
+
**Best OCR model (recommended).** LightOnOCR-2-1B is our flagship OCR model, refined with RLVR training for maximum accuracy. We recommend this variant for most OCR tasks.
|
| 33 |
|
| 34 |
## Highlights
|
| 35 |
|
|
|
|
| 84 |
device = "mps" if torch.backends.mps.is_available() else "cuda" if torch.cuda.is_available() else "cpu"
|
| 85 |
dtype = torch.float32 if device == "mps" else torch.bfloat16
|
| 86 |
|
| 87 |
+
model = LightOnOcrForConditionalGeneration.from_pretrained("lightonai/LightOnOCR-2-1B", torch_dtype=dtype).to(device)
|
| 88 |
+
processor = LightOnOcrProcessor.from_pretrained("lightonai/LightOnOCR-2-1B")
|
| 89 |
|
| 90 |
url = "https://huggingface.co/datasets/hf-internal-testing/fixtures_ocr/resolve/main/SROIE-receipt.jpeg"
|
| 91 |
|
|
|
|
| 111 |
## Usage with vLLM
|
| 112 |
|
| 113 |
```bash
|
| 114 |
+
vllm serve lightonai/LightOnOCR-2-1B \
|
| 115 |
--limit-mm-per-prompt '{"image": 1}' --mm-processor-cache-gb 0 --no-enable-prefix-caching
|
| 116 |
```
|
| 117 |
|
|
|
|
| 122 |
import io
|
| 123 |
|
| 124 |
ENDPOINT = "http://localhost:8000/v1/chat/completions"
|
| 125 |
+
MODEL = "lightonai/LightOnOCR-2-1B"
|
| 126 |
|
| 127 |
# Download PDF from arXiv
|
| 128 |
pdf_url = "https://arxiv.org/pdf/2412.13663"
|
|
|
|
| 171 |
|
| 172 |
## Fine-tuning
|
| 173 |
|
| 174 |
+
LightOnOCR-2 is fully differentiable and supports:
|
| 175 |
|
| 176 |
* LoRA fine-tuning
|
| 177 |
* Domain adaptation (receipts, scientific articles, forms, etc.)
|
| 178 |
* Multilingual fine-tuning with task-specific corpora
|
| 179 |
+
|
| 180 |
+
For fine-tuning, we recommend starting with the **[LightOnOCR-2-1B-base](https://huggingface.co/lightonai/LightOnOCR-2-1B-base)** variant.
|
| 181 |
|
| 182 |
---
|
| 183 |
|