m-ric HF Staff commited on
Commit
5897436
Β·
1 Parent(s): 31aa24a

Select date

Browse files
Files changed (1) hide show
  1. app.py +30 -27
app.py CHANGED
@@ -29,7 +29,7 @@ from utils import (
29
 
30
  def restart_space():
31
  HfApi(token=os.getenv("HF_TOKEN", None)).restart_space(
32
- repo_id="andrewrreed/closed-vs-open-arena-elo"
33
  )
34
  print(f"Space restarted on {datetime.now()}")
35
 
@@ -181,9 +181,13 @@ org_info = {
181
  "Zhipu AI": ("#FFC300", "πŸ‡¨πŸ‡³"),
182
  }
183
 
184
- def make_figure(df):
185
  fig = go.Figure()
186
 
 
 
 
 
187
  for i, org in enumerate(
188
  df.groupby("Organization")["rating"]
189
  .max()
@@ -276,13 +280,15 @@ def make_figure(df):
276
  legend_title="Ranking as of November 2024",
277
  title="The race for the best LLM",
278
  )
 
 
279
  fig.update_layout(
280
  xaxis_title="Date",
281
  hovermode="closest",
282
- xaxis_range=[pd.Timestamp("2024-01-01"), current_date], # Extend x-axis for labels
283
- yaxis_range=[best_models_df["rating"].min() - 10, df["rating"].max() + 30],
284
  )
285
- apply_template(fig, annotation_text="Aymeric Roucher")
286
 
287
  fig.update_xaxes(
288
  tickformat="%m-%Y",
@@ -290,8 +296,8 @@ def make_figure(df):
290
  return fig, df
291
 
292
  def filter_df(top_n_orgs=11, minimum_rating=1000):
293
- top_orgs = ratings_df.groupby("Organization")["rating"].max().nlargest(top_n_orgs).index.tolist()
294
- return ratings_df.loc[(ratings_df["Organization"].isin(top_orgs)) & (ratings_df["rating"] > minimum_rating)]
295
 
296
  with gr.Blocks(
297
  theme=gr.themes.Soft(
@@ -310,8 +316,9 @@ with gr.Blocks(
310
 
311
  filtered_df = gr.State()
312
  with gr.Row():
313
- top_n_orgs = gr.Slider(minimum=1, maximum=30, value=10, label="View top N companies")
314
- minimum_rating = gr.Slider(minimum=800, maximum=1300, value=1000, label="Restrict to ELO scores above N")
 
315
  with gr.Group():
316
  with gr.Tab("Plot"):
317
  plot = gr.Plot(show_label=False)
@@ -333,31 +340,27 @@ with gr.Blocks(
333
 
334
  demo.load(
335
  fn=filter_df,
336
- inputs=[top_n_orgs, minimum_rating],
337
  outputs=filtered_df,
338
  ).then(
339
  fn=make_figure,
340
- inputs=[filtered_df],
341
  outputs=[plot, display_df],
342
  )
343
 
344
- minimum_rating.change(
345
- fn=filter_df,
346
- inputs=[top_n_orgs, minimum_rating],
347
- outputs=filtered_df,
348
- ).then(
349
- fn=make_figure,
350
- inputs=[filtered_df],
351
- outputs=[plot, display_df],
352
- )
353
-
354
- top_n_orgs.change(
355
- fn=filter_df,
356
- inputs=[top_n_orgs, minimum_rating],
357
- outputs=filtered_df,
358
- ).then(
359
  fn=make_figure,
360
- inputs=[filtered_df],
361
  outputs=[plot, display_df],
362
  )
363
 
 
29
 
30
  def restart_space():
31
  HfApi(token=os.getenv("HF_TOKEN", None)).restart_space(
32
+ repo_id="m-ric/llm-race-to-the-top"
33
  )
34
  print(f"Space restarted on {datetime.now()}")
35
 
 
181
  "Zhipu AI": ("#FFC300", "πŸ‡¨πŸ‡³"),
182
  }
183
 
184
+ def make_figure(original_df, start_time_gradio):
185
  fig = go.Figure()
186
 
187
+ start_date = pd.to_datetime(start_time_gradio, unit='s')
188
+ original_df["Release Date"] = pd.to_datetime(original_df["Release Date"])
189
+ df = original_df.copy()
190
+
191
  for i, org in enumerate(
192
  df.groupby("Organization")["rating"]
193
  .max()
 
280
  legend_title="Ranking as of November 2024",
281
  title="The race for the best LLM",
282
  )
283
+ print("START TIME:", start_time)
284
+ margin = 30
285
  fig.update_layout(
286
  xaxis_title="Date",
287
  hovermode="closest",
288
+ xaxis_range=[start_date, current_date], # Extend x-axis for labels
289
+ yaxis_range=[df.loc[df["Release Date"] >= start_date]["rating"].min() - margin, df["rating"].max() + margin],
290
  )
291
+ apply_template(fig, annotation_text="Aymeric Roucher", height=500)
292
 
293
  fig.update_xaxes(
294
  tickformat="%m-%Y",
 
296
  return fig, df
297
 
298
  def filter_df(top_n_orgs=11, minimum_rating=1000):
299
+ top_orgs = ratings_df.groupby("Organization")["rating"].max().nlargest(int(top_n_orgs)).index.tolist()
300
+ return ratings_df.loc[(ratings_df["Organization"].isin(top_orgs))]
301
 
302
  with gr.Blocks(
303
  theme=gr.themes.Soft(
 
316
 
317
  filtered_df = gr.State()
318
  with gr.Row():
319
+ top_n_orgs = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="View top N companies")
320
+ # minimum_rating = gr.Slider(minimum=800, maximum=1300, value=1000, step=1, label="Restrict to ELO scores above N")
321
+ start_time = gr.DateTime(value="2024-01-01 00:00:00")
322
  with gr.Group():
323
  with gr.Tab("Plot"):
324
  plot = gr.Plot(show_label=False)
 
340
 
341
  demo.load(
342
  fn=filter_df,
343
+ inputs=[top_n_orgs],
344
  outputs=filtered_df,
345
  ).then(
346
  fn=make_figure,
347
+ inputs=[filtered_df, start_time],
348
  outputs=[plot, display_df],
349
  )
350
 
351
+ # minimum_rating.change(
352
+ # fn=filter_df,
353
+ # inputs=[top_n_orgs, minimum_rating],
354
+ # outputs=filtered_df,
355
+ # ).then(
356
+ # fn=make_figure,
357
+ # inputs=[filtered_df],
358
+ # outputs=[plot, display_df],
359
+ # )
360
+
361
+ start_time.change(
 
 
 
 
362
  fn=make_figure,
363
+ inputs=[filtered_df, start_time],
364
  outputs=[plot, display_df],
365
  )
366