TuringsSolutions
commited on
Commit
•
1041b24
1
Parent(s):
bfe56c9
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
+
|
4 |
+
# Load tokenizer and model
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("TuringsSolutions/Phi3LawCaseManagement", trust_remote_code=True)
|
6 |
+
model = AutoModelForCausalLM.from_pretrained("TuringsSolutions/Phi3LawCaseManagement", trust_remote_code=True)
|
7 |
+
|
8 |
+
def predict(prompt):
|
9 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs)
|
11 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
return response
|
13 |
+
|
14 |
+
# Create Gradio interface
|
15 |
+
iface = gr.Interface(fn=predict,
|
16 |
+
inputs="text",
|
17 |
+
outputs="text",
|
18 |
+
title="Phi3 Law Case Management Model",
|
19 |
+
description="A model to assist with law case management.")
|
20 |
+
|
21 |
+
# Launch the Gradio app
|
22 |
+
iface.launch()
|