Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +7 -2
src/streamlit_app.py
CHANGED
|
@@ -206,6 +206,12 @@ def initialize_pinecone():
|
|
| 206 |
index = pc.Index("rag-v2")
|
| 207 |
return index
|
| 208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
@st.cache_resource(show_spinner=False)
|
| 210 |
def initialize_groq():
|
| 211 |
client = Groq(api_key=GROQ_API_KEY)
|
|
@@ -226,8 +232,7 @@ if "chat_mode" not in st.session_state:
|
|
| 226 |
# -------------------------------
|
| 227 |
def search_documents(query, filter_dict, top_k):
|
| 228 |
"""Search for relevant documents using embedding similarity and reranking."""
|
| 229 |
-
|
| 230 |
-
bm25 = BM25Encoder()
|
| 231 |
dense_query = embed_model.encode(query).tolist()
|
| 232 |
sparse_query = bm25.encode_queries([query])[0]
|
| 233 |
|
|
|
|
| 206 |
index = pc.Index("rag-v2")
|
| 207 |
return index
|
| 208 |
|
| 209 |
+
@st.cache_resource(show_spinner=False)
|
| 210 |
+
def initialize_bm25():
|
| 211 |
+
with open("bm25_model.pkl", "rb") as f:
|
| 212 |
+
bm25 = pickle.load(f)
|
| 213 |
+
retrun bm25
|
| 214 |
+
|
| 215 |
@st.cache_resource(show_spinner=False)
|
| 216 |
def initialize_groq():
|
| 217 |
client = Groq(api_key=GROQ_API_KEY)
|
|
|
|
| 232 |
# -------------------------------
|
| 233 |
def search_documents(query, filter_dict, top_k):
|
| 234 |
"""Search for relevant documents using embedding similarity and reranking."""
|
| 235 |
+
|
|
|
|
| 236 |
dense_query = embed_model.encode(query).tolist()
|
| 237 |
sparse_query = bm25.encode_queries([query])[0]
|
| 238 |
|