AI Optimizer & Toolkit: test and generate apps

In this article, we’ll explore automated testing with the Oracle AI Optimizer & Toolkit, and then generate Python LangChain or Java Spring AI applications from our tested AI configurations.

What is the Oracle AI Optimizer & 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 vector search configured.

I suggest finishing parts 1 & 2 before continuing!

Create a Q&A Test Set

A Q&A test set is a collection of prompts and expected answers. We use test sets to evaluate a given AI configuration (models, vector data, parameters) for accuracy.

Q&A test sets are created and evaluated from the http://localhost:8501/testbed page. Q&A test set data is either user-provided or generated using the AI Optimizer.

In this example, we’ll use an AI model to generate a Q&A test set for us. To do this, download the Oracle AI Database Vector Search User Guide PDF and upload it using the “Browse Files” button on the testbed page:

Interface for generating a Q&A test set using the Oracle AI Optimizer. It includes options for number of Q&As, language model selection, and file upload functionality.
Attach the PDF for Q&A test set generation

Next, choose the language and embedding models you want to test with. Here we’ll use OpenAI models configured in part 2, but you can use any supported model provider. Note that the testbed “judge” model doesn’t have to match the model that built your knowledge base. In fact, using a different model often produces better test coverage.

Upload the PDF, and click “Generate Q&A” to create the Q&A test set. Q&A test set generation may take some time depending on the size of your data set:

A user interface displaying a 'Processing Q&A... please be patient.' message with a timer, alongside 'Generate Q&A' and 'Reset' buttons.
Generating a Q&A test set

Review the details of the generated Q&A test set, which the optimizer uses to score your model configuration:

Screenshot of a Q&A test set detail interface showing a test set name, record navigation, a question about SQL commands, and its corresponding answer.
Each Question is asked to your model configuration. The judge model assesses responses for accuracy to the Answer.

Score the Q&A Test Set

Now it’s time to score the Q&A test set with our model configuration! In the sidebar, ensure you have “Vector Search” selected as the Toolkit, and any model parameters configured as desired. Then, click “Start Evaluation” to score the Q&A test set:

Screenshot of the AI Optimizer and Toolkit configuration settings, showing options for Toolkit selection, language model parameters, and various adjustable sliders for model tuning.
Screenshot of a Q&A evaluation interface, showing options to select a model, a warning about OCI configuration, and a button to start the evaluation process.

The evaluation runs and generates a test report, showing a correctness score (% of questions passed) with failures flagged:

A graphical evaluation report displaying AI model settings, vector search configuration, and an overall correctness score of 100%.

The optimizer stores the generated Q&A test sets and test reports so you can review and reuse them. You can keep as many test sets as you need.

If your model scoring is incorrect, use the optimizer to experiment with the Q&A, model parameters, models used, and vector search settings – after all the purpose of the optimizer is experimentation!

Download an app template

From the http://localhost:8501/config page, choose to download either a LangChain or Spring AI app template.

Settings page of the Oracle AI Optimizer displaying client settings, upload option, and source code templates for downloading LangChain and SpringAI.

Downloading the Spring AI sample, the result application contains the following files:

Directory structure of a Spring AI project, showing folders like 'java', 'org', 'samples', and resource files.

If you’re a Python or Java developer, you can take and extend this template to build an AI application using your optimizer configuration!

References

Leave a Reply

Discover more from andersswanson.dev

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

Continue reading