Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoTokenizer, AutoModel
|
3 |
import torch
|
4 |
-
import json
|
5 |
|
6 |
# Load the tokenizer
|
7 |
-
model_name = "TuringsSolutions/
|
8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
-
adapter_model_url = "https://huggingface.co/TuringsSolutions/TechLegalV1/resolve/main/adapter_model.safetensors"
|
13 |
-
|
14 |
-
# Download and load the adapter configuration
|
15 |
-
adapter_config = torch.hub.download_url_to_file(adapter_config_url, 'adapter_config.json')
|
16 |
-
with open(adapter_config, 'r') as f:
|
17 |
-
adapter_config = json.load(f)
|
18 |
-
|
19 |
-
# Initialize the model with the adapter configuration
|
20 |
-
model = AutoModel.from_pretrained(model_name, trust_remote_code=True)
|
21 |
-
|
22 |
-
# Load adapter weights
|
23 |
-
model.load_adapter(adapter_model_url, config=adapter_config)
|
24 |
|
25 |
# Function to make predictions
|
26 |
def predict(text):
|
@@ -34,8 +21,8 @@ iface = gr.Interface(
|
|
34 |
fn=predict,
|
35 |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
|
36 |
outputs="json",
|
37 |
-
title="
|
38 |
-
description="A model for analyzing
|
39 |
)
|
40 |
|
41 |
# Launch the interface
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoTokenizer, AutoModel
|
3 |
import torch
|
|
|
4 |
|
5 |
# Load the tokenizer
|
6 |
+
model_name = "TuringsSolutions/LegalModelTest1"
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
|
9 |
+
# Initialize the model
|
10 |
+
model = AutoModel.from_pretrained(model_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Function to make predictions
|
13 |
def predict(text):
|
|
|
21 |
fn=predict,
|
22 |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
|
23 |
outputs="json",
|
24 |
+
title="Legal Model Test",
|
25 |
+
description="A model for analyzing legal documents."
|
26 |
)
|
27 |
|
28 |
# Launch the interface
|