RAG Strategies for Natural Language-Based SQL Query and REST API Call Generation
Organizations: IU International University of Applied Sciences, Germany
Abstract
Enterprise software systems commonly expose functionality through relational databases and REST APIs, requiring users to understand schemas, endpoints, and parameters. Retrieval-augmented generation (RAG) can support natural language interfaces by grounding large language models (LLMs) in enterprise-specific documentation. We evaluate three training-free RAG configurations - Standard RAG, Relevance Filtering RAG, and Iterative Retrieval RAG - for SQL query generation, REST API call generation, and a combined task requiring routing between both operation types. Using SAP Transactional Banking, we constructed an expert-reviewed dataset with mock execution screening and compared the configurations under database-only, API-only, and mixed-documentation settings. Without retrieval, exact match accuracy is 0% across all tasks, whereas retrieval achieves mock execution success of up to 79.30% and component match accuracy of up to 78.86%. In the combined task, Iterative Retrieval RAG achieves higher exact match accuracy than Standard RAG (10.29% vs. 7.45%), with similar mock execution success (68.93% vs. 67.10%). However, for REST API call generation under mixed documentation, Iterative Retrieval RAG achieves lower mock execution success than Standard RAG (50.53% vs. 75.79%). Overall, retrieval-control strategies show task- and metric-dependent behavior under mixed-documentation settings.
Figures & tables
| Setting | Approach | EM | CM | ER | Mock Exec. |
|---|---|---|---|---|---|
| API-only | Baseline | 0.00 | 20.31 | 0.00 | 28.45 |
| RAG Standard | 4.21 | 45.23 | 44.41 | 71.58 | |
| RAG RelevanceFiltering | 4.15 | 61.26 | 44.06 | 68.51 | |
| RAG IterativeRetrieval | 3.51 | 61.14 | 54.55 | 79.30 | |
| Mixed-doc. | Baseline | 0.00 | 20.31 | 0.00 | 28.45 |
| RAG Standard | 3.86 | 57.09 | 42.66 | 75.79 |
| Setting | Approach | EM | CM | Mock Exec. |
|---|---|---|---|---|
| DB-only | Baseline | 0.00 | 58.51 | 0.00 |
| RAG Standard | 14.45 | 78.34 | 71.97 | |
| RAG RelevanceFiltering | 15.61 | 78.24 | 72.83 | |
| RAG IterativeRetrieval | 15.61 | 77.85 | 73.12 | |
| Mixed-doc. | Baseline | 0.00 | 58.51 | 0.00 |
| RAG Standard | 11.56 | 76.59 | 69.08 |
| Approach | EM | CM | Mock Exec. | Class |
|---|---|---|---|---|
| Baseline | 0.00 | 42.06 | 5.30 | 97.79 |
| RAG Standard | 7.45 | 67.68 | 67.10 | 97.00 |
| RAG RelevanceFiltering | 8.54 | 67.99 | 64.20 | 97.63 |
| RAG IterativeRetrieval | 10.29 | 70.77 | 68.93 | 95.89 |
Retrieval-Augmented Generation
Retrieval-augmented generation connects language models to external knowledge so answers can use current, domain-specific evidence.
See all 766 papers