Spaces:
Build error
Build error
app.py
CHANGED
|
@@ -26,7 +26,7 @@ model_refs = load_all_models()
|
|
| 26 |
metadata = {}
|
| 27 |
|
| 28 |
# prepare LLM
|
| 29 |
-
model_name = "maxidl/
|
| 30 |
model = AutoModelForCausalLM.from_pretrained(
|
| 31 |
model_name,
|
| 32 |
torch_dtype=torch.bfloat16,
|
|
@@ -189,7 +189,8 @@ def generate(paper_text, review_template):
|
|
| 189 |
input_ids=input_ids,
|
| 190 |
max_new_tokens=2048,
|
| 191 |
do_sample=True,
|
| 192 |
-
temperature=0.
|
|
|
|
| 193 |
)
|
| 194 |
generated_ids = [
|
| 195 |
output_ids[len(input_ids):] for input_ids, output_ids in zip(input_ids, generated_ids)
|
|
@@ -205,10 +206,10 @@ def generate(paper_text, review_template):
|
|
| 205 |
css = """
|
| 206 |
#warning {background: red;}
|
| 207 |
|
| 208 |
-
.gradio-container {background-color: #FFFDFA !important;}
|
| 209 |
-
.title {background-color: #FFFDFA !important;}
|
| 210 |
.button {background-color: #8C1B13 !important; color: white !important;}
|
| 211 |
"""
|
|
|
|
|
|
|
| 212 |
#8C1B13 red
|
| 213 |
#4D8093 blue
|
| 214 |
#767676 med grey
|
|
@@ -217,23 +218,42 @@ css = """
|
|
| 217 |
#FFFDFA white
|
| 218 |
|
| 219 |
title = "# OpenReviewer"
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
-
theme = gr.themes.Default()
|
| 223 |
with gr.Blocks(theme=theme, css=css) as demo:
|
| 224 |
title = gr.Markdown(title, elem_classes=["title"])
|
|
|
|
| 225 |
description = gr.Markdown(description)
|
| 226 |
-
instr = gr.Markdown("
|
| 227 |
file_input = gr.File(file_types=[".pdf"], file_count="single")
|
| 228 |
paper_text_field= gr.Textbox("Upload a pdf or paste the full text of your paper in markdown format here.", label="Paper Text", max_lines=20, autoscroll=False)
|
| 229 |
-
with gr.Accordion("
|
| 230 |
-
|
|
|
|
| 231 |
generate_button = gr.Button("Generate Review", interactive=not paper_text_field)
|
| 232 |
-
# generate_button = gr.Button("Generate Review")
|
| 233 |
file_input.upload(process_file, file_input, paper_text_field)
|
| 234 |
paper_text_field.change(lambda text: gr.update(interactive=True) if len(text) > 200 else gr.update(interactive=False), paper_text_field, generate_button)
|
| 235 |
|
| 236 |
-
review_field = gr.Markdown("# Review\n\n\n", label="Review")
|
| 237 |
generate_button.click(fn=lambda: gr.update(interactive=False), inputs=None, outputs=generate_button).then(generate, [paper_text_field, review_template_field], review_field).then(fn=lambda: gr.update(interactive=True), inputs=None, outputs=generate_button)
|
| 238 |
demo.title = "Paper Review Generator"
|
| 239 |
|
|
|
|
| 26 |
metadata = {}
|
| 27 |
|
| 28 |
# prepare LLM
|
| 29 |
+
model_name = "maxidl/Llama-OpenReviewer-8B"
|
| 30 |
model = AutoModelForCausalLM.from_pretrained(
|
| 31 |
model_name,
|
| 32 |
torch_dtype=torch.bfloat16,
|
|
|
|
| 189 |
input_ids=input_ids,
|
| 190 |
max_new_tokens=2048,
|
| 191 |
do_sample=True,
|
| 192 |
+
temperature=0.6,
|
| 193 |
+
top_p=0.9
|
| 194 |
)
|
| 195 |
generated_ids = [
|
| 196 |
output_ids[len(input_ids):] for input_ids, output_ids in zip(input_ids, generated_ids)
|
|
|
|
| 206 |
css = """
|
| 207 |
#warning {background: red;}
|
| 208 |
|
|
|
|
|
|
|
| 209 |
.button {background-color: #8C1B13 !important; color: white !important;}
|
| 210 |
"""
|
| 211 |
+
# .gradio-container {background-color: #FFFDFA !important;}
|
| 212 |
+
# .title {background-color: #FFFDFA !important;}
|
| 213 |
#8C1B13 red
|
| 214 |
#4D8093 blue
|
| 215 |
#767676 med grey
|
|
|
|
| 218 |
#FFFDFA white
|
| 219 |
|
| 220 |
title = "# OpenReviewer"
|
| 221 |
+
title_icons = """<div style="text-align: center; display: flex; justify-content: left; gap: 5px;">
|
| 222 |
+
<a href="https://huggingface.co/maxidl/Llama-OpenReviewer-8B""><img src="https://img.shields.io/badge/🤗-Model-ffbd45.svg" alt="HuggingFace"></a>
|
| 223 |
+
</div>
|
| 224 |
+
"""
|
| 225 |
+
|
| 226 |
+
description = """This is an online demo of the `Llama-OpenReviewer-8B` model, which generates high-quality reviews for machine learning and AI-related papers.
|
| 227 |
+
|
| 228 |
+
## Demo Guidelines
|
| 229 |
+
|
| 230 |
+
1. Upload you paper as a pdf file. Alternatively you can paste the full text of your paper in markdown format below. Note that we do **not** store anything. All data is kept in ephemeral storage during processing.
|
| 231 |
+
|
| 232 |
+
2. Once you upload a pdf it will be converted to markdown. This takes some time as it runs multiple transformer models to parse the layout and extract text and tables. Checkout [marker](https://github.com/VikParuchuri/marker/tree/master) for details.
|
| 233 |
+
|
| 234 |
+
3. Having obtained a markdown version of your paper, you can now click `Generate Review`.
|
| 235 |
+
|
| 236 |
+
4. (Optional) Take a look at the Review Template to properly interpret the generated review. You can also change the review template before generating in case you want to generate a review with a different schema and aspects.
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
"""
|
| 240 |
|
| 241 |
+
theme = gr.themes.Default(primary_hue="gray", secondary_hue="blue", neutral_hue="slate")
|
| 242 |
with gr.Blocks(theme=theme, css=css) as demo:
|
| 243 |
title = gr.Markdown(title, elem_classes=["title"])
|
| 244 |
+
title_icons = gr.Markdown(title_icons)
|
| 245 |
description = gr.Markdown(description)
|
| 246 |
+
instr = gr.Markdown("Upload your paper in pdf format")
|
| 247 |
file_input = gr.File(file_types=[".pdf"], file_count="single")
|
| 248 |
paper_text_field= gr.Textbox("Upload a pdf or paste the full text of your paper in markdown format here.", label="Paper Text", max_lines=20, autoscroll=False)
|
| 249 |
+
with gr.Accordion("Review Template", open=False):
|
| 250 |
+
review_template_description = gr.Markdown("We use the ICLR 2025 review template by default, but you can modify the template below as you like.")
|
| 251 |
+
review_template_field = gr.Textbox(max_lines=20, autoscroll=False, value=REVIEW_FIELDS)
|
| 252 |
generate_button = gr.Button("Generate Review", interactive=not paper_text_field)
|
|
|
|
| 253 |
file_input.upload(process_file, file_input, paper_text_field)
|
| 254 |
paper_text_field.change(lambda text: gr.update(interactive=True) if len(text) > 200 else gr.update(interactive=False), paper_text_field, generate_button)
|
| 255 |
|
| 256 |
+
review_field = gr.Markdown("# Review\n\n\n\n\n", label="Review")
|
| 257 |
generate_button.click(fn=lambda: gr.update(interactive=False), inputs=None, outputs=generate_button).then(generate, [paper_text_field, review_template_field], review_field).then(fn=lambda: gr.update(interactive=True), inputs=None, outputs=generate_button)
|
| 258 |
demo.title = "Paper Review Generator"
|
| 259 |
|