Content area

Abstract

In recent years, large language models (LLMs) have shown an impressive ability in translating text to SQL queries. However, in real-world applications, standard loss functions frequently fail to capture the complexity of queries adequately. Therefore, in this study, a dynamic loss function is proposed, which assigns different weights to specific groups of tokens, such as SQL keywords or table names. The objective is to guide the model during training to facilitate the mastery of more fundamental concepts within the SQL. Our custom loss function is composed of four components: cross-entropy with sequence matching loss, focal loss, F-beta loss, and contrastive sequence loss. During the training process, the weights of each component of the loss function are dynamically adjusted to prioritize different aspects of query generation at the appropriate stage. This approach avoids computationally expensive approaches such as SQL validation or detokenization, which improves the efficiency of the learning process compared to alternative methods. We empirically tested this method on several open source LLMs with less than 2 billion parameters, using a customized real vehicle diagnostic dataset. The findings demonstrate that the employment of our dynamic loss function can enhance SQL execution accuracy by up to 20% in comparison with standard cross-entropy loss. It has been demonstrated that customized loss functions for specific tasks can improve the efficiency of LLMs without extending the model or acquiring additional labelled data. The proposed technique is also scalable and adaptable to new domains or more complex weighting schemes, highlighting the importance of custom design of loss functions in real world applications.

Details

1009240
Title
Beyond Standard Losses: Redefining Text-to-SQL with Task-Specific Optimization
Author
Azurmendi Iker 1   VIAFID ORCID Logo  ; Ekaitz, Zulueta 2 ; García, Gustavo 3 ; Uriarte-Arrazola Nekane 1 ; Lopez-Guede, Jose Manuel 2   VIAFID ORCID Logo 

 Department of Systems and Automatic Control, Faculty of Engineering of Vitoria-Gasteiz, University of the Basque Country (EHU), Nieves Cano, 01006 Vitoria-Gasteiz, Spain or [email protected] (I.A.); [email protected] (E.Z.); or [email protected] (N.U.-A.), MC3 Mondragon Componentes Competence Center, Avda. Álava 3, 20550 Aretxabaleta, Spain; [email protected] 
 Department of Systems and Automatic Control, Faculty of Engineering of Vitoria-Gasteiz, University of the Basque Country (EHU), Nieves Cano, 01006 Vitoria-Gasteiz, Spain or [email protected] (I.A.); [email protected] (E.Z.); or [email protected] (N.U.-A.) 
 MC3 Mondragon Componentes Competence Center, Avda. Álava 3, 20550 Aretxabaleta, Spain; [email protected] 
Publication title
Volume
13
Issue
14
First page
2315
Number of pages
24
Publication year
2025
Publication date
2025
Publisher
MDPI AG
Place of publication
Basel
Country of publication
Switzerland
Publication subject
e-ISSN
22277390
Source type
Scholarly Journal
Language of publication
English
Document type
Journal Article
Publication history
 
 
Online publication date
2025-07-20
Milestone dates
2025-06-04 (Received); 2025-07-17 (Accepted)
Publication history
 
 
   First posting date
20 Jul 2025
ProQuest document ID
3233232345
Document URL
https://www.proquest.com/scholarly-journals/beyond-standard-losses-redefining-text-sql-with/docview/3233232345/se-2?accountid=208611
Copyright
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/). Notwithstanding the ProQuest Terms and Conditions, you may use this content in accordance with the terms of the License.
Last updated
2025-07-25
Database
2 databases
  • ProQuest One Academic
  • ProQuest One Academic