Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,8 @@ Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder
|
|
21 |
tokenizer = AutoModelForCausalLM.from_pretrained(model_id)
|
22 |
tokenizer = YiTokenizer.from_pretrained(tokenizer_path)
|
23 |
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True)
|
|
|
|
|
24 |
|
25 |
def format_prompt(user_message, system_message="I am YiTonic, an AI language model created by Tonic-AI. I am a cautious assistant. I carefully follow instructions. I am helpful and harmless and I follow ethical guidelines and promote positive behavior."):
|
26 |
prompt = f"<|im_start|>assistant\n{self.system_message}<|im_end|>\n<|im_start|>\nuser\n{user_message}<|im_end|>\nassistant\n"
|
@@ -52,6 +54,9 @@ with gr.Blocks(theme='ParityError/Anime') as demo:
|
|
52 |
textbox = gr.Textbox(placeholder='Your Message Here', label='Your Message', lines=2)
|
53 |
system_prompt = gr.Textbox(placeholder='Provide a System Prompt In The First Person', label='System Prompt', lines=2, value="You are YiTonic, an AI language model created by Tonic-AI. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior.")
|
54 |
|
|
|
|
|
|
|
55 |
with gr.Group():
|
56 |
submit_button = gr.Button('Submit', variant='primary')
|
57 |
|
@@ -60,7 +65,7 @@ with gr.Blocks(theme='ParityError/Anime') as demo:
|
|
60 |
temperature = gr.Slider(label='Temperature', minimum=0.1, maximum=4.0, step=0.1, value=1.2)
|
61 |
top_p = gr.Slider(label='Top-P (nucleus sampling)', minimum=0.05, maximum=1.0, step=0.05, value=0.9)
|
62 |
top_k = gr.Slider(label='Top-K', minimum=1, maximum=1000, step=1, value=900)
|
63 |
-
do_sample_checkbox = gr.Checkbox(label='Disable for faster inference', value=
|
64 |
|
65 |
submit_button.click(
|
66 |
fn=predict,
|
@@ -68,7 +73,4 @@ with gr.Blocks(theme='ParityError/Anime') as demo:
|
|
68 |
outputs=chatbot
|
69 |
)
|
70 |
|
71 |
-
with gr.Group():
|
72 |
-
chatbot = gr.Chatbot(label='TonicYi-6B-200K-🦙')
|
73 |
-
|
74 |
demo.launch()
|
|
|
21 |
tokenizer = AutoModelForCausalLM.from_pretrained(model_id)
|
22 |
tokenizer = YiTokenizer.from_pretrained(tokenizer_path)
|
23 |
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True)
|
24 |
+
tokenizer.eos_token_id = eos_token_id
|
25 |
+
model.config.eos_token_id = eos_token_id
|
26 |
|
27 |
def format_prompt(user_message, system_message="I am YiTonic, an AI language model created by Tonic-AI. I am a cautious assistant. I carefully follow instructions. I am helpful and harmless and I follow ethical guidelines and promote positive behavior."):
|
28 |
prompt = f"<|im_start|>assistant\n{self.system_message}<|im_end|>\n<|im_start|>\nuser\n{user_message}<|im_end|>\nassistant\n"
|
|
|
54 |
textbox = gr.Textbox(placeholder='Your Message Here', label='Your Message', lines=2)
|
55 |
system_prompt = gr.Textbox(placeholder='Provide a System Prompt In The First Person', label='System Prompt', lines=2, value="You are YiTonic, an AI language model created by Tonic-AI. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior.")
|
56 |
|
57 |
+
with gr.Group():
|
58 |
+
chatbot = gr.Chatbot(label='TonicYi-6B-200K-🦙')
|
59 |
+
|
60 |
with gr.Group():
|
61 |
submit_button = gr.Button('Submit', variant='primary')
|
62 |
|
|
|
65 |
temperature = gr.Slider(label='Temperature', minimum=0.1, maximum=4.0, step=0.1, value=1.2)
|
66 |
top_p = gr.Slider(label='Top-P (nucleus sampling)', minimum=0.05, maximum=1.0, step=0.05, value=0.9)
|
67 |
top_k = gr.Slider(label='Top-K', minimum=1, maximum=1000, step=1, value=900)
|
68 |
+
do_sample_checkbox = gr.Checkbox(label='Disable for faster inference', value=True)
|
69 |
|
70 |
submit_button.click(
|
71 |
fn=predict,
|
|
|
73 |
outputs=chatbot
|
74 |
)
|
75 |
|
|
|
|
|
|
|
76 |
demo.launch()
|