Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
8ffdf4e
feat: delete custom_logger_handler (#289)
CarltonXiang Sep 10, 2025
541191f
fix: change env model name (#292)
fridayL Sep 10, 2025
99d8e19
fix:#286:https://github.com/MemTensor/MemOS/issues/286 (#293)
kakack Sep 11, 2025
6b8cf85
Feat:add self defined memcube id for reg user (#295)
fridayL Sep 11, 2025
709f87c
update: test branch ci
fridayL Sep 15, 2025
5285829
Feat/add opentelmetry (#298)
CarltonXiang Sep 15, 2025
0b0cad8
feat: add orginal context for reranking (#284)
fridayL Sep 15, 2025
7b245b9
revert: nebular require_python (#300)
CarltonXiang Sep 15, 2025
8f87b33
feat: chat bot api (#294)
CaralHsi Sep 15, 2025
c688ead
feat: chat bot api (#302)
CaralHsi Sep 16, 2025
778c3b4
feat: chat bot api, add reranker filter; fix pydantic bug (#303)
CaralHsi Sep 16, 2025
30cfdbf
fix: bug in internet pydantic error (#304)
CaralHsi Sep 16, 2025
065a378
Feat/add opentelmetry (#307)
CarltonXiang Sep 16, 2025
02b0983
feat: update nebula to nebula 5.1.1 (#311)
CaralHsi Sep 17, 2025
9be4cb5
fix: nebula multi db bug (#313)
CaralHsi Sep 17, 2025
05dac26
Feat/memos client (#312)
CarltonXiang Sep 18, 2025
663c157
Feat: add time log for threaddict and change openai packacge singleto…
fridayL Sep 18, 2025
6304368
rebase to address conflicts
tangg555 Jul 25, 2025
6f8963a
fix bugs: fix a bug in retriever, and add new auth info for neo4j db
tangg555 Jul 29, 2025
d62ff33
fix bugs & new feat: fix bugs in mem_scheduler examples, and remove i…
tangg555 Jul 31, 2025
945c44b
fix bugs: modify configs, examples, schedule handlers of mem_schedule…
tangg555 Aug 6, 2025
f930506
new feat: allow load auth config from env
tangg555 Aug 7, 2025
9deb368
finish the first verion code of orm, but it still has some problems w…
tangg555 Aug 28, 2025
e4fa4f2
new version of scheduler: 1. orm support for monitors 2. refined sear…
tangg555 Sep 10, 2025
44f0138
refactor: refactor the eval function of the scheduler
tangg555 Sep 11, 2025
cb9519d
fix bugs caused by auth config in tests
tangg555 Sep 11, 2025
e024fea
modify scheduler evaluation codes
tangg555 Sep 16, 2025
020e6c6
add the first version of scheduler test by creating temporal locomo b…
tangg555 Sep 16, 2025
391b422
fix bugs in temporal locomo codes in evaluation
tangg555 Sep 18, 2025
fcdb21c
fix bugs in text mem with neo4j backend, and set huggingface backend …
tangg555 Sep 19, 2025
c407987
Feat/add timerlog (#317)
fridayL Sep 19, 2025
f8e972d
Feat/add opentelmetry (#315)
CarltonXiang Sep 19, 2025
1dc230a
feat: add api client (#316)
CarltonXiang Sep 19, 2025
267a0c1
Feat: add segment lock dict (#319)
fridayL Sep 20, 2025
1dc3b2e
fix:fix dump parallel for dumps cubes (#320)
fridayL Sep 21, 2025
beb0e07
feat: add sinlgleton (#321)
fridayL Sep 22, 2025
301178d
feat: nebula&reorganize update (#322)
CaralHsi Sep 22, 2025
5639a91
fix: nebula reset bug (#323)
CaralHsi Sep 22, 2025
5b27384
feat: add default processing in mem-reader (#325)
CaralHsi Sep 22, 2025
ee89e68
feat:add time step (#326)
fridayL Sep 23, 2025
bb63d7a
Feat:add time step (#327)
fridayL Sep 23, 2025
a4de6bd
docker start (#324)
pursues Sep 23, 2025
46406ea
Feat: remove json (#328)
fridayL Sep 23, 2025
b25f68b
feat: remove (#329)
fridayL Sep 23, 2025
312223c
fix: not include embedding (#330)
CaralHsi Sep 23, 2025
3646712
Feat/add time step (#331)
fridayL Sep 23, 2025
8c1e4ee
Feat/add time step (#332)
fridayL Sep 23, 2025
94ec427
new feat: add a rule-based baseline which uses historical evidences t…
tangg555 Sep 22, 2025
4fa115b
new feat: add eval and metric codes into the pipeline, and fix the bu…
tangg555 Sep 23, 2025
7119091
Fix/default add (#333)
CaralHsi Sep 23, 2025
4a4abca
fix the bugs in rule-based baselines, and change the temporal data so…
tangg555 Sep 23, 2025
73c9fa1
feat: recall and searcher use parallel (#337)
lijicode Sep 24, 2025
1f57a62
feat: api client (#334)
CarltonXiang Sep 24, 2025
a75af07
Merge branch 'dev' into test
CaralHsi Sep 24, 2025
f8d8c60
feat: API 1.0 (#339)
CaralHsi Sep 24, 2025
62cce47
fix: format (#341)
CaralHsi Sep 24, 2025
6f1159f
Merge branch 'main' into dev
CaralHsi Sep 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add orginal context for reranking (#284)
* fix: add memory

* update: update  orginal data

* Chore: Change version to v1.0.1

* feat:fix conflict

* fix: update memory get

* fix: ci code

* update: search_reranker

* change: rerank_source for reranking

* update config
  • Loading branch information
fridayL authored Sep 15, 2025
commit 0b0cad858b1a93e26ba825651b08253c14356ec9
4 changes: 3 additions & 1 deletion src/memos/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ def get_reranker_config() -> dict[str, Any]:
"backend": "http_bge",
"config": {
"url": os.getenv("MOS_RERANKER_URL"),
"model": "bge-reranker-v2-m3",
"model": os.getenv("MOS_RERANKER_MODEL", "bge-reranker-v2-m3"),
"timeout": 10,
"headers_extra": os.getenv("MOS_RERANKER_HEADERS_EXTRA"),
"rerank_source": os.getenv("MOS_RERANK_SOURCE"),
},
}
else:
Expand Down
59 changes: 59 additions & 0 deletions src/memos/reranker/concat.py
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adapt to 'new sourge message'

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import re

from typing import Any


_TAG1 = re.compile(r"^\s*\[[^\]]*\]\s*")


def process_source(
items: list[tuple[Any, str | dict[str, Any] | list[Any]]] | None = None, recent_num: int = 3
) -> str:
"""
Args:
items: List of tuples where each tuple contains (memory, source).
source can be str, Dict, or List.
recent_num: Number of recent items to concatenate.
Returns:
str: Concatenated source.
"""
if items is None:
items = []
concat_data = []
memory = None
for item in items:
memory, source = item
for content in source:
if isinstance(content, str):
if "assistant:" in content:
continue
concat_data.append(content)
if memory is not None:
concat_data = [memory, *concat_data]
return "\n".join(concat_data)


def concat_original_source(
graph_results: list,
merge_field: list[str] | None = None,
) -> list[str]:
"""
Merge memory items with original dialogue.
Args:
graph_results (list[TextualMemoryItem]): List of memory items with embeddings.
merge_field (List[str]): List of fields to merge.
Returns:
list[str]: List of memory and concat orginal memory.
"""
if merge_field is None:
merge_field = ["sources"]
documents = []
for item in graph_results:
memory = _TAG1.sub("", m) if isinstance((m := getattr(item, "memory", None)), str) else m
sources = []
for field in merge_field:
source = getattr(item.metadata, field, "")
sources.append((memory, source))
concat_string = process_source(sources)
documents.append(concat_string)
return documents
1 change: 1 addition & 0 deletions src/memos/reranker/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def from_config(cfg: RerankerConfigFactory | None) -> BaseReranker | None:
model=c.get("model", "bge-reranker-v2-m3"),
timeout=int(c.get("timeout", 10)),
headers_extra=c.get("headers_extra"),
rerank_source=c.get("rerank_source"),
)

if backend in {"cosine_local", "cosine"}:
Expand Down
27 changes: 21 additions & 6 deletions src/memos/reranker/http_bge.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

import requests

from memos.log import get_logger

from .base import BaseReranker
from .concat import concat_original_source


logger = get_logger(__name__)


if TYPE_CHECKING:
Expand All @@ -28,6 +34,7 @@ def __init__(
model: str = "bge-reranker-v2-m3",
timeout: int = 10,
headers_extra: dict | None = None,
rerank_source: list[str] | None = None,
):
if not reranker_url:
raise ValueError("reranker_url must not be empty")
Expand All @@ -36,6 +43,7 @@ def __init__(
self.model = model
self.timeout = timeout
self.headers_extra = headers_extra or {}
self.concat_source = rerank_source

def rerank(
self,
Expand All @@ -47,11 +55,18 @@ def rerank(
if not graph_results:
return []

documents = [
(_TAG1.sub("", m) if isinstance((m := getattr(item, "memory", None)), str) else m)
for item in graph_results
]
documents = [d for d in documents if isinstance(d, str) and d]
documents = []
if self.concat_source:
documents = concat_original_source(graph_results, self.concat_source)
else:
documents = [
(_TAG1.sub("", m) if isinstance((m := getattr(item, "memory", None)), str) else m)
for item in graph_results
]
documents = [d for d in documents if isinstance(d, str) and d]

logger.info(f"[HTTPBGERerankerSample] query: {query} , documents: {documents[:5]}...")

if not documents:
return []

Expand Down Expand Up @@ -95,5 +110,5 @@ def rerank(
return [(item, 0.0) for item in graph_results[:top_k]]

except Exception as e:
print(f"[HTTPBGEReranker] request failed: {e}")
logger.error(f"[HTTPBGEReranker] request failed: {e}")
return [(item, 0.0) for item in graph_results[:top_k]]
Loading