Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
import torch
|
4 |
|
5 |
-
# Load the
|
6 |
model_name = "TuringsSolutions/TechLegalV1"
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
-
|
|
|
|
|
|
|
9 |
|
10 |
# Function to make predictions
|
11 |
def predict(text):
|
12 |
inputs = tokenizer(text, return_tensors="pt")
|
13 |
with torch.no_grad():
|
14 |
-
outputs = model(**inputs)
|
15 |
-
|
16 |
-
# Modify this part based on your model's output format
|
17 |
-
return outputs.last_hidden_state.mean(dim=1).squeeze().tolist()
|
18 |
|
19 |
# Create a Gradio interface
|
20 |
iface = gr.Interface(
|
21 |
fn=predict,
|
22 |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
|
23 |
-
outputs="
|
24 |
title="Tech Legal Model",
|
25 |
description="A model for analyzing tech legal documents."
|
26 |
)
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
import torch
|
4 |
|
5 |
+
# Load the tokenizer
|
6 |
model_name = "TuringsSolutions/TechLegalV1"
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
+
|
9 |
+
# Load the model
|
10 |
+
# Assuming it's a CausalLM model, you might need to adjust based on your model's architecture
|
11 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
|
12 |
|
13 |
# Function to make predictions
|
14 |
def predict(text):
|
15 |
inputs = tokenizer(text, return_tensors="pt")
|
16 |
with torch.no_grad():
|
17 |
+
outputs = model.generate(**inputs)
|
18 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
|
|
19 |
|
20 |
# Create a Gradio interface
|
21 |
iface = gr.Interface(
|
22 |
fn=predict,
|
23 |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
|
24 |
+
outputs="text",
|
25 |
title="Tech Legal Model",
|
26 |
description="A model for analyzing tech legal documents."
|
27 |
)
|