dominiks commited on
Commit
4836358
·
verified ·
1 Parent(s): ec88dba

Upload app_federal.py

Browse files
Files changed (1) hide show
  1. app_federal.py +3 -8
app_federal.py CHANGED
@@ -80,7 +80,7 @@ def text_prompt_call(model_to_be_used, system_prompt, user_prompt ):
80
 
81
  def format_metadata_as_str(metadata):
82
  try:
83
- out = metadata["case_name"] + ", " + metadata["court_short_name"] + ", " + metadata["date_filed"] + ", precedential status " + metadata["precedential_status"]
84
  except:
85
  out = ""
86
  return out
@@ -98,15 +98,11 @@ def show_user_query(user_message, history):
98
  def format_metadata_for_reranking(metadata, text, idx):
99
  #print (metadata)
100
  #keys = [["case_name", "case name"], ["court_short_name", "court"], ["date_filed", "year"], ["citation_count", "citation count"], ["precedential_status", "precedential status"]]
101
- keys = [["court_short_name", "court"], ["date_filed", "year"], ["citation_count", "citation count"], ["precedential_status", "precedential status"]]
102
  out_str = []
103
  out_str = ["<id>" + str(idx) + "</id>"]
104
  for key in keys:
105
  i,j = key
106
- print ("i, j", i,j)
107
- print (metadata)
108
- print ("(metadata[i]", metadata[i])
109
-
110
  out_str.append("<" + j + ">" + str(metadata[i]) + "</" + j + ">")
111
  out_str.append("<paragraph>" + " ".join(text.split()) + "</paragraph>")
112
  return "\n".join(out_str) + "\n"
@@ -241,12 +237,11 @@ def run_dense_retrieval(query):
241
  def rerank_with_chatGPT(query, search_results):
242
  search_results_as_dict = {str(i["index"]):i for i in search_results}
243
 
244
- system_prompt = """You are given a list of search results for a query. Rerank the search results such that the paragraphs answering the query in the most comprehensive way are listed first. If multiple paragraphs answer the question, prioritize the reranking in the following order:
245
  1. prioritize metadata according to the query.
246
  2. If the query doesn't ask for specific metadata, prioritize paragraphs from higher courts (Supreme Court first, Circuit courts next, district courts last)
247
  3. Prioritize paragraphs which have higher citation counts.
248
  4. Prioritize parapgrahs from more recent opinions.
249
- 5. Prioritize paragraphs which are published compared to unpublished ones.
250
  Return a python list with the ids of the five highest ranking results, nothing else.
251
  <query>""" + query + "</query>\n\n"
252
  user_prompt = []
 
80
 
81
  def format_metadata_as_str(metadata):
82
  try:
83
+ out = metadata["case_name"] + ", " + metadata["court_short_name"] + ", " + metadata["date_filed"] #+ ", precedential status " + metadata["precedential_status"]
84
  except:
85
  out = ""
86
  return out
 
98
  def format_metadata_for_reranking(metadata, text, idx):
99
  #print (metadata)
100
  #keys = [["case_name", "case name"], ["court_short_name", "court"], ["date_filed", "year"], ["citation_count", "citation count"], ["precedential_status", "precedential status"]]
101
+ keys = [["court_short_name", "court"], ["date_filed", "year"], ["citation_count", "citation count"]]# , ["precedential_status", "precedential status"]]
102
  out_str = []
103
  out_str = ["<id>" + str(idx) + "</id>"]
104
  for key in keys:
105
  i,j = key
 
 
 
 
106
  out_str.append("<" + j + ">" + str(metadata[i]) + "</" + j + ">")
107
  out_str.append("<paragraph>" + " ".join(text.split()) + "</paragraph>")
108
  return "\n".join(out_str) + "\n"
 
237
  def rerank_with_chatGPT(query, search_results):
238
  search_results_as_dict = {str(i["index"]):i for i in search_results}
239
 
240
+ system_prompt = """You are given a list of search results for a query. Rerank the search results such that the paragraphs answering the query in the most comprehensive way are listed first. Additionaly, prioritize reranking in the following order:
241
  1. prioritize metadata according to the query.
242
  2. If the query doesn't ask for specific metadata, prioritize paragraphs from higher courts (Supreme Court first, Circuit courts next, district courts last)
243
  3. Prioritize paragraphs which have higher citation counts.
244
  4. Prioritize parapgrahs from more recent opinions.
 
245
  Return a python list with the ids of the five highest ranking results, nothing else.
246
  <query>""" + query + "</query>\n\n"
247
  user_prompt = []