Update app.py
Browse files
app.py
CHANGED
@@ -4,14 +4,14 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
4 |
from hf_olmo import * # registers the Auto* classes
|
5 |
|
6 |
|
7 |
-
title = """# 👋🏻Welcome to 🌟Tonic's 👴🏻🏑Olmo
|
8 |
-
"[👴🏻🏑allenai/OLMo-
|
9 |
Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community 👻 [![Join us on Discord](https://img.shields.io/discord/1109943800132010065?label=Discord&logo=discord&style=flat-square)](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to 🌟 [DataTonic](https://github.com/Tonic-AI/DataTonic) 🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
|
10 |
"""
|
11 |
|
12 |
-
model_name = "allenai/OLMo-
|
13 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
14 |
-
model = AutoModelForCausalLM.from_pretrained(model_name
|
15 |
|
16 |
def generate_text(prompt, max_new_tokens, top_k, top_p, do_sample):
|
17 |
inputs = tokenizer(prompt, return_tensors='pt', return_token_type_ids=False)
|
@@ -23,11 +23,12 @@ def main():
|
|
23 |
gr.Markdown(title)
|
24 |
output = gr.Textbox(label="👴🏻🏑OLMo", lines=10)
|
25 |
submit_button = gr.Button("🌟Try it Out!")
|
26 |
-
with gr.Accordion("🤖Optional Parameters"):
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
31 |
prompt = gr.Textbox(label="Enter your prompt")
|
32 |
submit_button.click(fn=generate_text, inputs=[prompt, max_new_tokens, top_k, top_p, do_sample], outputs=output)
|
33 |
|
|
|
4 |
from hf_olmo import * # registers the Auto* classes
|
5 |
|
6 |
|
7 |
+
title = """# 👋🏻Welcome to 🌟Tonic's 👴🏻🏑Olmo-on-Device
|
8 |
+
"[👴🏻🏑allenai/OLMo-1B](https://huggingface.co/allenai/OLMo-1B) is an on-device LLM from Allen-ai that can fit on your laptop ! You can use this demo to try out their model. You can also use [👴🏻🏑allenai/OLMo-1B](https://huggingface.co/allenai/OLMo-7B) [on your laptop & by cloning this space](https://huggingface.co/spaces/Tonic/Olmo/tree/main?clone=true). 🧬🔬🔍 Simply click here: <a style="display:inline-block" href="https://huggingface.co/spaces/Tonic/Olmo?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></h3>
|
9 |
Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community 👻 [![Join us on Discord](https://img.shields.io/discord/1109943800132010065?label=Discord&logo=discord&style=flat-square)](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to 🌟 [DataTonic](https://github.com/Tonic-AI/DataTonic) 🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
|
10 |
"""
|
11 |
|
12 |
+
model_name = "allenai/OLMo-1B"
|
13 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
14 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
15 |
|
16 |
def generate_text(prompt, max_new_tokens, top_k, top_p, do_sample):
|
17 |
inputs = tokenizer(prompt, return_tensors='pt', return_token_type_ids=False)
|
|
|
23 |
gr.Markdown(title)
|
24 |
output = gr.Textbox(label="👴🏻🏑OLMo", lines=10)
|
25 |
submit_button = gr.Button("🌟Try it Out!")
|
26 |
+
with gr.Accordion("🤖Optional Parameters", open=False):
|
27 |
+
with gr.Row():
|
28 |
+
do_sample = gr.Checkbox(value=False, label="Untick for faster inference")
|
29 |
+
max_new_tokens = gr.Slider(minimum=1, maximum=650, step=1, value=300, label="🪙new tokens in reply")
|
30 |
+
top_k = gr.Slider(minimum=1, maximum=100, step=1, value=50, label="🗣️Top K")
|
31 |
+
top_p = gr.Slider(minimum=0.1, maximum=1.0, step=0.01, value=0.95, label="🤫Repetition Penalty")
|
32 |
prompt = gr.Textbox(label="Enter your prompt")
|
33 |
submit_button.click(fn=generate_text, inputs=[prompt, max_new_tokens, top_k, top_p, do_sample], outputs=output)
|
34 |
|