C.W.K.
Stream
Lesson 04 of 05 · published

값 하는 메타데이터

~20 min · chunking, metadata

Level 0Scout
0 XP0/41 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

최소 useful 메타데이터 스키마

임베딩하는 모든 청크에 저장해:

  • source — 파일 경로, URL, 또는 문서 id
  • chunk_index — source 안에서의 위치
  • updated_at — source revision 의 ISO 타임스탬프
  • doc_type — markdown, pdf, code, html, conversation 등
  • query 시점에 필터 가능한 무엇이든 (tenant_id, language, project, classification level)

ranking 전에 filter

프로덕션 retrieval 에서 단일 가장 큰 성능 win 이 메타데이터 pre-filtering. 1000만 벡터에 cosine 은 느려. {tenant: 'acme', lang: 'en'} 매칭하는 5만 벡터에 cosine 은 빨라. 진지한 vector store 는 다 where 필터 지원 — 써.

메타데이터가 곧 provenance

LLM 이 답할 때 "source: handbook.md (updated 2026-04-12)" 보여주고 싶잖아. 그 인용은 메타데이터에서 직접 옴. ingest 시점에 메타데이터 빼면 나중에 만들 수 없어.

Code

discipline 있는 메타데이터로 청크 빌드·python
import hashlib
from pathlib import Path
from datetime import datetime, timezone

def ingest_markdown(path: Path):
    text = path.read_text()
    chunks = splitter.split_text(text)
    updated = datetime.fromtimestamp(path.stat().st_mtime, tz=timezone.utc).isoformat()
    return [
        {
            'id': hashlib.sha1(f'{path}:{i}:{c[:80]}'.encode()).hexdigest(),
            'text': c,
            'metadata': {
                'source': str(path),
                'chunk_index': i,
                'updated_at': updated,
                'doc_type': 'markdown',
                'project': path.parts[-3] if len(path.parts) >= 3 else None,
            },
        }
        for i, c in enumerate(chunks)
    ]

External links

Exercise

본인이 유지하는 코퍼스 하나. 모든 청크에 요구할 최소 메타데이터 스키마 (5–7 필드) 정의. 각 필드를 진짜 돌리고 싶은 query 로 정당화. 정당화 못 하는 필드는 버려.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.