The TextTiling algorithm is an unsupervised method for segmenting a long document into coherent, multi-paragraph topical units by analyzing patterns of lexical cohesion. It operates by sliding a fixed-size window across the text, calculating a similarity score—typically using term frequency or cosine similarity—between adjacent blocks of sentences. Local minima in this similarity curve are identified as topic boundaries, where the vocabulary shifts significantly, indicating a change in subject matter. This approach is foundational for semantic chunking in information retrieval systems.
Glossary
TextTiling Algorithm

What is the TextTiling Algorithm?
A foundational algorithm for unsupervised text segmentation based on lexical cohesion analysis.
The algorithm's core strength is its ability to detect subtopic shifts without pre-defined categories or training data, making it highly applicable to document preprocessing for retrieval-augmented generation (RAG). It directly addresses the challenge of creating semantically cohesive chunks for vector databases, optimizing downstream semantic search relevance. While modern methods may use sentence embeddings, TextTiling established the paradigm of using quantitative lexical analysis for segmentation, influencing later techniques like embedding-based chunking.
Key Features of TextTiling
The TextTiling algorithm segments text into coherent topical units by analyzing lexical cohesion. Its unsupervised, domain-agnostic design makes it a foundational technique for semantic chunking.
Lexical Cohesion Analysis
TextTiling's core mechanism is the analysis of lexical cohesion—the patterns of word repetition and co-occurrence that signal a consistent topic. It operates by:
- Calculating a similarity score (e.g., cosine similarity) between term-frequency vectors within a moving window.
- Plotting these scores to create a cohesion graph, where peaks indicate high topical continuity and valleys signal potential topic boundaries.
- This approach is unsupervised and language-agnostic, requiring no pre-labeled data or domain-specific rules.
Sliding Window & Block Comparison
The algorithm uses a sliding window to simulate a reader's attention span. The text is divided into token sequences (pseudo-sentences).
- A fixed-size window moves across these sequences, dividing them into two adjacent blocks.
- A similarity score is computed between the blocks at each position, measuring the lexical overlap.
- A deep valley in the resulting similarity plot indicates a topic shift, as the vocabulary between the two blocks becomes dissimilar. The window size is a critical hyperparameter controlling sensitivity to topic changes.
Boundary Detection via Depth Score
Topic boundaries are not identified by simple thresholding but by calculating a depth score for each valley in the cohesion graph.
- The depth score measures the magnitude of the dip relative to the surrounding peaks.
- Boundaries are placed at the deepest valleys, corresponding to the most significant drops in lexical cohesion.
- This method is robust to minor vocabulary fluctuations, preventing over-segmentation of text with minor subtopic digressions.
Unsupervised & Domain-Agnostic
A key strength of TextTiling is that it requires no training data. It operates purely on the lexical statistics of the input text.
- This makes it immediately applicable to any domain—from legal documents to scientific papers—without fine-tuning.
- Its performance is dependent on the vocabulary consistency within a topic; it works best on formal, expository text where authors use consistent terminology.
- It is less effective on highly narrative or conversational text where vocabulary may shift for stylistic rather than topical reasons.
Preprocessing & Tokenization Sensitivity
TextTiling's output is highly sensitive to preprocessing steps. Effective implementation requires:
- Stop word removal: Common function words ("the," "is") are typically filtered out as they add noise to cohesion signals.
- Stemming or Lemmatization: Reducing words to their root form (e.g., "running" to "run") groups morphologically related terms, strengthening cohesion signals.
- The choice of token sequence size (pseudo-sentence length) directly impacts the granularity of the detected segments.
Applications in RAG & Semantic Chunking
TextTiling is a foundational technique for semantic chunking in Retrieval-Augmented Generation (RAG) pipelines.
- It creates chunks that are topically coherent, which improves the relevance of retrieved context for language models compared to arbitrary fixed-size splitting.
- It is often used in a hybrid approach, combined with other methods like recursive character splitting to respect both semantic boundaries and hard token limits.
- Its output provides a strong baseline for more advanced, embedding-based segmentation methods.
Frequently Asked Questions
The TextTiling algorithm is a foundational unsupervised method for segmenting long-form text into coherent, multi-paragraph topical units. These questions address its core mechanics, applications, and how it compares to modern semantic chunking techniques.
The TextTiling algorithm is an unsupervised method for segmenting a document into coherent, multi-paragraph topical units by analyzing patterns of lexical cohesion. It works by sliding a fixed-size window across the text and calculating a similarity score (typically using term co-occurrence) between adjacent blocks of sentences. A deep valley in the resulting similarity plot indicates a topic boundary, where the vocabulary shifts significantly. The algorithm then inserts a boundary at these valleys, creating segments where the internal vocabulary is consistent.
Key steps:
- Tokenization & Stopword Removal: The text is split into sentences, tokenized, and common stopwords are filtered out.
- Block Formation: Sentences are grouped into pseudo-sentences or blocks of size
k(e.g., every 20 words). - Similarity Scoring: A cosine similarity or dice coefficient is calculated between adjacent blocks based on their term vectors.
- Boundary Detection: The sequence of similarity scores is plotted, and boundaries are identified at the local minima (valleys) of this plot, signifying a drop in lexical cohesion.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
TextTiling operates within a broader ecosystem of algorithms and data structures designed to segment, index, and retrieve information based on meaning. These related concepts are essential for engineers building semantic search and retrieval-augmented generation systems.
Semantic Chunking
The overarching goal of segmenting documents into coherent units based on contextual meaning and topic boundaries. Unlike fixed-size splitting, semantic chunking aims to preserve the integrity of ideas.
- Core Objective: Optimize the relevance of retrieved information for language models by ensuring each chunk is a self-contained semantic unit.
- Methods: Includes algorithms like TextTiling, embedding-based segmentation, and markdown header splitting.
- Key Benefit: Reduces the risk of providing language models with fragmented or contextually incomplete information, which is critical for accurate retrieval-augmented generation.
Lexical Cohesion
The linguistic phenomenon where a text is held together by the repetition and semantic relatedness of words. TextTiling's algorithm is fundamentally a computational measure of this concept.
- Mechanism: Analyzes patterns of term co-occurrence across a moving window. A drop in cohesion signals a potential topic boundary.
- Measurement: Often calculated using cosine similarity or a dot product of term frequency vectors within adjacent blocks of text.
- Engineering Relevance: Provides an unsupervised, language-agnostic signal for segmentation without requiring pre-trained models or labeled data.
Sentence-BERT (SBERT)
A modification of the BERT model designed to derive semantically meaningful sentence embeddings. It enables a modern, embedding-based approach to measuring semantic similarity for chunking.
- Function: Creates dense vector representations for sentences or paragraphs where cosine similarity indicates semantic relatedness.
- Contrast with TextTiling: Can be used for embedding-based chunking by segmenting text where the similarity between consecutive sentence embeddings falls below a threshold.
- Trade-off: More computationally intensive than lexical methods but can capture deeper semantic relationships beyond simple word overlap.
Sliding Window Chunk
A simple but effective chunking technique created by moving a fixed-size context window across text with a specified overlap. It addresses a key limitation of semantic methods.
- Process: The window (e.g., 200 tokens) advances by a stride (e.g., 50 tokens), creating overlapping chunks.
- Purpose: Preserves context across arbitrary split points imposed by semantic segmenters, mitigating information loss at boundaries.
- Common Use Case: Often applied after a primary semantic chunking step (like TextTiling) to create final, size-constrained chunks for a vector database, ensuring no key context is isolated at a chunk edge.
BM25 (Best Matching 25)
A robust probabilistic ranking function for keyword search. It represents the sparse retrieval paradigm, which contrasts with the semantic cohesion analysis used in TextTiling.
- Core Principle: Scores documents based on term frequency, inverse document frequency, and document length normalization.
- Relation to TextTiling: While TextTiling analyzes term distribution within a single document for segmentation, BM25 analyzes term distribution across a corpus for retrieval.
- Hybrid Systems: Modern hybrid search architectures combine BM25's precise lexical matching with dense vector similarity (semantic search) for improved recall and precision.
Dense Vector Index
A database index optimized for Approximate Nearest Neighbor (ANN) search over high-dimensional embeddings. It is the destination for chunks created by algorithms like TextTiling.
- Purpose: Enables fast semantic search by finding stored vectors (chunk embeddings) most similar to a query vector.
- Common Algorithms: Includes Hierarchical Navigable Small World (HNSW) graphs and Inverted File (IVF) indexes, as implemented in libraries like Faiss and vector databases (Weaviate, Qdrant).
- Data Pipeline: TextTiling segments text → an embedding model (e.g., SBERT) creates vectors → vectors are inserted into a dense vector index for sub-second retrieval.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us