Spaces:
Build error
Build error
import gradio as gr | |
from transformers import AutoModel, AutoTokenizer | |
import torch | |
# Load the model and tokenizer | |
model_name = "TuringsSolutions/TechLegalV1" | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
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) | |
# Assuming we need to extract some specific information from outputs | |
# Modify this part based on your model's output format | |
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="Tech Legal Model", | |
description="A model for analyzing tech legal documents." | |
) | |
# Launch the interface | |
if __name__ == "__main__": | |
iface.launch() | |