Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import gradio as gr
|
|
7 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
8 |
|
9 |
|
10 |
-
def generate(html, entity, website_desc, datasource, year, month, title):
|
11 |
html_text = "html | " if html == "on" else ""
|
12 |
entity_text = ""
|
13 |
if entity != "":
|
@@ -23,12 +23,12 @@ def generate(html, entity, website_desc, datasource, year, month, title):
|
|
23 |
month_text = "Month: " + month + " | " if month != "" else ""
|
24 |
title_text = "Title: " + title + " | " if title != "" else ""
|
25 |
|
26 |
-
|
27 |
|
28 |
model = AutoModelForCausalLM.from_pretrained("bs-modeling-metadata/checkpoints_all_04_23", subfolder="checkpoint-30000step")
|
29 |
tokenizer = AutoTokenizer.from_pretrained("bs-modeling-metadata/checkpoints_all_04_23", subfolder="tokenizer")
|
30 |
|
31 |
-
inputs = tokenizer(
|
32 |
|
33 |
outputs = model.generate(**inputs, max_new_tokens=128)
|
34 |
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
@@ -41,10 +41,11 @@ datasource = gr.Textbox(placeholder="enter a datasource", label="datasource")
|
|
41 |
year = gr.Textbox(placeholder="enter a year", label="year")
|
42 |
month = gr.Textbox(placeholder="enter a month", label="month")
|
43 |
title = gr.Textbox(placeholder="enter a website title", label="website title")
|
|
|
44 |
|
45 |
demo = gr.Interface(
|
46 |
fn=generate,
|
47 |
-
inputs=[html, entity, website_desc, datasource, year, month, title],
|
48 |
outputs="text",
|
49 |
)
|
50 |
demo.launch()
|
|
|
7 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
8 |
|
9 |
|
10 |
+
def generate(html, entity, website_desc, datasource, year, month, title, prompt):
|
11 |
html_text = "html | " if html == "on" else ""
|
12 |
entity_text = ""
|
13 |
if entity != "":
|
|
|
23 |
month_text = "Month: " + month + " | " if month != "" else ""
|
24 |
title_text = "Title: " + title + " | " if title != "" else ""
|
25 |
|
26 |
+
final_prompt = html_text + year_text + month_text + website_desc_text + title_text + datasource_text + entity_text + prompt
|
27 |
|
28 |
model = AutoModelForCausalLM.from_pretrained("bs-modeling-metadata/checkpoints_all_04_23", subfolder="checkpoint-30000step")
|
29 |
tokenizer = AutoTokenizer.from_pretrained("bs-modeling-metadata/checkpoints_all_04_23", subfolder="tokenizer")
|
30 |
|
31 |
+
inputs = tokenizer(final_prompt, return_tensors="pt")
|
32 |
|
33 |
outputs = model.generate(**inputs, max_new_tokens=128)
|
34 |
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
|
|
41 |
year = gr.Textbox(placeholder="enter a year", label="year")
|
42 |
month = gr.Textbox(placeholder="enter a month", label="month")
|
43 |
title = gr.Textbox(placeholder="enter a website title", label="website title")
|
44 |
+
prompt = gr.Textbox(placeholder="enter a prompt", label="prompt")
|
45 |
|
46 |
demo = gr.Interface(
|
47 |
fn=generate,
|
48 |
+
inputs=[html, entity, website_desc, datasource, year, month, title, prompt],
|
49 |
outputs="text",
|
50 |
)
|
51 |
demo.launch()
|