Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,11 +7,11 @@ from llama_cpp import Llama
|
|
| 7 |
from huggingface_hub import hf_hub_download #load from huggingfaces
|
| 8 |
|
| 9 |
|
| 10 |
-
llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/
|
| 11 |
|
| 12 |
history = []
|
| 13 |
|
| 14 |
-
pre_prompt = " The user and the AI are having a conversation : "
|
| 15 |
|
| 16 |
def generate_text(input_text, history):
|
| 17 |
print("history ",history)
|
|
@@ -23,7 +23,7 @@ def generate_text(input_text, history):
|
|
| 23 |
input_text_with_history = f"{history[-1][1]}"+ "\n"
|
| 24 |
input_text_with_history += f"<|prompter|> {input_text}" + "\n" +" <|assistant|>"
|
| 25 |
print("new input", input_text_with_history)
|
| 26 |
-
output = llm(input_text_with_history, max_tokens=1024, stop=["<|prompter|>", "<|endoftext|>"], stream=True)
|
| 27 |
for out in output:
|
| 28 |
stream = copy.deepcopy(out)
|
| 29 |
print(stream["choices"][0]["text"])
|
|
|
|
| 7 |
from huggingface_hub import hf_hub_download #load from huggingfaces
|
| 8 |
|
| 9 |
|
| 10 |
+
llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/Dolphin-Llama2-7B-GGML", filename="dolphin-llama2-7b.ggmlv3.q4_1.bin"), n_ctx=2048) #download model from hf/ n_ctx=2048 for high ccontext length
|
| 11 |
|
| 12 |
history = []
|
| 13 |
|
| 14 |
+
pre_prompt = " The user and the AI are having a conversation : <|endoftext|> \n "
|
| 15 |
|
| 16 |
def generate_text(input_text, history):
|
| 17 |
print("history ",history)
|
|
|
|
| 23 |
input_text_with_history = f"{history[-1][1]}"+ "\n"
|
| 24 |
input_text_with_history += f"<|prompter|> {input_text}" + "\n" +" <|assistant|>"
|
| 25 |
print("new input", input_text_with_history)
|
| 26 |
+
output = llm(input_text_with_history, max_tokens=1024, stop=["<|prompter|>", "<|endoftext|>", "<|endoftext|> \n"], stream=True)
|
| 27 |
for out in output:
|
| 28 |
stream = copy.deepcopy(out)
|
| 29 |
print(stream["choices"][0]["text"])
|