Data query method and device, electronic equipment and computer program product

A fine-grained knowledge base managed as a database table enhances data query systems by accurately processing user inputs, improving query accuracy and efficiency through structured knowledge management.

CN119149579APending Publication Date: 2024-12-17BEIJING VOLCANO ENGINE TECH CO LTD

Patent Information

Application Number
CN202411658443.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

Existing data query systems using language models struggle with accurately understanding domain-specific user inputs due to the lack of refined knowledge management, leading to inefficient and inaccurate query results, especially in complex scenarios.

Method used

Implement a fine-grained knowledge base managed as a database table with structured knowledge items, including names and descriptions, to assist language models in data query by generating accurate SQL queries through vectorization and knowledge vector matching.

Benefits of technology

Improves the accuracy and efficiency of data queries by enabling language models to better understand user inputs and exclude irrelevant information, ensuring query results align with user needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119149579A_ABST
    Figure CN119149579A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to a data query method and device, electronic equipment and a computer program product. The method includes obtaining a user input and generating an input vector of the user input using a vectorization model. The method further includes determining a knowledge vector associated with the user input from a library of knowledge vectors based on the input vector. The method further includes determining query knowledge corresponding to the knowledge vector from a knowledge base based on the knowledge vector. The method further includes generating a target SQL query using the language model, and determining target data related to the query demand according to the target SQL query. According to the embodiment of the invention, the external knowledge is introduced more accurately by utilizing the fine-grained knowledge base, so that a large model can be helped to accurately understand and process user input, and a large amount of irrelevant information is prevented from being contained in cue words, thereby ensuring that the generated query result better meets user requirements, and improving the accuracy and efficiency of data query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more particularly to a method, device, electronic device and computer program product for data query. Background Art

[0002] In recent years, language models have developed rapidly. Thanks to the support of advanced algorithms, powerful computing resources and massive data, the model scale and performance have been continuously improved. With the advancement of artificial intelligence, the importance of language models in the field of technology has become increasingly prominent. They have demonstrated excellent performance in natural language processing, code generation, knowledge reasoning, etc., and have become the key to promoting innovation and development in related fields.

[0003] Language models are increasingly used in the field of data query. With their natural language processing and knowledge reasoning capabilities, they are applicable to a variety of query scenarios and meet various data analysis needs. With the continuous optimization of language model technology, data analysis and information retrieval methods are gradually improving, and data query is becoming more intelligent and efficient, providing new development opportunities for data-intensive fields. Summary of the invention

[0004] Embodiments of the present disclosure provide a method, an apparatus, an electronic device, and a computer program product for data query.

[0005] According to a first aspect of the present disclosure, a method for data query is provided. The method includes obtaining user input, wherein the user input indicates a query requirement in a natural language form. The method also includes generating an input vector of the user input using a vectorization model based on the user input. The method also includes determining a knowledge vector associated with the user input from a knowledge vector library based on the input vector, wherein the knowledge vector library is constructed by vectorizing each knowledge item in the knowledge library using a vectorization model. The method also includes determining query knowledge corresponding to the knowledge vector from the knowledge library based on the knowledge vector, wherein the knowledge library is stored in the form of a database table, wherein each knowledge item includes at least a knowledge name and a knowledge description. The method also includes generating a target SQL query using a language model based on the user input and the query knowledge. The method also includes determining target data related to the query requirement based on the target SQL query.

[0006] According to a second aspect of the present disclosure, a device for data query is provided. The device includes a user input acquisition module configured to acquire user input, wherein the user input indicates a query requirement in a natural language form. The device also includes an input vector generation module configured to generate an input vector of the user input based on the user input using a vectorization model. The device also includes a knowledge vector determination module configured to determine a knowledge vector associated with the user input from a knowledge vector library based on the input vector, wherein the knowledge vector library is constructed by vectorizing each knowledge item in the knowledge library using a vectorization model. The device also includes a query knowledge determination module configured to determine query knowledge corresponding to the knowledge vector from a knowledge library based on the knowledge vector, wherein the knowledge library is stored in the form of a database table, wherein each knowledge item includes at least a knowledge name and a knowledge description. The device also includes a target query generation module configured to generate a target SQL query based on the user input and the query knowledge using a language model. The device also includes a target data determination module configured to determine target data related to the query requirement based on the target SQL query.

[0007] According to a third aspect of the present disclosure, an electronic device is provided, comprising a processor and a memory coupled to the processor, wherein the memory has instructions stored therein, and when the instructions are executed by the processor, the electronic device executes the method according to the first aspect.

[0008] In a fourth aspect of the present disclosure, a computer program product is provided. The computer program product is tangibly stored on a non-transitory computer readable medium and comprises computer executable instructions, which when executed cause a computer to perform the steps of the method of the first aspect of the present disclosure.

[0009] The purpose of this Summary is to introduce a selection of concepts in a simplified form that are further described in the Detailed Description below. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to limit the scope of the claimed subject matter. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein: Figure 1 A schematic diagram showing an example environment in which devices and / or methods according to embodiments of the present disclosure may be implemented; Figure 2 A flow chart of a method 200 for data query according to an embodiment of the present disclosure is shown; Figure 3A schematic diagram showing a process of performing data query using a knowledge base according to an embodiment of the present disclosure; Figure 4A A schematic diagram showing an interface of knowledge management according to an embodiment of the present disclosure; Figure 4B A schematic diagram of a pop-up window for adding knowledge according to an embodiment of the present disclosure is shown; Figure 4C A schematic diagram showing a pop-up window for editing knowledge according to an embodiment of the present disclosure is shown; Figure 4D A schematic diagram showing a pop-up window for deleting knowledge according to an embodiment of the present disclosure is shown; Figure 5 A block diagram showing a data query device according to an embodiment of the present disclosure; and Figure 6 A block diagram of an electronic device according to an embodiment of the present disclosure is shown.

[0011] Throughout the drawings, the same or similar reference numbers denote the same or similar elements. DETAILED DESCRIPTION

[0012] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the type, scope of use, usage scenarios, etc. of the personal information (such as voice) involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0013] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0014] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. may refer to different or the same objects, unless explicitly stated. Other explicit and implicit definitions may also be included below.

[0015] As mentioned earlier, language models are increasingly used in data query. When using language models for data query, user input often contains a large number of domain-specific terms. These terms are simplified, abstract, or specialized expressions used by users when asking questions, and may differ significantly from the field names or contents in the actual data table. Therefore, in order to accurately understand these domain-specific terms, external knowledge is usually required. External knowledge provides the necessary background information for language models by providing definitions, associations, and explanations of terms, enabling them to better understand and process complex language forms.

[0016] In related technologies, when citing external knowledge, the entire knowledge data set is often directly added to the prompt word for processing, and there is a lack of refined management of knowledge granularity. Although this method is relatively simple to implement in engineering, it has limited effect when processing large-scale and complex knowledge. Due to the lack of refined knowledge management, the model needs to perform additional knowledge screening when understanding specific domain terms in user input, which actually transfers the burden of knowledge screening to the language model itself. Especially in scenarios involving complex business logic, this processing method can easily make it difficult for the model to accurately understand user intent, and thus fail to generate expected query results, affecting the accuracy and efficiency of data queries.

[0017] To this end, an embodiment of the present disclosure provides a data query solution. The solution obtains the natural language query requirements input by the user and processes the input content using a vectorized model, thereby finding the query knowledge related to it in the knowledge base to assist the large model in data query. The knowledge base is stored in the form of a database table, and each knowledge item is managed independently, including the knowledge name and knowledge description, etc., to achieve fine-grained management of knowledge.

[0018] Therefore, through the embodiments of the present disclosure, a fine-grained knowledge base is used to more accurately introduce external knowledge, which can help the large model accurately understand and process user input and avoid including a large amount of irrelevant information in the prompt words, thereby ensuring that the generated query results are more in line with user needs and improving the accuracy and efficiency of data queries.

[0019] Figure 1 Schematic diagram of an example environment in which the device and / or method according to an embodiment of the present disclosure may be implemented. Figure 1As shown, the example environment 100 may include a computing device 110, which may be a user terminal, a mobile device, a computer, etc., or a computing system, a single server, a distributed server, or a cloud-based server. The computing device 110 may receive a user input 112, which indicates a query requirement in a natural language form. For example, the user input 112 may be "I want to know the fuel consumption of Model A sedan". The computing device 110 may generate an input vector of the user input 112 based on the user input 112 using a vectorization model. The vectorization model may use machine learning or deep learning to capture its semantic information by converting text data into a vector representation. For example, the user input 112 may be input into a vectorization model, and the vectorization model may output a vector representation corresponding to the user input 112.

[0020] The computing device 110 can determine the knowledge vector 140 associated with the user input from the knowledge vector library 130 based on the input vector. The knowledge vector library 130 is constructed by vectorizing each knowledge item in the knowledge base 150 using a vectorization model. For example, the vectorization process can convert each knowledge item in the knowledge base into a corresponding vector representation so that it represents the semantic features of the knowledge in the vector space. The computing device 110 can determine the query knowledge 160 corresponding to the knowledge vector 140 from the knowledge base 150 based on the knowledge vector 140. The knowledge base 150 is stored in the form of a database table, and each knowledge item includes at least a knowledge name and a knowledge description. Each knowledge item in the knowledge base is structured and stored as a row of records in the database table to ensure that it can be quickly retrieved. For example, the corresponding query knowledge can be determined by matching the knowledge vector with the knowledge items in the knowledge base, such as by matching through identifiers.

[0021] The computing device 110 may generate an SQL query 180 using the language model 170 based on the user input 112 and the query knowledge 160. For example, the user input 112 and the query knowledge 160 may be added to the prompt word, and the language model 170 may generate a corresponding SQL query statement according to the prompt word. The computing device 110 may determine target data 190 related to the query requirement based on the SQL query 180. For example, the generated SQL query may be executed to extract data related to the user's query requirement from the database.

[0022] Therefore, through the embodiments of the present disclosure, a fine-grained knowledge base is used to more accurately introduce external knowledge, which can help the large model accurately understand and process user input and avoid including a large amount of irrelevant information in the prompt words, thereby ensuring that the generated query results are more in line with user needs and improving the accuracy and efficiency of data queries.

[0023] It should be understood that the architecture and functions in the example environment 100 are described for exemplary purposes only and do not imply any limitation on the scope of the present disclosure. Embodiments of the present disclosure may also be applied to other environments with different structures and / or functions.

[0024] The following will combine Figures 2 to 6 The process according to the embodiment of the present disclosure is described in detail. For ease of understanding, the specific data mentioned in the following description are exemplary and are not intended to limit the scope of protection of the present disclosure. It is understood that the embodiments described below may also include additional actions not shown and / or the actions shown may be omitted, and the scope of the present disclosure is not limited in this respect.

[0025] Figure 2 The flowchart of the method 200 for data query according to an embodiment of the present disclosure is shown. The method can be executed by a computing device, which can be a user terminal, a mobile device, a computer, etc., or a computing system, a single server, a distributed server, or a cloud-based server. At block 202, user input can be obtained, and the user input indicates the query requirement in the form of natural language. For example, referring to Figure 1 , the computing device 110 may obtain user input 112, which indicates the query requirement in natural language. At block 204, an input vector of the user input may be generated based on the user input using a vectorization model. For example, referring to Figure 1 The computing device 110 may generate an input vector 120 of the user input 112 based on the user input 112 using a vectorization model.

[0026] At block 206, a knowledge vector associated with the user input may be determined from a knowledge vector library based on the input vector, where the knowledge vector library is constructed by vectorizing each knowledge item in the knowledge library using a vectorization model. Figure 1 The computing device 110 may determine a knowledge vector 140 associated with the user input 112 from a knowledge vector library 130 based on the input vector 120 , where the knowledge vector library 130 is constructed by vectorizing each knowledge item in the knowledge base 150 using a vectorization model.

[0027] At block 208, based on the knowledge vector, query knowledge corresponding to the knowledge vector may be determined from a knowledge base, where the knowledge base is stored in the form of a database table, and each knowledge item includes at least a knowledge name and a knowledge description. Figure 1 The computing device 110 may determine the query knowledge 160 corresponding to the knowledge vector 140 from the knowledge base 150 , based on the knowledge vector 140 . The knowledge base 150 is stored in the form of a database table, and each knowledge item includes at least a knowledge name and a knowledge description.

[0028] At block 210, a target SQL query may be generated using a language model based on user input and query knowledge. Figure 1 , the computing device 110 can generate a target SQL query 180 using the language model 170 based on the user input 112 and the query knowledge 160. At block 212, target data related to the query requirement can be determined based on the target SQL query. Figure 1 The computing device 110 may determine target data 190 related to the query requirement based on the target SQL query 180 .

[0029] Therefore, according to method 200 of an embodiment of the present disclosure, a fine-grained knowledge base is used to more accurately introduce external knowledge, which can help the large model accurately understand and process user input and avoid including a large amount of irrelevant information in the prompt words, thereby ensuring that the generated query results are more in line with user needs and improving the accuracy and efficiency of data queries.

[0030] Figure 3 FIG. 3 is a schematic diagram showing a process 300 of performing data query using a knowledge base according to an embodiment of the present disclosure. Figure 3 As shown, the knowledge base may include a dedicated knowledge base 302 and a shared knowledge base 322. The dedicated knowledge base 302 is used for refined management of specific domain and project knowledge, including domain knowledge 304 and project knowledge 320. Domain knowledge 304 is used to store knowledge related to a specific domain, and is stored in the form of a database table, such as a MySQL data table. Each domain knowledge table can focus on a certain domain, such as automotive domain knowledge, and can store knowledge data related to the domain. Project knowledge 320 is also stored in the form of a database table and may include relevant knowledge of a specific project. These project knowledge may be customized by the developer according to project requirements, for example, for specific business logic, data structure and processing rules in a specific project. It should be understood that a dedicated knowledge base may include multiple domain knowledge and multiple project knowledge, and the present disclosure does not limit this.

[0031] Through domain- and project-level knowledge management, it is possible to more accurately recall the required knowledge from the corresponding knowledge base table when the user inputs. For example, when the data queried by the user belongs to the automotive field, only the knowledge needs to be recalled from the knowledge base table related to the automotive field, without having to retrieve from the knowledge base tables of other fields. This not only improves the accuracy of knowledge recall, but also avoids recalling knowledge that is irrelevant to the current query, reducing interference with the language model.

[0032] Domain knowledge 304 may include knowledge items 306 and metadata 314. Knowledge items 306 are used to store knowledge related to a specific business domain, including knowledge names 308, knowledge descriptions 310, and synonyms 312. Knowledge name 308 is the name of the knowledge item, knowledge description 310 provides a detailed description of the knowledge name 308, and synonyms 312 are used to store other expressions related to the knowledge name 308. As mentioned above, domain knowledge 304 may be automotive domain knowledge, which is stored in the form of a database table, and knowledge item 306 may be a row of data in the database table. For example, knowledge name 308 may be "fuel consumption", knowledge description 310 may be "if it is not specifically stated that it is trip fuel consumption, it generally refers to the average fuel consumption per mile", and synonym 312 may be "fuel consumption". It should be understood that a knowledge name may have no synonyms or may have multiple synonyms, and the present disclosure does not limit this. In some embodiments, a knowledge item may also include a knowledge creation timestamp and a knowledge modification timestamp.

[0033] Domain knowledge 304 also includes metadata 314, which includes full tables 316 and field filters 318. Full tables 316 provide the table structure of domain knowledge 304, including complete information about the table and its fields, such as table name, field name, data type, etc. Field filters 318 are used to define the filter conditions and rules for each field in the data table in order to accurately limit the query scope. For example, the value range or filter condition of a specific field can be set through field filters 318 to ensure that the system only retrieves data related to the user's input requirements.

[0034] The shared knowledge base 322 may include knowledge content that is common in multiple fields or projects, including business terminology knowledge 324, metadata knowledge 326, and SQL question-answer pairs 328. Business terminology knowledge 324 may include commonly used business terms and their explanations, which can provide support for queries in multiple fields. Metadata knowledge 326 is used to describe the structure and attribute information of a data set, including the organization of data tables, field types, field relationships, data specifications, etc. SQL question-answer pairs 328 are used to store common SQL queries and corresponding answers, providing fast query response capabilities. Dedicated knowledge bases are able to perform fine-grained knowledge management for specific fields or projects, while shared knowledge bases provide cross-domain general knowledge support, improving the reusability of knowledge.

[0035] At box 330, knowledge aggregation can be performed. In some embodiments, based on the input vector input by the user, the similarity score between each knowledge vector in the knowledge vector library and the input vector can be calculated, and the knowledge vector associated with the user input can be determined based on the similarity score and a predetermined threshold. For example, the knowledge vector library can be constructed based on a dedicated knowledge base or a shared knowledge base. In some embodiments, the system can generate a vector representation of the knowledge item based on the knowledge name and synonyms in the knowledge base using a vectorization model, and construct the knowledge vector library based on this. For example, both the dedicated knowledge base and the shared knowledge base can be used to construct the corresponding knowledge vector library.

[0036] Then, similar knowledge vectors can be retrieved from the corresponding knowledge vector library according to the input vector, and corresponding query knowledge can be obtained according to the similar vectors. For example, the user input can be "I want to know the fuel consumption of Model A car". At this time, the vectorization model can be used to convert the user input into an input vector, and similar vectors can be retrieved from the knowledge vector library (for example, the knowledge vector library corresponding to the automotive field knowledge), and the corresponding knowledge items can be determined according to the similar vectors. For example, the knowledge name of the acquired knowledge item is "fuel consumption", and the knowledge description is "if it is not specifically stated that it is the trip fuel consumption, it generally refers to the average fuel consumption per mile", and the synonym is "fuel consumption". It should be understood that the system can obtain one or more related knowledge according to the user input, and the present disclosure does not limit this.

[0037] At box 332, knowledge application can be performed. In some examples, a target prompt word can be generated based on the user input and the knowledge name and knowledge description in the query knowledge, the target prompt word instructs the language model to generate an SQL query, and based on the target prompt word, the target SQL query is generated using the language model. For example, the user input "I want to know the fuel consumption of Model A car", the knowledge name "fuel consumption" and the knowledge description "if it is not specifically stated that it is the trip fuel consumption, it generally refers to the average fuel consumption per mile" can be added to the prompt word, the language model can generate an SQL query based on the prompt word, and then the corresponding fuel consumption data can be obtained from the database based on the SQL query, and the result can be displayed to the user.

[0038] In some embodiments, a query output related to the query demand can be generated by using a language model based on user input, query knowledge and target data, and the query output displays the query knowledge and target data in a natural language form. For example, the fuel consumption data obtained from the database can be "10 liters", and a prompt word can be constructed at this time, which contains the user input, the content of the query knowledge and the target data. The content of the prompt word can be as follows: the user input is "I want to know what the fuel consumption of model A is"; the query knowledge includes "fuel consumption", and its knowledge description is "if it is not specifically stated that it is the fuel consumption of the trip, it generally refers to the average fuel consumption per mile"; the target data is "10 liters". According to the prompt word, the language model can generate a query output, for example: "The fuel consumption of model A is 10 liters / mile. If it is not specifically stated that it is the fuel consumption of the trip, the fuel consumption generally refers to the average fuel consumption per mile". In this way, not only the query results are provided to the user, but also the results are explained in combination with the query knowledge, so that the user can better understand the acquired data and its meaning.

[0039] Figure 4A FIG. 4 is a schematic diagram of a knowledge management interface 400A according to an embodiment of the present disclosure. Figure 4A As shown, the interface provides a one-stop fine-grained knowledge management function for independently managing the knowledge in each data set. Interface 400A includes a knowledge list, which may include knowledge name, description, synonyms, person in charge, and operation options. In the row of each knowledge item, the knowledge name column displays the name of the knowledge item, the description column displays a detailed description of the knowledge, the synonym column displays synonyms related to the knowledge name, the person in charge column displays the person who manages or maintains the knowledge item, and the operation column displays the operation button. For example, the operation button may include buttons such as "Edit" and "Delete" so that users can perform management operations on knowledge items, such as modifying existing knowledge items or removing them from the knowledge base. The "Add Knowledge" button is provided in the upper right corner of interface 400A, through which users can add new knowledge items to the knowledge base, thereby realizing dynamic expansion and maintenance of the knowledge base. In addition, the knowledge list can be displayed in reverse order of the knowledge editing time, and a paging function is provided. When the knowledge list has a lot of content and cannot be fully displayed on the interface, you can hover the mouse over the knowledge item to view the complete information.

[0040] In addition, to ensure the security and data compliance of knowledge management operations, the knowledge management interface will only be visible to users when certain conditions are met. For example, the entrance will only be displayed if the dataset is compliant and the user has the dataset edit permission or above, otherwise the entrance will be hidden. Through this mechanism, the system ensures that only authenticated users can access the knowledge management function, thereby maintaining the security of the knowledge base.

[0041] Figure 4B A schematic diagram of a pop-up window 400B for adding knowledge according to an embodiment of the present disclosure is shown. For example, when a user clicks the "Add Knowledge" button in the knowledge management interface, a pop-up window 400B will appear to receive the user-entered information on the knowledge item to be added. During this process, the user can enter the name, description, synonyms and other relevant information of the new knowledge. After the system responds to the user's request to add, it adds the input information as a new knowledge item to the knowledge base. The newly added knowledge item can be processed by a vectorization model and converted into a knowledge vector. For example, the knowledge name and synonyms can be concatenated, and the corresponding vector representation can be generated using a vectorization model. Subsequently, the generated knowledge vector will be added to the knowledge vector library and stored together with the vectors of other knowledge items.

[0042] In addition, to ensure the uniqueness of knowledge in a single data set, a judgment can be made when adding new knowledge. When the knowledge name entered by the user has the same name in the same data set, the saving of duplicate knowledge can be automatically prevented. For example, the save button will be grayed out and cannot be submitted. At the same time, the user is prompted that there is duplicate knowledge, ensuring that the knowledge items in each data set are unique.

[0043] Figure 4C A schematic diagram of a pop-up window 400C for editing knowledge according to an embodiment of the present disclosure is shown. For example, when a user clicks the "Edit" button corresponding to a knowledge item in the knowledge management interface, a pop-up window 400C will appear. The pop-up window is used to display the currently existing knowledge item information, including the knowledge name, description, synonyms and other content. The user can modify this information in the pop-up window, and click the "Save" button after editing. The system will update the corresponding content in the knowledge base according to the user's input. After successful saving, the pop-up window 400C will automatically close, and the user will return to the knowledge list page. At this time, the corresponding knowledge item in the knowledge list will be updated to the content modified by the user. At the same time, the knowledge list will be reordered according to the editing time of the knowledge item. In addition, the vectorization model can be used to regenerate the knowledge vector related to the knowledge item, and replace the original vector representation in the knowledge vector library.

[0044] Figure 4DA schematic diagram of a pop-up window 400D for deleting knowledge according to an embodiment of the present disclosure is shown. For example, when a user clicks the "Delete" button corresponding to a knowledge item in the knowledge management interface, a pop-up window 400D will appear, allowing the user to reconfirm the deletion operation. A prompt message is displayed in the pop-up window to remind the user that the deletion operation will remove the knowledge item, and the user can select the "Confirm" or "Cancel" button. If the user clicks "Confirm", the system will delete the knowledge item from the knowledge base, and at the same time, the corresponding knowledge vector in the knowledge vector library will also be deleted accordingly to ensure that the data in the knowledge base and the knowledge vector library remain consistent. If the user clicks "Cancel", the deletion operation will be terminated and the knowledge item remains unchanged.

[0045] Figure 5 FIG. 5 shows a block diagram of a data query device 500 according to some embodiments of the present disclosure. Figure 5 As shown, the apparatus 500 includes a user input acquisition module 502, which is configured to acquire user input, and the user input indicates the query requirement in the form of natural language. The apparatus 500 also includes an input vector generation module 504, which is configured to generate an input vector of the user input based on the user input using a vectorization model. The apparatus 500 also includes a knowledge vector determination module 506, which is configured to determine a knowledge vector associated with the user input from a knowledge vector library based on the input vector, and the knowledge vector library is constructed by vectorizing each knowledge item in the knowledge library using a vectorization model.

[0046] The apparatus 500 further includes a query knowledge determination module 508, which is configured to determine the query knowledge corresponding to the knowledge vector from the knowledge base based on the knowledge vector, wherein the knowledge base is stored in the form of a database table, and each knowledge item includes at least a knowledge name and a knowledge description. The apparatus 500 further includes a target query generation module 510, which is configured to generate a target SQL query using a language model based on user input and query knowledge. In addition, the apparatus 500 further includes a target data determination module 512, which is configured to determine the target data related to the query requirement based on the target SQL query.

[0047] Figure 6 A block diagram of an electronic device 600 is shown in accordance with certain embodiments of the present disclosure. Figure 6 1 shows a block diagram of an electronic device 600 according to some embodiments of the present disclosure, and the device 600 may be a device or apparatus described in an embodiment of the present disclosure. Figure 6As shown, the device 600 includes a central processing unit (CPU) and / or a graphics processing unit (GPU) 601, which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) 602 or loaded from a storage unit 608 to a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The CPU / GPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604. Although not shown in FIG. Figure 6 As shown in FIG. 6 , device 600 may also include a co-processor.

[0048] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0049] The various methods or processes described above may be performed by the CPU / GPU 601. For example, in some embodiments, the methods may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the CPU / GPU 601, one or more steps or actions in the methods or processes described above may be performed.

[0050] In some embodiments, the methods and processes described above may be implemented as a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present disclosure.

[0051] Computer readable storage medium can be a tangible device that can hold and store instructions used by an instruction execution device. Computer readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (non-exhaustive list) of computer readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, for example, a punch card or a convex structure in a groove on which instructions are stored, and any suitable combination thereof. The computer readable storage medium used here is not interpreted as a transient signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagated by a waveguide or other transmission medium (for example, a light pulse by an optical fiber cable), or an electrical signal transmitted by a wire.

[0052] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0053] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, and conventional procedural programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as a separate software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby implementing various aspects of the present disclosure.

[0054] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processing unit of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0055] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0056] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the equipment, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each frame in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the frame can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous frames can actually be executed substantially in parallel, and they can also be executed in the opposite order sometimes, depending on the functions involved. It should also be noted that each frame in the block diagram and / or flow chart, and the combination of frames in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0057] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

[0058] Some example implementations of the present disclosure are listed below.

[0059] Example 1. A data query method, comprising: Obtaining user input, where the user input indicates a query requirement in a natural language form; Based on the user input, generate an input vector of the user input using a vectorization model; Based on the input vector, determining a knowledge vector associated with the user input from a knowledge vector library, wherein the knowledge vector library is constructed by vectorizing each knowledge item in the knowledge library using the vectorization model; Based on the knowledge vector, determining query knowledge corresponding to the knowledge vector from the knowledge base, wherein the knowledge base is stored in the form of a database table, and each knowledge item includes at least a knowledge name and a knowledge description; Based on the user input and the query knowledge, generating a target SQL query using a language model; and Based on the target SQL query, target data related to the query requirement is determined.

[0060] Example 2. The method of Example 1, wherein determining the knowledge vector associated with the user input comprises: Based on the input vector, determining a similarity score between each knowledge vector in the knowledge vector library and the input vector; and Based on the similarity score and a predetermined threshold, the knowledge vector associated with the user input is determined.

[0061] Example 3. According to any one of Examples 1-2, the method of generating the target SQL query using the language model includes: Generate a target prompt word based on the user input and the knowledge name and knowledge description in the query knowledge, wherein the target prompt word is used to guide the language model to generate an SQL query; and Based on the target prompt word, the target SQL query is generated using the language model.

[0062] Example 4. The method according to any one of Examples 1-3, wherein each knowledge item in the knowledge base further includes a synonym of the knowledge name.

[0063] Example 5. The method according to any one of Examples 1-4, further comprising: Based on the knowledge name and synonyms of each knowledge item in the knowledge base, generating a knowledge vector corresponding to the knowledge item using the vectorization model; and Based on the knowledge vector, the knowledge vector library is constructed.

[0064] Example 6. The method according to any one of Examples 1-5, further comprising: In response to receiving the adding request, obtaining the knowledge item to be added; Adding the knowledge item to be added to the knowledge base; Generating a knowledge vector of the knowledge item to be added by using the vectorized model; and The knowledge vector of the knowledge item to be added is added to the knowledge vector library.

[0065] Example 7. The method according to any one of Examples 1-6, further comprising: In response to receiving the deletion request, determining a knowledge item to be deleted; Deleting the knowledge item to be deleted from the knowledge base; and The knowledge vector corresponding to the knowledge item to be deleted is deleted from the knowledge vector library.

[0066] Example 8. The method according to any one of Examples 1-7, further comprising: Based on the user input, the query knowledge and the target data, the language model is used to generate a query output related to the query requirement, and the query output presents the query knowledge and the target data in a natural language form.

[0067] Example 9. A data query device, comprising: A user input acquisition module is configured to acquire user input, wherein the user input indicates a query requirement in a natural language form; An input vector generation module, configured to generate an input vector of the user input by using a vectorization model based on the user input; a knowledge vector determination module configured to determine, based on the input vector, a knowledge vector associated with the user input from a knowledge vector library, wherein the knowledge vector library is constructed by vectorizing each knowledge item in the knowledge library using the vectorization model; A query knowledge determination module, configured to determine query knowledge corresponding to the knowledge vector from the knowledge base based on the knowledge vector, wherein the knowledge base is stored in the form of a database table, and each knowledge item includes at least a knowledge name and a knowledge description; a target query generation module, configured to generate a target SQL query using a language model based on the user input and the query knowledge; and The target data determination module is configured to determine target data related to the query requirement based on the target SQL query.

[0068] Example 10. The apparatus according to Example 9, wherein the knowledge vector determination module comprises: a similarity score determination module configured to determine, based on the input vector, a similarity score between each knowledge vector in the knowledge vector library and the input vector; and The knowledge vector second determination module is configured to determine the knowledge vector associated with the user input based on the similarity score and a predetermined threshold.

[0069] Example 11. The apparatus according to any one of Examples 9-10, wherein the target query generation module comprises: a target prompt word determination module, configured to generate a target prompt word based on the user input and the knowledge name and knowledge description in the query knowledge, wherein the target prompt word is used to guide the language model to generate an SQL query; and The target query second generation module is configured to generate the target SQL query based on the target prompt word using the language model.

[0070] Example 12. The apparatus according to any one of Examples 9-11, wherein each knowledge item in the knowledge base further includes a synonym of the knowledge name.

[0071] Example 13. The apparatus according to any one of Examples 9-12, further comprising: a knowledge vector generation module configured to generate a knowledge vector corresponding to each knowledge item in the knowledge base using the vectorization model based on the knowledge name and synonyms of the knowledge item; and The vector library construction module is configured to construct the knowledge vector library based on the knowledge vector.

[0072] Example 14. The apparatus according to any one of Examples 9-13, further comprising: A knowledge acquisition module, configured to acquire a knowledge item to be added in response to receiving an adding request; A knowledge adding module, configured to add the knowledge item to be added to the knowledge base; a vector generation module, configured to generate a knowledge vector of the knowledge item to be added by using the vectorization model; and The vector adding module is configured to add the knowledge vector of the knowledge item to be added to the knowledge vector library.

[0073] Example 15. The apparatus according to any one of Examples 9-14, further comprising: A deletion knowledge determination module, configured to determine a knowledge item to be deleted in response to receiving a deletion request; a knowledge item deletion module, configured to delete the knowledge item to be deleted from the knowledge base; and The knowledge vector deletion module is configured to delete the knowledge vector corresponding to the knowledge item to be deleted from the knowledge vector library.

[0074] Example 16. The apparatus according to any one of Examples 9-15, further comprising: The query output generation module is configured to generate a query output related to the query requirement based on the user input, the query knowledge and the target data using the language model, wherein the query output presents the query knowledge and the target data in a natural language form.

[0075] Example 17. An electronic device comprising: Processor; and A memory coupled to the processor, the memory having instructions stored therein, wherein when the instructions are executed by the processor, the electronic device performs actions, the actions comprising: Obtaining user input, where the user input indicates a query requirement in a natural language form; Based on the user input, generate an input vector of the user input using a vectorization model; Based on the input vector, determining a knowledge vector associated with the user input from a knowledge vector library, wherein the knowledge vector library is constructed by vectorizing each knowledge item in the knowledge library using the vectorization model; Based on the knowledge vector, determining query knowledge corresponding to the knowledge vector from the knowledge base, wherein the knowledge base is stored in the form of a database table, and each knowledge item includes at least a knowledge name and a knowledge description; Based on the user input and the query knowledge, generating a target SQL query using a language model; and Based on the target SQL query, target data related to the query requirement is determined.

[0076] Example 18. The electronic device of Example 17, wherein determining the knowledge vector associated with the user input comprises: Based on the input vector, determining a similarity score between each knowledge vector in the knowledge vector library and the input vector; and Based on the similarity score and a predetermined threshold, the knowledge vector associated with the user input is determined.

[0077] Example 19. The electronic device according to any one of Examples 17-18, wherein generating the target SQL query using the language model comprises: Generate a target prompt word based on the user input and the knowledge name and knowledge description in the query knowledge, wherein the target prompt word is used to guide the language model to generate an SQL query; and Based on the target prompt word, the target SQL query is generated using the language model.

[0078] Example 20. The electronic device of any one of Examples 17-19, wherein each knowledge item in the knowledge base further includes a synonym of the knowledge name.

[0079] Example 21. The electronic device according to any one of Examples 17-20, wherein the actions further include: Based on the knowledge name and synonyms of each knowledge item in the knowledge base, generating a knowledge vector corresponding to the knowledge item using the vectorization model; and Based on the knowledge vector, the knowledge vector library is constructed.

[0080] Example 22. The electronic device according to any one of Examples 17-21, wherein the actions further include: In response to receiving the adding request, obtaining the knowledge item to be added; Adding the knowledge item to be added to the knowledge base; Generating a knowledge vector of the knowledge item to be added by using the vectorized model; and The knowledge vector of the knowledge item to be added is added to the knowledge vector library.

[0081] Example 23. The electronic device according to any one of Examples 17-22, wherein the actions further include: In response to receiving the deletion request, determining a knowledge item to be deleted; Deleting the knowledge item to be deleted from the knowledge base; and The knowledge vector corresponding to the knowledge item to be deleted is deleted from the knowledge vector library.

[0082] Example 24. The electronic device according to any one of Examples 17-23, wherein the actions further include: Based on the user input, the query knowledge and the target data, the language model is used to generate a query output related to the query requirement, and the query output presents the query knowledge and the target data in a natural language form.

[0083] Example 25. A computer-readable storage medium having one or more computer instructions stored thereon, wherein the one or more computer instructions are executed by a processor to implement the method according to any one of Examples 1 to 8.

[0084] Example 26. A computer program product tangibly stored on a computer-readable medium and comprising computer-executable instructions that, when executed by a device, cause the device to perform the method according to any one of Examples 1 to 8.

[0085] Although the disclosure has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Instead, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A method for data query, include: Obtaining user input, where the user input indicates a query requirement in a natural language form; Based on the user input, generate an input vector of the user input using a vectorization model; Based on the input vector, determining a knowledge vector associated with the user input from a knowledge vector library, wherein the knowledge vector library is constructed by vectorizing each knowledge item in the knowledge library using the vectorization model; Based on the knowledge vector, determining query knowledge corresponding to the knowledge vector from the knowledge base, wherein the knowledge base is stored in the form of a database table, and each knowledge item includes at least a knowledge name and a knowledge description; Based on the user input and the query knowledge, generating a target SQL query using a language model; as well as Based on the target SQL query, target data related to the query requirement is determined.

2. The method of claim 1, wherein determining the knowledge vector associated with the user input include: Based on the input vector, determining a similarity score between each knowledge vector in the knowledge vector library and the input vector; as well as Based on the similarity score and a predetermined threshold, the knowledge vector associated with the user input is determined.

3. The method according to claim 1, wherein the target SQL query is generated using the language model include: Generate a target prompt word based on the user input and the knowledge name and knowledge description in the query knowledge, wherein the target prompt word is used to guide the language model to generate an SQL query; as well as Based on the target prompt word, the target SQL query is generated using the language model. The method according to claim 1 , wherein each knowledge item in the knowledge base further includes a synonym of the knowledge name.

5. The method according to claim 4, further comprising: include: Based on the knowledge name and synonyms of each knowledge item in the knowledge base, generating a knowledge vector corresponding to the knowledge item using the vectorization model; as well as Based on the knowledge vector, the knowledge vector library is constructed.

6. The method according to claim 4, further comprising: include: In response to receiving the adding request, obtaining the knowledge item to be added; Adding the knowledge item to be added to the knowledge base; Generating a knowledge vector of the knowledge item to be added by using the vectorization model; as well as The knowledge vector of the knowledge item to be added is added to the knowledge vector library.

7. The method according to claim 4, further comprising: include: In response to receiving the deletion request, determining a knowledge item to be deleted; Deleting the knowledge item to be deleted from the knowledge base; as well as The knowledge vector corresponding to the knowledge item to be deleted is deleted from the knowledge vector library.

8. The method according to claim 1, further comprising: include: Based on the user input, the query knowledge and the target data, the language model is used to generate a query output related to the query requirement, and the query output presents the query knowledge and the target data in a natural language form.

9. A data query device, include: A user input acquisition module is configured to acquire user input, wherein the user input indicates a query requirement in a natural language form; An input vector generation module, configured to generate an input vector of the user input by using a vectorization model based on the user input; a knowledge vector determination module configured to determine, based on the input vector, a knowledge vector associated with the user input from a knowledge vector library, wherein the knowledge vector library is constructed by vectorizing each knowledge item in the knowledge library using the vectorization model; A query knowledge determination module, configured to determine query knowledge corresponding to the knowledge vector from the knowledge base based on the knowledge vector, wherein the knowledge base is stored in the form of a database table, and each knowledge item includes at least a knowledge name and a knowledge description; A target query generation module is configured to generate a target SQL query using a language model based on the user input and the query knowledge; as well as The target data determination module is configured to determine target data related to the query requirement based on the target SQL query.

10. An electronic device, include: processor; as well as A memory coupled to the processor, the memory having instructions stored therein, wherein when the instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 8.

11. A computer program product tangibly stored on a non-transitory computer readable medium and comprising computer executable instructions for performing the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Water conservancy knowledge base system based on large language model

    CN117909455A

  • Knowledge base response method and system based on large language model

    CN117951249A

  • Database query statement generation method and device, equipment and storage medium

    CN118227655A

  • Knowledge question and answer method and device, readable medium, electronic equipment and program product

    CN118964694A

  • System and method for querying questions and answers

    US20170228372A1

Cited By

  • TextureSql method and device based on large model and storage medium

    CN120011548A

  • Knowledge base construction and use method and device of trusted data space, equipment and medium

    CN120338085A