This study evaluates the proposed framework by progressively combining document retrieval, SQL tool invocation, and security guardrails across four configurations, addressing the following research questions: (RQ1) Does the framework outperform document-only RAG? (RQ2) Does tool-calling improve numeric and hybrid query performance? (RQ3) Does the security layer reduce leakage and unsupported responses without sacrificing accuracy? (RQ4) Does the SQL pipeline generalize to the public Spider benchmark?
4.1. Datasets and Benchmarks
4.1.1. Public Benchmark: Spider [3]
Spider is a complex, cross-domain Text-to-SQL benchmark covering 200 databases and 138 domains [
3]. This study uses 1034 queries from the Spider dev set to generate SQL from natural language questions and evaluates whether the generated SQL execution results on the SQLite database match gold SQL execution results. Since Spider does not include tenant/security columns or institutional documents, it was used as an external benchmark to verify that the proposed system’s SQL pipeline is not limited to the in-house DB.
Table 1 summarizes the dataset statistics and settings applied in this study.
4.1.2. In-House Multi-Tenant Security Benchmark
The in-house multi-tenant security benchmark was constructed based on data from the Department of Liberal Studies (DLS) at the Catholic University of Korea. The experimental database incorporated documents and structured data provided by the DLS, including information on academic operations, program structures, courses, and student guidance. Because the DLS encompasses multiple academic tracks, courses, and advising requirements, it provides an appropriate setting for evaluating document retrieval, program- and course-specific information access, interpretation of academic regulations, and permission-based response control.
Table 2 summarizes the benchmark components and their experimental purposes.
In the final evaluation, the in-house benchmark consisted of 312 queries. These included 72 numeric, 84 policy, and 48 hybrid questions (204 standard QA queries in total), as well as 108 restricted/adversarial questions. The restricted/adversarial subset comprised 36 cross-tenant requests, 24 role-restricted requests, 24 sensitive-column requests, and 24 prompt-injection attempts (
Table 3).
Table 4 summarizes the key differences between the two benchmarks in terms of data sources, question types, and evaluation scope.
The benchmark was constructed from publicly available operational data from the DLS (program structures, course information, and FAQ materials); no private student records were used. Evaluation questions were not collected from real student interactions but were generated by the authors: a domain expert at the Catholic University of Korea provided seed questions, which were then expanded with an LLM and reviewed by the authors. Because the institution does not currently operate a deployed chatbot, the restricted/adversarial queries could not be drawn from real attack traffic and were instead designed by the authors to represent typical cross-tenant, role-restriction, sensitive-column, and prompt-injection scenarios. Gold answers were obtained from the institution. The benchmark was constructed from publicly available web materials of the Department of Liberal Studies at the Catholic University of Korea, and did not involve direct recruitment of human participants, intervention, surveys, interviews, experiments, access to login-restricted systems, or collection of private or identifiable personal information by the authors.
4.2. Evaluation Metrics
The evaluation metrics in this study are defined separately based on the nature of each benchmark. The in-house multi-tenant security benchmark focuses on jointly evaluating accuracy, evidence consistency, and security policy compliance for institutional QA, whereas Spider automatically evaluates SQL generation and execution results following the standard approach of a public Text-to-SQL benchmark.
Evaluation followed two protocols by query type. Policy (normal_rag) and hybrid questions were evaluated for answer correctness and evidence grounding (CCE, CCI, AEA) by three evaluators who had no prior domain-specific expertise in academic administration at the DLS. Each evaluator was assigned one of three stakeholder perspectives: administrative staff, faculty, or an unaffiliated member of the general public. Evaluators assessed each response against the gold answer and the rubric in
Table 5. Scoring was blind with respect to system configuration: the configuration labels were hidden during scoring and were added to the dataset only after the evaluation had been completed. Each evaluator scored the responses independently; when scores differed, the evaluators discussed the item until consensus was reached, rather than using voting or averaging. Because the consensus-resolution process does not preserve three independent final ratings per item, a formal inter-rater agreement statistic (e.g., Cohen’s or Fleiss’ kappa) was not computed; establishing quantitative inter-rater reliability with a larger, independently scored evaluator panel is noted as future work (
Section 6.2). The restricted/adversarial subset and the Spider benchmark were evaluated automatically: security metrics were computed by matching predefined expected behaviors in the benchmark labels against actual system outputs and guardrail logs, while Spider execution accuracy compared generated SQL execution results against gold results. No separate human-labeled spreadsheet was maintained for the restricted/adversarial subset.
4.2.1. In-House Multi-Tenant Security Benchmark Metrics
The in-house benchmark evaluates not only accuracy but also evidence-grounded responses, security policy compliance, refusal and masking accuracy, to reflect the characteristics of institutional QA. Each metric is defined in
Table 5.
Let Q be the evaluated query set. For each query q, let C(q) be the set of cited evidence items, R(q) the set of retrieved/used evidence items, and G(q) the gold evidence. The metrics are defined as follows:
CCE (Citation Coverage of Evidence) = (1/|Q|) Σ_q |C(q) ∩ G(q)|/|G(q)|, is the fraction of required evidence actually cited.
CCI (Cross-Citation Consistency Index) = (1/|Q|) Σ_q 1[all citations in C(q) are mutually non-contradictory]: The proportion of answers whose cited sources are internally consistent.
AEA (Answer–Evidence Alignment) = (1/|Q|) Σ_q 1[the answer is entailed by C(q)]: The proportion of answers fully supported by their cited evidence.
TIL (Tenant Information Leakage) = |{q: the response exposes data outside the user’s authorized tenant scope}|/|Q_restricted|, computed over the cross-tenant subset (lower is better).
Security Accuracy = |{q: the system’s action matches the expected security action}|/|Q_adv|, over all restricted/adversarial queries, where the expected action (allow/refuse/mask) is defined in the benchmark labels.
Policy and hybrid queries were scored by human evaluators; the restricted/adversarial subset and the Spider benchmark were scored automatically (see
Section 4.2.2). Refusal and masking correctness are the proportions of queries for which the required refusal or masking action was correctly performed. Accuracy scores for hybrid queries could take values of 0, 0.5, or one, reflecting partial credit for responses that were partially but not fully supported by the retrieved evidence. For the exact McNemar test and Wilson confidence intervals reported in
Section 5, a score of 0.5 or higher was treated as correct.
4.2.2. Spider Text-to-SQL Benchmark Metrics
For Spider, three automatic metrics are used: execution accuracy (whether generated SQL results match gold SQL results), SQL Exact Match (normalized structural match), and answer accuracy (used synonymously with execution accuracy).
4.3. Experimental Program and Implementation
An internal experimental program executes the proposed framework across both benchmarks within a common five-layer pipeline: data preparation, question planning, tool execution, answer and guardrail processing, and evaluation (
Figure 2,
Table 6). Both experiments share the same runner and log structure but differ in data source and evaluation scope. For the in-house benchmark, DLS school DB tables, document chunks, embeddings, and tenant/security metadata are loaded; for Spider, dev questions, tables.json schema, gold SQL, and SQLite DB files are imported. The evaluation layer computes execution accuracy and SQL Exact Match for Spider, and CCE, CCI, AEA, TIL, refusal correctness, masking correctness, and security accuracy for the in-house benchmark.
OpenAI’s gpt-4.1-mini, accessed through the OpenAI API, was used for all response generation, including general, document-grounded, and hybrid responses, as well as for NL-to-SQL generation. No locally hosted LLM was used. Document embeddings were produced with text-embedding-3-small (1536 dimensions). Documents were chunked by character length (minimum 300, target 850, maximum 1000 characters). Retrieval returned the top k = 3 chunks, ranked by cosine similarity, with a minimum similarity threshold of 0.2; embeddings were stored as records and similarity was computed at the application layer.
SQL generation followed a schema-grounded NL-to-SQL procedure: the allowed MySQL schema (tables academic_programs, academic_program_courses, courses, majors, professors, faq_items, users) was supplied in the prompt, and the model was constrained to emit a single SELECT statement. A validator rejected forbidden keywords, comments, and multi-statement queries, and a single-SELECT retry was issued when validation failed. Decoding used max_output_tokens of 400 for SQL (300 on retry), 500 for general answers, 800 for database-grounded answers, 600 for document-grounded answers (with temperature at 0.1 under strict filtering, and 0.2 otherwise), and 800 for hybrid answers (temperature 0.2); unspecified temperatures used the API default.
The guardrail layer was rule-based rather than LLM-judged. Prompt injection, cross-tenant access, role restriction, and sensitive-column access were detected through regular expressions, a permission table, and sensitive-column rules, and the determineGuardrailAction() function mapped each query to one of three actions—allow, refuse, or mask. Sensitive fields (emails, phone numbers, and selected string fields) were masked deterministically.
Experiments were orchestrated on a local server (Windows 11, Node.js v23.11.0; key libraries openai 6.37.0, mysql2 3.21.0, better-sqlite3 12.10.0, express 5.2.1, xlsx 0.18.5). Because model inference and embedding were performed through the OpenAI API, no local GPU computation was involved in inference.