Spaces:
Runtime error
Runtime error
CreativeWorks
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -22,14 +22,15 @@ LICENSE = """
|
|
22 |
<p/>
|
23 |
|
24 |
---
|
25 |
-
|
|
|
26 |
"""
|
27 |
|
28 |
PLACEHOLDER = """
|
29 |
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
30 |
-
<img src="https://
|
31 |
-
<h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">
|
32 |
-
<p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">
|
33 |
</div>
|
34 |
"""
|
35 |
|
@@ -50,7 +51,7 @@ h1 {
|
|
50 |
|
51 |
# Load the tokenizer and model
|
52 |
tokenizer = AutoTokenizer.from_pretrained("CreativeWorksAi/CreativeWorks_Mistral_7b_Chat_V1")
|
53 |
-
model = AutoModelForCausalLM.from_pretrained("CreativeWorksAi/CreativeWorks_Mistral_7b_Chat_V1",
|
54 |
#model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct", device_map="auto") # to("cuda:0")
|
55 |
terminators = [
|
56 |
tokenizer.eos_token_id,
|
@@ -89,6 +90,7 @@ def chat_llama3_8b(message: str,
|
|
89 |
do_sample=True,
|
90 |
temperature=temperature,
|
91 |
eos_token_id=terminators,
|
|
|
92 |
)
|
93 |
# This will enforce greedy generation (do_sample=False) when the temperature is passed 0, avoiding the crash.
|
94 |
if temperature == 0:
|
@@ -110,7 +112,7 @@ chatbot=gr.Chatbot(height=450, placeholder=PLACEHOLDER, label='Gradio ChatInterf
|
|
110 |
with gr.Blocks(fill_height=True, css=css) as demo:
|
111 |
|
112 |
gr.Markdown(DESCRIPTION)
|
113 |
-
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
114 |
gr.ChatInterface(
|
115 |
fn=chat_llama3_8b,
|
116 |
chatbot=chatbot,
|
@@ -123,8 +125,8 @@ with gr.Blocks(fill_height=True, css=css) as demo:
|
|
123 |
value=0.95,
|
124 |
label="Temperature",
|
125 |
render=False),
|
126 |
-
gr.Slider(minimum=
|
127 |
-
maximum=
|
128 |
step=1,
|
129 |
value=512,
|
130 |
label="Max new tokens",
|
@@ -143,5 +145,5 @@ with gr.Blocks(fill_height=True, css=css) as demo:
|
|
143 |
gr.Markdown(LICENSE)
|
144 |
|
145 |
if __name__ == "__main__":
|
146 |
-
demo.launch()
|
147 |
|
|
|
22 |
<p/>
|
23 |
|
24 |
---
|
25 |
+
CreativeWoks AI: Intelligence System for Advanced Dialogue and Organized Responses Assistance
|
26 |
+
|
27 |
"""
|
28 |
|
29 |
PLACEHOLDER = """
|
30 |
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
31 |
+
<img src="https://utfs.io/f/4c8a3309-2ac3-453b-8441-04e5c5a3ed0f-361e80.svg" style="width: 80%; max-width: 550px; height: auto; opacity: 0.55; ">
|
32 |
+
<h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">CreativeWorks Ai</h1>
|
33 |
+
<p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">CreativeWorks 7B Chat</p>
|
34 |
</div>
|
35 |
"""
|
36 |
|
|
|
51 |
|
52 |
# Load the tokenizer and model
|
53 |
tokenizer = AutoTokenizer.from_pretrained("CreativeWorksAi/CreativeWorks_Mistral_7b_Chat_V1")
|
54 |
+
model = AutoModelForCausalLM.from_pretrained("CreativeWorksAi/CreativeWorks_Mistral_7b_Chat_V1", token=HF_TOKEN, device_map="auto")
|
55 |
#model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct", device_map="auto") # to("cuda:0")
|
56 |
terminators = [
|
57 |
tokenizer.eos_token_id,
|
|
|
90 |
do_sample=True,
|
91 |
temperature=temperature,
|
92 |
eos_token_id=terminators,
|
93 |
+
pad_token_id=tokenizer.eos_token_id
|
94 |
)
|
95 |
# This will enforce greedy generation (do_sample=False) when the temperature is passed 0, avoiding the crash.
|
96 |
if temperature == 0:
|
|
|
112 |
with gr.Blocks(fill_height=True, css=css) as demo:
|
113 |
|
114 |
gr.Markdown(DESCRIPTION)
|
115 |
+
#gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
116 |
gr.ChatInterface(
|
117 |
fn=chat_llama3_8b,
|
118 |
chatbot=chatbot,
|
|
|
125 |
value=0.95,
|
126 |
label="Temperature",
|
127 |
render=False),
|
128 |
+
gr.Slider(minimum=256,
|
129 |
+
maximum=8192,
|
130 |
step=1,
|
131 |
value=512,
|
132 |
label="Max new tokens",
|
|
|
145 |
gr.Markdown(LICENSE)
|
146 |
|
147 |
if __name__ == "__main__":
|
148 |
+
demo.launch(share=True)
|
149 |
|