A Novel Approach to Detecting AI-Generated SQL Queries and Explanations By Utilizing Parallel Dual-Encoder Architecture

AI code generation disrupts programming education by facilitating academic dishonesty but also presents risks to software development, introducing unintended code into complex systems. Specifically for SQL, these risks escalate dramatically because unlike application crashes from coding errors, faulty AI-generated queries corrupt, delete, or expose sensitive data, possibly costing companies billions in losses and regulatory penalties. Traditional detectors for AI generated code are multifaceted and are not specific to SQL Code. This research presents a novel detection system for AI-generated SQL queries and their explanations using a parallel dual-encoder architecture which processes SQL code through specialized transformers (DeepSeek-Coder-V2, StarCoder 2) while simultaneously analyzing explanatory text using language models (DeBERTaV3, LLaMA 3). The detector was trained and evaluated on LeetCode SQL problems using human solutions from LeetCode posts, complemented by AI-generated solutions from GPT-o3, Claude 4 Opus, Gemini 2.5 Pro, and DeepSeek R1 generated by the research team. Our Multi-Model Feature Fusion with Binary Classifier Training achieved 98% accuracy and 98% F1-score, demonstrating consistent performance in all tested AI models. This framework provides educators and organizations with a reliable tool for maintaining academic integrity and database security while establishing a foundational methodology for AI-generated code detection research. Future work involves modifying the dataset to address syntax and structural differences across various SQL dialects, such as PostgreSQL, MySQL, and SQLite.

Institutions

Publication Details

Journal
George Mason University
Published
2025-09-12
DOI
https://doi.org/10.13021/jssr2025.5153
Primary Topic
Irish and British Studies
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

A Novel Approach to Detecting AI-Generated SQL Queries and Explanations By Utilizing Parallel Dual-Encoder Architecture

George Mason University
Irish and British Studies
article

A Novel Approach to Detecting AI-Generated SQL Queries and Explanations By Utilizing Parallel Dual-Encoder Architecture

article en

Abstract

AI code generation disrupts programming education by facilitating academic dishonesty but also presents risks to software development, introducing unintended code into complex systems. Specifically for SQL, these risks escalate dramatically because unlike application crashes from coding errors, faulty AI-generated queries corrupt, delete, or expose sensitive data, possibly costing companies billions in losses and regulatory penalties. Traditional detectors for AI generated code are multifaceted and are not specific to SQL Code. This research presents a novel detection system for AI-generated SQL queries and their explanations using a parallel dual-encoder architecture which processes SQL code through specialized transformers (DeepSeek-Coder-V2, StarCoder 2) while simultaneously analyzing explanatory text using language models (DeBERTaV3, LLaMA 3). The detector was trained and evaluated on LeetCode SQL problems using human solutions from LeetCode posts, complemented by AI-generated solutions from GPT-o3, Claude 4 Opus, Gemini 2.5 Pro, and DeepSeek R1 generated by the research team. Our Multi-Model Feature Fusion with Binary Classifier Training achieved 98% accuracy and 98% F1-score, demonstrating consistent performance in all tested AI models. This framework provides educators and organizations with a reliable tool for maintaining academic integrity and database security while establishing a foundational methodology for AI-generated code detection research. Future work involves modifying the dataset to address syntax and structural differences across various SQL dialects, such as PostgreSQL, MySQL, and SQLite.

George Mason University
Georgia Institute of Technology (US), George Mason University (US), Inova Loudoun Hospital (US), OFM Research (United States) (US)
Quality Education
Openalex Percentile: Top 36%
Irish and British Studies
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.