pushkarsharma commited on
Commit
f3dfc01
·
verified ·
1 Parent(s): 4242663

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +108 -1
README.md CHANGED
@@ -1,3 +1,110 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ library_name: llama-cpp-python
5
+ tags:
6
+ - legal
7
+ - india
8
+ - gguf
9
+ - quantized
10
+ - rag
11
+ - llama-3.1
12
+ pipeline_tag: text-generation
13
+ base_model: unsloth/Meta-Llama-3.1-8B-Instruct
14
+ license: other
15
  ---
16
+
17
+ # LegalSahyak (Q4_K_M GGUF)
18
+
19
+ ## Model Description
20
+ `LegalSahyak_q4_k_m.gguf` is a quantized GGUF model intended for local legal question answering workflows, especially when paired with retrieval over contracts and Indian statutes.
21
+
22
+ - Base model: `unsloth/Meta-Llama-3.1-8B-Instruct`
23
+ - Adaptation: LoRA fine-tuning (rank `r=128`) and merge
24
+ - Quantization: `q4_k_m` GGUF
25
+ - Primary runtime target: `llama.cpp` / `llama-cpp-python`
26
+
27
+ ## Intended Use
28
+ - Contract clause explanation and extraction
29
+ - Statute-grounded legal QA in a retrieval-augmented (RAG) pipeline
30
+ - Local/offline inference where low memory usage is needed
31
+
32
+ This model should be used with retrieval and human review for any high-stakes legal scenario.
33
+
34
+ ## Out-of-Scope Use
35
+ - Autonomous legal advice without human oversight
36
+ - Any use requiring guaranteed legal correctness or jurisdictional completeness
37
+ - Sensitive decisions where model hallucinations can cause harm
38
+
39
+ ## Training Data
40
+ The training pipeline in `models/train.py` uses two public datasets:
41
+
42
+ 1. `Prarabdha/indian-legal-supervised-fine-tuning-data`
43
+ 2. `opennyaiorg/aalap_instruction_dataset`
44
+
45
+ Training was performed in two stages:
46
+
47
+ 1. Knowledge injection on legal supervised examples
48
+ 2. Behavioral alignment on instruction-following data
49
+
50
+ ## Training Procedure (Summary)
51
+ - Context length: up to `8192`
52
+ - Precision during training: `bfloat16`
53
+ - LoRA target modules: `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`
54
+ - Optimizer: `adamw_8bit`
55
+ - Scheduler: cosine
56
+ - Export: merged weights -> GGUF quantized as `q4_k_m`
57
+
58
+ ## Inference
59
+ Example with `llama-cpp-python`:
60
+
61
+ ```python
62
+ from llama_cpp import Llama
63
+
64
+ llm = Llama(
65
+ model_path="LegalSahyak_q4_k_m.gguf",
66
+ n_ctx=4096,
67
+ n_gpu_layers=20,
68
+ verbose=False,
69
+ )
70
+
71
+ resp = llm.create_chat_completion(
72
+ messages=[
73
+ {"role": "system", "content": "You are a legal assistant. Use provided context only."},
74
+ {"role": "user", "content": "Explain the notice period clause in simple words."},
75
+ ],
76
+ max_tokens=512,
77
+ temperature=0.0,
78
+ )
79
+
80
+ print(resp["choices"][0]["message"]["content"])
81
+ ```
82
+
83
+ ## Model File Details
84
+ - Filename: `LegalSahyak_q4_k_m.gguf`
85
+ - Size (bytes): `4920738464`
86
+ - Approx size: `4.58 GiB`
87
+ - SHA256: `F32460DD8E7DC927B3CF33065D1E753FC1F85ED102A678512C8A5F520F544405`
88
+
89
+ ## Limitations
90
+ - Can produce plausible but incorrect legal text
91
+ - Performance depends heavily on retrieval quality and prompt constraints
92
+ - May not reflect the latest statutory amendments
93
+ - Not a substitute for licensed legal counsel
94
+
95
+ ## Bias, Risk, and Safety
96
+ - Dataset and model biases may propagate into outputs
97
+ - Should not be used as the sole basis for legal, compliance, or policy decisions
98
+ - Recommended controls:
99
+ - Ground responses in retrieved sources
100
+ - Log model outputs and review manually
101
+ - Add refusal/uncertainty handling when context is missing
102
+
103
+
104
+
105
+ ## Citation
106
+ If you use this model in research or products, cite:
107
+
108
+ - The base model (`Meta-Llama-3.1`)
109
+ - The datasets listed above
110
+ - This repository (`Legalsahyak`)