OCR/Text β†’ SLM β€” Financial-Statement Page Classifier (synthetic, 5-class + metadata)

A LoRA adapter on Qwen-2.5-1.5B-Instruct that reads the OCR text of one page from a financial report and returns a JSON object that both classifies the page into one of five statement types and extracts its metadata. It is the text-based counterpart to an image-based vision page classifier (the scan β†’ OCR β†’ SLM route), trained/evaluated on synthetic pages as an in-distribution capability check.

Model Details

Model Description

  • Developed by: Sudith Amarasinghe @ H2O.ai
  • Model type: LoRA adapter (PEFT) for a causal LM; page classification + metadata extraction via constrained JSON generation
  • Language(s): English
  • License: apache-2.0 (same as the base model)
  • Finetuned from model: Qwen/Qwen2.5-1.5B-Instruct

Model Sources

  • Repository:

Uses

Direct Use

Given the OCR text of a financial-statement page, predict a single JSON object:

{"statement_type": "balance_sheet", "primary_entity": "...", "closing_date": "YYYY-MM-DD",
 "duration": "as_at|year_ended|quarter|half_year", "output_fields": ["Total Assets", ...],
 "continuing_page_flag": false}
statement_type ∈ {balance_sheet, income_statement, cash_flow, changes_in_equity,
other}. Useful for classifying statement pages and pulling key header/total fields.

Out-of-Scope Use
Trained on synthetic pages only β€” it is a capability check, not a
production/real-world model. Use the real-data 3-class adapter for generalization to
actual filings.

Bias, Risks, and Limitations
In-distribution: train and eval come from the same synthetic generator, so metrics reflect learned structure, not real-world generalization.
English, single-page inputs; assumes reasonable OCR quality.
Small (1.5B) model.
Recommendations
Do not rely on synthetic-only metrics for real documents; evaluate on real, source-disjoint
pages (see the companion real-data adapter) before any production use.

How to Get Started with the Model

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import json, re

repo = "SudithH2O/ocr-slm-synthetic-qwen1.5b"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct").eval()
model = PeftModel.from_pretrained(model, repo)

SYSTEM = ('You are a financial-document analyst. You are shown one page from a financial '
          'report. Classify the page and extract its metadata.\n\n'
          'Respond with a single JSON object and nothing else, using exactly these keys:\n'
          '  "statement_type": one of "balance_sheet", "income_statement", "cash_flow", '
          '"changes_in_equity", "other".\n'
          '  "primary_entity": the company/entity name, or null.\n'
          '  "closing_date": the reporting/closing date as YYYY-MM-DD, or null.\n'
          '  "duration": one of "as_at", "year_ended", "quarter", "half_year", or null.\n'
          '  "output_fields": a list of the key total/subtotal line labels on the page.\n'
          '  "continuing_page_flag": true if this page continues a statement from a '
          'previous page, else false.\n\n'
          'If the page is not one of the four statements, use "other" and set the '
          'financial fields to null / empty as appropriate.')

def analyze(page_text):
    msgs = [{"role": "system", "content": SYSTEM},
            {"role": "user", "content": page_text}]
    prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
    ids = tok(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
    out = model.generate(**ids, max_new_tokens=200, do_sample=False)
    text = tok.decode(out[0, ids["input_ids"].shape[1]:], skip_special_tokens=True)
    return json.loads(re.search(r"\{.*\}", text, re.S).group())
Training Details
Training Data
Synthetic financial-statement pages generated with internally-consistent numbers
(ReportLab β†’ PNG), then OCR'd with Tesseract back into text (deliberately including OCR
noise). Labels: 5 statement types + metadata fields. Trained on 500 pages.

Training Procedure
Preprocessing
Each example is a chat: system instruction + OCR page text β†’ the label JSON.

Training Hyperparameters
LoRA: r=16, alpha=16, dropout=0, target=all-linear, task=CAUSAL_LM (~1.18% params trained)
Objective: completion-only SFT (loss on the JSON target only)
Optimizer: AdamW, lr 2e-4, cosine schedule, 2 epochs, batch 2 Γ— grad-accum 4, max_len 2048
Training regime: bf16, gradient checkpointing
Hardware: Apple Silicon (MPS); ~30 min
Evaluation
Testing Data & Metrics
Held-out synthetic val split (n=200), same generator as training (in-distribution).
Metrics: statement-type accuracy, macro-F1, JSON-validity, and per-field accuracy.

Results
accuracy	macro-F1	JSON-validity	closing_date	duration	continuing_page_flag
1.000	1.000	1.000	1.000	1.000	1.000
Per-class F1 = 1.00 for all four statement types; confusion matrix is perfectly diagonal.
This matches (marginally exceeds) the Gemma-4 vision model's 0.993 on the same synthetic
task β€” i.e., on synthetic data the text route is on par with vision.

Summary
In-distribution, the fine-tuned text SLM classifies statement type and extracts metadata
essentially perfectly, and reliably emits valid JSON. This establishes capability; the
real-data adapter measures generalization.

Technical Specifications
Model Architecture and Objective
LoRA adapters over Qwen-2.5-1.5B-Instruct; trained to generate the label+metadata JSON.

Framework versions
PEFT 0.19.1
Transformers 5.x
Downloads last month
18
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for SudithH2O/ocr-slm-synthetic-qwen1.5b

Adapter
(1,791)
this model