AI Optimizer & Toolkit: connect LLMs and use your data

In this article, we’ll configure the Oracle AI Optimizer and Toolkit with an LLM, enable embedding and chat APIs, and integrate user context through vectorized data for RAG-powered responses. We’ll embed and store user data in Oracle AI Database with vector indexes, all without a single line of code!

What is the Oracle AI Optimizer and Toolkit? It’s a free and open-source tool designed to make it easier for developers and data engineers to build, benchmark, and optimize AI workflows running on Oracle Database.

Prerequisites: A running AI Optimizer and Toolkit server with a connected Oracle Database. If you don’t have an optimizer server, check out my previous article, Set Up A Local Sandbox.

Configure a Chat LLM

We’ll use OpenAI LLMs for this example, though the optimizer supports many different providers both public (like OpenAI) and private self-hosted LLMs—For example, you could run this with a local Llama3.1 container on your laptop!

Create an OpenAI API key if you don’t have one already. You can follow OpenAI’s quickstart to generate an API key. Remember to fund your OpenAI account—this tutorial should only use $0.01-$0.02!

Adding a language model to the optimizer

Let’s add OpenAI’s gpt-4.1.mini model. From the optimizer configuration page (http://localhost:8501/config), select the “Models” tab:

User interface of the Oracle AI Optimizer and Toolkit showing the 'Models' configuration page with options to update, add, or delete model parameters.

From the models tab, click the “Add” button in the Language Models section:

Screenshot of the Oracle AI Optimizer and Toolkit interface displaying model configuration options for language models, including model names and provider URLs.

Fill in the model configuration, with “openai” as the provider, gpt-4.1-mini as the model, and paste in your OpenAI API key. Fill the fields, and click
“Add” to save the model in the optimizer’s configuration:

Model configuration interface showing fields for provider selection, model name, provider URL, API key, and token limits.

Now you can use the OpenAI gpt-4.1-mini language model in the optimizer!

Adding an embedding model to the optimizer

We’ll now configure an embedding model to create embedding vectors for Oracle AI Database. If you’re unfamiliar with vector databases, I suggest reading my prior article, What’s a Vector Database?

From the “Models” configuration tab, scroll down to the Embedding Models section, and click the “Edit” button for the openai/text-embedding-3-small model:

Screenshot of the embedding models configuration interface showing different model names and their corresponding provider URLs.

Paste your OpenAI API key and click “Save” to configure the embedding model:

Model configuration interface showing options for enabling, selecting provider and model, entering provider URL, API key, and max chunk size.

Create and populate a vector store

To enable Retrieval-Augmented Generation (RAG), we need to vectorize external knowledge so the LLM can retrieve it during chat. This lets us ground AI responses in real documentation, not just the model’s training cutoff.

From the “Tools” section, click on the “Split/Embed” tab to open the optimizer’s embedding configuration:

Screenshot of the AI Optimizer & Toolkit embedding configuration page, displaying a warning about incomplete OCI configuration and options for embedding settings.

From this page, you can configure embedding parameters like the embedding model, chunk size, distance metric, vector index, and more. We’ll stick to the defaults for now:

Embedding configuration settings for Oracle AI Optimizer, including options for embedding models, chunk size, chunk overlap, and distance metrics.

In the “Load Knowledge Base” section, we can select data to load as vector embeddings. Choose “Web” as the knowledge base source, and copy the Oracle AI Database Vector Search documentation (https://docs.oracle.com/en/database/oracle/oracle-database/26/vecse/ai-vector-search-users-guide.pdf) as the URL.

We’ll name this vector store “OracleDocs”:

Screenshot of the Oracle AI Optimizer interface showing the 'Load Knowledge Base' and 'Populate Vector Store' sections, including fields for Knowledge Base source, URL, Vector Store Alias, and Rate Limit.

Click “Populate Vector Store” to begin processing the data. This should take around 10 seconds.

Loading animation indicating the process of populating the vector store, with a message suggesting patience.

You will see a message like this, indicating your Oracle AI Database was successfully populated with vector data from the knowledge base:

A confirmation message indicating that the vector store has been populated with 1243 embedded chunks.

Using the vector store (RAG query)

To use our new “OracleDocs” vector store, navigate to the optimizer’s “ChatBot” section and select “Vector Search” as the toolkit. This enables vector search (RAG) retrieval of data:

Screenshot of the Oracle AI Optimizer and Toolkit interface, showcasing the Toolkit options including 'ChatBot', 'Testbed', 'API Server', 'Tools', and 'Configuration'.

Because we have a single vector store, it is automatically selected in the “Vector Store” chatbot configuration:

A user interface screenshot showing the 'Vector Store' configuration section, with a dropdown labeled 'Select Alias:' and the option 'OracleDocs' visible.

Now we can chat using our vector store! Since we loaded a knowledge base about Oracle AI Database Vector Search, I’m going to ask a question about vector indexes:

A user interface prompting for an example of creating an IVF vector index, featuring text in a chat-like format.

The chatbot response is enhanced by our vector data, including instructions on how to create an IVF index:

Code snippet showing examples of creating a global IVF vector index in Oracle Database with parameters for organization, distance, and target accuracy.

You can click on each reference to see where the optimizer sourced its information from the knowledge base:

Configuration interface of the Oracle AI Optimizer and Toolkit showcasing various language models.

That’s it! You now have a working vector store for your knowledge base—enhancing an LLM beyond the knowledge cutoff.

In next part AI Optimizer & Toolkit: test and generate apps, we’ll walk through automated testing of optimizer configurations, and generating app code from those tested configurations!

References

Leave a Reply

Discover more from andersswanson.dev

Subscribe now to keep reading and get access to the full archive.

Continue reading