Text Generation
PEFT
Safetensors
PyTorch
English
legal
indian-legal
custom-decoder
lorma
lora
qlora
adalora
knowledge-distillation
cs781
iit-kanpur
Instructions to use sarweshbarnwal/CS781-Legal-Models with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use sarweshbarnwal/CS781-Legal-Models with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
|
Download README.md from sarweshbarnwal/CS781-Legal-Models: direct link, hf CLI and curl.
- Browser
- Download file 5.87 kB
-
https://huggingface.co/sarweshbarnwal/CS781-Legal-Models/resolve/main/README.md
- Command line
-
hf download hf://sarweshbarnwal/CS781-Legal-Models/README.md
-
curl -L -o README.md https://huggingface.co/sarweshbarnwal/CS781-Legal-Models/resolve/main/README.md
5.87 kB
| language: | |
| - en | |
| license: other | |
| tags: | |
| - legal | |
| - indian-legal | |
| - custom-decoder | |
| - peft | |
| - lorma | |
| - lora | |
| - qlora | |
| - adalora | |
| - knowledge-distillation | |
| - pytorch | |
| - cs781 | |
| - iit-kanpur | |
| pipeline_tag: text-generation | |
| # CS-781 Legal Language Models (IIT Kanpur) | |
| Master repository hosting the foundation models, Parameter-Efficient Fine-Tuning (PEFT) adapters, and evaluation artifacts for the **CS-781 Capstone Project: Legal Language Modelling Challenge** at the **Indian Institute of Technology Kanpur (IITK)** under the supervision of **Prof. Ashutosh Modi**. | |
| --- | |
| ## ποΈ Project & Research Overview | |
| This repository establishes a unified model hub for legal NLP tailored to the jurisdictional, statutory, and linguistic complexities of the **Indian Judicial System**, benchmarked against the [IL-TUR](https://arxiv.org/abs/2407.05399) benchmark. | |
| In strict compliance with competition constraints: | |
| - **Zero Pretrained Weights:** No commercial LLMs (GPT-4, Claude, Gemini) or off-the-shelf open-source checkpoints (BERT, LLaMA-3, Mistral) were utilized. | |
| - **Scratch Foundation Pretraining:** Four decoder-only transformer architectures were pre-trained strictly from scratch on Indian Supreme Court and High Court judgments. | |
| --- | |
| ## π§ Phase 1 Foundation Models (Trained from Scratch) | |
| | Model Subfolder | Architecture Style | Layers | $d_{\text{model}}$ | Attention Heads (Q / KV) | Max Context | Parameters | Core Structural Innovation | | |
| | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | |
| | **`model1-deep-llama-135m/`** | Deep LLaMA Causal Decoder | 16 | 768 | 12 / 4 (GQA 3:1) | 1024 | 134.7M | Deep representational capacity, RMSNorm, SwiGLU FFN | | |
| | **`model2-wide-mistral-136m/`** | Wide Mistral Long-Flow | 12 | 896 | 14 / 7 (GQA 2:1) | 1536 | 136.2M | Wide channel dimension, extended 1536 context flow | | |
| | **`model3-statutory-mha-110m/`** | Statutory Precision Decoder | 12 | 768 | 12 / 12 (Full MHA) | 1024 | 109.5M | Full unshared multi-head attention for fine syntax | | |
| | **`model4-capacity-boundary-154m/`** | Peak Capacity Boundary | 14 | 896 | 14 / 14 (Full MHA) | 1024 | 153.9M | Tied embeddings, peak capacity boundary model | | |
| --- | |
| ## π Repository Checkpoint Architecture | |
| Checkpoints and CodaBench evaluation files are continuously synchronized from Kaggle Dual-T4 training sessions into dedicated phase namespaces: | |
| ```text | |
| sarweshbarnwal/CS781-Legal-Models/ | |
| βββ model1-deep-llama-135m/ # Phase 1 scratch-trained backbone | |
| βββ model2-wide-mistral-136m/ # Phase 1 scratch-trained backbone | |
| βββ model3-statutory-mha-110m/ # Phase 1 scratch-trained backbone | |
| βββ model4-capacity-boundary-154m/ # Phase 1 scratch-trained backbone | |
| β | |
| βββ Phase_7/ # Prior Case Retrieval (PCR) | |
| β βββ sub01_model4_full_ft_hierarchical/ | |
| β βββ sub02_model1_true_lorma_hard_negs/ # COMPULSORY LoRMA | |
| β βββ sub03_model2_qlora_ratio/ | |
| β βββ sub04_model1_adalora_margin_mse/ | |
| β βββ sub05_model2_houlsby_cosent/ | |
| β βββ sub06_model3_distill_alignment/ # MANDATORY KD | |
| β βββ sub07_model4_bm25_dense_hybrid/ | |
| β βββ sub08_master_ensemble/ | |
| β | |
| βββ Phase_6/ # Abstractive Summarization | |
| β βββ sub01_model4_full_ft/ | |
| β βββ sub02_model1_true_lorma/ # COMPULSORY LoRMA | |
| β βββ sub03_model2_qlora/ | |
| β βββ sub04_model1_adalora/ | |
| β βββ sub05_model2_houlsby/ | |
| β βββ sub06_model4_to_model3_distill/ # MANDATORY KD | |
| β βββ sub07_model4_hierarchical_summary/ | |
| β βββ sub08_master_ensemble/ | |
| β | |
| βββ Phase_5/ # Legal Statute Identification (LSI) | |
| β βββ sub01_model4_full_ft_asl/ | |
| β βββ sub02_model1_true_lorma/ # COMPULSORY LoRMA | |
| β βββ sub03_model2_qlora/ | |
| β βββ sub04_model1_adalora/ | |
| β βββ sub05_model2_houlsby/ | |
| β βββ sub06_model4_to_model3_distill/ # MANDATORY KD | |
| β βββ sub07_model4_hierarchical_pool/ | |
| β βββ sub08_master_ensemble/ | |
| β | |
| βββ Phase_4/ # Court Judgment Prediction (CJPE) | |
| β βββ sub01_model4_full_ft/ | |
| β βββ sub02_model1_true_lorma/ # COMPULSORY LoRMA | |
| β βββ sub03_model2_qlora/ | |
| β βββ sub04_model1_adalora/ | |
| β βββ sub05_model2_houlsby/ | |
| β βββ sub06_model4_to_model3_distill/ # MANDATORY KD | |
| β βββ sub07_model4_hierarchical_pool/ | |
| β βββ sub08_master_ensemble/ | |
| β | |
| βββ Phase_3/ # Rhetorical Role Prediction (RR) | |
| βββ Phase_2/ # Legal Named Entity Recognition (L-NER) | |
| ``` | |
| --- | |
| ## π¬ Methodological Innovations | |
| ### 1. Compulsory Method: True Multiplicative LoRMA | |
| Implemented according to Bihany, Patel, and Modi (2025): | |
| $$y_{\text{adapted}} = y + \frac{\alpha}{r} B( A(y) )$$ | |
| - Zero-initialized $B$ strictly guarantees identity mapping at step 0. | |
| - All base model weights are frozen; trainable parameters $< 1.5\%$. | |
| ### 2. Mandatory Method: Cross-Model Knowledge Distillation | |
| Transfers rich representations from 153.9M Model 4 to compact 109.5M Model 3: | |
| $$\mathcal{L}_{\text{total}} = 0.5 \mathcal{L}_{\text{hard}} + 0.4 T^2 \text{KL}\left(\sigma\left(\frac{z_s}{T}\right) \parallel \sigma\left(\frac{z_t}{T}\right)\right) + 0.1 \left(1 - \cos\left(W_{\text{proj}}(u_s), u_t\right)\right)$$ | |
| --- | |
| ## π¨βπ» Author & Attribution | |
| - **Student:** Sarwesh Barnwal (Roll No: 250987) | |
| - **Course:** CS-781: Deep Learning for Natural Language Processing | |
| - **Institution:** Department of Computer Science and Engineering, Indian Institute of Technology Kanpur (IITK) | |
| - **Course Supervisor:** Prof. Ashutosh Modi | |