sealior-modernbert-vi-exam-seq-labeling
Production-grade token classification and sequence labelling model fine-tuned from aisingapore/SEA-LION-ModernBERT-300M on the comprehensive Vietnamese Exam Sequence Labelling Dataset v3.
Designed for granular structural extraction from Vietnamese educational examinations (grades 8–12 across Math, Physics, Chemistry, Biology, History, Geography, Literature, and English), supporting both scanned and digital documents with Zero Character Mutation guarantee.
Model Architecture
- Base Encoder:
aisingapore/SEA-LION-ModernBERT-300M(Multilingual ModernBERT, 8192 max context, unpad flash attention) - Classification Head:
EnhancedBertForTokenClassificationfeaturing:- SigmoidWeightedLayerPooling: 4-layer sigmoid-gated layer pooling replacing competing softmax
- 1D Depthwise Convolutional Refinement:
kernel_size=7capturing local boundary n-grams - Multi-Sample Dropout (MSD):
[0.05, 0.10, 0.15, 0.20, 0.25]
- Context Length: Trained with dynamic multi-scale windows (
768,1024,1536,2048) withLengthGroupedBatchSampler.
Entity Schema (7 Core Examination Entities)
The model performs token-level sequence labelling using standard BIO tagging:
| Entity Tag | Description | Example |
|---|---|---|
QUESTION_LABEL | Question prefix and numbering | Câu 1:, Question 20., Bài 3: |
STEM | Main question prompt or problem statement | Cho hàm số $y=f(x)$... |
OPTION_LABEL | Multiple-choice identifier | A., B., C., D. |
OPTION_TEXT | Content text of the choice | x = 2, increase rapidly |
STIMULUS | Shared reading comprehension text, poem, or stimulus passage | Reading passages, dialogues, texts |
SECTION | Examination headers, directions, and instructions | PHẦN I. TRẮC NGHIỆM, Read the following... |
EXPLANATION | Detailed solutions, answer keys, or scoring barems | Lời giải: Áp dụng định lý... |
Architectural Invariants
- Stemless Cloze Questions: Full support for cloze / fill-in questions where
<question_label>directly precedes<option_label>without an explicit<stem>. - Zero Character Mutation Guarantee: Sequence labeling and XML reconstruction wrap tags directly around input substrings with 0% character deletion, alteration, or hallucination.
Evaluation Results (Gold Benchmark Test Set)
Evaluated on the strictly isolated 4-tier Gold Benchmark (51 pristine real exam documents, ~458k tokens):
| Metric | Score |
|---|---|
| Validation Macro F1 | 82.93% |
| Precision | 79.36% |
| Recall | 86.83% |
| Micro F1 | 82.93% |
Checkpoint synced at Epoch 8/8.
Quickstart & Usage
1. Installation
pip install torch transformers huggingface_hub
2. Python Inference
import torch
from transformers import AutoTokenizer
from model.module.head import EnhancedBertForTokenClassification
from model.inference.predict import predict_text, load_label_mapping
repo_id = "daominhwysi/sealior-modernbert-vi-exam-seq-labeling"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(repo_id)
tag_to_id, id_to_tag = load_label_mapping(repo_id)
model = EnhancedBertForTokenClassification.from_pretrained(
repo_id,
num_labels=len(tag_to_id),
id2label=id_to_tag,
label2id=tag_to_id
).to(device)
text = """
Read the following passage and mark the letter A, B, C or D on your answer sheet.
Digital tools help modern students collaborate more effectively across borders.
Question 1: What do digital tools help students do?
A. Play games
B. Collaborate effectively
C. Avoid homework
D. Work alone
"""
res = predict_text(text, model=model, tokenizer=tokenizer, id_to_tag=id_to_tag, device=device)
print(res["xml_text"])
Output:
<section>Read the following passage and mark the letter A, B, C or D on your answer sheet.</section>
<stimulus>Digital tools help modern students collaborate more effectively across borders.</stimulus>
<question_label>Question 1:</question_label> <stem>What do digital tools help students do?</stem>
<option_label>A.</option_label> <option_text>Play games</option_text>
<option_label>B.</option_label> <option_text>Collaborate effectively</option_text>
<option_label>C.</option_label> <option_text>Avoid homework</option_text>
<option_label>D.</option_label> <option_text>Work alone</option_text>
Training Details
- Dataset:
daominhwysi/synthetic-seq-labelling-vi-exam-v2(776 documents, 5.2M tokens, 90k multi-scale sliding chunks). - Optimizer: AdamW (Learning Rate:
3e-05) with Linear Warmup and Cosine Decay. - Batch Size:
4 - Sequence Length:
None - License: Apache 2.0