fix(memory): rank the whole history and keep relevant recent records
- Search scored only the newest 5,000 matching records, so an old record behind enough newer chatter was never found. Both passes (word rarity counts and the score) now run in SQLite over every record in scope and only the best rows come back. - context() excluded the recent window from search and then cut that window for the budget, so a relevant recent record could vanish. Search now covers the recent window, matches keep their half of the budget, and a matched record is removed from the recent block so it appears once. - Matching used SQLite's ASCII-only lower() against Python's lowercasing. Stored text gets a folded column (NFKC + casefold) and query words are folded the same way, so case is ignored in every script. - Prompt label "Records related to this question" (matches may now be recent); eval re-run 3x on qwen2.5:7b, all pass. Spec, memory.md and roadmap updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,4 +38,5 @@ v2에서는 다음 두 가지를 **전부** 대화 기록 저장소(SQLite)에
|
||||
- 질문의 낱말이 기록에 들어 있는지로 찾습니다. 낱말 뒤쪽이 조금 달라도 찾습니다(앞부분이 60% 이상 같으면 됨, "영화를"로 "영화", "watching"으로 "watched"). 드문 낱말에 점수를 더 줍니다. 특정 언어의 낱말 목록은 쓰지 않습니다.
|
||||
- 뜻으로 찾는 검색(임베딩)은 아직 넣지 않았습니다. Strata는 대화 모델만 돌려서 임베딩을 만들지 못하고, 넣으려면 음성 워커에 작은 다국어 임베딩 모델을 따로 둬야 합니다. 실제 대화에서 낱말 검색이 놓치는 경우가 보이면 그때 넣습니다.
|
||||
- 참고 분량 상한 안에서 지난 기록은 절반까지만 씁니다. 최근 대화가 길어도 이번 질문과 관련된 기록이 밀려나지 않게 하기 위해서입니다.
|
||||
- 기록 10만 개에서 한 번 찾는 데 24~61ms, 두뇌에 넘길 내용을 만드는 데 54ms가 걸렸습니다(이 서버 기준). 이 시간은 LLM 호출 없이 SQLite만 읽는 데 드는 시간입니다.
|
||||
- 최근 기록만 고르지 않고 전체 기간에서 관련도가 높은 기록을 고릅니다. 대소문자는 모든 문자에서 같게 봅니다("МОСКВА"로 "москва" 찾기). 최근 대화 안에 있는 관련 기록도 지난 기록 몫으로 지켜서, 분량 상한 때문에 빠지지 않습니다.
|
||||
- 기록 10만 개에서 한 번 찾는 데 48~143ms, 두뇌에 넘길 내용을 만드는 데 36ms가 걸렸습니다(이 서버 기준, 10만 개 중 가장 오래된 기록도 찾음). LLM 호출 없이 SQLite만 읽는 시간입니다.
|
||||
|
||||
Reference in New Issue
Block a user