Premchan369 commited on
Commit
feded35
·
verified ·
1 Parent(s): cbbf368

Update JurisGPT — fixed datasets, improved RAG pipeline

Browse files
README.md CHANGED
@@ -1,74 +1,16 @@
1
  ---
2
- language:
3
- - en
4
- - hi
5
- tags:
6
- - legal
7
- - indian-law
8
- - rag
9
- - question-answering
10
- - classification
11
- - legal-bert
12
  license: apache-2.0
13
- datasets:
14
- - nlp4all/indian-constitution
15
- - law-ai/ipc-sections
16
- - lex_glue
17
- - nguha/legalbench
18
  base_model: Qwen/Qwen2-7B-Instruct
19
  ---
20
-
21
- # ⚖️ JurisGPT Indian Legal AI Assistant
22
-
23
- An AI-powered Indian legal assistant built with **RAG + LegalBERT + Qwen2-7B**.
24
-
25
- ## 🚀 Capabilities
26
- - Answer questions about Indian Constitution, IPC sections, and case law
27
- - Predict case outcomes using LegalBERT classifier
28
- - Analyze uploaded legal PDF documents
29
- - Retrieve relevant laws using FAISS semantic search
30
- - Support for Hindi and regional Indian languages
31
-
32
- ## 🤖 Architecture
33
- | Component | Model |
34
- |-----------|-------|
35
- | Main LLM | Qwen2-7B-Instruct (4-bit quantized) |
36
- | Embeddings | BAAI/bge-large-en |
37
- | Classifier | LegalBERT |
38
- | Vector DB | FAISS |
39
-
40
- ## 📚 Legal Corpus (2000 documents)
41
- - Indian Constitution (`nlp4all/indian-constitution`)
42
- - IPC Sections (`law-ai/ipc-sections`)
43
- - LexGLUE Case Law (`lex_glue`)
44
- - LegalBench (`nguha/legalbench`)
45
- - Indian Court Judgments
46
-
47
- ## 💻 Usage
48
-
49
  ```python
50
  from transformers import AutoModelForCausalLM, AutoTokenizer
51
-
52
  tokenizer = AutoTokenizer.from_pretrained("Premchan369/JurisGPT")
53
  model = AutoModelForCausalLM.from_pretrained("Premchan369/JurisGPT")
54
-
55
- messages = [
56
- {"role": "system", "content": "You are JurisGPT, an expert Indian legal AI assistant."},
57
- {"role": "user", "content": "Explain IPC Section 302"}
58
- ]
59
- text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
60
- inputs = tokenizer(text, return_tensors="pt")
61
- output = model.generate(**inputs, max_new_tokens=512)
62
- print(tokenizer.decode(output[0], skip_special_tokens=True))
63
  ```
64
-
65
- ## ⚠️ Disclaimer
66
- JurisGPT provides general legal information for educational purposes only.
67
- Always consult a qualified lawyer for serious legal matters.
68
-
69
- ## 🏗️ Built With
70
- - [Hugging Face Transformers](https://huggingface.co/docs/transformers)
71
- - [FAISS](https://faiss.ai/)
72
- - [Sentence Transformers](https://www.sbert.net/)
73
- - [Gradio](https://gradio.app/)
74
- - [Kaggle](https://www.kaggle.com/)
 
1
  ---
2
+ language: [en, hi]
3
+ tags: [legal, indian-law, rag, question-answering]
 
 
 
 
 
 
 
 
4
  license: apache-2.0
 
 
 
 
 
5
  base_model: Qwen/Qwen2-7B-Instruct
6
  ---
7
+ # ⚖️ JurisGPT — Indian Legal AI
8
+ Built with Qwen2-7B + LegalBERT + FAISS RAG on 5027 legal documents.
9
+ ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  ```python
11
  from transformers import AutoModelForCausalLM, AutoTokenizer
 
12
  tokenizer = AutoTokenizer.from_pretrained("Premchan369/JurisGPT")
13
  model = AutoModelForCausalLM.from_pretrained("Premchan369/JurisGPT")
 
 
 
 
 
 
 
 
 
14
  ```
15
+ ## Disclaimer
16
+ For informational purposes only. Not a substitute for professional legal advice.
 
 
 
 
 
 
 
 
 
added_tokens.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "<|endoftext|>": 151643,
3
+ "<|im_end|>": 151645,
4
+ "<|im_start|>": 151644
5
+ }
config.json CHANGED
@@ -1,52 +1,21 @@
1
  {
 
2
  "architectures": [
3
  "Qwen2ForCausalLM"
4
  ],
5
  "attention_dropout": 0.0,
6
  "bos_token_id": 151643,
7
- "dtype": "bfloat16",
8
  "eos_token_id": 151645,
9
  "hidden_act": "silu",
10
  "hidden_size": 3584,
11
  "initializer_range": 0.02,
12
  "intermediate_size": 18944,
13
- "layer_types": [
14
- "full_attention",
15
- "full_attention",
16
- "full_attention",
17
- "full_attention",
18
- "full_attention",
19
- "full_attention",
20
- "full_attention",
21
- "full_attention",
22
- "full_attention",
23
- "full_attention",
24
- "full_attention",
25
- "full_attention",
26
- "full_attention",
27
- "full_attention",
28
- "full_attention",
29
- "full_attention",
30
- "full_attention",
31
- "full_attention",
32
- "full_attention",
33
- "full_attention",
34
- "full_attention",
35
- "full_attention",
36
- "full_attention",
37
- "full_attention",
38
- "full_attention",
39
- "full_attention",
40
- "full_attention",
41
- "full_attention"
42
- ],
43
  "max_position_embeddings": 32768,
44
  "max_window_layers": 28,
45
  "model_type": "qwen2",
46
  "num_attention_heads": 28,
47
  "num_hidden_layers": 28,
48
  "num_key_value_heads": 4,
49
- "pad_token_id": null,
50
  "quantization_config": {
51
  "_load_in_4bit": true,
52
  "_load_in_8bit": false,
@@ -63,13 +32,11 @@
63
  "quant_method": "bitsandbytes"
64
  },
65
  "rms_norm_eps": 1e-06,
66
- "rope_parameters": {
67
- "rope_theta": 1000000.0,
68
- "rope_type": "default"
69
- },
70
  "sliding_window": null,
71
  "tie_word_embeddings": false,
72
- "transformers_version": "5.2.0",
 
73
  "use_cache": true,
74
  "use_sliding_window": false,
75
  "vocab_size": 152064
 
1
  {
2
+ "_name_or_path": "Qwen/Qwen2-7B-Instruct",
3
  "architectures": [
4
  "Qwen2ForCausalLM"
5
  ],
6
  "attention_dropout": 0.0,
7
  "bos_token_id": 151643,
 
8
  "eos_token_id": 151645,
9
  "hidden_act": "silu",
10
  "hidden_size": 3584,
11
  "initializer_range": 0.02,
12
  "intermediate_size": 18944,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  "max_position_embeddings": 32768,
14
  "max_window_layers": 28,
15
  "model_type": "qwen2",
16
  "num_attention_heads": 28,
17
  "num_hidden_layers": 28,
18
  "num_key_value_heads": 4,
 
19
  "quantization_config": {
20
  "_load_in_4bit": true,
21
  "_load_in_8bit": false,
 
32
  "quant_method": "bitsandbytes"
33
  },
34
  "rms_norm_eps": 1e-06,
35
+ "rope_theta": 1000000.0,
 
 
 
36
  "sliding_window": null,
37
  "tie_word_embeddings": false,
38
+ "torch_dtype": "float16",
39
+ "transformers_version": "4.44.0",
40
  "use_cache": true,
41
  "use_sliding_window": false,
42
  "vocab_size": 152064
generation_config.json CHANGED
@@ -10,5 +10,5 @@
10
  "temperature": 0.7,
11
  "top_k": 20,
12
  "top_p": 0.8,
13
- "transformers_version": "5.2.0"
14
  }
 
10
  "temperature": 0.7,
11
  "top_k": 20,
12
  "top_p": 0.8,
13
+ "transformers_version": "4.44.0"
14
  }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24aaa99d9d11209d9e7218e9d775872219f99d3f0e97f332df6cdb581ea01151
3
+ size 4457259454
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:38b6eef54ae6fe69f5715367e066a3f8a1c6d233fed8feb5bb358bf107d54660
3
+ size 1089994880
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
special_tokens_map.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>"
5
+ ],
6
+ "eos_token": {
7
+ "content": "<|im_end|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false
12
+ },
13
+ "pad_token": {
14
+ "content": "<|endoftext|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false
19
+ }
20
+ }
tokenizer.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:48f722bc04c884e2fe1525fdcd85a1293a8499b6e620c1ac7c083c49632305fb
3
- size 11418262
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a12e3ba5d5e0ad173cf7b408ab8534c6be8cbc6a146714e9c7dc8cf2346603b1
3
+ size 7028043
tokenizer_config.json CHANGED
@@ -1,15 +1,40 @@
1
  {
2
  "add_prefix_space": false,
3
- "backend": "tokenizers",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  "bos_token": null,
 
5
  "clean_up_tokenization_spaces": false,
6
  "eos_token": "<|im_end|>",
7
  "errors": "replace",
8
- "extra_special_tokens": [
9
- "<|im_start|>",
10
- "<|im_end|>"
11
- ],
12
- "is_local": false,
13
  "model_max_length": 131072,
14
  "pad_token": "<|endoftext|>",
15
  "split_special_tokens": false,
 
1
  {
2
  "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "151643": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "151644": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "151645": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ }
28
+ },
29
+ "additional_special_tokens": [
30
+ "<|im_start|>",
31
+ "<|im_end|>"
32
+ ],
33
  "bos_token": null,
34
+ "chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
35
  "clean_up_tokenization_spaces": false,
36
  "eos_token": "<|im_end|>",
37
  "errors": "replace",
 
 
 
 
 
38
  "model_max_length": 131072,
39
  "pad_token": "<|endoftext|>",
40
  "split_special_tokens": false,
vocab.json ADDED
The diff for this file is too large to render. See raw diff