May 05, 2026
AI in Finance in the Food Sector: Natural Language Translation to SQL
Lucas Prado Nogueira; Ricardo Antônio Câmara Da Silva
Summary prepared by the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege focused on synthesis and writing.
The food industry plays a fundamental role in the subsistence of the global population, ensuring food security through constant innovations in production processes and the offering of products at accessible costs. In the Brazilian scenario, this sector assumes even greater relevance, representing approximately 10% of the national Gross Domestic Product and being responsible for generating jobs for millions of citizens. With the advancement of digital transformation, large corporations in this segment have begun to operate under a regime of intense digitalization, in which the use of structured and relational databases has become the backbone for maintaining information integrity and supporting strategic decision-making. As Silberschatz, Korth, and Sudarshan (2020) point out, efficient data management is what allows for the agility required in competitive markets. However, interaction with these data repositories generally requires mastery of the Structured Query Language, a standardized programming language for manipulating and querying data in relational systems.
Despite the omnipresence of databases in corporate structures, direct access to strategic information still poses a substantial challenge for professionals in departments such as Finance and Controlling. These employees frequently face a technical barrier, depending on specialized information technology teams for report extraction or specific query execution. This dependence creates operational bottlenecks, rework, and limits managers’ autonomy, hindering real-time responses to market fluctuations. The need to transform raw data into actionable information often requires advanced programming knowledge or the construction of complex visualization dashboards, which demands considerable time for structuring queries. In this context, artificial intelligence emerges as a transformative element, defined by Russell and Norvig (2016) as the ability of machines to simulate human cognitive processes, including learning and logical reasoning for solving complex problems.
Within the field of artificial intelligence, natural language processing stands out as the subfield dedicated to making communication between humans and computers more efficient and intuitive. According to Jurafsky and Martin (2021), the development of models capable of understanding the nuances of human speech and writing allows users without technical computing backgrounds to interact with complex systems in a simplified way. The recent evolution of large-scale language models has made it possible for the translation of questions formulated in natural language into technical commands, such as SQL code, to become a viable reality for the corporate environment. Zhou, Zhang, and Lin (2022) corroborate this perspective by demonstrating that the application of natural language processing techniques to structured databases democratizes access to information, allowing business intuition to guide data exploration without the constraints of programming syntax.
The justification for implementing solutions of this nature lies in the pursuit of managerial efficiency and the reduction of response time for economic indicator analysis. The central objective is to develop a tool that acts as a bridge between the end-user and the database, translating search intentions into precise queries. The application focuses on the Statement of Income, also known as Profit and Loss, which is one of the pillars of corporate accounting. This statement is essential for finance employees to analyze the performance of companies, especially publicly traded ones, which require transparency and rigor in presenting their results. By automating the generation of queries about profit, expenses, and revenue, the proposed solution aims not only for productivity but also to reinforce knowledge about the potential of emerging technologies in the financial sector.
The methodology adopted for conducting this study is characterized as applied research, qualitative in nature and exploratory in character. The main focus was on solving a specific problem within a multinational company in the food sector, seeking to broaden knowledge about the integration of language models into financial workflows. According to Theóphilo and Martins (2009), qualitative research allows direct contact with the real context of the problem, prioritizing the understanding of phenomena over mere statistical measurements. To support the development, a systematic literature review was conducted, covering scientific articles, books, and technical reports that discuss theoretical advances in language models and data warehouse architectures. Gil (2022) emphasizes that the exploratory approach is ideal for providing greater familiarity with the subject, allowing the planning to consider various aspects of the object of study.
The operational process was divided into rigorous stages, starting with the collection of user perceptions and culminating in the technical development of a functional prototype. To understand the challenges faced by professionals, a structured questionnaire was administered via Google Forms to collaborators from the Finance and Information Technology areas. The questionnaire investigated the level of familiarity with SQL language, the frequency of queries performed, and the average time spent obtaining data. Flick (2009) highlights that the researcher’s prior experience and contact with research subjects are fundamental for supporting reflections and decisions during knowledge production. Participation was voluntary and anonymous, ensuring the confidentiality necessary for respondents to express their real difficulties and expectations regarding the use of automated tools.
In the back-end development, the Python programming language was used, integrating libraries such as SQLite for data persistence and SQLAlchemy for query abstraction. The choice of these tools was due to their robustness and extensive documentation, facilitating communication with the simulated database. Integration with artificial intelligence occurred through application programming interfaces from the Groq Cloud platform, where various language models were tested. The llama-3.1-8b-instant model was prioritized, as it presented a satisfactory balance between computational cost and interpretive accuracy. To enhance the system’s accuracy, a linguistic preprocessing layer was implemented, responsible for semantic normalization, removal of accents, and handling of synonyms specific to the corporate vocabulary, ensuring that different ways of asking about the same financial indicator resulted in the same valid SQL command.
The user interface, or front-end, was built using the Streamlit framework, which allows for the creation of interactive web applications in an agile manner and with low development cost. This interface enabled users to type their questions in Portuguese, view the generated SQL command in real-time, and access query results directly on the screen, without the need for additional installations. Usability features, such as search history and the option to export data in CSV format, were incorporated to increase the tool’s practical applicability. The database modeling followed a star schema structure, organizing information into fact and dimension tables, which is ideal for quick analysis in business intelligence systems. The database contained fictitious Profit and Loss information for Latin America, detailed by country, business unit, and sales channel, reflecting the complexity of a real corporate environment.
The system validation occurred on two distinct fronts: technical and perceptual. On the technical dimension, the system was subjected to a set of 110 predefined questions, covering various dimensions of the database, such as net revenues and operating expenses in countries like Brazil, Argentina, and Mexico, for the years 2023 and 2024. Each response generated by artificial intelligence was compared with a reference value obtained through manual query, allowing for the measurement of the translator’s accuracy. On the perceptual dimension, the questionnaire data were analyzed to identify the level of acceptance of the solution. The analysis of the results also included a comparison with traditional methods, such as direct code execution by specialists and the use of Business Intelligence tools, evaluating processing time and ease of use.
The results obtained revealed that the language model-based application presents highly competitive performance, especially in low and medium complexity queries. It was observed that 85.7% of the consulted professionals agree that the use of natural language significantly facilitates data access, reducing dependence on technical teams for routine tasks. Furthermore, the same percentage of respondents stated that they would support the formal adoption of an artificial intelligence tool for this purpose within the organization. Regarding comfort in using conversational interfaces, 78.6% of participants declared themselves comfortable using a chatbot to search for financial information. This data suggests that there is a real demand and a favorable predisposition towards the adoption of technologies that simplify interaction with structured data.
During technical tests, the llama-3.1-8b-instant model demonstrated a robust understanding of questions formulated in Portuguese, correctly mapping user intentions to the database schema. However, it was identified that excessively ambiguous questions or those using terms outside the normalized vocabulary could lead to interpretation errors. Wang, Li, and Chen (2023) highlight that, although language models possess enormous potential for automatic code generation, the incidence of hallucinations is a factor that cannot be ignored. In the context of this study, hallucinations manifested as the creation of queries that, while syntactically correct, lacked support in the available data or business logic, resulting in incorrect values or error messages. This phenomenon reinforces the need for systematic validation mechanisms and a layer of human governance over the generated results.
The financial analysis of the system’s operation also yielded relevant data. During a single day of intensive testing, token consumption was approximately 16,049 input tokens and 4,648 output tokens. Although the experimental stage was made possible by the free limits of the Groq Cloud platform, transitioning to a large-scale production environment would require detailed budgetary planning. The cost per information acquisition is directly linked to the volume of requests and the usage pattern of the models. Therefore, the scalability of the solution depends on a balance between computational cost and response quality, necessitating an evaluation of whether smaller, cheaper models are sufficient or if the complexity of the queries demands more advanced and costly instances.
The discussion on data security emerged as a critical point in the qualitative responses of the form. Users expressed concerns about the risk of sensitive information leakage when using third-party platforms or external connections. Many participants indicated that they would feel more secure if the tool were formally approved by the information technology team and if there were strict access controls. This concern is legitimate, as financial data has a high strategic impact. As a mitigation measure, isolating the models in controlled environments and implementing robust authentication protocols are suggested. The loss of analytical autonomy was also mentioned as a risk, should teams become excessively dependent on the tool and lose the ability to perform independent critical analyses.
Comparing the developed solution with traditional Business Intelligence tools, it was noted that the main advantage of artificial intelligence is flexibility. While Business Intelligence dashboards are generally static and limited to predefined views, the natural language interface allows for ad hoc queries, meeting specific needs that may not have been foreseen in the original dashboard development. On the other hand, traditional tools still offer greater statistical reliability and a lower risk of misinterpretations. Thus, the proposed application should not be seen as a definitive substitute for technical knowledge in SQL or for consolidated visualization tools, but rather as a complement that enhances autonomy and accelerates decision-making in complex environments.
The identified technical limitations, such as the restriction of requests per minute in the free version of the API and local environment execution, point towards future evolutions. Integration with cloud databases and adaptation for multiple languages are necessary steps for the tool to reach an industrial maturity level. Furthermore, the implementation of additional semantic constraints in the translation engine could drastically reduce the occurrence of hallucinations, ensuring that the model operates within strict logical boundaries. Testing in real environments, with a massive volume of data and a more diverse user base, would allow for further refinement of the preprocessing algorithms and the user interface.
In summary, the application architecture, which connects the front-end in Streamlit to the processing agent implemented with orchestration libraries and the SQLite database, proved to be an effective proof of concept. The interaction flow, from the user’s query to the display of the results table, demonstrated that the technical barrier to accessing financial data can be significantly reduced. The democratization of corporate information, provided by this technological integration, contributes to a more data-driven organizational culture, where agility in obtaining economic indicators becomes a competitive advantage. The need for technical supervision and prior knowledge in finance by the end-user remains essential for critical validation of the results, ensuring that technological innovation goes hand in hand with the analytical rigor required by the sector.
It is concluded that the objective was achieved, as the developed application validated the technical feasibility of using large language models for translating financial queries in natural language to SQL, demonstrating a high acceptance rate among professionals in finance and technology. The solution provided relevant gains in terms of agility and autonomy in accessing income statement data, reducing operational bottlenecks and dependence on programming specialists for routine queries. Despite the challenges identified, such as the occurrence of hallucinations in smaller models and concerns about the security of sensitive data, the study showed that the integration of artificial intelligence into corporate workflows is an irreversible and promising trend. The functional prototype fulfilled its role of simplifying the exploration of economic indicators, paving the way for future research seeking cloud scalability and the improvement of governance and linguistic accuracy mechanisms in decision support systems.
Bibliographic References:
FLICK, U. An introduction to qualitative research. Thousand Oaks: SAGE Publications, 2009.
GIL, A. C. Como elaborar projetos de pesquisa. 57. ed. São Paulo: GEN | Atlas, 2022
JURAFSKY, D.; MARTIN, J. H. Speech and language processing: an introduction to natural language processing, computational linguistics, and speech recognition. 3. ed. New Jersey: Prentice Hall, 2021.
RUSSELL, S.; NORVIG, P. Inteligência artificial: uma abordagem moderna. 3. ed. São Paulo: Pearson Education, 2016.
SILBERSCHATZ, A.; KORTH, H. F.; SUDARSHAN, S. Database system concepts. 7. ed. New York: McGraw-Hill, 2020.
THEÓPHILO, C. R.; MARTINS, G. A. Metodologia da investigação científica para ciências sociais aplicadas. 2. ed. São Paulo: Atlas, 2009.
WANG, B.; LI, T.; CHEN, Y. GPT-powered SQL query generation: challenges and opportunities. Journal of Artificial Intelligence Research (JAIR), v. 67, n. 2, p. 112-130, 2023.
ZHOU, Y.; ZHANG, M.; LIN, C. A survey on natural language processing for database querying. ACM Computing Surveys, v. 55, n. 3, p. 1-39, 2022.
Executive summary from the Final Course Work of the Specialization in Software Engineering of the MBA USP/Esalq
To learn more about the course, click here and access the MBX Academy platform