Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,33 +1,99 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
dtype: image
|
| 10 |
-
- name: text
|
| 11 |
-
dtype: string
|
| 12 |
-
- name: alto_xml
|
| 13 |
-
dtype: string
|
| 14 |
-
- name: has_image
|
| 15 |
-
dtype: bool
|
| 16 |
-
- name: has_alto
|
| 17 |
-
dtype: bool
|
| 18 |
-
- name: markdown
|
| 19 |
-
dtype: string
|
| 20 |
-
- name: inference_info
|
| 21 |
-
dtype: string
|
| 22 |
-
splits:
|
| 23 |
-
- name: train
|
| 24 |
-
num_bytes: 924669558
|
| 25 |
-
num_examples: 4096
|
| 26 |
-
download_size: 680802103
|
| 27 |
-
dataset_size: 924669558
|
| 28 |
-
configs:
|
| 29 |
-
- config_name: default
|
| 30 |
-
data_files:
|
| 31 |
-
- split: train
|
| 32 |
-
path: data/train-*
|
| 33 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
tags:
|
| 3 |
+
- ocr
|
| 4 |
+
- document-processing
|
| 5 |
+
- lighton-ocr
|
| 6 |
+
- markdown
|
| 7 |
+
- uv-script
|
| 8 |
+
- generated
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
+
|
| 11 |
+
# Document OCR using LightOnOCR-0.9B-32k-1025
|
| 12 |
+
|
| 13 |
+
This dataset contains OCR results from images in [NationalLibraryOfScotland/Britain-and-UK-Handbooks-Dataset](https://huggingface.co/datasets/NationalLibraryOfScotland/Britain-and-UK-Handbooks-Dataset) using LightOnOCR, a fast and compact 1B OCR model.
|
| 14 |
+
|
| 15 |
+
## Processing Details
|
| 16 |
+
|
| 17 |
+
- **Source Dataset**: [NationalLibraryOfScotland/Britain-and-UK-Handbooks-Dataset](https://huggingface.co/datasets/NationalLibraryOfScotland/Britain-and-UK-Handbooks-Dataset)
|
| 18 |
+
- **Model**: [lightonai/LightOnOCR-0.9B-32k-1025](https://huggingface.co/lightonai/LightOnOCR-0.9B-32k-1025)
|
| 19 |
+
- **Vocabulary Size**: 32k tokens
|
| 20 |
+
- **Number of Samples**: 4,096
|
| 21 |
+
- **Processing Time**: 27.8 min
|
| 22 |
+
- **Processing Date**: 2025-10-24 12:35 UTC
|
| 23 |
+
|
| 24 |
+
### Configuration
|
| 25 |
+
|
| 26 |
+
- **Image Column**: `image`
|
| 27 |
+
- **Output Column**: `markdown`
|
| 28 |
+
- **Dataset Split**: `train`
|
| 29 |
+
- **Batch Size**: 4096
|
| 30 |
+
- **Target Image Size**: 1288px (longest dimension)
|
| 31 |
+
- **Max Model Length**: 8,192 tokens
|
| 32 |
+
- **Max Output Tokens**: 6,500
|
| 33 |
+
- **Temperature**: 0.2
|
| 34 |
+
- **Top P**: 0.9
|
| 35 |
+
- **GPU Memory Utilization**: 93.0%
|
| 36 |
+
|
| 37 |
+
## Model Information
|
| 38 |
+
|
| 39 |
+
LightOnOCR is a fast, compact OCR model that excels at:
|
| 40 |
+
- β‘ **Production Speed** - 5.71 pages/second on H100 GPU
|
| 41 |
+
- π― **Compact Size** - Only 1B parameters
|
| 42 |
+
- π **LaTeX formulas** - Mathematical notation in LaTeX format
|
| 43 |
+
- π **Tables** - Extracted and formatted as markdown
|
| 44 |
+
- π **Document structure** - Hierarchy and layout preservation
|
| 45 |
+
- π **Multilingual** - Optimized for European languages
|
| 46 |
+
- π€ **Flexible vocabulary** - 151k/32k/16k token variants
|
| 47 |
+
|
| 48 |
+
### Vocabulary Variants
|
| 49 |
+
|
| 50 |
+
- **151k tokens**: Full vocabulary, supports all languages
|
| 51 |
+
- **32k tokens**: European languages optimized (~12% faster decoding)
|
| 52 |
+
- **16k tokens**: European languages optimized (~12% faster decoding)
|
| 53 |
+
|
| 54 |
+
## Dataset Structure
|
| 55 |
+
|
| 56 |
+
The dataset contains all original columns plus:
|
| 57 |
+
- `markdown`: The extracted text in markdown format with LaTeX formulas
|
| 58 |
+
- `inference_info`: JSON list tracking all OCR models applied to this dataset
|
| 59 |
+
|
| 60 |
+
## Usage
|
| 61 |
+
|
| 62 |
+
```python
|
| 63 |
+
from datasets import load_dataset
|
| 64 |
+
import json
|
| 65 |
+
|
| 66 |
+
# Load the dataset
|
| 67 |
+
dataset = load_dataset("{output_dataset_id}", split="train")
|
| 68 |
+
|
| 69 |
+
# Access the markdown text
|
| 70 |
+
for example in dataset:
|
| 71 |
+
print(example["markdown"])
|
| 72 |
+
break
|
| 73 |
+
|
| 74 |
+
# View all OCR models applied to this dataset
|
| 75 |
+
inference_info = json.loads(dataset[0]["inference_info"])
|
| 76 |
+
for info in inference_info:
|
| 77 |
+
print(f"Column: {info['column_name']} - Model: {info['model_id']}")
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
## Reproduction
|
| 81 |
+
|
| 82 |
+
This dataset was generated using the [uv-scripts/ocr](https://huggingface.co/datasets/uv-scripts/ocr) LightOnOCR script:
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
uv run https://huggingface.co/datasets/uv-scripts/ocr/raw/main/lighton-ocr.py \
|
| 86 |
+
NationalLibraryOfScotland/Britain-and-UK-Handbooks-Dataset \
|
| 87 |
+
<output-dataset> \
|
| 88 |
+
--vocab-size 32k \
|
| 89 |
+
--image-column image \
|
| 90 |
+
--batch-size 4096
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
## Performance
|
| 94 |
+
|
| 95 |
+
- **Processing Speed**: ~2.46 images/second
|
| 96 |
+
- **Benchmark Score**: 76.1% overall (across diverse document types)
|
| 97 |
+
- **Optimization**: Native resolution ViT + lightweight decoder
|
| 98 |
+
|
| 99 |
+
Generated with π€ [UV Scripts](https://huggingface.co/uv-scripts)
|