CoolFace
Modelpublic

protonx-models/nano-protonx-legal-tc

sourceHugging Faceupdated 10mo agoView on Hugging Face
5likes161downloads
Model Card

<div align="center">

<p align="center"> <img src="https://storage.googleapis.com/mle-courses-prod/users/61b6fa1ba83a7e37c8309756/private-files/018f9e40-d681-11f0-92ab-79af56b23c9c-GeneratedImageDecember11,2025-6_02PM.jpeg" width="260"/> </p>

<h1 align="center"> Nano Vietnamese Legal Document Correction </h1>

![GitHub](https://github.com/protonx-engineering/protonx-text-correction) ![HuggingFace](https://huggingface.co/protonx-models/nano-protonx-legal-tc) ![Website](https://protonx.co) ![Colab](https://colab.research.google.com/drive/17m37QYMG4LO6oyMdkTxNtFzQW8uWDd_-?usp=sharing)

</div>


Introduction

Nano ProtonX Legal Text Correction (v1.3-NC)

This model is a distilled version of the ProtonX Legal Text Correction

A specialized Vietnamese correction model engineered for high-accuracy OCR post-processing, especially to fix noisy PaddleOCR outputs in enterprise and legal workflows.

Best Use Case (Primary Focus): Fixing PaddleOCR text errors

<img src="https://protonx.co/assets/img/paddle-ocr-protonx.png">

The model is optimized to clean up real-world OCR mistakes such as:

  • —missing or incorrect diacritics
  • —broken word segmentation
  • —misrecognized legal terms
  • —punctuation artifacts
  • —formatting inconsistencies

Built on a Seq2Seq Transformer architecture, the model is trained on 800,000 correction pairs, including 30,000 pairs manually annotated by expert Vietnamese annotators, covering:

  • —official legal documents
  • —OCR outputs from scanned PDFs
  • —colloquial → standardized legal text

Strict constraints ensure:

  • —Correction ≠ rewriting
  • —meaning of legal text must never change
  • —no hallucination / no added legal terms
  • —confidence-based correction
  • —no paraphrasing

LICENSE

This model is released under the ProtonX Text Correction Model License (v1.3-NC).

See LICENSE.md for full terms, conditions, and usage restrictions.

Current Version: v1.3.1

Highlights

  1. 1.ROUGE-L: 96.53
  2. 2.Achieved on the ProtonX Legal Correction Validation Dataset. The evaluation dataset will be released in an upcoming public release.
  3. 3.The model is 5× smaller than the teacher model.

Quick Usage with Transformers

python
import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

model_path = "protonx-models/nano-protonx-legal-tc"

tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
model.eval()

examples = [
    "can cu bo luat lao dong 2019 va cac van ban huong dan thuc hien.",
]

for text in examples:
    inputs = tokenizer(
        text,
        return_tensors="pt",
        truncation=True,
        max_length=160
    ).to(device)

    with torch.no_grad():
        outputs = model.generate(
            **inputs,
            num_beams=10,
            max_new_tokens=160,
            length_penalty=1.0,
            early_stopping=True,
            pad_token_id=tokenizer.pad_token_id,
            eos_token_id=tokenizer.eos_token_id,
        )

    result = tokenizer.decode(outputs[0], skip_special_tokens=True)

    print(f"Input:  {text}")
    print(f"Output: {result}")
    print("-" * 30)

Benchmark

ProtonX Legal Text Correction Validation Dataset

MetricScore
ROUGE-L96.53

Training Details

  • —Model: Seq2Seq Transformer
  • —Legal-domain augmentation
  • —Beam search decoding
  • —Max sequence length: 256 tokens total (128 tokens for input and 128 tokens for output).
  • —High-precision diacritic + punctuation restoration

Domain Coverage:

  • —Government decrees
  • —Resolutions
  • —Contract clauses
  • —Administrative procedures
  • —OCR-normalized scanned documents

Example Outputs

Input:

2.Trong Lut này các tù ng dui day dugc hiéu nhur sau

Output:

2. Trong Luật này các từ ngữ dưới đây được hiểu như sau

Use Cases

  • —Legal OCR text normalization
  • —Standardizing government documents
  • —Contract proofreading
  • —Preprocessing for legal RAG systems
  • —Administrative workflow automation
  • —Compliance document processing

Limitations

  • —Does not paraphrase or rewrite legal clauses
  • —Cannot restore missing semantic content
  • —Primarily optimized for Vietnamese
  • —Not designed for informal social media slang

Future Work

  • —Achieving even higher ROUGE-L performance on legal-domain datasets
  • —Extending maximum sequence length from 128 to 1024 tokens for long-clause legal documents ---

Acknowledgments

Thanks to: