danieldux commited on
Commit
9696cd0
1 Parent(s): 6ee9bbb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -42,7 +42,13 @@ def retrieve_and_rerank_faiss(job_duties, model_name="BAAI/bge-m3", top_k=4):
42
  query_embedding = np.array(query_embedding).astype("float32")
43
  distances, indices = index.search(query_embedding, top_k)
44
  results = [
45
- (isco_taxonomy[str(idx)]["ESCO_DESCRIPTION"], distances[0][i])
 
 
 
 
 
 
46
  for i, idx in enumerate(indices[0])
47
  ]
48
  return results
@@ -50,7 +56,7 @@ def retrieve_and_rerank_faiss(job_duties, model_name="BAAI/bge-m3", top_k=4):
50
  # Gradio Interface
51
  def gradio_interface(job_duties):
52
  results = retrieve_and_rerank_faiss(job_duties)
53
- return [f"Description: {desc}, Distance: {dist}" for desc, dist in results]
54
 
55
- iface = gr.Interface(fn=gradio_interface, inputs="text", outputs="text", title="Job Duties to ISCO Descriptions")
56
  iface.launch()
 
42
  query_embedding = np.array(query_embedding).astype("float32")
43
  distances, indices = index.search(query_embedding, top_k)
44
  results = [
45
+ {
46
+ "ISCO_CODE_4": isco_taxonomy[str(idx)]["ISCO_CODE_4"],
47
+ "ISCO_LABEL_4": isco_taxonomy[str(idx)]["ISCO_LABEL_4"],
48
+ "ESCO_OCCUPATION": isco_taxonomy[str(idx)]["ESCO_OCCUPATION"],
49
+ "ESCO_DESCRIPTION": isco_taxonomy[str(idx)]["ESCO_DESCRIPTION"],
50
+ "Similarity": distances[0][i]
51
+ }
52
  for i, idx in enumerate(indices[0])
53
  ]
54
  return results
 
56
  # Gradio Interface
57
  def gradio_interface(job_duties):
58
  results = retrieve_and_rerank_faiss(job_duties)
59
+ return results
60
 
61
+ iface = gr.Interface(fn=gradio_interface, inputs="text", outputs=gr.outputs.Dataframe(type="pandas"), title="Semantic similarity matches with ESCO descriptions")
62
  iface.launch()