File size: 8,108 Bytes
d06d36f
 
 
 
475df0d
d06d36f
 
f69892b
d06d36f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475df0d
f69892b
d06d36f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38eb481
d06d36f
 
 
 
 
 
 
 
 
 
f69892b
 
 
 
d06d36f
 
 
 
 
 
 
f69892b
 
 
 
 
 
 
 
 
52de44b
0e03ced
 
 
 
 
f69892b
d06d36f
 
 
 
 
 
 
 
 
 
 
 
f69892b
 
 
 
475df0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d06d36f
 
 
 
 
f69892b
 
 
 
 
52de44b
d06d36f
f69892b
52de44b
f69892b
52de44b
 
 
 
f69892b
 
 
 
 
 
 
 
 
 
 
d06d36f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475df0d
 
 
d06d36f
f69892b
 
 
 
 
 
475df0d
 
d06d36f
f69892b
 
 
 
d06d36f
 
 
 
 
f69892b
d06d36f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#!/usr/bin/env python

import gradio as gr
import polars as pl
from gradio_modal import Modal

from app_pr import demo as demo_pr
from semantic_search import semantic_search
from table import df_orig

DESCRIPTION = "# ICLR 2025"

TUTORIAL = """\
#### Claiming Authorship for Papers on arXiv

If your ICLR 2025 paper is available on arXiv and listed in the table below, you can claim authorship by following these steps:

1. Find your paper in the table.
2. Click the link to the paper page in the table.
3. On that page, click your name.
4. Click **"Claim authorship"**.
    - You'll be redirected to the *Papers* section of your Settings.
5. Confirm the request on the redirected page.

The admin team will review your request shortly.
Once confirmed, your paper page will be marked as verified, and you'll be able to add a project page and a GitHub repository.

If you need further help, check out the [guide here](https://huggingface.co./docs/hub/paper-pages).


#### Updating Missing or Incorrect Information in the Table

If you notice any missing or incorrect information in the table, feel free to submit a PR via the "Open PR" page, which you can find at the top right of this page.
"""

# TODO: remove this once https://github.com/gradio-app/gradio/issues/10916 https://github.com/gradio-app/gradio/issues/11001 https://github.com/gradio-app/gradio/issues/11002 are fixed  # noqa: TD002, FIX002
NOTE = """\
Note: Sorting by upvotes or comments may not work correctly due to a known bug in Gradio.
"""


df_main = df_orig.select(
    "title",
    "authors_str",
    "openreview_md",
    "type",
    "paper_page_md",
    "upvotes",
    "num_comments",
    "project_page_md",
    "github_md",
    "Spaces",
    "Models",
    "Datasets",
    "claimed",
    "abstract",
    "paper_id",
)

df_main = df_main.rename(
    {
        "title": "Title",
        "authors_str": "Authors",
        "openreview_md": "OpenReview",
        "type": "Type",
        "paper_page_md": "Paper page",
        "upvotes": "👍",
        "num_comments": "💬",
        "project_page_md": "Project page",
        "github_md": "GitHub",
    }
)

COLUMN_INFO = {
    "Title": ("str", "40%"),
    "Authors": ("str", "20%"),
    "Type": ("str", None),
    "Paper page": ("markdown", "135px"),
    "👍": ("number", "50px"),
    "💬": ("number", "50px"),
    "OpenReview": ("markdown", None),
    "Project page": ("markdown", None),
    "GitHub": ("markdown", None),
    "Spaces": ("markdown", None),
    "Models": ("markdown", None),
    "Datasets": ("markdown", None),
    "claimed": ("markdown", None),
}


DEFAULT_COLUMNS = [
    "Title",
    "Type",
    "Paper page",
    "👍",
    "💬",
    "OpenReview",
    "Project page",
    "GitHub",
    "Spaces",
    "Models",
    "Datasets",
]


def update_num_papers(df: pl.DataFrame) -> str:
    if "claimed" in df.columns:
        return f"{len(df)} / {len(df_main)} ({df.select(pl.col('claimed').str.contains('✅').sum()).item()} claimed)"
    return f"{len(df)} / {len(df_main)}"


def update_df(
    search_mode: str,
    search_query: str,
    candidate_pool_size: int,
    score_threshold: float,
    presentation_type: str,
    column_names: list[str],
    case_insensitive: bool = True,
) -> gr.Dataframe:
    df = df_main.clone()
    column_names = ["Title", *column_names]

    if search_query:
        if search_mode == "Title Search":
            if case_insensitive:
                search_query = f"(?i){search_query}"
            try:
                df = df.filter(pl.col("Title").str.contains(search_query))
            except pl.exceptions.ComputeError as e:
                raise gr.Error(str(e)) from e
        else:
            paper_ids, scores = semantic_search(search_query, candidate_pool_size, score_threshold)
            if not paper_ids:
                df = df.head(0)
            else:
                df = pl.DataFrame({"paper_id": paper_ids, "score": scores}).join(df, on="paper_id", how="inner")
                df = df.sort("score", descending=True).drop("score")

    if presentation_type != "(ALL)":
        df = df.filter(pl.col("Type").str.contains(presentation_type))

    sorted_column_names = [col for col in COLUMN_INFO if col in column_names]
    df = df.select(sorted_column_names)
    return gr.Dataframe(
        value=df,
        datatype=[COLUMN_INFO[col][0] for col in sorted_column_names],
        column_widths=[COLUMN_INFO[col][1] for col in sorted_column_names],
    )


def update_search_mode(search_mode: str) -> gr.Accordion:
    return gr.Accordion(visible=search_mode == "Semantic Search")


def df_row_selected(
    evt: gr.SelectData,
) -> tuple[
    Modal,
    gr.Textbox,  # title
    gr.Textbox,  # abstract
]:
    if evt.index[1] != 0:
        return Modal(), gr.Textbox(), gr.Textbox()

    title = evt.row_value[0]
    row = df_main.filter(pl.col("Title") == title)
    return (
        Modal(visible=True),
        gr.Textbox(value=row["Title"].item()),  # title
        gr.Textbox(value=row["abstract"].item()),  # abstract
    )


with gr.Blocks(css_paths="style.css") as demo:
    gr.Markdown(DESCRIPTION)
    with gr.Accordion(label="Tutorial", open=True):
        gr.Markdown(TUTORIAL)
    with gr.Group():
        search_mode = gr.Radio(
            label="Search Mode",
            choices=["Semantic Search", "Title Search"],
            value="Semantic Search",
            show_label=False,
            info="Note: Semantic search consumes your ZeroGPU quota.",
        )
        search_query = gr.Textbox(label="Search", submit_btn=True, show_label=False, placeholder="Enter query here")
        with gr.Accordion(label="Advanced Search Options", open=False) as advanced_search_options:
            with gr.Row():
                candidate_pool_size = gr.Slider(
                    label="Candidate Pool Size", minimum=1, maximum=1000, step=1, value=300
                )
                score_threshold = gr.Slider(label="Score Threshold", minimum=0, maximum=1, step=0.01, value=0.5)

    presentation_type = gr.Radio(
        label="Presentation Type",
        choices=["(ALL)", "Oral", "Spotlight", "Poster"],
        value="(ALL)",
    )
    column_names = gr.CheckboxGroup(
        label="Columns",
        choices=[col for col in COLUMN_INFO if col != "Title"],
        value=[col for col in DEFAULT_COLUMNS if col != "Title"],
    )

    num_papers = gr.Textbox(label="Number of papers", value=update_num_papers(df_orig), interactive=False)

    gr.Markdown(NOTE)
    df = gr.Dataframe(
        value=df_main,
        datatype=list(COLUMN_INFO.values()),
        type="polars",
        row_count=(0, "dynamic"),
        show_row_numbers=True,
        interactive=False,
        max_height=1000,
        elem_id="table",
        column_widths=[COLUMN_INFO[col][1] for col in COLUMN_INFO],
    )
    with Modal(visible=False, elem_id="abstract-modal") as abstract_modal:
        title = gr.Textbox(label="Title")
        abstract = gr.Textbox(label="Abstract")

    search_mode.change(
        fn=update_search_mode,
        inputs=search_mode,
        outputs=advanced_search_options,
    )

    df.select(fn=df_row_selected, outputs=[abstract_modal, title, abstract])

    inputs = [
        search_mode,
        search_query,
        candidate_pool_size,
        score_threshold,
        presentation_type,
        column_names,
    ]
    gr.on(
        triggers=[
            search_query.submit,
            presentation_type.input,
            column_names.input,
        ],
        fn=update_df,
        inputs=inputs,
        outputs=df,
        api_name=False,
    ).then(
        fn=update_num_papers,
        inputs=df,
        outputs=num_papers,
        queue=False,
        api_name=False,
    )
    demo.load(
        fn=update_df,
        inputs=inputs,
        outputs=df,
        api_name=False,
    ).then(
        fn=update_num_papers,
        inputs=df,
        outputs=num_papers,
        queue=False,
        api_name=False,
    )


with demo.route("Open PR"):
    demo_pr.render()


if __name__ == "__main__":
    demo.queue(api_open=False).launch(show_api=False)