TuringsSolutions
commited on
Commit
•
5d16554
1
Parent(s):
e13e1dd
Update app.py
Browse files
app.py
CHANGED
@@ -5,18 +5,28 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
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(
|
|
|
|
|
|
|
|
|
11 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
return response
|
13 |
|
14 |
# Create Gradio interface
|
15 |
-
iface = gr.Interface(
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
# Launch the Gradio app
|
22 |
-
iface.launch()
|
|
|
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, temperature, max_tokens):
|
9 |
inputs = tokenizer(prompt, return_tensors="pt")
|
10 |
+
outputs = model.generate(
|
11 |
+
**inputs,
|
12 |
+
max_new_tokens=max_tokens,
|
13 |
+
temperature=temperature
|
14 |
+
)
|
15 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
16 |
return response
|
17 |
|
18 |
# Create Gradio interface
|
19 |
+
iface = gr.Interface(
|
20 |
+
fn=predict,
|
21 |
+
inputs=[
|
22 |
+
gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
|
23 |
+
gr.inputs.Slider(minimum=0.1, maximum=1.0, default=0.7, label="Temperature"),
|
24 |
+
gr.inputs.Slider(minimum=10, maximum=200, default=50, step=10, label="Number of Output Tokens")
|
25 |
+
],
|
26 |
+
outputs="text",
|
27 |
+
title="Phi3 Law Case Management Model",
|
28 |
+
description="A model to assist with law case management. Adjust the temperature and number of output tokens as needed."
|
29 |
+
)
|
30 |
|
31 |
# Launch the Gradio app
|
32 |
+
iface.launch()
|