Token Lab검색

← 모든 연구 도구
로컬 전용 · 모델 호출 없음

RAG 청크 실험실

유니코드 안전 경계, 겹침 범위, 실제 텍스트 토큰 수를 확인합니다.

Study guide & lesson outlineLEARNING CONTRACT

Understand → implement → investigate

Goal: explain the mechanism in this lesson, reproduce one example and test a failure case. Reading alone does not mark mastery.

01설정

02입력 추가

설정 후 예제를 불러오거나 입력을 붙여 넣으세요.

03결과 확인

설정 후 예제를 불러오거나 입력을 붙여 넣으세요.

화면은 일부만 표시할 수 있으며 JSON 보고서는 전체 계산 결과를 포함합니다.

결과 해석

크기와 겹침은 토큰이 아닌 유니코드 코드 포인트입니다. 문단 우선 모드는 청크 후반의 줄바꿈을 선호합니다. 모든 청크의 토큰을 계산합니다. 겹침이 크면 텍스트와 임베딩 작업이 늘 수 있지만 검색 품질을 측정하지는 않습니다. 최대 100,000 코드 포인트와 2,000청크.

방법 참고 자료

MATHEMATICAL REVIEW · 2026-10-26

Assumptions, implementation & acceptance

Chunk size and overlap are Unicode code points, not tokens or UTF-8 bytes. Reconstruct the input without duplicating overlaps; then separately count tokens.

Reviewed counting units, statistical assumptions and numerical examples. Provider accounting and actual GPU allocation still require external measurement.

Unicode text → code points → Fixed / paragraph boundaries → Apply overlap and preserve offsets → Reconstruct text + count tokens
Mechanism map: follow the transformations from top to bottom.

Before running: predict a boundary case

Chunk size and overlap are Unicode code points, not tokens or UTF-8 bytes. Reconstruct the input without duplicating overlaps; then separately count tokens.

Hint: isolate the assumption

Keep the baseline input fixed, change one parameter or boundary, and compare both the numerical result and the claimed units. A passing example verifies this fixture only.

Minimal executable example

Save the example and linked modules in one folder. Use Node.js 22 or newer, then run node rag-chunker.mjs. npm install gpt-tokenizer@4.1.0

import {encode as rawEncode} from 'gpt-tokenizer/encoding/cl100k_base';
import {promptDiff,inspectDataset,chunkDocument,compareScores,estimateVRAM,samplingLab,speculativeLab} from './research-core.mjs';
const encode=s=>rawEncode(s,{disallowedSpecial:new Set()});
const text='你好🌍 abc '.repeat(8);
const result=chunkDocument(text,16,5,'fixed',encode);
const rebuilt=result.chunks.map(c=>Array.from(c.text).slice(c.overlapWithPrevious).join('')).join('');
console.log(rebuilt===text); // true

Test and transfer

Chunk size and overlap are Unicode code points, not tokens or UTF-8 bytes. Reconstruct the input without duplicating overlaps; then separately count tokens.

Record input, code version, expected result and observed result in the notebook below. Then construct a counterexample that violates the assumption above and explain why the original conclusion no longer follows.

Download complete kit (.tar.gz) · Complete reference kit and regression checks

Predict, test and keep evidence

Before revealing an answer, predict one result. After the exercise, record the discrepancy and a transfer test. Saved locally across language editions.

Open notebook / export / clear →

The mathematical review scope is recorded per lesson. It does not establish empirical paper reproduction; report suspected errors in your notes. Review scope