Spaces:
Runtime error
Runtime error
yuchenlin
commited on
Commit
·
643a2a0
1
Parent(s):
fd8b009
add header and change theem
Browse files
app.py
CHANGED
@@ -4,6 +4,20 @@ import spaces
|
|
4 |
from threading import Thread
|
5 |
from typing import Iterator
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
# Load model and tokenizer
|
8 |
model_name = "Magpie-Align/MagpieLM-4B-Chat-v0.1"
|
9 |
|
@@ -11,7 +25,8 @@ device = "cuda" # the device to load the model onto
|
|
11 |
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
12 |
model = AutoModelForCausalLM.from_pretrained(
|
13 |
model_name,
|
14 |
-
torch_dtype="auto"
|
|
|
15 |
)
|
16 |
model.to(device)
|
17 |
|
@@ -64,21 +79,23 @@ def respond(
|
|
64 |
demo = gr.ChatInterface(
|
65 |
respond,
|
66 |
additional_inputs=[
|
67 |
-
gr.Textbox(value="You are Magpie, a helpful AI assistant.", label="System message"),
|
68 |
-
gr.Slider(minimum=
|
69 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.
|
70 |
gr.Slider(
|
71 |
minimum=0.1,
|
72 |
maximum=1.0,
|
73 |
value=0.9,
|
74 |
-
step=0.
|
75 |
label="Top-p (nucleus sampling)",
|
76 |
),
|
77 |
gr.Slider(minimum=0.5, maximum=1.5, value=1.0, step=0.1, label="Repetation Penalty"),
|
78 |
],
|
|
|
|
|
|
|
79 |
)
|
80 |
|
81 |
-
|
82 |
if __name__ == "__main__":
|
83 |
demo.queue()
|
84 |
demo.launch(share=True)
|
|
|
4 |
from threading import Thread
|
5 |
from typing import Iterator
|
6 |
|
7 |
+
# Add markdown header
|
8 |
+
header = """
|
9 |
+
# 🐦⬛ MagpieLMs: Open LLMs with Fully Transparent Alignment Recipes
|
10 |
+
|
11 |
+
💬 We've aligned Llama-3.1-8B and a 4B version (distilled by NVIDIA) using purely synthetic data generated by our [Magpie](https://arxiv.org/abs/2406.08464) method. Our open-source post-training recipe includes: SFT and DPO data, all training configs + logs. This allows everyone to reproduce the alignment process for their own research. Note that our data does not contain any GPT-generated data, and has a much friendly license for both commercial and academic use.
|
12 |
+
|
13 |
+
- **Magpie Collection**: [Magpie on Hugging Face](https://lnkd.in/g_pgX5Y2)
|
14 |
+
- **Magpie Paper**: [Read the research paper](https://arxiv.org/abs/2406.08464)
|
15 |
+
|
16 |
+
Contact: [Zhangchen Xu](https://zhangchenxu.com) and [Bill Yuchen Lin](https://yuchenlin.xyz).
|
17 |
+
|
18 |
+
---
|
19 |
+
"""
|
20 |
+
|
21 |
# Load model and tokenizer
|
22 |
model_name = "Magpie-Align/MagpieLM-4B-Chat-v0.1"
|
23 |
|
|
|
25 |
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
26 |
model = AutoModelForCausalLM.from_pretrained(
|
27 |
model_name,
|
28 |
+
torch_dtype="auto",
|
29 |
+
ignore_mismatched_sizes=True
|
30 |
)
|
31 |
model.to(device)
|
32 |
|
|
|
79 |
demo = gr.ChatInterface(
|
80 |
respond,
|
81 |
additional_inputs=[
|
82 |
+
gr.Textbox(value="You are Magpie, a helpful AI assistant. For simple qeuries, try to answer them directly; for complex questions, try to think step-by-step before providing an answer.", label="System message"),
|
83 |
+
gr.Slider(minimum=128, maximum=2048, value=512, step=64, label="Max new tokens"),
|
84 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
85 |
gr.Slider(
|
86 |
minimum=0.1,
|
87 |
maximum=1.0,
|
88 |
value=0.9,
|
89 |
+
step=0.1,
|
90 |
label="Top-p (nucleus sampling)",
|
91 |
),
|
92 |
gr.Slider(minimum=0.5, maximum=1.5, value=1.0, step=0.1, label="Repetation Penalty"),
|
93 |
],
|
94 |
+
description=header, # Add the header as the description
|
95 |
+
title="MagpieLM-4B Chat (v0.1)",
|
96 |
+
theme=gr.themes.Soft()
|
97 |
)
|
98 |
|
|
|
99 |
if __name__ == "__main__":
|
100 |
demo.queue()
|
101 |
demo.launch(share=True)
|