Feedback
Select AI enables you to provide feedback to help improve your selected LLM's ability to generate more accurate SQL queries.
Note:
This feature is available only on Oracle Database 23ai. You can use it
alongside the existing Select AI actions: runsql
,
showsql
, and explainsql
.
Ensure
that your AI profile is configured for NL2SQL generation and not RAG.
You can provide feedback to improve the accuracy of the generated SQL
through the feedback
action or the DBMS_CLOUD_AI.FEEDBACK
procedure. Select AI creates a
default vector index named <profile_name>_FEEDBACK_VECINDEX
with
default attributes when you use the feedback feature for the first time. This index
helps refine future generated SQL based on the feedback provided. See Vector Index for FEEDBACK for more information.
Tip:
Use the DBMS_CLOUD_AI.FEEDBACK
procedure when your specified
LLM fails to generate the correct SQL query or does not return the expected result
from one of the NL2SQL SELECT AI
actions. You can
also use the DBMS_CLOUD_AI.FEEDBACK
procedure to add the correct
SQL directly to the vector table. This helps guide future SQL generation by serving
as a reference for similar prompts.
-
Positive feedback: You approve and confirm the accuracy of the generated SQL. The system stores the confirmed query for future reference.
-
Negative feedback: If the results from your NL2SQL
SELECT AI
action fails to generate the correct SQL, you can provide the necessary SQL query improvements usingSELECT AI feedback <feedback>
or using theDBMS_CLOUD_AI.FEEDBACK
procedure by identifying errors in the query or providing guidance as to what was expected in prose. The system refines the query using an LLM and stores the refined version for future Select AI query generation. The stored refined queries are then used as hints and sent to the LLM as part of the augmented prompt.
See FEEDBACK Procedure and Example: Select AI Feedback to learn more.
Topics
- Benefits of Feedback
The feedback action and procedure in Select AI introduces a prompt tuning mechanism that enhances the accuracy of SQL query generation. - How Do I Use Feedback
Select AI enables you to provide feedback either by using thefeedback
action or by calling theDBMS_CLOUD_AI.FEEDBACK
procedure.
Parent topic: Select AI Features
Benefits of Feedback
The feedback action and procedure in Select AI introduces a prompt tuning mechanism that enhances the accuracy of SQL query generation.
- Can improve accuracy of SQL queries.
- Enables the owner of AI profile to provide feedback by confirming the correct queries or suggesting corrections by providing the semantic intention or business definitions to produce a correct query.
- Uses historical feedback as hints for future query generation thereby adapting to your needs.
Parent topic: Feedback
How Do I Use Feedback
Select AI enables you to provide feedback either
by using the feedback
action or by calling the DBMS_CLOUD_AI.FEEDBACK
procedure.
Caution:
Do not use the feedback action in applications where multiple users share database sessions under a single database user that owns the AI profile. The AI profile owner should provide feedback only after confirming that the corrected query is appropriate for all users of that profile.
-
SQL_TEXT
: Include the feedback in quotes for your current SQL query or you can get theSQL_TEXT
for a particular query by querying theV$MAPPED_SQL
view. -
SQL_ID
: You can get theSQL_ID
by querying theV$MAPPED_SQL
view. -
Use the last generated SQL: Provide your feedback in natural language.
Note:
To use last sql, be sure to set server output off in Oracle SQL*Plus or Oracle SQLcl. You must haveSELECT
privilege onv$session
andv$mapped_sql
tables.
See FEEDBACK Procedure and Example: Select AI Feedback to learn more.
Parent topic: Feedback