Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,6 @@ sys_message = """
|
|
5 |
This model can generate untruths, lies or inappropriate things. Only for testing and validation.
|
6 |
"""
|
7 |
|
8 |
-
# Load the model from Hugging Face Model Hub
|
9 |
-
llm = AutoModelForCausalLM.from_pretrained("tevykuch/sl0th")
|
10 |
-
|
11 |
# Configuration settings for model generation (example)
|
12 |
generation_config = {
|
13 |
"max_new_tokens": 2048,
|
@@ -18,15 +15,17 @@ generation_config = {
|
|
18 |
"stop_token": '### Instruction:'
|
19 |
}
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
E_INST = " "
|
24 |
-
system, user, assistant = "###Instruction", "###Input", "###Response"
|
25 |
-
prompt = f"{system}\n{system_prompt}{E_INST}\n{user}\n{prompt.strip()}{E_INST}\n{assistant}\n"
|
26 |
-
|
27 |
-
output = llm.generate(prompt, **generation_config)
|
28 |
-
return output
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
|
32 |
|
@@ -44,16 +43,16 @@ chat_interface = gr.ChatInterface(
|
|
44 |
)
|
45 |
|
46 |
with gr.Blocks() as demo:
|
47 |
-
gr.HTML("<h1><center> sl0th <h1><center>")
|
48 |
gr.HTML(
|
49 |
"<h4 style='text-align: center'>"
|
50 |
"<a href='https://huggingface.co/tevykuch/sl0th' target='_blank'>Model: Sl0th Mistral 7b 0.2</a> | "
|
51 |
"</h4>"
|
52 |
)
|
53 |
-
gr.HTML("<p><center>Finetune
|
54 |
chat_interface.render()
|
55 |
gr.Markdown(sys_message)
|
56 |
-
gr.DuplicateButton(value="
|
57 |
|
58 |
if __name__ == "__main__":
|
59 |
demo.queue(max_size=10).launch()
|
|
|
5 |
This model can generate untruths, lies or inappropriate things. Only for testing and validation.
|
6 |
"""
|
7 |
|
|
|
|
|
|
|
8 |
# Configuration settings for model generation (example)
|
9 |
generation_config = {
|
10 |
"max_new_tokens": 2048,
|
|
|
15 |
"stop_token": '### Instruction:'
|
16 |
}
|
17 |
|
18 |
+
tokenizer = AutoTokenizer.from_pretrained("tevykuch/sl0th")
|
19 |
+
llm = AutoModelForCausalLM.from_pretrained("tevykuch/sl0th")
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
def stream(prompt):
|
22 |
+
# Tokenize the prompt
|
23 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
24 |
+
# Generate a response
|
25 |
+
output_ids = llm.generate(inputs, **generation_config)
|
26 |
+
# Decode the generated ids to a string
|
27 |
+
response = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
28 |
+
return response
|
29 |
|
30 |
|
31 |
|
|
|
43 |
)
|
44 |
|
45 |
with gr.Blocks() as demo:
|
46 |
+
gr.HTML("<h1><center> sl0th inference tester only (not final) <h1><center>")
|
47 |
gr.HTML(
|
48 |
"<h4 style='text-align: center'>"
|
49 |
"<a href='https://huggingface.co/tevykuch/sl0th' target='_blank'>Model: Sl0th Mistral 7b 0.2</a> | "
|
50 |
"</h4>"
|
51 |
)
|
52 |
+
gr.HTML("<p><center>Finetune here <a href='https://huggingface.co/unsloth/mistral-7b-bnb-4bit' target='_blank'>Mistral 7b</a> thanks dataset maker (my coworker) <a href='https://huggingface.co/datasets/metythorn/khmerllm-dataset-alpaca-52k-v1'>Alpaca-data-pt-br</a>.<p><center>")
|
53 |
chat_interface.render()
|
54 |
gr.Markdown(sys_message)
|
55 |
+
gr.DuplicateButton(value="Duplicate the Magic", elem_id="duplicate-button")
|
56 |
|
57 |
if __name__ == "__main__":
|
58 |
demo.queue(max_size=10).launch()
|