비정형 Recall에서 Schema 기반 Memory로: 반복적 Schema-Aware Extraction을 통한 신뢰할 수 있는 AI Memory
From Unstructured Recall to Schema-Grounded Memory: Reliable AI Memory via Iterative, Schema-Aware Extraction
TL;DR Highlight
RAG 스타일 텍스트 검색 대신 Schema로 정의된 구조화 레코드에 메모리를 저장하면, 정확한 사실 조회·상태 추적·집계 쿼리에서 압도적으로 높은 정확도를 얻을 수 있다.
Who Should Read
AI 에이전트나 챗봇에 장기 메모리를 붙이려는 백엔드/ML 엔지니어. 특히 RAG 기반 메모리에서 오래된 상태가 리턴되거나 집계 쿼리가 틀리는 문제를 겪고 있는 개발자.
Core Mechanics
- RAG 스타일 메모리(텍스트 저장 + 임베딩 검색)는 주제 기반 탐색엔 괜찮지만, 정확한 값 조회·상태 추적·집계·관계형 쿼리·부재(absence) 확인엔 구조적으로 한계가 있다.
- Schema를 '무엇을 기억해야 하는가'에 대한 명시적 계약으로 정의하면, 누락된 필드가 '조용한 실패'가 아니라 '감지 가능한 오류'가 된다.
- 단일 패스(one-shot) 구조화 출력은 필드 정확도가 97%라도, 필드가 20개면 전체 레코드 정확도는 0.97^20 ≈ 54%로 폭락한다 — 복합 오류 때문.
- xmemory는 추출을 Object Detection → Field Detection → Field Value Extraction 세 단계로 나누고, 각 단계에 검증 게이트(validation gate)와 로컬 재시도를 붙여서 이 문제를 해결한다.
- 메모리 컨텍스트를 Request(단일 요청) / Session(세션 전체) / Main(영구 저장소) 세 층으로 분리해서, 각 층이 담당하는 결정의 범위를 좁힌다.
- 쓰기 경로(write path)가 복잡해지는 대신, 읽기는 검증된 레코드에 대한 단순 쿼리가 되어 토큰 소비가 약 3배 줄고 결정 레이턴시도 낮아진다.
Evidence
- end-to-end 메모리 벤치마크에서 xmemory F1 97.10% vs 비교 대상(Cognee, Mem0, Supermemory, Zep) 80.16%~87.24% — 최고 경쟁자 대비 약 10%p 차이.
- 구조화 추출(보험 청구 데이터셋) Object-level accuracy: xmemory + LLM judge 90.42% vs GPT-5.5 high reasoning 83.98%, Gemini 3.1 Pro 89.24% — 프론티어 모델 단독 사용보다 높음.
- Output-level accuracy(전체 클레임의 모든 객체가 완벽히 맞는 비율): xmemory + judge 62.67% vs 최고 경쟁 모델 Gemini 3.1 Pro 61.67%, GPT-5.5 high reasoning 44%.
- Splitwise 애플리케이션 태스크(자연어 식사 이벤트 → 집계 질의): xmemory 95.2% vs Supermemory 73.75%, Cognee 68%, Mem0(graph) 59.1%, Zep 25.7%.
How to Apply
- 현재 RAG 메모리에서 '지금 DB는 뭐야?', '현재 상태는?', '총 몇 번 실패했어?' 같은 쿼리가 틀릴 때: 대화 로그를 그대로 임베딩하는 대신 Schema(YAML/JSON Schema)를 먼저 정의하고, 그 Schema에 맞춰 구조화된 레코드로 변환하는 write pipeline을 추가하면 된다.
- 단일 LLM 호출로 복잡한 JSON을 뽑으려다 레코드 전체가 틀리는 문제가 있다면: 추출을 '객체 존재 여부 판단 → 어떤 필드가 있는지 판단 → 각 필드 값 추출' 3단계로 쪼개고, 각 단계에 타입/포맷 검증 + 실패 시 해당 필드만 재시도하는 로직을 넣으면 레코드 정확도가 크게 올라간다.
- 에이전트가 세션 간 상태를 유지해야 하는 경우: 단일 컨텍스트 대신 Request/Session/Main 세 레이어로 나눠서, 현재 요청의 임시 추출 결과는 Request에, 세션 중 부분 완성 객체는 Session에, 최종 확정된 사실은 Main에 버전 관리와 함께 저장하는 아키텍처를 적용할 수 있다.
Code Example
# Schema 정의 예시 (YAML)
# 'ServiceConfig'라는 엔티티: 어떤 컴포넌트가 어떤 DB를 쓰는지 기억
ServiceConfig:
required:
- component # string: 'session store', 'cache' 등
- database # string: 'Redis', 'Postgres' 등
- status # enum: active | rejected | unknown
optional:
- reason # string: 상태 변경 이유
- changed_at # datetime
# Write path: 대화에서 구조화 레코드 추출 (3단계 분해)
def extract_memory(text: str, schema: dict) -> dict:
# 1단계: 객체가 존재하는지 판단
obj_detected = llm_call(
f"Does this text mention a ServiceConfig entity? Answer yes/no.\n{text}"
)
if obj_detected != 'yes':
return None
# 2단계: 어떤 필드가 언급됐는지 판단
fields_present = llm_call(
f"Which fields from {list(schema['required'] + schema['optional'])} "
f"are mentioned in the text? Return JSON list.\n{text}"
)
# 3단계: 각 필드 값 추출 + 검증 + 재시도
record = {}
for field in fields_present:
for attempt in range(3): # 최대 3번 재시도
value = llm_call(
f"Extract '{field}' from the text. "
f"If not mentioned, return null. Do NOT infer or approximate.\n{text}"
)
if validate_field(field, value, schema):
record[field] = value
break
else:
record[field] = None # 명시적 unknown
return record
# Read path: 구조화 쿼리 (추론 없이 직접 조회)
# SELECT database FROM ServiceConfig WHERE component = 'session store' AND status = 'active'Terminology
관련 논문
Atomic – Local-first, AI 기반 개인 지식 그래프 앱
노트, 웹 클립, RSS 피드를 자동으로 임베딩·태깅·연결해주는 오픈소스 개인 지식 그래프 앱으로, 시맨틱 검색과 LLM 기반 위키 합성, MCP 통합까지 지원한다.
RAG 대신 Virtual Filesystem으로 AI 문서 어시스턴트 만든 이야기
Mintlify의 ChromaFs(Chroma DB 위의 UNIX 명령어 흉내 가상 파일시스템)가 RAG 청킹 한계를 극복해 세션 부팅 시간을 46초에서 100ms로 단축한다.
Chroma Context-1: Self-Editing 기능을 갖춘 검색 에이전트 학습 방법
Chroma의 20B 파라미터 agentic search 모델이 프론티어급 LLM 수준의 검색 성능을 1/10의 비용과 10배 빠른 속도로 달성한다.
Gemini의 네이티브 비디오 임베딩으로 만든 sub-second 영상 의미 검색 도구 'SentrySearch'
Google Gemini Embedding 모델은 비디오를 텍스트 변환 없이 벡터로 직접 임베딩하여 'red truck running a stop sign' 같은 자연어로 블랙박스 영상에서 해당 장면을 검색한다.
RAG 시스템 구축 실전기: 성공과 실패의 기록
저자가 1TB 규모의 회사 내부 기술 문서를 대상으로 로컬 LLM 기반 RAG 시스템을 데이터 전처리부터 벡터 인덱싱까지 처음부터 구축하며 발생한 시행착오를 솔직하게 공유함.
정비소를 위한 AI 전화 접수원 만들기 (RAG + Voice Agent 실전 구현)
RAG 파이프라인과 Vapi 음성 플랫폼을 조합한 AI 접수원이 자동차 정비소의 전화 미응답으로 인한 매달 수천 달러 손실을 제거했다.
Memori: LLM 에이전트를 위한 효율적이고 맥락 인식 가능한 Persistent Memory Layer
Related Resources
Original Abstract (Expand)
Persistent AI memory is often reduced to a retrieval problem: store prior interactions as text, embed them, and ask the model to recover relevant context later. This design is useful for thematic recall, but it is mismatched to the kinds of memory that agents need in production: exact facts, current state, updates and deletions, aggregation, relations, negative queries, and explicit unknowns. These operations require memory to behave less like search and more like a system of record. This paper argues that reliable external AI memory must be schema-grounded. Schemas define what must be remembered, what may be ignored, and which values must never be inferred. We present an iterative, schema-aware write path that decomposes memory ingestion into object detection, field detection, and field-value extraction, with validation gates, local retries, and stateful prompt control. The result shifts interpretation from the read path to the write path: reads become constrained queries over verified records rather than repeated inference over retrieved prose. We evaluate this design on structured extraction and end-to-end memory benchmarks. On the extraction benchmark, the judge-in-the-loop configuration reaches 90.42% object-level accuracy and 62.67% output accuracy, above all tested frontier structured-output baselines. On our end-to-end memory benchmark, xmemory reaches 97.10% F1, compared with 80.16%-87.24% across the third-party baselines. On the application-level task, xmemory reaches 95.2% accuracy, outperforming specialised memory systems, code-generated Markdown harnesses, and customer-facing frontier-model application harnesses. The results show that, for memory workloads requiring stable facts and stateful computation, architecture matters more than retrieval scale or model strength alone.