Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
rerank model
Browse files
pages/Semantic_Search.py
CHANGED
|
@@ -242,7 +242,7 @@ if "KendraResourcePlanID" not in st.session_state:
|
|
| 242 |
st.session_state.KendraResourcePlanID= ""
|
| 243 |
|
| 244 |
if "SAGEMAKER_CrossEncoder_MODEL_ID" not in st.session_state:
|
| 245 |
-
st.session_state.SAGEMAKER_CrossEncoder_MODEL_ID = "
|
| 246 |
|
| 247 |
|
| 248 |
if "SAGEMAKER_SPARSE_MODEL_ID" not in st.session_state:
|
|
@@ -910,7 +910,7 @@ if(search_all_type == True or 1==1):
|
|
| 910 |
if(st.session_state.re_ranker == "true"):
|
| 911 |
st.subheader(':blue[Re-ranking]')
|
| 912 |
reranker = st.selectbox('Choose a Re-Ranker',
|
| 913 |
-
('None','
|
| 914 |
|
| 915 |
),
|
| 916 |
|
|
|
|
| 242 |
st.session_state.KendraResourcePlanID= ""
|
| 243 |
|
| 244 |
if "SAGEMAKER_CrossEncoder_MODEL_ID" not in st.session_state:
|
| 245 |
+
st.session_state.SAGEMAKER_CrossEncoder_MODEL_ID = "deBS3pYB5VHEj-qVuPHT"
|
| 246 |
|
| 247 |
|
| 248 |
if "SAGEMAKER_SPARSE_MODEL_ID" not in st.session_state:
|
|
|
|
| 910 |
if(st.session_state.re_ranker == "true"):
|
| 911 |
st.subheader(':blue[Re-ranking]')
|
| 912 |
reranker = st.selectbox('Choose a Re-Ranker',
|
| 913 |
+
('None','Cohere Rerank'#'Kendra Rescore'
|
| 914 |
|
| 915 |
),
|
| 916 |
|
semantic_search/all_search_execute.py
CHANGED
|
@@ -136,8 +136,6 @@ def handler(input_,session_id):
|
|
| 136 |
|
| 137 |
|
| 138 |
opensearch_search_pipeline = (requests.get(host+'_search/pipeline/hybrid_search_pipeline', auth=awsauth,headers=headers)).text
|
| 139 |
-
print("opensearch_search_pipeline")
|
| 140 |
-
print(opensearch_search_pipeline)
|
| 141 |
if(opensearch_search_pipeline!='{}'):
|
| 142 |
path = "_search/pipeline/hybrid_search_pipeline"
|
| 143 |
url = host + path
|
|
@@ -145,11 +143,6 @@ def handler(input_,session_id):
|
|
| 145 |
print("Hybrid Search Pipeline updated: "+str(r.status_code))
|
| 146 |
######## Combining hybrid+rerank pipeline #######
|
| 147 |
opensearch_rerank_pipeline = (requests.get(host+'_search/pipeline/rerank_pipeline', auth=awsauth,headers=headers)).text
|
| 148 |
-
print("opensearch_rerank_pipeline")
|
| 149 |
-
print(opensearch_rerank_pipeline)
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
######## start of Applying LLM filters #######
|
| 154 |
if(st.session_state.input_rewritten_query!=""):
|
| 155 |
filter_ = {"filter": {
|
|
@@ -419,7 +412,7 @@ def handler(input_,session_id):
|
|
| 419 |
single_query = hybrid_payload["query"]["hybrid"]["queries"][0]
|
| 420 |
del hybrid_payload["query"]["hybrid"]
|
| 421 |
hybrid_payload["query"] = single_query
|
| 422 |
-
if(st.session_state.re_ranker == 'true' and st.session_state.input_reranker == '
|
| 423 |
path = "demostore-search-index/_search?search_pipeline=rerank_pipeline"
|
| 424 |
url = host + path
|
| 425 |
hybrid_payload["ext"] = {"rerank": {
|
|
@@ -439,7 +432,7 @@ def handler(input_,session_id):
|
|
| 439 |
if( st.session_state.input_hybridType == "OpenSearch Hybrid Query"):
|
| 440 |
url_ = url + "?search_pipeline=hybrid_search_pipeline"
|
| 441 |
|
| 442 |
-
if(st.session_state.re_ranker == 'true' and st.session_state.input_reranker == '
|
| 443 |
|
| 444 |
url_ = url + "?search_pipeline=hybrid_rerank_pipeline"
|
| 445 |
|
|
|
|
| 136 |
|
| 137 |
|
| 138 |
opensearch_search_pipeline = (requests.get(host+'_search/pipeline/hybrid_search_pipeline', auth=awsauth,headers=headers)).text
|
|
|
|
|
|
|
| 139 |
if(opensearch_search_pipeline!='{}'):
|
| 140 |
path = "_search/pipeline/hybrid_search_pipeline"
|
| 141 |
url = host + path
|
|
|
|
| 143 |
print("Hybrid Search Pipeline updated: "+str(r.status_code))
|
| 144 |
######## Combining hybrid+rerank pipeline #######
|
| 145 |
opensearch_rerank_pipeline = (requests.get(host+'_search/pipeline/rerank_pipeline', auth=awsauth,headers=headers)).text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
######## start of Applying LLM filters #######
|
| 147 |
if(st.session_state.input_rewritten_query!=""):
|
| 148 |
filter_ = {"filter": {
|
|
|
|
| 412 |
single_query = hybrid_payload["query"]["hybrid"]["queries"][0]
|
| 413 |
del hybrid_payload["query"]["hybrid"]
|
| 414 |
hybrid_payload["query"] = single_query
|
| 415 |
+
if(st.session_state.re_ranker == 'true' and st.session_state.input_reranker == 'Cohere Rerank'):
|
| 416 |
path = "demostore-search-index/_search?search_pipeline=rerank_pipeline"
|
| 417 |
url = host + path
|
| 418 |
hybrid_payload["ext"] = {"rerank": {
|
|
|
|
| 432 |
if( st.session_state.input_hybridType == "OpenSearch Hybrid Query"):
|
| 433 |
url_ = url + "?search_pipeline=hybrid_search_pipeline"
|
| 434 |
|
| 435 |
+
if(st.session_state.re_ranker == 'true' and st.session_state.input_reranker == 'Cohere Rerank'):
|
| 436 |
|
| 437 |
url_ = url + "?search_pipeline=hybrid_rerank_pipeline"
|
| 438 |
|