hg-codes/INLP-Project-26

Course project for INLP 26

Jupyter Notebook

1

24 commits

updated Apr 10, 2026

See the code

README

Juris-Clarify (INLP-Project-26)

Course Project for INLP 26 A verifiable, multi-stage NLP pipeline for legal text simplification.

πŸ”— View Pipeline Outputs (All Stages)

Overview

Juris-Clarify translates complex legal contracts into accessible language while formally guaranteeing semantic faithfulness. Unlike standard generative LLMs, our Writer-Critic architecture prevents "semantic drift" by explicitly extracting constraints and verifying outputs using Natural Language Inference (NLI).

Pipeline Architecture

The system is divided into five modular stages:

  • Stage 1: Hierarchical Clause Segmentation Uses LegalBERT and a Conditional Random Field (CRF) to detect clause boundaries and structural metadata.
  • Stage 2: Constraint Extraction Identifies core entities (Dates, Money, Parties) and legal obligations to prevent hallucination during rewriting.
  • Stage 3: Constraint-Aware Rewriting A fine-tuned BART model generates simplified text while explicitly preserving the constraints extracted in Stage 2.
  • Stage 4: NLI Verification Loop A DeBERTa-v3 critic checks if the simplified text logically entails the original. If not, it rejects the text and triggers regeneration.
  • Stage 5: Persona Adaptation A prompt-tuned Flan-T5 model adapts the verified text to match the reading levels of specific audiences (Layperson, Student, or Professional).

Results Folder Structure

results/kaggle/working
β”œβ”€β”€ exp1  (Stage 1)
β”‚Β Β  β”œβ”€β”€ best_model
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ config.json              # Model configuration settings
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ model.pt
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ tokenizer_config.json    # Tokenizer configuration settings
β”‚Β Β  β”‚Β Β  └── tokenizer.json           # Serialized tokenizer vocabulary
β”‚Β Β  β”œβ”€β”€ best_threshold.json          # Optimal threshold computed for predictions
β”‚Β Β  β”œβ”€β”€ data
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test.jsonl               # Stage 1 formatted test split
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ train.jsonl              # Stage 1 formatted train split
β”‚Β Β  β”‚Β Β  └── val.jsonl                # Stage 1 formatted validation split
β”‚Β Β  └── test_results.json            # Model evaluation results on the test data
β”œβ”€β”€ stage1_predictions
β”‚Β Β  β”œβ”€β”€ predicted_test.jsonl         # Model predictions on test subset
β”‚Β Β  β”œβ”€β”€ predicted_train.jsonl        # Model predictions on train subset
β”‚Β Β  └── predicted_val.jsonl          # Model predictions on validation subset
β”œβ”€β”€ stage2_output
β”‚Β Β  β”œβ”€β”€ checkpoints
β”‚Β Β  β”‚Β Β  └── best_model
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ constraint_config.json # Stage 2 model configuration
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ constraint_model.pt
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ tokenizer_config.json
β”‚Β Β  β”‚Β Β      └── tokenizer.json
β”‚Β Β  β”œβ”€β”€ demo_output.json             # Sample demonstration outputs from Stage 2
β”‚Β Β  β”œβ”€β”€ eval_metrics.json            # Quantitative metrics for the Stage 2 model
β”‚Β Β  β”œβ”€β”€ final_model
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ constraint_config.json
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ constraint_model.pt
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ tokenizer_config.json
β”‚Β Β  β”‚Β Β  └── tokenizer.json
β”‚Β Β  β”œβ”€β”€ test_constraints.json        # Test data with constraint pairs 
β”‚Β Β  β”œβ”€β”€ train_constraints.json       # Training data with constraint pairs
β”‚Β Β  β”œβ”€β”€ training_history.json        # Epoch-wise training and validation logs
β”‚Β Β  └── val_constraints.json         # Validation data with constraint pairs
β”œβ”€β”€ stage3_output
β”‚Β Β  β”œβ”€β”€ evaluation_metrics.json      # Evaluation metrics from simplification
β”‚Β Β  β”œβ”€β”€ simplified_test_clauses.json # Stage 3 text simplification results
β”‚Β Β  β”œβ”€β”€ synthetic_pairs.json         # Synthetic positive/negative pairs generated for Stage 3
β”‚Β Β  └── training_history.json        # Stage 3 epoch-wise progress logs
β”œβ”€β”€ stage4_output
β”‚Β Β  β”œβ”€β”€ human_review_queue.json          # Simplifications flagged by NLI that require human review
β”‚Β Β  β”œβ”€β”€ stage4_evaluation_metrics.json   # Efficacy metrics post-NLI correction loop
β”‚Β Β  └── stage4_simplified_clauses.json   # Refined simplifications fully conforming to NLI entailment
└── stage5_output
    └── persona_targets.json         # Final output mapped to user-specific personas

hg-codes/INLP-Project-26

Course project for INLP 26

Jupyter Notebook

1

24 commits

updated Apr 10, 2026

See the code

README

Juris-Clarify (INLP-Project-26)

Course Project for INLP 26 A verifiable, multi-stage NLP pipeline for legal text simplification.

πŸ”— View Pipeline Outputs (All Stages)

Overview

Juris-Clarify translates complex legal contracts into accessible language while formally guaranteeing semantic faithfulness. Unlike standard generative LLMs, our Writer-Critic architecture prevents "semantic drift" by explicitly extracting constraints and verifying outputs using Natural Language Inference (NLI).

Pipeline Architecture

The system is divided into five modular stages:

  • Stage 1: Hierarchical Clause Segmentation Uses LegalBERT and a Conditional Random Field (CRF) to detect clause boundaries and structural metadata.
  • Stage 2: Constraint Extraction Identifies core entities (Dates, Money, Parties) and legal obligations to prevent hallucination during rewriting.
  • Stage 3: Constraint-Aware Rewriting A fine-tuned BART model generates simplified text while explicitly preserving the constraints extracted in Stage 2.
  • Stage 4: NLI Verification Loop A DeBERTa-v3 critic checks if the simplified text logically entails the original. If not, it rejects the text and triggers regeneration.
  • Stage 5: Persona Adaptation A prompt-tuned Flan-T5 model adapts the verified text to match the reading levels of specific audiences (Layperson, Student, or Professional).

Results Folder Structure

results/kaggle/working
β”œβ”€β”€ exp1  (Stage 1)
β”‚Β Β  β”œβ”€β”€ best_model
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ config.json              # Model configuration settings
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ model.pt
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ tokenizer_config.json    # Tokenizer configuration settings
β”‚Β Β  β”‚Β Β  └── tokenizer.json           # Serialized tokenizer vocabulary
β”‚Β Β  β”œβ”€β”€ best_threshold.json          # Optimal threshold computed for predictions
β”‚Β Β  β”œβ”€β”€ data
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test.jsonl               # Stage 1 formatted test split
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ train.jsonl              # Stage 1 formatted train split
β”‚Β Β  β”‚Β Β  └── val.jsonl                # Stage 1 formatted validation split
β”‚Β Β  └── test_results.json            # Model evaluation results on the test data
β”œβ”€β”€ stage1_predictions
β”‚Β Β  β”œβ”€β”€ predicted_test.jsonl         # Model predictions on test subset
β”‚Β Β  β”œβ”€β”€ predicted_train.jsonl        # Model predictions on train subset
β”‚Β Β  └── predicted_val.jsonl          # Model predictions on validation subset
β”œβ”€β”€ stage2_output
β”‚Β Β  β”œβ”€β”€ checkpoints
β”‚Β Β  β”‚Β Β  └── best_model
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ constraint_config.json # Stage 2 model configuration
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ constraint_model.pt
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ tokenizer_config.json
β”‚Β Β  β”‚Β Β      └── tokenizer.json
β”‚Β Β  β”œβ”€β”€ demo_output.json             # Sample demonstration outputs from Stage 2
β”‚Β Β  β”œβ”€β”€ eval_metrics.json            # Quantitative metrics for the Stage 2 model
β”‚Β Β  β”œβ”€β”€ final_model
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ constraint_config.json
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ constraint_model.pt
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ tokenizer_config.json
β”‚Β Β  β”‚Β Β  └── tokenizer.json
β”‚Β Β  β”œβ”€β”€ test_constraints.json        # Test data with constraint pairs 
β”‚Β Β  β”œβ”€β”€ train_constraints.json       # Training data with constraint pairs
β”‚Β Β  β”œβ”€β”€ training_history.json        # Epoch-wise training and validation logs
β”‚Β Β  └── val_constraints.json         # Validation data with constraint pairs
β”œβ”€β”€ stage3_output
β”‚Β Β  β”œβ”€β”€ evaluation_metrics.json      # Evaluation metrics from simplification
β”‚Β Β  β”œβ”€β”€ simplified_test_clauses.json # Stage 3 text simplification results
β”‚Β Β  β”œβ”€β”€ synthetic_pairs.json         # Synthetic positive/negative pairs generated for Stage 3
β”‚Β Β  └── training_history.json        # Stage 3 epoch-wise progress logs
β”œβ”€β”€ stage4_output
β”‚Β Β  β”œβ”€β”€ human_review_queue.json          # Simplifications flagged by NLI that require human review
β”‚Β Β  β”œβ”€β”€ stage4_evaluation_metrics.json   # Efficacy metrics post-NLI correction loop
β”‚Β Β  └── stage4_simplified_clauses.json   # Refined simplifications fully conforming to NLI entailment
└── stage5_output
    └── persona_targets.json         # Final output mapped to user-specific personas