Skip to content

adm_ai_rag_chunk_api

Chunking API for RAG implementations Provides reusable text chunking functionality with smart break points and support for markdown headers

Default chunking parameters:

  • Target chunk size: 2048 characters (approximately 512 tokens)
  • Minimum chunk size: 512 characters (25% of target)
  • Maximum chunk size: 2560 characters (150% of target)
  • Overlap size: 256 characters (12.5% of target)

Find the next good break point in content Prefers: paragraph breaks, code blocks, sentence endings, then newlines

Signature:

function find_break_point (
p_content in clob,
p_start_pos in number,
p_target_pos in number,
p_max_pos in number
) return number;

Parameters:

NameDirectionTypeDescription
p_contentinclobThe content to search in
p_start_posinnumberThe starting position for the search
p_target_posinnumberThe target position for the break
p_max_posinnumberThe maximum position allowed

Returns: number - Position where the break should occur


Find header positions in markdown content Returns table of positions where headers start

Signature:

function find_header_positions (
p_content in clob
) return sys.odcinumberlist;

Parameters:

NameDirectionTypeDescription
p_contentinclobThe markdown content to analyze

Returns: sys.odcinumberlist - Collection of header positions


Find HTML heading positions (h1-h6 tags) Returns table of positions where headings start

Signature:

function find_html_heading_positions (
p_content in clob
) return sys.odcinumberlist;

Parameters:

NameDirectionTypeDescription
p_contentinclobThe HTML content to analyze

Returns: sys.odcinumberlist - Collection of heading positions


Find HTML tag boundaries (major structural tags like div, section, article, table) Returns table of positions where these tags start

Signature:

function find_html_tag_positions (
p_content in clob
) return sys.odcinumberlist;

Parameters:

NameDirectionTypeDescription
p_contentinclobThe HTML content to analyze

Returns: sys.odcinumberlist - Collection of tag positions


Find JSON object/array boundaries at root level Returns table of positions where top-level structures start

Signature:

function find_json_structure_positions (
p_content in clob
) return sys.odcinumberlist;

Parameters:

NameDirectionTypeDescription
p_contentinclobThe JSON content to analyze

Returns: sys.odcinumberlist - Collection of boundary positions


Find XML element boundaries (major elements) Returns table of positions where major elements start

Signature:

function find_xml_element_positions (
p_content in clob
) return sys.odcinumberlist;

Parameters:

NameDirectionTypeDescription
p_contentinclobThe XML content to analyze

Returns: sys.odcinumberlist - Collection of element positions


Find paragraph boundaries in plain text content Returns table of positions where paragraphs start

Signature:

function find_paragraph_positions (
p_content in clob
) return sys.odcinumberlist;

Parameters:

NameDirectionTypeDescription
p_contentinclobThe text content to analyze

Returns: sys.odcinumberlist - Collection of paragraph positions


Determine chunking strategy based on MIME type Returns: ‘markdown_headers’, ‘html_tags’, ‘json_structure’, ‘xml_elements’, ‘paragraphs’, or ‘default’

Signature:

function get_chunking_strategy (
p_mime_type in varchar2
) return varchar2;

Parameters:

NameDirectionTypeDescription
p_mime_typeinvarchar2The MIME type of the content

Returns: varchar2 - The chunking strategy to use


Create RAG chunks for content with MIME type-aware chunking strategy Automatically selects appropriate chunking strategy based on content type:

  • Markdown: respects headers (h1-h6)
  • HTML: respects major structural tags (div, section, article, table)
  • JSON: respects root-level objects/arrays
  • XML: respects major element boundaries
  • Plain text: respects paragraph boundaries
  • Other: uses character-based smart breaking

Signature:

procedure create_rag_chunks (
p_file_id in adm_ai_rag_collection_files.rag_collection_file_id%type,
p_target_chunk_size in number default 2048,
p_min_chunk_size in number default 512,
p_max_chunk_size in number default 2560,
p_overlap_size in number default 256
);

Parameters:

NameDirectionTypeDescription
p_file_idinadm_ai_rag_collection_files.rag_collection_file_id%typeThe RAG collection file ID
p_target_chunk_sizeinnumber default 2048Target chunk size in characters (default: 2048)
p_min_chunk_sizeinnumber default 512Minimum chunk size in characters (default: 512)
p_max_chunk_sizeinnumber default 2560Maximum chunk size in characters (default: 2560)
p_overlap_sizeinnumber default 256Overlap size in characters for adjacent chunks (default: 256)