Semantic Text Splitter
Semantic Text Splitter compares the meaning of consecutive sentences and cuts where the topic changes. That way each piece is about a single thing, even if pieces come out in different sizes. It needs an embeddings component to compare sentences.
Long documents are cut into pieces before being stored in a vector database: that way each search returns only the piece that answers, not the whole document.
When to use it
- Your documents mix topics without a clear section structure.
- You want pieces that deal with a single matter.
Configuration
| Field | What it does |
|---|---|
| Data Inputs (required) | The texts to cut. |
| Embeddings (required) | The embeddings component that compares sentences. |
| Breakpoint Threshold Type | How to decide where to cut: percentile (default), standard_deviation or interquartile. |
| Breakpoint Threshold Amount | How much the meaning must change to cut (with percentile, from 0 to 100, for example 95). Only used when Number Of Chunks is 0. Default: 0.5. |
| Number Of Chunks | How many pieces to try to split the text into. Set it to 0 to let Breakpoint Threshold Amount decide where to cut. Default: 5. |
Advanced options
| Field | What it does |
|---|---|
| Sentence Split Regex | Pattern to separate sentences, if your texts need it. Optional. |
| Buffer Size | How many neighbouring sentences are taken into account when comparing. Default: 0. |
Output
The Data output holds the pieces, each with the data of the document it comes from. Connect it to Ingest Data of a vector database, such as Chroma DB.
Example
A consultancy has meeting minutes covering several matters in a row.
- Connect the minutes to Data Inputs and an embeddings component to Embeddings.
- Connect Data to a vector database to search by matter.
Good practices
- Cutting this way queries the embeddings service for each sentence: it costs money on very long texts.
Related components
- Recursive Character Text Splitter: the recommended splitter for ordinary texts.
- Chroma DB: where to store the pieces.