Run this model with HF Jobs

Run TLDRKKU/thai-sentence 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 to fine-tune https://huggingface.co/TLDRKKU/thai-sentence. 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/TLDRKKU/thai-sentence 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/TLDRKKU/thai-sentence. 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/TLDRKKU/thai-sentence. 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.

thai-sentence β€” Thai Handwritten Sentence LoRA (Qwen2.5-VL-7B)

LoRA adapter that fine-tunes Qwen/Qwen2.5-VL-7B-Instruct to transcribe connected Thai handwriting β€” sentences, not isolated characters (experiment e5 of THIRA β€” Thai Handwriting Intelligence Recognition & Analysis).

This is the Thai recogniser selected for the THIRA production pipeline.

Model Details

  • Base model: Qwen/Qwen2.5-VL-7B-Instruct, revision cc594898137f460bfe9f0759e9844b3ce807cfb5
  • Adapter: LoRA, r=16, alpha=32, dropout=0.05
  • Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
  • Prompt used during training/inference: "Transcribe the handwritten Thai sentence in the image exactly as written. Answer with the transcription only."

Dataset

Trained on iapp/thai_handwriting_dataset (13,550 rows, single train split; the training pipeline carves its own train/val/test from it).

Evaluation

Test set N CER char F1 Exact match
burapha (Thai characters) 13,600 1.2451 0.1315 14.68%
hme (handwritten maths) 24,607 0.3428 0.7923 15.29%
thai_sentence (Thai prose) 2,032 0.1049 0.9362 38.34%
combined 38,207 0.3535 0.7817 15.07%

Findings

1. Best Thai result in the project, by a wide margin. On Thai sentences it reaches CER 0.1049 / char F1 0.9362, against e1 (BURAPHA characters) at 0.5041 and e3 (joint) at 0.6753 β€” roughly 6Γ— lower error than e3. Sentence-level training is what buys this; character-level training does not transfer to connected script.

2. The converse is also true: it is bad at isolated characters. On BURAPHA it scores CER 1.2451 β€” worse than 1.0, i.e. it emits more erroneous characters than the reference contains. A sentence model asked for a single glyph produces a sentence-shaped answer. Do not use this adapter for character-level OCR; use TLDRKKU/burapha.

3. It is not a maths reader (hme CER 0.3428). In the THIRA pipeline Thai-script regions are routed here and symbolic/mathematical regions to e3; routing beat either adapter alone on real worksheets (symbol-level CER 0.453 routed, vs 0.532 this adapter alone and 0.507 e3 alone, n=34 matched regions).

4. It flattens mathematical structure. Across 1,145 real worksheet lines, only 10.0% of this adapter's readings carry LaTeX structure, against 34.7% for e3; \\frac appears on 38 lines versus 170. That matters downstream because mathematical verification needs the structure, and character error rate cannot see it. This is the measured reason THIRA routes maths away from this adapter despite its lower headline CER.

5. Real worksheets are harder than the benchmark. On real Thai student homework the routed configuration scores symbol-level CER 0.453 (n=34 matched regions), against 0.1049 here. Treat the benchmark number as in-domain only.

How to Use

import torch
from peft import PeftModel
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor

base = Qwen2_5_VLForConditionalGeneration.from_pretrained(
    "Qwen/Qwen2.5-VL-7B-Instruct",
    revision="cc594898137f460bfe9f0759e9844b3ce807cfb5",
    torch_dtype=torch.bfloat16,
)
model = PeftModel.from_pretrained(base, "TLDRKKU/thai-sentence")

Related

  • TLDRKKU/burapha β€” BURAPHA-only Thai character LoRA (e1)
  • TLDRKKU/HMk100 β€” HME100K-only maths LoRA (e2)
  • TLDRKKU/burapha-HMk100 β€” joint adapter (e3), the selected maths recogniser
  • TLDRKKU/thai-sentence β€” Thai sentence LoRA (e5), the selected Thai recogniser

Part of THIRA β€” Thai Handwriting Intelligence Recognition & Analysis.

Downloads last month
13
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for TLDRKKU/thai-sentence

Adapter
(425)
this model

Dataset used to train TLDRKKU/thai-sentence