Abstract
The role of intelligent information retrieval systems in legal research optimization has become increasingly recognized. There are many methods for exhibiting advancements in the proficient retrieval of legal documents. However, those methods fail to tackle the specific challenges encountered in real-world labor law searches. This research breaks new ground in Vietnamese labor law retrieval by leveraging a comprehensive dataset of 300,000 documents across diverse categories (20 document types and 27 legal fields) to train and evaluate retrieval models specifically designed for Vietnamese labor law. Unlike previous approaches, this work goes beyond simple information retrieval. It also constructs a question & answer (Q&A) dataset specifically tailored to this legal domain. Besides, this study introduces a novel approach of incorporating a legal ontology built from the dataset itself. This knowledge infusion significantly improves retrieval performance across legal search tasks, as demonstrated through rigorous experimentation. These advancements empower intelligent systems to grasp the intricate semantic nuances of Vietnamese labor law.
Introduction
Navigating legal documents is notoriously difficult for non-experts due to "legalese"—dense, complex language that creates a significant barrier to justice. While intelligent search systems could bridge this gap, existing tools for Vietnamese law have been severely limited by data scarcity. For instance, previous benchmark datasets contained as few as 23 documents, making it nearly impossible to train modern, deep-learning-based retrieval models.
Furthermore, standard search engines often treat documents as flat text, ignoring the vital hierarchical structure (Chapters, Articles, Clauses, and Points) that defines how laws are organized and applied. This research addresses these gaps by introducing a massive legal corpus and a retrieval pipeline that respects the inherent structure of the law.
Methods
The researchers propose a "knowledge-infused" pipeline that moves beyond simple keyword matching to capture the semantic and structural nuances of legal text. The process involves three core components:
- Hierarchical Indexing: Using regex patterns and custom scrapers, the team decomposed legal documents into a nested structure. This allows the system to retrieve specific, relevant "chunks" (like a specific Clause) rather than just a massive, 50-page PDF.
- Sentence Transformers: They utilized the
Instructor-basemodel, a state-of-the-art architecture for text embeddings that can be guided by specific instructions (e.g., "Represent the legal document for retrieval"). - Two-Stage Fine-Tuning (FTS):
- Stage 1 (FTS1): The model was trained using "triplets"—a user query, a positive (correct) legal chunk, and a negative (irrelevant) chunk—using contrastive learning to align the model with legal terminology.
- Stage 2 (FTS2): To make the model even sharper, they used the Stage 1 model to find "hard negatives"—documents that look relevant but are actually incorrect. Fine-tuning on these difficult cases significantly boosted precision.
Datasets
The study introduces two major data contributions that address the historical scarcity of Vietnamese legal data:
- Large-Scale Legal Corpus: Approximately 300,000 legal normative documents crawled from the Vietnam legal library, spanning 20 document types and 27 legal fields.
- VSS Q&A Dataset: A specialized dataset of 4,368 high-quality question-and-answer pairs extracted from the Vietnam Social Security (VSS) portal. Each pair is manually labeled with specific indices (e.g.,
[Law ID] > [Chapter] > [Article]) to provide "ground truth" for training and evaluation.
Key Insights and Results
The quantitative improvements were dramatic, demonstrating the necessity of domain-specific training. Interestingly, before fine-tuning, the sophisticated Instructor-base model actually performed worse than simple TF-IDF (keyword matching), with only 9.44% accuracy compared to 52.89%. This highlights that general-purpose AI models are often "blind" to the specific nuances of legal language without domain-specific training.
By treating the table of contents and document hierarchy as an ontology, the researchers "infused" the system with the logic of the legal system itself. The jump in accuracy from FTS1 (77.65%) to FTS2 (89.12%) proves that teaching a model why a "close-but-wrong" answer is incorrect is just as important as showing it the right answer. This represents a massive improvement over prior specialized research in this field, which peaked at approximately 68% accuracy.
Conclusion and Future Work
The primary limitation acknowledged was hardware constraints. Due to limited computing resources, the researchers could only fine-tune the "base" version of the Instructor model. They speculate that fine-tuning the "Large" or "XL" versions (which have 1.5 billion parameters) would yield even higher performance.
Future work aims to incorporate Knowledge Graphs to help the system reason across different laws and to explore the use of Large Language Models (LLMs) to generate more conversational, user-friendly summaries of the retrieved legal articles.
Summary updated