Sheshera Mysore commited on
Commit
e710ef9
·
1 Parent(s): 517ce65

Update UI.

Browse files
Files changed (1) hide show
  1. app.py +21 -16
app.py CHANGED
@@ -250,6 +250,9 @@ def second_stage_ranked_docs(selected_query_kps, first_stage_pids, pid2abstract,
250
  for pid in top_pids:
251
  # Exclude papers from the seed set in the result set.
252
  norm_title = " ".join(pid2abstract[pid]['title'].lower().strip().split())
 
 
 
253
  if norm_title in st.session_state.seed_titles:
254
  continue
255
  retrieved_papers[pid2abstract[pid]['title']] = {
@@ -375,10 +378,9 @@ def perp_result_json():
375
  ########################################
376
  st.title('\U0001F341 Maple Paper Recommender \U0001F341')
377
  st.markdown(
378
- '\U0001F341 Maple \U0001F341 makes controllable paper recommendations personalized to you based on a \U0001F331 seed set '
379
- '\U0001F331 of papers. The seed set of papers is used to build a \U0001F9D1 personalized profile \U0001F9D1 of keyphrases '
380
- 'which describe the seed papers. These are your profile descriptors. You can change your recommendations by editing '
381
- 'the list of descriptors, or including or excluding descriptors.')
382
 
383
  # Load candidate documents and models.
384
  pid2abstract_cands, pid2sent_vectors_cands = read_candidates(in_path)
@@ -406,8 +408,9 @@ with st.sidebar:
406
  # type='json',
407
  # help='Upload a json file with titles and abstracts of the papers to '
408
  # 'include in your profile.')
409
- selected_user = st.selectbox('Select your username from the drop-down',
410
- available_users)
 
411
  if selected_user is not None:
412
  user_papers = json.load(
413
  open(os.path.join(in_path, 'users', selected_user, f'seedset-{selected_user}-maple.json')))
@@ -419,7 +422,7 @@ with st.sidebar:
419
  # Perform first stage retrieval.
420
  first_stage_ret_pids = first_stage_ranked_docs(user_doc_queries=doc_vectors_user, per_doc_to_rank=500)
421
  with st.expander("Examine seed papers"):
422
- st.markdown(f'**Initial profile descriptors**:')
423
  st.markdown(display_profile_kps)
424
  st.markdown('**Seed papers**: {:d}'.format(len(user_papers['papers'])))
425
  for paper in user_papers['papers']:
@@ -430,13 +433,15 @@ with st.sidebar:
430
 
431
  if selected_user is not None:
432
  # Create a text box where users can see their profile keyphrases.
433
- st.subheader('\U0001F4DD Seed paper descriptors')
434
  with st.form('profile_kps'):
435
- input_kps = st.text_area('Edit seed descriptors:', display_profile_kps,
436
- help='Edit the profile descriptors if they are redundant, incomplete, nonsensical, '
437
- 'or dont describe the seed papers. OR if you would like the descriptors to '
438
- 'capture aspects of the seed papers that the descriptors dont currently capture.',
439
- placeholder='If left empty initial profile descriptors will be used...')
 
 
440
  input_user_kps = parse_input_kps(unparsed_kps=input_kps, initial_user_kps=user_kps)
441
  col1, col2, col3 = st.columns([1, 1, 1])
442
  with col2:
@@ -462,13 +467,13 @@ if selected_user is not None:
462
 
463
  # Create a multiselect dropdown
464
  if 'kp2val_vectors' in st.session_state:
465
- # with st.expander("Examine paper-descriptor alignment"):
466
  # user_tplan = st.session_state.user_tplan
467
  # fig = plot_sent_kp_alignment(tplan=user_tplan, kp_labels=input_user_kps,
468
  # sent_labels=range(user_tplan.shape[0]))
469
  # st.write(fig)
470
 
471
- st.subheader('\U0001F9D1 Profile descriptors for ranking')
472
  with st.form('profile_input'):
473
  st.markdown("""
474
  <style>
@@ -477,7 +482,7 @@ if selected_user is not None:
477
  }
478
  </style>
479
  """, unsafe_allow_html=True)
480
- profile_selections = st.multiselect(label='Add or remove profile descriptors to use for recommendations:',
481
  default=input_user_kps, # Use all the values by default.
482
  options=input_user_kps,
483
  help='Items selected here will be used for creating your '
 
250
  for pid in top_pids:
251
  # Exclude papers from the seed set in the result set.
252
  norm_title = " ".join(pid2abstract[pid]['title'].lower().strip().split())
253
+ # The mlconf pid2abstract has braces in the titles sometimes - remove them
254
+ norm_title = re.sub('\{', '', norm_title)
255
+ norm_title = re.sub('\}', '', norm_title)
256
  if norm_title in st.session_state.seed_titles:
257
  continue
258
  retrieved_papers[pid2abstract[pid]['title']] = {
 
378
  ########################################
379
  st.title('\U0001F341 Maple Paper Recommender \U0001F341')
380
  st.markdown(
381
+ '\U0001F341 Maple \U0001F341 uses a seed set of authored papers to make paper recommendations from ML and NLP conferences: NeurIPS, ICLR, ICML, UAI, AISTATS, ACL*, and EMNLP from years 2018 to 2023.'
382
+ '\n1. :white_check_mark: Select your username on the left\n2. :eyes: Verify keyphrases inferred for the papers and click '
383
+ '"\U0001F9D1 Generate profile \U0001F9D1"\n3. :mag: Request recommendations\n4. :repeat: Tune recommendations')
 
384
 
385
  # Load candidate documents and models.
386
  pid2abstract_cands, pid2sent_vectors_cands = read_candidates(in_path)
 
408
  # type='json',
409
  # help='Upload a json file with titles and abstracts of the papers to '
410
  # 'include in your profile.')
411
+ st.markdown(f"<b style='color:red;'>Select your username from the drop-down:</b>", unsafe_allow_html=True)
412
+ selected_user = st.selectbox('**Select your username from the drop-down**',
413
+ available_users, label_visibility="hidden")
414
  if selected_user is not None:
415
  user_papers = json.load(
416
  open(os.path.join(in_path, 'users', selected_user, f'seedset-{selected_user}-maple.json')))
 
422
  # Perform first stage retrieval.
423
  first_stage_ret_pids = first_stage_ranked_docs(user_doc_queries=doc_vectors_user, per_doc_to_rank=500)
424
  with st.expander("Examine seed papers"):
425
+ st.markdown(f'**Initial profile keyphrases**:')
426
  st.markdown(display_profile_kps)
427
  st.markdown('**Seed papers**: {:d}'.format(len(user_papers['papers'])))
428
  for paper in user_papers['papers']:
 
433
 
434
  if selected_user is not None:
435
  # Create a text box where users can see their profile keyphrases.
436
+ st.subheader('\U0001F4DD Seed paper keyphrases')
437
  with st.form('profile_kps'):
438
+ input_kps = st.text_area(
439
+ 'Add/remove keyphrases to fix redundancy, inaccuracy, incompleteness, or being nonsensical:',
440
+ display_profile_kps,
441
+ help='Edit the profile keyphrases if they are redundant, incomplete, nonsensical, '
442
+ 'or dont accurately describe the seed papers. You can also add keyphrases to '
443
+ 'capture aspects of the seed papers that the keyphrases dont currently capture.',
444
+ placeholder='If left empty initial profile keyphrases will be used...')
445
  input_user_kps = parse_input_kps(unparsed_kps=input_kps, initial_user_kps=user_kps)
446
  col1, col2, col3 = st.columns([1, 1, 1])
447
  with col2:
 
467
 
468
  # Create a multiselect dropdown
469
  if 'kp2val_vectors' in st.session_state:
470
+ # with st.expander("Examine paper-keyphrase alignment"):
471
  # user_tplan = st.session_state.user_tplan
472
  # fig = plot_sent_kp_alignment(tplan=user_tplan, kp_labels=input_user_kps,
473
  # sent_labels=range(user_tplan.shape[0]))
474
  # st.write(fig)
475
 
476
+ st.subheader('\U0001F9D1 Profile keyphrases for ranking')
477
  with st.form('profile_input'):
478
  st.markdown("""
479
  <style>
 
482
  }
483
  </style>
484
  """, unsafe_allow_html=True)
485
+ profile_selections = st.multiselect(label='Include or exclude profile keyphrases to use for recommendations:',
486
  default=input_user_kps, # Use all the values by default.
487
  options=input_user_kps,
488
  help='Items selected here will be used for creating your '