--- language: - vi library_name: transformers tags: - SemViQA - question-answering - fact-checking - information-retrieval pipeline_tag: question-answering license: mit --- # SemViQA-QATC: Vietnamese Question Answering Token Classifier ## Model Description **SemViQA-QATC** is a component of the **SemViQA** system, fine-tuned from Vi-MRC to perform **Extractive Question Answering (QA)** and **evidence extraction** for fact-checking in Vietnamese. ### **Model Information** - **Developed by:** [SemViQA Research Team](https://huggingface.co/SemViQA) - **Fine-tuned model:** [Vi-MRC](https://huggingface.co/nguyenvulebinh/vi-mrc-large) - **Supported Language:** Vietnamese - **Task:** Extractive QA, Evidence Extraction - **Dataset:** [ViWikiFC](https://arxiv.org/abs/2405.07615) QATCForQuestionAnswering utilizes XLM-RoBERTa as a pre-trained language model. We further enhance it by incorporating a Token Classification mechanism, allowing the model to not only predict answer spans but also classify tokens as part of the rationale selection process. During training, we introduce Rationale Regularization Loss, which consists of sparsity and continuity constraints to encourage more precise and interpretable token-level predictions. This loss function ensures that the model effectively learns to identify relevant rationale tokens while maintaining coherence in token selection. ## Usage Example Direct Model Usage ```python # Install semviqa !pip install semviqa # Initalize a pipeline from transformers import AutoTokenizer from semviqa.ser.qatc_model import QATCForQuestionAnswering import torch tokenizer = AutoTokenizer.from_pretrained("SemViQA/qatc-vimrc-viwikifc") model = QATCForQuestionAnswering.from_pretrained("SemViQA/qatc-vimrc-viwikifc") claim = "Chiến tranh với Campuchia đã kết thúc trước khi Việt Nam thống nhất." context = "Sau khi thống nhất, Việt Nam tiếp tục gặp khó khăn do sự sụp đổ và tan rã của đồng minh Liên Xô cùng Khối phía Đông, các lệnh cấm vận của Hoa Kỳ, chiến tranh với Campuchia, biên giới giáp Trung Quốc và hậu quả của chính sách bao cấp sau nhiều năm áp dụng. Năm 1986, Đảng Cộng sản ban hành cải cách đổi mới, tạo điều kiện hình thành kinh tế thị trường và hội nhập sâu rộng. Cải cách đổi mới kết hợp cùng quy mô dân số lớn đưa Việt Nam trở thành một trong những nước đang phát triển có tốc độ tăng trưởng thuộc nhóm nhanh nhất thế giới, được coi là Hổ mới châu Á dù cho vẫn gặp phải những thách thức như tham nhũng, tội phạm gia tăng, ô nhiễm môi trường và phúc lợi xã hội chưa đầy đủ. Ngoài ra, giới bất đồng chính kiến, chính phủ một số nước phương Tây và các tổ chức theo dõi nhân quyền có quan điểm chỉ trích hồ sơ nhân quyền của Việt Nam liên quan đến các vấn đề tôn giáo, kiểm duyệt truyền thông, hạn chế hoạt động ủng hộ nhân quyền cùng các quyền tự do dân sự." inputs = tokenizer(claim, context, return_tensors="pt", truncation=True, max_length=512) with torch.no_grad(): outputs = model(**inputs) start_logits = outputs.start_logits end_logits = outputs.end_logits start_idx = torch.argmax(start_logits) end_idx = torch.argmax(end_logits) tokens = inputs["input_ids"][0][start_idx : end_idx + 1] evidence = tokenizer.decode(tokens, skip_special_tokens=True) print(evidence) # evidence: Sau khi thống nhất, Việt Nam tiếp tục gặp khó khăn do sự sụp đổ và tan rã của đồng minh Liên Xô cùng Khối phía Đông, các lệnh cấm vận của Hoa Kỳ, chiến tranh với Campuchia, biên giới giáp Trung Quốc và hậu quả của chính sách bao cấp sau nhiều năm áp dụng. ``` Using TF-IDF and QATC Combination with Confidence Threshold ```python import torch from transformers import AutoTokenizer from semviqa.ser.qatc_model import QATCForQuestionAnswering from semviqa.ser.ser_eval import extract_evidence_tfidf_qatc device = torch.device("cuda" if torch.cuda.is_available() else "cpu") tokenizer = AutoTokenizer.from_pretrained("SemViQA/qatc-vimrc-viwikifc") model = QATCForQuestionAnswering.from_pretrained("SemViQA/qatc-vimrc-viwikifc").to(device) claim = "Chiến tranh với Campuchia đã kết thúc trước khi Việt Nam thống nhất." context = "Sau khi thống nhất, Việt Nam tiếp tục gặp khó khăn do sự sụp đổ và tan rã của đồng minh Liên Xô cùng Khối phía Đông, các lệnh cấm vận của Hoa Kỳ, chiến tranh với Campuchia, biên giới giáp Trung Quốc và hậu quả của chính sách bao cấp sau nhiều năm áp dụng. Năm 1986, Đảng Cộng sản ban hành cải cách đổi mới, tạo điều kiện hình thành kinh tế thị trường và hội nhập sâu rộng. Cải cách đổi mới kết hợp cùng quy mô dân số lớn đưa Việt Nam trở thành một trong những nước đang phát triển có tốc độ tăng trưởng thuộc nhóm nhanh nhất thế giới, được coi là Hổ mới châu Á dù cho vẫn gặp phải những thách thức như tham nhũng, tội phạm gia tăng, ô nhiễm môi trường và phúc lợi xã hội chưa đầy đủ. Ngoài ra, giới bất đồng chính kiến, chính phủ một số nước phương Tây và các tổ chức theo dõi nhân quyền có quan điểm chỉ trích hồ sơ nhân quyền của Việt Nam liên quan đến các vấn đề tôn giáo, kiểm duyệt truyền thông, hạn chế hoạt động ủng hộ nhân quyền cùng các quyền tự do dân sự." evidence = extract_evidence_tfidf_qatc( claim, context, model, tokenizer, device, confidence_threshold=0.5, length_ratio_threshold=0.6 ) print(evidence) # evidence: sau khi thống nhất việt nam tiếp tục gặp khó khăn do sự sụp đổ và tan rã của đồng minh liên xô cùng khối phía đông các lệnh cấm vận của hoa kỳ chiến tranh với campuchia biên giới giáp trung quốc và hậu quả của chính sách bao cấp sau nhiều năm áp dụng ``` ## **Evaluation Results**
Method ViWikiFC
ER VC Strict Acc VC Acc ER Acc Time (s)
TF-IDF InfoXLMlarge 75.56 82.21 90.15 131
XLM-Rlarge 76.47 82.78 90.15 134
Ernie-Mlarge 75.56 81.83 90.15 144
BM25 InfoXLMlarge 70.44 79.01 83.50 130
XLM-Rlarge 70.97 78.91 83.50 132
Ernie-Mlarge 70.21 78.29 83.50 141
SBert InfoXLMlarge 74.99 81.59 89.72 195
XLM-Rlarge 75.80 82.35 89.72 194
Ernie-Mlarge 75.13 81.44 89.72 203
QA-based approaches VC
ViMRClarge InfoXLMlarge 77.28 81.97 92.49 3778
XLM-Rlarge 78.29 82.83 92.49 3824
Ernie-Mlarge 77.38 81.92 92.49 3785
InfoXLMlarge InfoXLMlarge 78.14 82.07 93.45 4092
XLM-Rlarge 79.20 83.07 93.45 4096
Ernie-Mlarge 78.24 82.21 93.45 4102
LLM
Qwen2.5-1.5B-Instruct 51.03 65.18 78.96 7665
Qwen2.5-3B-Instruct 44.38 62.31 71.35 12123
LLM VC
Qwen2.5-1.5B-Instruct InfoXLMlarge 66.14 76.47 78.96 7788
XLM-Rlarge 67.67 78.10 78.96 7789
Ernie-Mlarge 66.52 76.52 78.96 7794
Qwen2.5-3B-Instruct InfoXLMlarge 59.88 72.50 71.35 12246
XLM-Rlarge 60.74 73.08 71.35 12246
Ernie-Mlarge 60.02 72.21 71.35 12251
SER Faster (ours) TVC (ours)
TF-IDF + ViMRClarge Ernie-Mlarge 79.44 82.93 94.60 410
TF-IDF + InfoXLMlarge Ernie-Mlarge 79.77 83.07 95.03 487
SER (ours) TVC (ours)
TF-IDF + ViMRClarge InfoXLMlarge 80.25 83.84 94.69 2731
XLM-Rlarge 80.34 83.64 94.69 2733
Ernie-Mlarge 79.53 82.97 94.69 2733
TF-IDF + InfoXLMlarge InfoXLMlarge 80.68 83.98 95.31 3860
XLM-Rlarge 80.82 83.88 95.31 3843
Ernie-Mlarge 80.06 83.17 95.31 3891
**SemViQA-QATC** plays a crucial role in the **SemViQA** system by enhancing accuracy in evidence extraction. When integrated into a pipeline, this model helps determine whether a claim is supported or refuted based on retrieved evidence. ## **Citation** If you use **SemViQA-QATC** in your research, please cite: ```bibtex @misc{nguyen2025semviqasemanticquestionanswering, title={SemViQA: A Semantic Question Answering System for Vietnamese Information Fact-Checking}, author={Nam V. Nguyen and Dien X. Tran and Thanh T. Tran and Anh T. Hoang and Tai V. Duong and Di T. Le and Phuc-Lu Le}, year={2025}, eprint={2503.00955}, archivePrefix={arXiv}, primaryClass={cs.CL}, url={https://arxiv.org/abs/2503.00955}, } ``` 🔗 **Paper Link:** [SemViQA on arXiv](https://arxiv.org/abs/2503.00955) 🔗 **Source Code:** [GitHub - SemViQA](https://github.com/DAVID-NGUYEN-S16/SemViQA) ## About *Built by Dien X. Tran* [![LinkedIn](https://img.shields.io/badge/LinkedIn-Profile-blue?logo=linkedin)](https://www.linkedin.com/in/xndien2004/) For more details, visit the project repository. [![GitHub stars](https://img.shields.io/github/stars/DAVID-NGUYEN-S16/SemViQA?style=social)](https://github.com/DAVID-NGUYEN-S16/SemViQA)