Spaces:
Runtime error
Runtime error
antonioneto11
commited on
Commit
•
79246a2
1
Parent(s):
aeb75ab
Delete app.py
Browse files
app.py
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
-
|
4 |
-
# Initialize the tokenizer and model from Hugging Face's transformers
|
5 |
-
tokenizer = AutoTokenizer.from_pretrained("AdaptLLM/finance-chat")
|
6 |
-
model = AutoModelForCausalLM.from_pretrained("AdaptLLM/finance-chat")
|
7 |
-
|
8 |
-
def generate_answer(user_input):
|
9 |
-
our_system_prompt = ("\nYou are a helpful, respectful and honest assistant. English your note and knead it to a narrative, fact-wise, and sure. Anything out of the known or virtuous, decked kindly and in skill.\n\n")
|
10 |
-
prompt = f"{our_system_prompt}{user_input}\n\n###\n"
|
11 |
-
|
12 |
-
#
|
13 |
-
inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True, max_length=512)
|
14 |
-
output = model.generate(**inputs, max_length=512, temperature=0.7, num_return_sequences=1)
|
15 |
-
predicted_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
16 |
-
|
17 |
-
return predicted_text
|
18 |
-
|
19 |
-
# Gradio app interface
|
20 |
-
iface = gr.Interface(
|
21 |
-
fn=generate_answer,
|
22 |
-
inputs=gr.Textbox(lines=7, placeholder="Enter your finance question here..."),
|
23 |
-
outputs="text",
|
24 |
-
title="Finance Expert with AdaptLLM",
|
25 |
-
description="Get your finance questions answered confidently and clearly. Whether it's the realm of trading, financial technology, or business savvy you're intrigued by, cast your text here to press a layout of custom, company, or policy lay of our NLP response. The jibe is to an affected, content-cashed ear in line with today's AdaptLLM/finance-chat discourse."
|
26 |
-
)
|
27 |
-
|
28 |
-
iface.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|