Tejasw1 commited on
Commit
4e8b0c3
·
verified ·
1 Parent(s): 4e20d76

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -64,3 +64,4 @@ venv/lib/python3.11/site-packages/pyarrow/libarrow_substrait.so.1500 filter=lfs
64
  venv/lib/python3.11/site-packages/pyarrow/libparquet.so.1500 filter=lfs diff=lfs merge=lfs -text
65
  venv/lib/python3.11/site-packages/pydantic_core/_pydantic_core.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
66
  venv/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
 
 
64
  venv/lib/python3.11/site-packages/pyarrow/libparquet.so.1500 filter=lfs diff=lfs merge=lfs -text
65
  venv/lib/python3.11/site-packages/pydantic_core/_pydantic_core.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
66
  venv/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
67
+ Apr.csv filter=lfs diff=lfs merge=lfs -text
Apr.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4bc09d1274c0b59e8cae97dd8c66e749178ce1706d9e2cd19a7fbb5fc94f7025
3
+ size 249616475
__pycache__/gradio_app.cpython-311.pyc CHANGED
Binary files a/__pycache__/gradio_app.cpython-311.pyc and b/__pycache__/gradio_app.cpython-311.pyc differ
 
gradio_app.py CHANGED
@@ -1,5 +1,5 @@
1
-
2
- from openai import AzureOpenAI
3
  import re
4
  import gradio as gr
5
 
@@ -9,6 +9,12 @@ client = AzureOpenAI(
9
  azure_endpoint="https://votum.openai.azure.com/",
10
  )
11
 
 
 
 
 
 
 
12
 
13
  fact = '''In service Mr. In-charge Inspector Mr. City of Police Station Kotwali Mr. G Candidate Chetna Gupta alias Chanchal Gupta Advocate Resident of Flat No., 76/44 Halsey Road Kanpur Nagar and practicing law from a pucca chamber just in front of CMO office at Kachehri. On 2024, at around 8: 30 am, my chamber suddenly caught fire and at around 9: 00 am, I got a call informing me that my chamber was on fire. I reached the chamber immediately. By then, Manish, who was cleaning my chamber, was dousing the fire with water. All my chamber's luggage, files, AC, sofa wings, amalt glass walls, necessary documents, miscellaneous items, etc. have been destroyed. I am informing the concerned post. Please take appropriate action. Dated 29. 2024 Signature English unreadable Candidate Chetna Gupta alias Chanchal Gupta Md. 7376222267 Note I hereby certify that 674 Dhirendra Pratap Singh, permanent & tahrir copy of the complaint was literally typed by me on the computer 5057 Lalit Kumar. That I attest to.'''
14
 
@@ -16,35 +22,11 @@ prompt = """Task: Given examples of a Supreme Court case and the statutes applie
16
  You should to showcase creativity and knowledge to enhance the accuracy of statute predictions based on the given fact statement.
17
 
18
  Context:
 
 
19
 
20
- Fact Statement:"In this one gets used to writing common orders, for orders are written either on behalf of the [PRODUCT], or on behalf of the [ORG].
21
- While endorsing the opinion expressed by [PERSON],, adjudicating upon the prayer for my recusal, from hearing the matters in hand, reasons for my continuation on the [ORG], also need to be expressed by me.
22
- It has been necessitated, for deciding an objection, about the present composition of the [PERSON].
23
- As already noted above,, [ORG] has rendered the decision on the objection.
24
- The events which followed the order of [PERSON],, are also of some significance.
25
- In my considered view, they too need to be narrated, for only then, the entire matter can be considered to have been fully expressed, as it ought to be.
26
- I also need to record reasons, why my continuation on the reconstituted [ORG], was the only course open to me.
27
- And therefore, my side of its understanding, dealing with the perception, of the other side of the [PRODUCT].
28
- Union of India [DATE] Indlaw SCO 185 Writ Petition C no.13 of, Mr. [PERSON], Senior Advocate, in [ORG] of [DATE], Mr. [PERSON], Advocate, in [ORG] Indlaw SC 29 Writ Petition C [DATE] and Mr. [PERSON], Advocate, in Change [GPE] v. [ORG] no.70 of [DATE], representing the petitioners were heard.iii The proceedings recorded by this [ORG] on 18.3.2015 reveal, that Mr. [PERSON], in Writ Petition C no.70 of [DATE] was heard again on, whereupon, Mr. [PERSON] and Mr., [ORG] [GPE], also made their submissions.
29
- [CARDINAL]. Based on the order passed by the Judge [PERSON] on 7.4.2015, Honble the Chief Justice of [GPE], constituted a [CARDINAL] Judge [PERSON], comprising of,,, and, JJ.
30
- [CARDINAL]. On 13.4.2015 the Constitution Ninety ninth Amendment Act, [DATE], and [ORG] Act, [DATE], were notified in the Gazette of India Extraordinary.Both the above enactments, were brought into force with effect from 13.4.2015.
31
- [CARDINAL]. When the reconstituted [PERSON] commenced hearing on 21.4.2015, Mr. made a prayer for my recusal from the [PRODUCT], which was seconded by Mr. Mathews [PERSON] petitioner in- person in Writ Petition C no.124 of [DATE], the latter advanced submissions, even though he had been barred from doing so, by an earlier order dated 24.3.2015 extracted above.
32
- The [ORDINAL] judgment was rendered, by a [CARDINAL] Judge [PERSON], by a majority of [CARDINAL], in the [ORDINAL] Judges case on [CARDINAL]. The correctness of the First Judges case was doubted by a Judge [PERSON] in of [GPE], [DATE] Supp 1 SCC 574 [ORG] [CARDINAL], which opined that the majority view, in the [ORG] case, should be considered by a larger.
33
- The amendment, received the assent of the President on [DATE].It was however given effect to, with effect from 13.4.2015 consequent upon its notification in the Gazette of India Extraordinary Part II, [SECTION_UNK].
34
- The same was also brought into force, with effect from 13.4.2015 by its notification in the Gazette of India Extraordinary Part II, [SECTION_UNK].
35
- The Judges case- [DATE] [EVENT] 87 [DATE] [ORG] [CARDINAL].[DATE].The Union Law Minister addressed a letter dated 18.3.1981 to the Governor of [PRODUCT] and to Chief Ministers of all other [GPE].
36
- The addressees were inter [PERSON], [CARDINAL] of [ORG], should as far as possible be from outside the in which is situated.
37
- Through the above letter, the addressees were requested to.a obtain from all additional Judges working in the High Courts.their consent to be appointed as permanent Judges in any other in the country.
38
- The above noted letter required, that the concerned appointees.be required to name [CARDINAL] High Courts, in order of preference, to which they would prefer to be appointed as permanent Judges and b obtain from persons who have already been or may in the future be proposed by you for initial appointment their consent to be appointed to any other [ORG] in the country along with a similar preference for [CARDINAL] High Courts.
39
- The Union Law Minister, in the above letter clarified, that furnishing of their consent or indication of their preference, would not imply any commitment, at the behest of the Government, to accommodate them in accordance with their preferences.
40
- In response, quite a few additional Judges, gave their consent to be appointed outside their parent [ORG].
41
- A series of [ORG] in [GPE] passed resolutions, condemning the letter dated 18.3.1981, as being subversive of judicial independence.
42
- Since that was not done, a writ petition was filed by the above Associations in the Bombay High Court, challenging the letter dated 18.3.1981.
43
- An interim order was passed by [ORG], restraining the Union Law Minister and the Government from implementing the letter dated 18.3.1981.
44
- While the matter was pending before this, the Union Law Minister and, filed a transfer petition under [LAW] The transfer petition was allowed, and the writ petition filed in the Bombay High Court, was transferred to [ORG].
45
- These short term appointments were assailed, as being unjustified under [LAW], besides being subversive of the independence of the judiciary."
46
-
47
- Statutes:['Constitution_226', 'Constitution_136', 'Constitution_14', 'Constitution_16', 'Constitution_227', 'Constitution_133', 'Constitution_246', 'Constitution_1', 'Constitution_21', 'Constitution_32', 'Constitution_19', 'Constitution_141', 'Constitution_4', 'Constitution_31', 'Constitution_12', 'Constitution_2', 'Constitution_39', 'Constitution_311', 'Constitution_13', 'Constitution_5', 'Constitution_3', 'Constitution_6', 'Constitution_15']
48
 
49
  ###
50
 
@@ -55,21 +37,22 @@ Instructions:
55
 
56
  Learn from the examples provided in the context to understand the task of charge or statute prediction.
57
  Your response should be focused on providing the exact statute or charge that aligns with the legal principles and precedents applicable to the given facts.
58
- In your response, include only the statutes you are most confident about.Ensure that the statutes generated as responses are valid and recognized legal statutes. Avoid generating fabricated or invalid statutes.
59
  The model's performance will be evaluated based on its ability to predict the correct statute, include only confident statutes, and showcase creativity in its predictions.
 
60
 
61
  Fact Statement: ```{fact}```
62
  """
63
 
64
- def generate(input_text):
65
- print(input_text)
66
-
67
  com = prompt.format(fact=input_text)
68
- chat_completion = client.chat.completions.create(
69
- model="gpt-4-turbo",
70
- temperature=0.5,
 
 
71
  messages=[
72
- {"role": "system", "content": "You are a legal assistant from India, skilled in and tagging applicable legal statutes to FIR(First Information Report)."},
73
  {
74
  "role": "user",
75
  "content": com,
@@ -87,10 +70,47 @@ def extract_statutes(gpt_output):
87
  return statutes
88
  return []
89
 
90
-
91
- def predict_statutes(fir_text):
92
- if fir_text:
93
- gpt_output = generate(fir_text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  statutes_list = extract_statutes(gpt_output)
95
  if statutes_list:
96
  return "\n".join(f"- {statute}" for statute in statutes_list)
@@ -102,9 +122,17 @@ def predict_statutes(fir_text):
102
  # Gradio app layout
103
  demo = gr.Interface(
104
  fn=predict_statutes,
105
- inputs=gr.Textbox(label="Enter the FIR:", placeholder="Type or paste the FIR here...", lines=10),
 
 
 
106
  outputs=gr.Textbox(label="Predicted Statutes"),
107
- examples=[fact],
108
  )
109
 
110
- demo.launch()
 
 
 
 
 
 
1
+ import requests, uuid, json
2
+ from openai import AzureOpenAI,OpenAI
3
  import re
4
  import gradio as gr
5
 
 
9
  azure_endpoint="https://votum.openai.azure.com/",
10
  )
11
 
12
+ mistral_client = OpenAI(
13
+ api_key='EMPTY',
14
+ base_url="http://20.124.240.6:8083/v1",
15
+ )
16
+
17
+
18
 
19
  fact = '''In service Mr. In-charge Inspector Mr. City of Police Station Kotwali Mr. G Candidate Chetna Gupta alias Chanchal Gupta Advocate Resident of Flat No., 76/44 Halsey Road Kanpur Nagar and practicing law from a pucca chamber just in front of CMO office at Kachehri. On 2024, at around 8: 30 am, my chamber suddenly caught fire and at around 9: 00 am, I got a call informing me that my chamber was on fire. I reached the chamber immediately. By then, Manish, who was cleaning my chamber, was dousing the fire with water. All my chamber's luggage, files, AC, sofa wings, amalt glass walls, necessary documents, miscellaneous items, etc. have been destroyed. I am informing the concerned post. Please take appropriate action. Dated 29. 2024 Signature English unreadable Candidate Chetna Gupta alias Chanchal Gupta Md. 7376222267 Note I hereby certify that 674 Dhirendra Pratap Singh, permanent & tahrir copy of the complaint was literally typed by me on the computer 5057 Lalit Kumar. That I attest to.'''
20
 
 
22
  You should to showcase creativity and knowledge to enhance the accuracy of statute predictions based on the given fact statement.
23
 
24
  Context:
25
+ -----
26
+ Fact Statement:"It is submitted that yesterday on 29/4/21, in the three-tier election, I have been on duty of U.P. Zone-2, whose headquarters is Police Station Vijaygarh, Sector No. 09 of which the headquarters is Pvt. Bhinauli. I was engaged as sector incharge along with Sector Magistrate Shri Dinesh Kumar. Primary School Kanakpur Primary School Gudmai, Primary School Bhinauli Primary School Bistauli and Pre-Secondary School Bistauli respectively. At 9.42 am, I received a call from HG Sanjay Kumar, posted at Kanakpur Primary School, about a quarrel on which I was going to village Gudmai with his Sector Magistrate at that time. Leaving them there, I immediately left for village Kanakpur, as soon as I reached village Kanakpur, I saw that they were distributing slips by laying bags with the candidates near the polling booth. Due to which there is a crowd there. On their previous visit to the village, all of them were instructed to put bags 200 meters away from the polling booth, the crowd present there had also blocked the narrow road to the village by putting their cars and bicycles. As soon as I reached there, the crowd started dispersing and the polling agents started picking up their bags and started removing their vehicles from there. And when the election system started becoming normal, my eyes fell on the house built next to the polling booth outside which the agents were sitting with bags. This house belonged to Rakesh Kumar son of Turi Singh and the polling agents who were crowded there were sitting in the bag of candidate Prempal son of Shriman Singh. Mohit Kumar, son of Rakesh Kumar (above), had gathered the crowd by setting up a sugarcane juice stall on the same house. To control the crowd, I used minimum necessary force to close Mohit's sugarcane juice stall and asked the agents sitting at his house to lift the bag. While I was taking this action, the landlord Rakesh Kumar came UP13W0027 with his Bolero number above and put the car from where I was removing the crowd. When asked to remove it, Mohit Kumar and Yogesh Kumar, who were present there, got into a scuffle with me while abusing, I tried to remove the key of the car for the purpose of sealing it, then Rakesh climbed the glass of the car so that my right hand got stuck in it, which also hurt my hand. He snatched the key from my hand and lowered the glass till then my companions HG Prakash Chandra and HG Keshav Singh came there, as soon as my companions reached me for my help, Rakesh Kumar got down by putting the above Bolero car in the middle of the road there and his sons Mohit and Yogesh Kumar got angry with me, Rakesh shouted that today he will be robbed by his pistol. Let's make it. On his instigation to kill me in this way, his two sons Mohit and Yogesh started trying to snatch my pistol and took it out of the holster and also damaged my uniform, till then HG Sanjay Kumar and the guard appointed with him came out running after hearing the noise and saved me and my pistol. I request you to register a case against Rakesh Kumar son of Turi Singh and Mohit Kumar and Yogesh Kumar son of Rakesh Kumar for committing serious crimes like obstructing the government work being done by me UP, abusing, threatening to kill and trying to snatch the government pistol. SD English Shashank Kaushik U.P. 30/4/21 Shashank Kaushik (U.P.) PNO 182025017 Police Station Akrabad District Aligarh Mob 9161222231 Note I CC 551 Sanjeev Kumar certify that the copy of Tahrir has been inscribed on the word 'B' on the compute."
27
 
28
+ Statutes:['IPC_186', 'IPC_353', 'IPC_506', 'IPC_332']
29
+ -----
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  ###
32
 
 
37
 
38
  Learn from the examples provided in the context to understand the task of charge or statute prediction.
39
  Your response should be focused on providing the exact statute or charge that aligns with the legal principles and precedents applicable to the given facts.
40
+ In your response, include only the statutes you are most confident about.Ensure that the statutes generated as responses are valid and recognized legal statutes appliable in FIRs like IPC or special acts like The_Arms_Act_27, Protection_of_Children_from_Sexual_Offenses_Act_2012, Motor_Vehicles_Act etc. Avoid generating fabricated or invalid statutes.
41
  The model's performance will be evaluated based on its ability to predict the correct statute, include only confident statutes, and showcase creativity in its predictions.
42
+ Think step by step to cover all possible statutes that are relevant to the fact statement.
43
 
44
  Fact Statement: ```{fact}```
45
  """
46
 
47
+ def generate(input_text,temperature=0.1):
 
 
48
  com = prompt.format(fact=input_text)
49
+ print(input_text)
50
+ chat_completion = mistral_client.chat.completions.create(
51
+ # model="gpt-4-turbo",
52
+ model='Qwen/Qwen1.5-72B-Chat-GPTQ-Int4',
53
+ temperature=temperature,
54
  messages=[
55
+ {"role": "system", "content": "You are a helpful assistant who is expert in tagging FIRs with relevant statutes from IPC among other special acts."},
56
  {
57
  "role": "user",
58
  "content": com,
 
70
  return statutes
71
  return []
72
 
73
+ def translate(text):
74
+ # Add your key and endpoint
75
+ key = "8760fcb757fe44a19d3ec590cb80836f"
76
+ endpoint = "https://api.cognitive.microsofttranslator.com"
77
+
78
+ # location, also known as region.
79
+ # required if you're using a multi-service or regional (not global) resource. It can be found in the Azure portal on the Keys and Endpoint page.
80
+ location = "centralindia"
81
+
82
+ path = '/translate'
83
+ constructed_url = endpoint + path
84
+
85
+ params = {
86
+ 'api-version': '3.0',
87
+ 'from': 'hi',
88
+ 'to': 'en',
89
+ }
90
+
91
+ headers = {
92
+ 'Ocp-Apim-Subscription-Key': key,
93
+ 'Ocp-Apim-Subscription-Region': location,
94
+ 'Content-type': 'application/json',
95
+ 'X-ClientTraceId': str(uuid.uuid4())
96
+ }
97
+
98
+ # You can pass more than one object in body.
99
+ body = [{
100
+ 'text': text
101
+ }]
102
+
103
+ request = requests.post(constructed_url, params=params, headers=headers, json=body)
104
+ return request.json()[0]['translations'][0]['text']
105
+
106
+ def predict_statutes(fir_text,language,temperature):
107
+ if language == 'Hindi':
108
+ text = translate(fir_text)
109
+ else:
110
+ text = fir_text
111
+
112
+ if text:
113
+ gpt_output = generate(text,temperature)
114
  statutes_list = extract_statutes(gpt_output)
115
  if statutes_list:
116
  return "\n".join(f"- {statute}" for statute in statutes_list)
 
122
  # Gradio app layout
123
  demo = gr.Interface(
124
  fn=predict_statutes,
125
+ inputs=[gr.Textbox(label="Enter the FIR:", placeholder="Type or paste the FIR here...", lines=10),
126
+ gr.Dropdown(label="Select Language", choices=["English", "Hindi"], value="English"),
127
+ # gr.Slider(minimum=0.1,maximum=1.0,value=0.5,step=0.1),
128
+ ],
129
  outputs=gr.Textbox(label="Predicted Statutes"),
130
+ examples=[[fact, "English"]],
131
  )
132
 
133
+ demo.launch()
134
+
135
+
136
+
137
+
138
+