Chris STC
commited on
Commit
·
618ed03
1
Parent(s):
f6c2dc2
Delete TESTapp.py
Browse files- TESTapp.py +0 -47
TESTapp.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import os
|
| 3 |
-
import wget
|
| 4 |
-
from llama_cpp import Llama
|
| 5 |
-
import random
|
| 6 |
-
|
| 7 |
-
os.system('CMAKE_ARGS="-DLLAMA_OPENBLAS=on" FORCE_CMAKE=1 pip install llama-cpp-python')
|
| 8 |
-
|
| 9 |
-
url = 'https://huggingface.co/TheBloke/WizardLM-7B-uncensored-GGML/resolve/main/WizardLM-7B-uncensored.ggmlv3.q2_K.bin'
|
| 10 |
-
filename = wget.download(url)
|
| 11 |
-
llm2 = Llama(model_path=filename, seed=random.randint(1, 2**31))
|
| 12 |
-
|
| 13 |
-
title = """<h1 align="center">Chat with awesome WizardLM 7b model!</h1><br>"""
|
| 14 |
-
description = "This model is awesome for its size! It is only 20th the size of Chatgpt but is around 90% as good as Chatgpt. However, please don't rely on WizardLM to provide 100% true information as it might be wrong sometimes."
|
| 15 |
-
|
| 16 |
-
def bot(user_message, temperature, top_p, top_k, repeat_penalty):
|
| 17 |
-
tokens3 = llm2.tokenize(user_message.encode())
|
| 18 |
-
token4 = llm2.tokenize(b"\n\n### Response:")
|
| 19 |
-
tokens = tokens3 + token4
|
| 20 |
-
|
| 21 |
-
output = ""
|
| 22 |
-
for token in llm2.generate(tokens, top_k=top_k, top_p=top_p, temp=temperature, repeat_penalty=repeat_penalty):
|
| 23 |
-
text = llm2.detokenize([token])
|
| 24 |
-
output += text.decode()
|
| 25 |
-
if token == llm2.token_eos():
|
| 26 |
-
break
|
| 27 |
-
|
| 28 |
-
# Removing other parts of the conversation, we just want the bot's response
|
| 29 |
-
response_start_idx = output.find("### Response:") + len("### Response:")
|
| 30 |
-
return output[response_start_idx:].strip()
|
| 31 |
-
|
| 32 |
-
interface = gr.Interface(
|
| 33 |
-
fn=bot,
|
| 34 |
-
inputs=[
|
| 35 |
-
gr.Textbox(label="Your Message", placeholder="Type your message here..."),
|
| 36 |
-
gr.Slider(minimum=0, maximum=2, default=1, label="Temperature"),
|
| 37 |
-
gr.Slider(minimum=0, maximum=1, default=0.73, label="Top P"),
|
| 38 |
-
gr.Slider(minimum=0, maximum=2048, default=50, label="Top_K"),
|
| 39 |
-
gr.Slider(minimum=0, maximum=2, default=1.1, label="Repeat Penalty")
|
| 40 |
-
],
|
| 41 |
-
outputs="text",
|
| 42 |
-
live=True,
|
| 43 |
-
description=description,
|
| 44 |
-
title=title
|
| 45 |
-
)
|
| 46 |
-
|
| 47 |
-
interface.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|