Semantic Splitter with Context
AI-generatedSummary
Split input text or documents into semantically coherent chunks enhanced with AI-generated contextual summaries for improved searchability and retrieval.
Inputs
- Chat Model (required) — An AI language model used to generate contextual summaries for each text chunk.
- Embeddings (required) — An embeddings model used to compute semantic similarities between text parts for effective splitting.
- Context Prompt — A string that instructs the AI model on how to generate concise contextual summaries for each chunk; the document and chunk content are automatically included in the prompt.
- Include Labels in Output — Boolean flag that controls whether the output includes labels such as "Context:" and "Chunk:" or just returns the plain context and chunk text.
- Options — A collection of optional parameters to customize the splitting behavior, including buffer size (number of sentences combined for context), breakpoint threshold type and amount (methods and values determining chunk boundaries by semantic distance), target number of chunks, similarity threshold for second-pass merging, minimum and maximum chunk sizes (in characters), and a regex pattern to split sentences.
Output shape
A list of text chunks each augmented with a contextual summary generated by the AI model, packaged as Document objects containing the enhanced chunk text and preserved metadata when splitting documents.
The node emits an ai_textSplitter type object representing the splitter configured with your parameters; invoking this splitter on input text or documents produces semantically segmented chunks with contextual enhancements. The output chunks respect size constraints and are generated via a two-pass semantic similarity merging approach. Contextual summaries focus on main topics and concepts rather than sequential flow and can be customized via the context prompt parameter.
Examples
Example 1: Splitting a long text for semantic retrieval
Connect an embeddings model and a chat model (e.g., an OpenAI GPT-based model) to the node. Provide an input text to split. Optionally customize the context prompt and chunk size limits. The node outputs semantically segmented and contextually labeled text chunks ready for downstream indexing or analysis.