> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # createDocumentChunkerTool() 그만큼`createDocumentChunkerTool()`기능은 효율적인 처리 및 검색을 위해 문서를 더 작은 덩어리로 분할하는 Tool을 만듭니다. 다양한 청크 전략과 구성 가능한 매개변수를 지원합니다. ## 기본 사용법 ```typescript import { createDocumentChunkerTool, MDocument } from '@mastra/rag' const document = new MDocument({ text: 'Your document content here...', metadata: { source: 'user-manual' }, }) const chunker = createDocumentChunkerTool({ doc: document, params: { strategy: 'recursive', size: 512, overlap: 50, separator: '\n', }, }) const { chunks } = await chunker.execute() ``` ## 매개변수 **doc** (`MDocument`): 청크로 분할할 문서 **params** (`ChunkParams`): 청크 분할을 위한 구성 매개변수 (Default: `기본 청크 분할 매개변수`) ### `ChunkParams` **strategy** (`'recursive'`): 사용할 청크 분할 전략 (Default: `'recursive'`) **size** (`number`): 각 청크의 목표 크기(토큰/문자) (Default: `512`) **overlap** (`number`): 청크 간에 중첩되는 토큰/문자 수 (Default: `50`) **separator** (`string`): 청크 구분자로 사용할 문자 (Default: `'\n'`) ## 보고 **chunks** (`DocumentChunk[]`): 콘텐츠와 메타데이터가 포함된 문서 청크 배열 ## 맞춤 매개변수의 예 ```typescript const technicalDoc = new MDocument({ text: longDocumentContent, metadata: { type: 'technical', version: '1.0', }, }) const chunker = createDocumentChunkerTool({ doc: technicalDoc, params: { strategy: 'recursive', size: 1024, // Larger chunks overlap: 100, // More overlap separator: '\n\n', // Split on double newlines }, }) const { chunks } = await chunker.execute() // Process the chunks chunks.forEach((chunk, index) => { console.log(`Chunk ${index + 1} length: ${chunk.content.length}`) }) ``` ## Tool 세부정보 청커는 다음 속성을 가진 Mastra Tool로 생성됩니다. - **Tool ID**: `Document Chunker {strategy} {size}` - **설명**: `Chunks document using {strategy} strategy with size {size} and {overlap} overlap` - **입력 스키마**: 빈 개체(추가 입력이 필요하지 않음) - **출력 스키마**: 청크 배열을 포함하는 객체 ## 관련된 - [M문서](https://mastra.zisheng.pro/ko/reference/rag/document) - [createVectorQueryTool](https://mastra.zisheng.pro/ko/reference/tools/vector-query-tool)