About Chainable Utility Functions and Common Use Cases

These are intended to be a set of chainable and flexible “stages” through which you pass your input data to transform into a different representation, including vectors.

Supplied Chainable Utility Functions

You can combine a set of chainable utility (UTL) functions together in an end-to-end pipeline.

Each pipeline or transformation chain can include a single function or a combination of functions, which are applied to source documents as they are transformed into other representations (text, chunks, summary, or vector). These functions are chained together, such that the output from one function is used as an input for the next.

Each chainable utility function performs a specific task of transforming data into other representations, such as converting data to text, converting text to chunks, or converting the extracted chunks to embeddings.

At a high level, the supplied chainable utility functions include:

Function Description Input and Return Value
UTL_TO_TEXT() Converts data (for example, Word, HTML, or PDF documents) to plain text.

Accepts the input as CLOB or BLOB.

Returns a plain text version of the document as CLOB.

UTL_TO_CHUNKS() Converts data to chunks.

Accepts the input as plain text (CLOB or VARCHAR2).

Splits the data to return an array of chunks (CLOB).

UTL_TO_EMBEDDING() Converts data to a single embedding.

Accepts the input as plain text (CLOB) or image (BLOB).

Returns a single embedding (VECTOR).

UTL_TO_EMBEDDINGS() Converts an array of chunks to an array of embeddings.

Accepts the input as an array of chunks (VECTOR_ARRAY_T).

Returns an array of embeddings (VECTOR_ARRAY_T).

UTL_TO_SUMMARY() Generates a concise summary for data, such as large or complex documents.

Accepts the input as plain text (CLOB).

Returns a summary in plain text as CLOB.

UTL_TO_GENERATE_TEXT() Generates text for prompts and images.

Accepts the input as text data (CLOB) for prompts, or as media data (BLOB) for media files such as images.

Processes this information to return CLOB containing the generated text.

UTL_TO_RERANK() Reassesses and reorders an initial list of documents based on their similarity score.

Accepts the input as a query (CLOB) and a list of documents (JSON).

Processes this information to return a JSON object containing a reranked list of documents, sorted by score.

Sequence of Chains

Chainable utility functions are designed to be flexible and modular. You can create transformation chains in various sequences, depending on your use case.

For example, you can directly extract vectors from a large PDF file by creating a chain of the UTL_TO_TEXT, UTL_TO_CHUNKS, and UTL_TO_EMBEDDINGS chainable utility functions.

As shown in the following diagram, a file-to-text-to-chunks-to-embeddings chain performs a set of operations in this order:

  1. Converts a PDF file to a plain text file by calling UTL_TO_TEXT.

  2. Splits the resulting text into many appropriate-sized chunks by calling UTL_TO_CHUNKS.

  3. Generates vector embeddings on each chunk by calling UTL_TO_EMBEDDINGS.

Description of image follows

Description of the illustration pdf_to_text_to_chunks_to_embeddings.jpg

Common Use Cases

Let us look at some common use cases to understand how you can customize and apply these transformation chains:

Single-Step or Direct Transformation:

Step-by-Step or Parallel Transformation:

Schedule Vector Utility Packages

Some of the transformation chains may take a long time depending on your workload and implementation, thus you can schedule to run Vector Utility PL/SQL packages in the background.

The DBMS_SCHEDULER PL/SQL package helps you effectively schedule these packages, without manual intervention.

For information on how to create, run, and manage jobs with Oracle Scheduler, see Oracle AI Database Administrator’s Guide.