[Paper Review] Document classification using a Bi-LSTM to unclog Brazil's supreme court
This paper proposes a Bidirectional Long Short-Term Memory (Bi-LSTM) network to classify Brazilian Supreme Court (STF) legal documents—specifically, 6,814 manually labeled 'peças' (legal briefs)—with 84% F1 score using only the first 1,000 tokens per document. The model processes text extracted via Tesseract OCR from raster-scanned PDFs, achieving high accuracy without preprocessing heuristics, significantly reducing manual classification time in a system clogged with 108 million pending cases.
The Brazilian court system is currently the most clogged up judiciary system in the world. Thousands of lawsuit cases reach the supreme court every day. These cases need to be analyzed in order to be associated to relevant tags and allocated to the right team. Most of the cases reach the court as raster scanned documents with widely variable levels of quality. One of the first steps for the analysis is to classify these documents. In this paper we present a Bidirectional Long Short-Term Memory network (Bi-LSTM) to classify these pieces of legal document.
Motivation & Objective
- Address the severe backlog in Brazil’s Supreme Court (STF), which handles ~42,000 cases per semester and faces a 73% congestion rate, by automating document classification.
- Reduce the time spent by judicial staff on manual classification—estimated at 22,000 man-hours per semester—by deploying machine learning on low-quality scanned documents.
- Develop a robust, end-to-end classification system for legal briefs (peças) that handles layout diversity, poor OCR quality, and noisy inputs without relying on rule-based preprocessing.
- Contribute to UN Sustainable Development Goal 16.3 by enabling equal access to justice through scalable, AI-driven legal document processing.
Proposed method
- Text extraction from PDFs using Tesseract OCR for raster images and regular expression validation for embedded text, with fallback to OCR if quality is low.
- Use of word embeddings to convert each token into a 100-dimensional distributed vector, enabling semantic representation of legal text.
- Implementation of a Bi-LSTM architecture with two 200-memory-block LSTMs (forward and backward) to capture sequential context in both directions.
- Concatenation of forward and backward LSTM outputs via summation, followed by ReLU activation and a dense layer with 6 neurons and Softmax activation for multi-class classification.
- Model input limited to the first 1,000 tokens per document, typically covering one page, to minimize OCR cost and focus on the most informative content.
- Training with 20 epochs, batch size 64, and initial learning rate 0.001 on a GPU (NVIDIA Titan XP), with inference time of 1.47ms per document.
Experimental results
Research questions
- RQ1Can a Bi-LSTM model achieve high classification accuracy on low-quality, scanned legal documents from the Brazilian Supreme Court without preprocessing?
- RQ2How effective is a model that uses only the first 1,000 tokens of a document in capturing sufficient information for accurate classification?
- RQ3Does the Bi-LSTM outperform previous methods, such as CNNs, when applied to noisy, unstructured legal text from raster PDFs?
- RQ4To what extent can end-to-end learning reduce reliance on hand-crafted rules and regular expressions in legal document classification?
Key findings
- The Bi-LSTM model achieved an F1 score of 84% on the test set, demonstrating strong performance on a challenging dataset with high within-class diversity.
- The model achieved a mean precision of 85% and mean recall of 84%, indicating balanced performance across all classes.
- The model achieved a high F1 score of 93% for the 'Sentença' (Judgment) class and 87% for 'Outros' (Others), indicating strong generalization on frequent and diverse document types.
- The model required no preprocessing heuristics or regular expressions, unlike prior CNN-based approaches, which relied on such rules to clean noisy OCR output.
- Inference time was only 1.47ms per document, significantly faster than the 5.87ms of the CNN model from prior work, excluding OCR time.
- The system reduces OCR processing to at most two pages per document, as the first 1,000 tokens are sufficient for classification, cutting computational cost.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.