The invention relates to a
data query method and device based on a
natural language and a medium, and belongs to the technical field of
data analysis. Receiving a
natural language query input by a user; constructing task planning guide information based on the
natural language query, and inputting the task planning guide information into the large
language model to identify a target task type corresponding to the natural language query; when the target task type is a
data query type task, determining a query target index corresponding to the natural language query from an index
library; on the basis of a DSL dimension normal form corresponding to the query target index, dimension fields related to
semantics of the natural language query and matched enumeration values are recognized from the
multiple dimension fields and enumeration value sets; and constructing a structured intermediate representation, generating an
executable code corresponding to the natural language query, and executing the
executable code to obtain a corresponding structured query result from a
data source. According to the method and the device, the accuracy and the
interpretability are considered, and meanwhile, the
SQL generation flexibility is improved.