> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Late Chunking

> Embed first, then split for better chunk embeddings

Late chunking embeds the entire document first, then splits. This produces chunks with better individual embeddings.

## Quick Start

<CodeGroup>
  ```python Agent with Late Chunking theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from praisonaiagents import Agent

  agent = Agent(
      instructions="Answer questions with high precision.",
      knowledge={
          "sources": ["technical_docs/"],
          "chunker": {
              "type": "late",
              "chunk_size": 512,
              "embedding_model": "all-MiniLM-L6-v2"
          }
      }
  )

  response = agent.start("Explain the architecture")
  ```

  ```python Direct API theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from praisonaiagents.knowledge.chunking import Chunking

  chunker = Chunking(
      chunker_type="late",
      chunk_size=512,
      embedding_model="all-MiniLM-L6-v2"
  )

  chunks = chunker.chunk("Your document content...")
  ```
</CodeGroup>

## When to Use

* High-precision retrieval needed
* Quality matters more than speed
* Complex technical documents
* Semantic similarity search critical

## Parameters

| Parameter         | Type | Default | Description          |
| ----------------- | ---- | ------- | -------------------- |
| `chunk_size`      | int  | 512     | Max tokens per chunk |
| `embedding_model` | str  | auto    | Embedding model      |

## How It Works

Traditional chunking: Split → Embed each chunk
Late chunking: Embed full doc → Split with context awareness

This preserves document-level context in each chunk's embedding.
