Spaces:
Runtime error
Runtime error
KvrParaskevi
commited on
Commit
•
a4697a1
1
Parent(s):
f339afc
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
from langchain.llms.base import LLM
|
4 |
from langchain import PromptTemplate, LLMChain
|
5 |
|
|
|
6 |
def initialize_model_and_tokenizer(model_name="KvrParaskevi/Llama-2-7b-Hotel-Booking-Model"):
|
7 |
-
model =
|
8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
return model, tokenizer
|
10 |
|
@@ -51,7 +52,7 @@ with gr.Blocks() as demo:
|
|
51 |
|
52 |
def user(user_message, history):
|
53 |
return "", history + [[user_message, None]]
|
54 |
-
|
55 |
def bot(history):
|
56 |
print("Question: ", history[-1][0])
|
57 |
bot_message = llm_chain.run(question=history[-1][0])
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
from langchain.llms.base import LLM
|
4 |
from langchain import PromptTemplate, LLMChain
|
5 |
|
6 |
+
@spaces.GPU
|
7 |
def initialize_model_and_tokenizer(model_name="KvrParaskevi/Llama-2-7b-Hotel-Booking-Model"):
|
8 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
9 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
10 |
return model, tokenizer
|
11 |
|
|
|
52 |
|
53 |
def user(user_message, history):
|
54 |
return "", history + [[user_message, None]]
|
55 |
+
@spaces.GPU
|
56 |
def bot(history):
|
57 |
print("Question: ", history[-1][0])
|
58 |
bot_message = llm_chain.run(question=history[-1][0])
|