Upload app_federal.py
Browse files- app_federal.py +10 -1
app_federal.py
CHANGED
@@ -312,7 +312,6 @@ def run_retrieval(query):
|
|
312 |
index = item["index"]
|
313 |
item["query"] = query
|
314 |
item["opinion_idx"] = str(ds_paragraphs[index]["idx"])
|
315 |
-
|
316 |
# only recover one paragraph / opinion
|
317 |
if item["opinion_idx"] in covered:
|
318 |
continue
|
@@ -329,7 +328,17 @@ def run_retrieval(query):
|
|
329 |
out_dict.append(item)
|
330 |
print ("out_dict_before_reranking")
|
331 |
#print (out_dict[:50])
|
|
|
|
|
|
|
332 |
out_dict = rerank_with_chatGPT(query, out_dict)[:NUM_RESULTS]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
print ("RETURNING OUT DICT")
|
334 |
return out_dict
|
335 |
|
|
|
312 |
index = item["index"]
|
313 |
item["query"] = query
|
314 |
item["opinion_idx"] = str(ds_paragraphs[index]["idx"])
|
|
|
315 |
# only recover one paragraph / opinion
|
316 |
if item["opinion_idx"] in covered:
|
317 |
continue
|
|
|
328 |
out_dict.append(item)
|
329 |
print ("out_dict_before_reranking")
|
330 |
#print (out_dict[:50])
|
331 |
+
res = {"result_type":"chatgpt_reranking"}
|
332 |
+
res["input_reranking"] = [i["index"]] for i in out_dict
|
333 |
+
res["scores"] = [i["NV_score"] for i in out_dict]
|
334 |
out_dict = rerank_with_chatGPT(query, out_dict)[:NUM_RESULTS]
|
335 |
+
|
336 |
+
# is that already good?
|
337 |
+
with scheduler.lock:
|
338 |
+
with JSON_DATASET_PATH.open("a") as f:
|
339 |
+
json.dump(res, f)
|
340 |
+
f.write("\n")
|
341 |
+
|
342 |
print ("RETURNING OUT DICT")
|
343 |
return out_dict
|
344 |
|