Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,47 +3,47 @@ from transformers import pipeline
|
|
3 |
import librosa
|
4 |
|
5 |
########################LLama model###############################
|
6 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
7 |
-
|
8 |
-
model_name_or_path = "TheBloke/llama2_7b_chat_uncensored-GPTQ"
|
9 |
-
# To use a different branch, change revision
|
10 |
-
# For example: revision="main"
|
11 |
-
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
|
19 |
-
Llama_pipe = pipeline(
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
)
|
30 |
-
history="""User: Hello, Rally?
|
31 |
-
Rally: I'm happy to see you again. What you want to talk to day?
|
32 |
-
User: Let's talk about food
|
33 |
-
Rally: Sure.
|
34 |
-
User: I'm hungry right now. Do you know any Vietnamese food?"""
|
35 |
-
|
36 |
-
prompt_template = f"""<|im_start|>system
|
37 |
-
Write one sentence to continue the conversation<|im_end|>
|
38 |
-
{history}
|
39 |
-
Rally:"""
|
40 |
-
print(Llama_pipe(prompt_template)[0]['generated_text'])
|
41 |
-
|
42 |
-
def RallyRespone(chat_history, message):
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
########################ASR model###############################
|
49 |
|
|
|
3 |
import librosa
|
4 |
|
5 |
########################LLama model###############################
|
6 |
+
# from transformers import AutoModelForCausalLM, AutoTokenizer
|
7 |
+
|
8 |
+
# model_name_or_path = "TheBloke/llama2_7b_chat_uncensored-GPTQ"
|
9 |
+
# # To use a different branch, change revision
|
10 |
+
# # For example: revision="main"
|
11 |
+
# model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
|
12 |
+
# device_map="auto",
|
13 |
+
# trust_remote_code=True,
|
14 |
+
# revision="main",
|
15 |
+
# #quantization_config=QuantizationConfig(disable_exllama=True)
|
16 |
+
# )
|
17 |
+
|
18 |
+
# tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
|
19 |
+
# Llama_pipe = pipeline(
|
20 |
+
# "text-generation",
|
21 |
+
# model=model,
|
22 |
+
# tokenizer=tokenizer,
|
23 |
+
# max_new_tokens=40,
|
24 |
+
# do_sample=True,
|
25 |
+
# temperature=0.7,
|
26 |
+
# top_p=0.95,
|
27 |
+
# top_k=40,
|
28 |
+
# repetition_penalty=1.1
|
29 |
+
# )
|
30 |
+
# history="""User: Hello, Rally?
|
31 |
+
# Rally: I'm happy to see you again. What you want to talk to day?
|
32 |
+
# User: Let's talk about food
|
33 |
+
# Rally: Sure.
|
34 |
+
# User: I'm hungry right now. Do you know any Vietnamese food?"""
|
35 |
+
|
36 |
+
# prompt_template = f"""<|im_start|>system
|
37 |
+
# Write one sentence to continue the conversation<|im_end|>
|
38 |
+
# {history}
|
39 |
+
# Rally:"""
|
40 |
+
# print(Llama_pipe(prompt_template)[0]['generated_text'])
|
41 |
+
|
42 |
+
# def RallyRespone(chat_history, message):
|
43 |
+
# chat_history += "User: " + message + "\n"
|
44 |
+
# t_chat = Llama_pipe(prompt_template)[0]['generated_text']
|
45 |
+
# res = t_chat[t_chat.rfind("Rally: "):]
|
46 |
+
# return res
|
47 |
|
48 |
########################ASR model###############################
|
49 |
|