feat(oss): port v3 pipeline with hybrid search, entity extraction, and additive scoring (#4805)

Co-authored-by: Soumil Rathi <soumilrathi@gmail.com>
Co-authored-by: Saket Aryan <saketaryan2002@gmail.com>
Co-authored-by: chaithanyak42 <chaithanya.kumar42a@gmail.com>
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
This commit is contained in:
soumil-rathi
2026-04-14 18:00:58 +05:30
committed by GitHub
co-authored by Soumil Rathi Saket Aryan chaithanyak42 kartik-mem0
parent 57f944e18a
commit a488e19044
120 changed files with 10107 additions and 17135 deletions
+43
View File
@@ -27,6 +27,7 @@ try:
VectorIndex,
)
from pymochow.model.table import (
BM25SearchRequest,
FloatVector,
Partition,
Row,
@@ -227,6 +228,48 @@ class BaiduDB(VectorStoreBase):
return output
def keyword_search(self, query, top_k=5, filters=None):
"""
Perform keyword-based search using Baidu Mochow's BM25 search.
Args:
query (str): The text query to search for.
top_k (int, optional): Number of results to return. Defaults to 5.
filters (Dict, optional): Filters to apply to the search.
Returns:
list: Search results, or None if the table lacks an inverted index.
"""
try:
search_filter = None
if filters:
search_filter = self._create_filter(filters)
request = BM25SearchRequest(
index_name="data_bm25_idx",
search_text=query,
limit=top_k,
filter=search_filter,
)
projections = ["id", "metadata"]
res = self._table.bm25_search(request=request, projections=projections)
output = []
for row in res.rows:
row_data = row.get("row", {})
output_data = OutputData(
id=row_data.get("id"),
score=row.get("score", 0.0),
payload=row_data.get("metadata", {}),
)
output.append(output_data)
return output
except Exception as e:
logger.error(f"Error during keyword search for query '{query}': {e}")
return None
def delete(self, vector_id):
"""
Delete a vector by ID.