Exploring Possibilities of AI-Powered Legal Assistance in Bangladesh through Large Language Modeling

Azmine Toushik Wasi, Wahid Faisal, Mst Rafia Islam, Mahathir Mohammad BappyarXiv 2024 · DOI

Abstract

The legal system in Bangladesh faces a significant backlog of over 3.7 million cases, coupled with high costs and complex jargon that hinder access to justice. This paper presents the development of GPT2-UKIL-EN, a specialized Large Language Model (LLM) fine-tuned on a custom corpus of Bangladeshi national laws (UKIL-DB-EN). Our findings indicate that smaller, domain-specific models can outperform larger general-purpose models in local legal contexts. While the model shows promise in semantic similarity and professional style, challenges regarding accuracy and "hallucinations" persist, highlighting the need for further refinement and expert oversight.

Introduction

Access to legal recourse in Bangladesh is often restricted to the wealthy, leaving millions of citizens frustrated by a system bogged down by unresolved cases and intricate procedures. While Natural Language Processing (NLP) has advanced legal technology in Western jurisdictions, these tools often lack the "jurisdiction-awareness" necessary for the specific penal codes and statutes of Bangladesh. This research addresses the critical gap by developing localized, accessible AI tools tailored for a population of 180 million.

Methodology and Dataset

The researchers adopted a "low-resource" development strategy to maximize domain specificity despite limited computational power.

UKIL-DB-EN Dataset

The study introduced UKIL-DB-EN, named after Ukil (the Bengali word for lawyer). This dataset comprises:

  • Scope: 595 Acts and approximately 18,023 sections scraped from the official Bangladesh Laws portal.
  • Structure: A hierarchical JSON format including act names, IDs, publication dates, and detailed provisions.
  • Statistics: Average acts contain 24 sections, with section details averaging 736 characters.

Model Development

The development process involved fine-tuning GPT-2 Medium using Instruction Tuning. To ensure efficiency on limited hardware, the team employed LoRA (Low-Rank Adaptation) and nf4 quantization. The model was trained using a question-and-answer format to simulate legal inquiries.

Workflow of the AI-based Legal Assistant development

Key Results

The evaluation focused on semantic similarity and expert validation.

Performance Comparison

A significant finding was that the fine-tuned GPT2-UKIL-EN (0.345B parameters) outperformed much larger models like Mistral-7b and Gemma-2b in semantic similarity to Bangladeshi legal texts.

Performance comparison of GPT2-UKIL-EN against general-purpose models

GPT2-UKIL-EN achieved a Cosine Similarity of 0.515, a substantial improvement over the base GPT-2 Medium (0.178) and superior to Mistral-7b (0.446) and Gemma-2b (0.436).

Expert Evaluation

A panel of five legal experts evaluated the model on real-world case studies (e.g., property disputes, murder charges) using a 7-point Likert scale. The model earned an average score of 4.81.

  • Highest Score: "Approach and Style" (5.58), reflecting a professional and helpful presentation.
  • Lowest Score: "Accuracy" (3.92), particularly in complex "Hard" cases requiring rigorous document verification.

Discussion and Limitations

While the results are encouraging, the study identifies several hurdles:

  • Hallucinations: The model occasionally confused specific legal authorities (e.g., mixing the Pensions Act with education amendments), indicating a struggle with deep contextual comprehension.
  • Language Constraints: The current model is English-only. Given that lower courts in Bangladesh primarily use Bangla, future iterations must be multilingual to be truly inclusive.
  • Architectural Scaling: Future work will explore larger architectures and Retrieval-Augmented Generation (RAG) to mitigate hallucinations and improve factual accuracy.

Conclusion

This research marks a foundational step toward democratizing justice in Bangladesh. By releasing the UKIL-DB-EN dataset and the GPT2-UKIL-EN model, the authors provide the community with essential building blocks for a more equitable and accessible legal future.

Summary updated

BibTeX
@misc{wasi2024exploring,
  author = {Azmine Toushik Wasi and Wahid Faisal and Mst Rafia Islam and Mahathir Mohammad Bappy},
  title = {{Exploring Possibilities of AI-Powered Legal Assistance in Bangladesh through Large Language Modeling}},
  year = {2024},
  eprint = {2410.17210},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.17210},
}
Figure