Trent commited on
Commit
fa5d8a4
1 Parent(s): f7a5664

Fix sort ordering

Browse files
Files changed (1) hide show
  1. backend/inference.py +4 -4
backend/inference.py CHANGED
@@ -20,18 +20,18 @@ def text_similarity(anchor: str, inputs: List[str], model_name: str, model_dict:
20
  # Creating embeddings
21
  if hasattr(model, 'encode'):
22
  anchor_emb = model.encode(anchor)[None, :]
23
- inputs_emb = model.encode([input for input in inputs])
24
  else:
25
  assert len(model) == 2
26
  anchor_emb = model[0].encode(anchor)[None, :]
27
- inputs_emb = model[1].encode([input for input in inputs])
28
 
29
  # Obtaining similarity
30
  similarity = list(jnp.squeeze(cos_sim(anchor_emb, inputs_emb)))
31
 
32
  # Returning a Pandas' dataframe
33
- d = {'inputs': [input for input in inputs],
34
  'score': [round(similarity[i], 3) for i in range(len(similarity))]}
35
  df = pd.DataFrame(d, columns=['inputs', 'score'])
36
 
37
- return df.sort_values('score', ascending=False)
 
20
  # Creating embeddings
21
  if hasattr(model, 'encode'):
22
  anchor_emb = model.encode(anchor)[None, :]
23
+ inputs_emb = model.encode(inputs)
24
  else:
25
  assert len(model) == 2
26
  anchor_emb = model[0].encode(anchor)[None, :]
27
+ inputs_emb = model[1].encode(inputs)
28
 
29
  # Obtaining similarity
30
  similarity = list(jnp.squeeze(cos_sim(anchor_emb, inputs_emb)))
31
 
32
  # Returning a Pandas' dataframe
33
+ d = {'inputs': inputs,
34
  'score': [round(similarity[i], 3) for i in range(len(similarity))]}
35
  df = pd.DataFrame(d, columns=['inputs', 'score'])
36
 
37
+ return df