Spaces:
Runtime error
Runtime error
NCTCMumbai
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -115,7 +115,7 @@ def bot(history, cross_encoder):
|
|
115 |
logger.warning('Retrieving documents...')
|
116 |
|
117 |
# if COLBERT RAGATATOUILLE PROCEDURE :
|
118 |
-
if cross_encoder=='ColBERT':
|
119 |
gr.Warning('Retrieving using ColBERT.. First time query will take a minute for model to load..pls wait')
|
120 |
RAG= RAGPretrainedModel.from_pretrained("colbert-ir/colbertv2.0")
|
121 |
RAG_db=RAG.from_index('.ragatouille/colbert/indexes/mockingbird')
|
@@ -150,9 +150,9 @@ def bot(history, cross_encoder):
|
|
150 |
logger.warning(f'start cross encoder {len(documents)}')
|
151 |
# Retrieve documents relevant to query
|
152 |
query_doc_pair = [[query, doc] for doc in documents]
|
153 |
-
if cross_encoder=='MiniLM-L6v2' :
|
154 |
cross_encoder1 = CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2')
|
155 |
-
elif cross_encoder=='BGE reranker':
|
156 |
cross_encoder1 = CrossEncoder('BAAI/bge-reranker-base')
|
157 |
|
158 |
cross_scores = cross_encoder1.predict(query_doc_pair)
|
@@ -187,7 +187,7 @@ with gr.Blocks(theme='Insuz/SimpleIndigo') as demo:
|
|
187 |
gr.HTML(value=f"""
|
188 |
<p style="font-family: sans-serif; font-size: 16px;">
|
189 |
A free chat bot assistant for Expenditure Observers on Compendium on Election Expenditure Monitoring using Open source LLMs. <br>
|
190 |
-
The bot can answer questions in natural language, taking relevant extracts from the ECI document which can be accessed <a href="https://www.eci.gov.in/eci-backend/public/api/download?url=LMAhAK6sOPBp%2FNFF0iRfXbEB1EVSLT41NNLRjYNJJP1KivrUxbfqkDatmHy12e%2Fzk1vx4ptJpQsKYHA87guoLjnPUWtHeZgKtEqs%2FyzfTTYIC0newOHHOjl1rl0u3mJBSIq%2Fi7zDsrcP74v%2FKr8UNw%3D%3D" style="color: #
|
191 |
</p>
|
192 |
""", elem_id='Sub-heading')
|
193 |
usage_count = get_and_increment_value_count(db,collection_name, field_name)
|
@@ -218,7 +218,7 @@ with gr.Blocks(theme='Insuz/SimpleIndigo') as demo:
|
|
218 |
)
|
219 |
txt_btn = gr.Button(value="Submit text", scale=1)
|
220 |
|
221 |
-
cross_encoder = gr.Radio(choices=['MiniLM-L6v2','BGE reranker','ColBERT'], value='BGE reranker',label="Embeddings", info="
|
222 |
|
223 |
prompt_html = gr.HTML()
|
224 |
# Turn off interactivity while generating if you click
|
|
|
115 |
logger.warning('Retrieving documents...')
|
116 |
|
117 |
# if COLBERT RAGATATOUILLE PROCEDURE :
|
118 |
+
if cross_encoder=='(HIGH ACCURATE) ColBERT':
|
119 |
gr.Warning('Retrieving using ColBERT.. First time query will take a minute for model to load..pls wait')
|
120 |
RAG= RAGPretrainedModel.from_pretrained("colbert-ir/colbertv2.0")
|
121 |
RAG_db=RAG.from_index('.ragatouille/colbert/indexes/mockingbird')
|
|
|
150 |
logger.warning(f'start cross encoder {len(documents)}')
|
151 |
# Retrieve documents relevant to query
|
152 |
query_doc_pair = [[query, doc] for doc in documents]
|
153 |
+
if cross_encoder=='(FAST) MiniLM-L6v2' :
|
154 |
cross_encoder1 = CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2')
|
155 |
+
elif cross_encoder=='(ACCURATE) BGE reranker':
|
156 |
cross_encoder1 = CrossEncoder('BAAI/bge-reranker-base')
|
157 |
|
158 |
cross_scores = cross_encoder1.predict(query_doc_pair)
|
|
|
187 |
gr.HTML(value=f"""
|
188 |
<p style="font-family: sans-serif; font-size: 16px;">
|
189 |
A free chat bot assistant for Expenditure Observers on Compendium on Election Expenditure Monitoring using Open source LLMs. <br>
|
190 |
+
The bot can answer questions in natural language, taking relevant extracts from the ECI document which can be accessed <a href="https://www.eci.gov.in/eci-backend/public/api/download?url=LMAhAK6sOPBp%2FNFF0iRfXbEB1EVSLT41NNLRjYNJJP1KivrUxbfqkDatmHy12e%2Fzk1vx4ptJpQsKYHA87guoLjnPUWtHeZgKtEqs%2FyzfTTYIC0newOHHOjl1rl0u3mJBSIq%2Fi7zDsrcP74v%2FKr8UNw%3D%3D" style="color: #00008B; text-decoration: none;">CLICK HERE !</a>.
|
191 |
</p>
|
192 |
""", elem_id='Sub-heading')
|
193 |
usage_count = get_and_increment_value_count(db,collection_name, field_name)
|
|
|
218 |
)
|
219 |
txt_btn = gr.Button(value="Submit text", scale=1)
|
220 |
|
221 |
+
cross_encoder = gr.Radio(choices=['(FAST) MiniLM-L6v2','(ACCURATE) BGE reranker','(HIGH ACCURATE) ColBERT'], value='BGE reranker',label="Embeddings", info="Only First query to Colbert may take litte time)")
|
222 |
|
223 |
prompt_html = gr.HTML()
|
224 |
# Turn off interactivity while generating if you click
|