File size: 825 Bytes
0d2d507
c0b89f3
0d2d507
 
0ce095d
5df7797
0d2d507
0ce095d
5df7797
 
0d2d507
 
 
 
 
c0b89f3
 
0d2d507
 
 
 
 
c0b89f3
5df7797
 
0d2d507
 
 
 
 
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
import gradio as gr
from transformers import AutoTokenizer, AutoModel
import torch

# Load the tokenizer
model_name = "TuringsSolutions/LegalModelTest1"
tokenizer = AutoTokenizer.from_pretrained(model_name)

# Initialize the model
model = AutoModel.from_pretrained(model_name)

# Function to make predictions
def predict(text):
    inputs = tokenizer(text, return_tensors="pt")
    with torch.no_grad():
        outputs = model(**inputs)
    return outputs.last_hidden_state.mean(dim=1).squeeze().tolist()

# Create a Gradio interface
iface = gr.Interface(
    fn=predict,
    inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
    outputs="json",
    title="Legal Model Test",
    description="A model for analyzing legal documents."
)

# Launch the interface
if __name__ == "__main__":
    iface.launch()