The invention discloses a user ad-hoc query report realization method and device based on a large
language model, and relates to the technical field of
natural language processing. The method comprises the following steps: constructing an ad hoc query report
system based on the large
language model, wherein the ad hoc query report
system comprises a semantic analysis module, an analysis engine module and a query statistics module; a
natural language query statement input by a user is input into a semantic analysis module to be analyzed through a fine-tuned large
language model, a structured query condition set and a structured query result index column set are output and input into an analysis engine module, and according to permission information of the
current user, through pre-constructed index
metadata and
SQL semantic analysis rules, the query result index column set is analyzed, and the query result index column set is analyzed. Generating a query
SQL statement; and inputting the query
SQL statement into a query statistics module, connecting a
target database to execute query operation to obtain a query
result set, and performing data formatting
processing on the query
result set to obtain a final query result. By adopting the method, complex query requirements can be met.