HiCoBERT: a hierarchical transformer-based framework for Pakistan legal judgment section segmentation with multi-level XAI insights

In many jurisdictions, legal judgments are written as long continuous narratives in which the functional progression of facts, issues, reasoning, and decision is expressed implicitly rather than through explicit section boundaries. Although recent advances in Transformer-based language models and large language models have significantly improved automated text analysis, these models still struggle with long judicial documents. Standard architectures encode documents as flat token sequences, do not explicitly model dependencies between discourse segments, and are constrained by input token limits, making it difficult to capture the ordered functional structure underlying judicial decisions. To address this limitation, we propose HiCoBERT, a hierarchically contextualized Transformer framework for segmenting functional sections in legal judgments. The model represents a judgment as an ordered sequence of contiguous text segments (fixed-length chunks). It first encodes intra-segment semantics and then models document-level dependencies across segments. This hierarchical design captures the logical flow of judicial decisions, enabling the efficient processing of lengthy judicial documents. Experiments on LeJA, a dataset of Supreme Court of Pakistan judgments curated for this study, show that the proposed framework achieves 0.80 accuracy, 0.70 macro-F1, and 0.79 span-F1, outperforming strong long-document baselines including Longformer, BigBird, and LongT5, as well as structured models such as LegalBERT + CRF. Additional comparisons with modern prompted LLMs (GPT-4o, Gemini Pro, DeepSeek-V3) further contextualize the performance. Cross-dataset evaluation on LegalSeg, a publicly available benchmark of annotated Indian legal judgments, demonstrates robustness under jurisdiction shift, while explainability analyses highlight the importance of hierarchical contextualization.

Authors

Institutions

Publication Details

Journal
Scientific Reports
Published
2026-04-07
DOI
https://doi.org/10.1038/s41598-026-45259-w
Primary Topic
Artificial Intelligence in Law
Type
article
Field-Weighted Citation Impact
0.00

Funders

Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

HiCoBERT: a hierarchical transformer-based framework for Pakistan legal judgment section segmentation with multi-level XAI insights

Khalid Mahmood Awan, Shahid Kamal, Zahoor-Ur Rehman, Maryam Bibi
Scientific Reports
Artificial Intelligence in Law
article

HiCoBERT: a hierarchical transformer-based framework for Pakistan legal judgment section segmentation with multi-level XAI insights

Khalid Mahmood Awan, Shahid Kamal, Zahoor-Ur Rehman, Maryam Bibi
article en

Abstract

In many jurisdictions, legal judgments are written as long continuous narratives in which the functional progression of facts, issues, reasoning, and decision is expressed implicitly rather than through explicit section boundaries. Although recent advances in Transformer-based language models and large language models have significantly improved automated text analysis, these models still struggle with long judicial documents. Standard architectures encode documents as flat token sequences, do not explicitly model dependencies between discourse segments, and are constrained by input token limits, making it difficult to capture the ordered functional structure underlying judicial decisions. To address this limitation, we propose HiCoBERT, a hierarchically contextualized Transformer framework for segmenting functional sections in legal judgments. The model represents a judgment as an ordered sequence of contiguous text segments (fixed-length chunks). It first encodes intra-segment semantics and then models document-level dependencies across segments. This hierarchical design captures the logical flow of judicial decisions, enabling the efficient processing of lengthy judicial documents. Experiments on LeJA, a dataset of Supreme Court of Pakistan judgments curated for this study, show that the proposed framework achieves 0.80 accuracy, 0.70 macro-F1, and 0.79 span-F1, outperforming strong long-document baselines including Longformer, BigBird, and LongT5, as well as structured models such as LegalBERT + CRF. Additional comparisons with modern prompted LLMs (GPT-4o, Gemini Pro, DeepSeek-V3) further contextualize the performance. Cross-dataset evaluation on LegalSeg, a publicly available benchmark of annotated Indian legal judgments, demonstrates robustness under jurisdiction shift, while explainability analyses highlight the importance of hierarchical contextualization.

Scientific ReportsVol. 16(1)
COMSATS University Islamabad (PK), Multimedia University (MY)
Multimedia University
Peace, Justice and strong institutions
Openalex Percentile: Top 28%
Artificial Intelligence in Law
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.