A common chunking configuration is a critical element in the data processing pipeline, particularly when creating embeddings and populating vector databases with the results. This configuration defines the parameters governing the segmentation of text into meaningful chunks, whether at the document, paragraph, or sentence level. It plays a pivotal role in determining the size and structure of these chunks, ensuring that they align with the specific requirements of downstream tasks, such as embedding generation and vector database population. By carefully configuring chunking parameters, users can optimize the granularity of data segments, ultimately contributing to more cohesive and contextually rich results. This is crucial for tasks like natural language processing and text analysis, as well as for the efficient storage and retrieval of embeddings in vector databases, enhancing the quality and relevance of the results.

Configs

  •   chunk_api_key: If chunk_by_api is set to True, requests that are sent to the Unstructured API will use this Unstructured API key to make authenticated calls.

  •   chunk_by_api: Default: False. If set to True, uses Unstructured API services to run chunking. If set to False, runs chunking locally.

  •   chunk_combine_text_under_n_chars: Combine consecutive chunks when the first does not exceed length n and the second will fit without exceeding the hard-maximum length. Only operative for the by_title chunking strategy.

  •   chunk_elements:

      Deprecated! False (default) to not run chunking as part of the ingest process. This option is deprecated in favor of the chunking_strategy option. Setting this to True has the same effect as chunking_strategy=by_title.

  •   chunk_include_orig_elements: True when chunking to add the original elements consolidated to form each chunk to .metadata.orig_elements on that chunk.

  •   chunk_max_characters: Default: 500. The hard-maximum chunk length. No chunk will exceed this length. An oversized element will be divided by text-splitting to fit this window.

  •   chunk_multipage_selections: True to ignore page boundaries when chunking such that elements from two different pages can appear in the same chunk. Only operative for the by_title chunking strategy.

  •   chunk_new_after_n_chars: The soft-maximum chunk length. Another element will not be added to a chunk of n length even when it would fit without exceeding the hard-maximum length.

  •   chunk_overlap: Default: 0. Prefix each chunk’s text with the last overlap of n characters from the prior chunk. Only applies to oversized chunks divided by text-splitting. To apply overlap to non-oversized chunks, use chunk_overlap_all.

  •   chunk_overlap_all: Applies overlap to chunks formed from whole elements as well as those formed by text-splitting oversized elements. The overlap length is taken from the chunk_overlap value.

  •   chunking_endpoint: If chunk_by_api is set to True, chunking requests are sent to this Unstructured API URL. By default, this URL is the Unstructured Serverless API URL: https://api.unstructuredapp.io/general/v0/general.

  •  ,

      chunking_strategy: One of basic or by_title. When omitted, no chunking is performed. The basic strategy maximally fills each chunk with whole elements, up the specified size limits as specified by max_characters and new_after_n_chars. A single element that exceeds this length is divided into two or more chunks using text-splitting. A Table element is never combined with any other element and appears as a chunk of its own or as a sequence of TableChunk elements splitting is required. The by_title behaviors are the same except that section and optionally page boundaries are respected such that two consecutive elements from different sections appear in separate chunks.

  •   combine_text_under_n_chars: Default: max_characters. Combines small elements (for example a series of Title elements) until a section reaches a length of n characters. Only operative for the by_title chunking strategy. Defaults to max_characters which combines chunks whenever space allows. Specifying 0 for this argument suppresses combining of small chunks.

  •   include_orig_elements: Default: True. Adds the document elements consolidated to form each chunk to the orig_elements field in metadata. Setting this to False allows for somewhat smaller payloads when you don’t need that metadata.

  •   max_characters: Default: 500. Combine elements into chunks no larger than n characters. This is a hard maximum: no chunk with text longer than this value will appear in the output stream.

  •   multipage_sections: Default: True. When False, in addition to section boundaries, page boundaries are also respected. Only operative for the by_title chunking strategy.

  •   new_after_n_chars: Default: max_characters (off). Cuts off new chunks once they reach a length of n characters. This is a soft maximum. Defaults to max_characters when not specified, which effectively disables any soft window. Specifying 0 for this argument causes each element to appear in a chunk by itself (although an element with text longer than max_characters will be still be divided into two or more chunks using text splitting).

  •   overlap: Default: 0. Prefix each chunk’s text with the last overlap of n characters from the prior chunk. Only applies to oversized chunks divided by text-splitting. To apply overlap to non-oversized chunks, use overlap_all.

  •   overlap_all: Applies overlap to chunks formed from whole elements as well as those formed by text-splitting oversized elements. The overlap length is taken from the overlap value.

Chunking will fail if you set both partition_by_api to False and chunking_strategy to by_page or by_similarity. However, the rest of your data processing pipeline should be unaffected by this setting.