TuringsSolutions's picture
Update app.py
5df7797 verified
raw
history blame contribute delete
825 Bytes
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()