File size: 910 Bytes
981f4d3
 
 
 
 
 
08114ea
981f4d3
 
 
08114ea
981f4d3
08114ea
 
 
 
 
 
 
 
 
 
981f4d3
 
 
 
 
08114ea
981f4d3
 
 
 
 
08114ea
 
 
 
 
981f4d3
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import gradio as gr
from transformers import pipeline

classifier = pipeline(
    "text-generation",
    model="AtrriJi/smolified-risk-clause-classifier",
    device=-1
)

def classify(clause):

    prompt = f"""
Classify the legal clause into one of:
Payment Terms, Intellectual Property, Confidentiality,
Termination, Indemnification, Force Majeure,
Governing Law, Warranty, Limitation of Liability,
Dispute Resolution.

Also predict risk level: Low, Medium, or High.

Return ONLY JSON like:
{{"category": "...", "risk_level": "..."}}

Clause:
{clause}
"""

    result = classifier(
        prompt,
        max_new_tokens=100,
        do_sample=False
    )[0]["generated_text"]

    # Remove prompt part
    clean_output = result[len(prompt):].strip()

    return clean_output


demo = gr.Interface(
    fn=classify,
    inputs="text",
    outputs="text",
    title="Risk Clause Classifier"
)

demo.launch()