ariG23498 HF staff commited on
Commit
7fb4c0c
1 Parent(s): c49578b

chore: lable interface

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -23,20 +23,19 @@ examples=[
23
  def get_titles(query):
24
  query_embed = model.encode(query)
25
  hits = semantic_search(query_embed, title_embeddings, top_k=5)[0]
26
-
27
- titles = list()
28
-
29
  for hit in hits:
30
  index = hit["corpus_id"]
31
  selected_title = title_dataset["train"]["title"][index]
32
- # score = hit["score"]
33
- titles.append(selected_title)
34
- return "\n".join(titles)
35
 
36
  space = gr.Interface(
37
  fn=get_titles,
38
  inputs=gr.Textbox(label="Input Title"),
39
- outputs=gr.Textbox(label="Similar Titles"),
 
40
  title=title,
41
  description=description,
42
  examples=examples,
 
23
  def get_titles(query):
24
  query_embed = model.encode(query)
25
  hits = semantic_search(query_embed, title_embeddings, top_k=5)[0]
26
+ titles = dict()
 
 
27
  for hit in hits:
28
  index = hit["corpus_id"]
29
  selected_title = title_dataset["train"]["title"][index]
30
+ score = hit["score"]
31
+ titles[selected_title] = score
32
+ return titles
33
 
34
  space = gr.Interface(
35
  fn=get_titles,
36
  inputs=gr.Textbox(label="Input Title"),
37
+ # outputs=gr.Textbox(label="Similar Titles"),
38
+ outputs=gr.Label(num_top_classes=5)
39
  title=title,
40
  description=description,
41
  examples=examples,