blunt-octopus commited on
Commit
d1b431d
1 Parent(s): aed7750

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -75,18 +75,22 @@ with st.form("Taxonomizer"):
75
  submitted = st.form_submit_button("Taxonomize")
76
  st.caption('We **do not** recommend using ArXivTaxonomizer© to choose tags for you new paper.')
77
  if submitted:
 
78
  if title == '':
79
  st.markdown("You are most definitely abusing our service. No ticket today, but you better be careful.")
 
80
  prompt = 'Title: ' + title + ' Abstract: ' + abstract
81
  tokens = tokenizer(prompt, truncation=True, padding='max_length', return_tensors='pt')['input_ids']
82
  preds = softmax(model(tokens.reshape(1, -1)).logits / temperature, dim=1)
83
  tags = top_xx(preds, xx)
84
  other_tags = []
85
- st.header('Inferred tags:')
86
- for i, tag_data in enumerate(tags):
87
- if i < 3:
88
- st.markdown('* ' + tag_data['tag'] + ' (' + tag_data['description'] + ')')
89
- else:
90
- if i == 3:
91
- st.subheader('Other possible tags:')
92
- st.caption('* ' + tag_data['tag'] + ' (' + tag_data['description'] + ')')
 
 
 
75
  submitted = st.form_submit_button("Taxonomize")
76
  st.caption('We **do not** recommend using ArXivTaxonomizer&copy; to choose tags for you new paper.')
77
  if submitted:
78
+ empty = False
79
  if title == '':
80
  st.markdown("You are most definitely abusing our service. No ticket today, but you better be careful.")
81
+ empty = True
82
  prompt = 'Title: ' + title + ' Abstract: ' + abstract
83
  tokens = tokenizer(prompt, truncation=True, padding='max_length', return_tensors='pt')['input_ids']
84
  preds = softmax(model(tokens.reshape(1, -1)).logits / temperature, dim=1)
85
  tags = top_xx(preds, xx)
86
  other_tags = []
87
+ if not empty:
88
+ st.header('Inferred tags:')
89
+ for i, tag_data in enumerate(tags):
90
+ if i < 3:
91
+ st.markdown('* ' + tag_data['tag'] + ' (' + tag_data['description'] + ')')
92
+ else:
93
+ if i == 3:
94
+ st.subheader('Other possible tags:')
95
+ st.caption('* ' + tag_data['tag'] + ' (' + tag_data['description'] + ')')
96
+