danieldux commited on
Commit
d960d1c
·
verified ·
1 Parent(s): 1bf4703

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -6
app.py CHANGED
@@ -24,14 +24,14 @@ def create_faiss_index(isco_taxonomy, model_name='BAAI/bge-m3'):
24
  dimension = embeddings.shape[1]
25
  index = faiss.IndexFlatL2(dimension)
26
  index.add(embeddings)
27
- faiss.write_index(index, 'isco_taxonomy.index')
28
  with open('isco_taxonomy_mapping.json', 'w') as f:
29
  json.dump({i: entry for i, entry in enumerate(isco_taxonomy)}, f)
30
 
31
  # Define a function to retrieve and rerank using FAISS
32
  def retrieve_and_rerank_faiss(job_duties, model_name="BAAI/bge-m3", top_k=4):
33
  # Check if isco_taxonomy.index exists, if not, create it with create_faiss_index
34
- if not os.path.exists("isco_taxonomy.index"):
35
  isco_taxonomy = load_isco_taxonomy('isco_taxonomy.jsonl')
36
  create_faiss_index(isco_taxonomy)
37
  index = faiss.read_index("isco_taxonomy.index")
@@ -47,10 +47,6 @@ def retrieve_and_rerank_faiss(job_duties, model_name="BAAI/bge-m3", top_k=4):
47
  ]
48
  return results
49
 
50
- # Load data and create index (should be done once and then commented out or moved to a setup script)
51
- # isco_taxonomy = load_isco_taxonomy('isco_taxonomy.jsonl')
52
- # create_faiss_index(isco_taxonomy)
53
-
54
  # Gradio Interface
55
  def gradio_interface(job_duties):
56
  results = retrieve_and_rerank_faiss(job_duties)
 
24
  dimension = embeddings.shape[1]
25
  index = faiss.IndexFlatL2(dimension)
26
  index.add(embeddings)
27
+ faiss.write_index(index, '/data/isco_taxonomy.index')
28
  with open('isco_taxonomy_mapping.json', 'w') as f:
29
  json.dump({i: entry for i, entry in enumerate(isco_taxonomy)}, f)
30
 
31
  # Define a function to retrieve and rerank using FAISS
32
  def retrieve_and_rerank_faiss(job_duties, model_name="BAAI/bge-m3", top_k=4):
33
  # Check if isco_taxonomy.index exists, if not, create it with create_faiss_index
34
+ if not os.path.exists("/data/isco_taxonomy.index"):
35
  isco_taxonomy = load_isco_taxonomy('isco_taxonomy.jsonl')
36
  create_faiss_index(isco_taxonomy)
37
  index = faiss.read_index("isco_taxonomy.index")
 
47
  ]
48
  return results
49
 
 
 
 
 
50
  # Gradio Interface
51
  def gradio_interface(job_duties):
52
  results = retrieve_and_rerank_faiss(job_duties)