Method and device for querying data, electronic equipment, storage medium and program product
By adopting large-scale model technology based on knowledge graph in the natural language retrieval system, processing users' natural language query statements and generating database query statements, the existing system's lack of flexibility and accuracy in complex queries and multi-source data integration is solved, and efficient and accurate information retrieval and data analysis are achieved.
Patent Information
- Application Number
- CN202411605293.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-02-28
AI Technical Summary
Existing natural language retrieval systems have problems of insufficient flexibility and accuracy when dealing with complex queries, multi-source data association and integration, and dynamic user needs.
Using knowledge graph-based big model technology, by receiving the user's natural language query statement, corresponding predefined query examples and processor executable statements are determined, and input them into the big model to generate processor executable statements, thereby retrieving query results from the database.
It significantly improves the accuracy and efficiency of information retrieval, has good flexibility, can better understand and process complex queries, and realizes efficient integration and dynamic updates of multi-source data.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, in particular to natural language retrieval technology, and specifically to a method, device, electronic device, computer-readable storage medium and computer program product for querying data. Background Art
[0002] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.
[0003] Natural language-based retrieval can quickly provide users with the information they need.
[0004] The methods described in this section are not necessarily methods that have been previously conceived or employed. Unless otherwise indicated, it should not be assumed that any method described in this section is considered to be prior art simply because it is included in this section. Similarly, unless otherwise indicated, the issues mentioned in this section should not be considered to have been recognized in any prior art. Summary of the invention
[0005] The present disclosure provides a method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product for querying data.
[0006] According to one aspect of the present disclosure, a method for querying data is provided, comprising: receiving an input of a query statement; determining a predefined query example corresponding to the query statement and a processor executable statement corresponding to the query example; inputting the query statement, the predefined query example corresponding to the query statement, and the processor executable statement corresponding to the query example into a big model, so that the big model generates a processor executable statement corresponding to the query statement; and executing the processor executable statement corresponding to the query statement to retrieve a query result corresponding to the query statement from a database.
[0007] According to another aspect of the present disclosure, a device for querying data is provided, comprising: an input unit configured to receive an input of a query statement; an example query unit configured to determine a predefined query example corresponding to the query statement and a processor executable statement corresponding to the query example; a generation unit configured to input the query statement, the predefined query example corresponding to the query statement, and the processor executable statement corresponding to the query example into a big model, so that the big model generates a processor executable statement corresponding to the query statement; and a query result acquisition unit configured to execute the processor executable statement corresponding to the query statement to retrieve a query result corresponding to the query statement from a database.
[0008] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to an embodiment of the present disclosure.
[0009] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method according to the embodiment of the present disclosure.
[0010] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the method according to the embodiment of the present disclosure is implemented.
[0011] According to one or more embodiments of the present disclosure, the accuracy of data query and the processing capability of complex query tasks can be improved.
[0012] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The accompanying drawings exemplarily illustrate the embodiments and constitute a part of the specification, and together with the text description of the specification, are used to explain the exemplary implementation of the embodiments. The embodiments shown are for illustrative purposes only and do not limit the scope of the claims. In all drawings, the same reference numerals refer to similar but not necessarily identical elements.
[0014] Figure 1 A schematic diagram showing an exemplary system in which the various methods described herein may be implemented according to an embodiment of the present disclosure;
[0015] Figure 2 An exemplary flow chart of a method for querying data according to an embodiment of the present disclosure is shown;
[0016] Figure 3 An example of a natural language query system according to an embodiment of the present disclosure is shown;
[0017] Figure 4 An exemplary block diagram of a device for querying data according to an embodiment of the present disclosure is shown;
[0018] Figure 5 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0019] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0020] In the present disclosure, unless otherwise specified, the use of the terms "first", "second", etc. to describe various elements is not intended to limit the positional relationship, temporal relationship, or importance relationship of these elements, and such terms are only used to distinguish one element from another element. In some examples, the first element and the second element may refer to the same instance of the element, and in some cases, based on the description of the context, they may also refer to different instances.
[0021] The terms used in the description of various examples in this disclosure are only for the purpose of describing specific examples and are not intended to be limiting. Unless the context clearly indicates otherwise, if the number of elements is not specifically limited, the element can be one or more. In addition, the term "and / or" used in this disclosure covers any one of the listed items and all possible combinations.
[0022] The embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0023] Figure 1 FIG. 1 is a schematic diagram of an exemplary system 100 in which various methods and apparatuses described herein may be implemented according to an embodiment of the present disclosure. Figure 1, the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. The client devices 101, 102, 103, 104, 105, and 106 may be configured to execute one or more applications.
[0024] In an embodiment of the present disclosure, the server 120 may run one or more services or software applications that enable execution of the method for data query.
[0025] In some embodiments, server 120 may also provide other services or software applications, which may include non-virtualized environments and virtualized environments. In some embodiments, these services may be provided as web-based services or cloud services, such as provided to users of client devices 101, 102, 103, 104, 105, and / or 106 under a software as a service (SaaS) model.
[0026] exist Figure 1 In the configuration shown, the server 120 may include one or more components that implement the functions performed by the server 120. These components may include software components, hardware components, or a combination thereof that can be executed by one or more processors. Users operating client devices 101, 102, 103, 104, 105, and / or 106 may in turn utilize one or more client applications to interact with the server 120 to utilize the services provided by these components. It should be understood that a variety of different system configurations are possible, which may differ from the system 100. Therefore, Figure 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.
[0027] The user may use client devices 101, 102, 103, 104, 105 and / or 106 to obtain a query statement input by the user and provide the user with an output of the query result. The client device may provide an interface that enables the user of the client device to interact with the client device. The client device may also output information to the user via the interface. Figure 1 Only six client devices are depicted, but one skilled in the art will appreciate that the present disclosure may support any number of client devices.
[0028] Client devices 101, 102, 103, 104, 105 and / or 106 may include various types of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptop computers), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, game systems, thin clients, various messaging devices, sensors or other sensing devices, etc. These computer devices may run various types and versions of software applications and operating systems, such as MICROSOFT Windows, APPLE iOS, UNIX-like operating systems, Linux or Linux-like operating systems (such as GOOGLE Chrome OS); or include various mobile operating systems, such as MICROSOFT Windows Mobile OS, iOS, Windows Phone, Android. Portable handheld devices may include cellular phones, smart phones, tablet computers, personal digital assistants (PDAs), etc. Wearable devices may include head-mounted displays (such as smart glasses) and other devices. Game systems may include various handheld game devices, Internet-enabled game devices, etc. Client devices are capable of executing various different applications, such as various Internet-related applications, communication applications (such as email applications), short message service (SMS) applications, and may use various communication protocols.
[0029] The network 110 may be any type of network known to those skilled in the art that may support data communications using any of a variety of available protocols, including but not limited to TCP / IP, SNA, IPX, etc. By way of example only, the one or more networks 110 may be a local area network (LAN), an Ethernet-based network, a token ring, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a blockchain network, a public switched telephone network (PSTN), an infrared network, a wireless network (e.g., Bluetooth, WIFI), and / or any combination of these and / or other networks.
[0030] Server 120 may include one or more general purpose computers, dedicated server computers (e.g., PC (personal computer) servers, UNIX servers, mid-range servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and / or combination. Server 120 may include one or more virtual machines running virtual operating systems, or other computing architectures involving virtualization (e.g., one or more flexible pools of logical storage devices that may be virtualized to maintain a server's virtual storage device). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.
[0031] The computing units in the server 120 may run one or more operating systems including any of the above operating systems and any commercially available server operating systems. The server 120 may also run any of a variety of additional server applications and / or middle-tier applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.
[0032] In some implementations, server 120 may include one or more applications to analyze and consolidate data feeds and / or event updates received from users of client devices 101, 102, 103, 104, 105, and / or 106. Server 120 may also include one or more applications to display data feeds and / or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and / or 106.
[0033] In some embodiments, the server 120 may be a server of a distributed system, or a server combined with a blockchain. The server 120 may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. A cloud server is a host product in a cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private servers (VPS) services.
[0034] The system 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of the databases 130 may be used to store information such as audio files and video files. The databases 130 may reside in various locations. For example, the database used by the server 120 may be local to the server 120, or may be remote from the server 120 and may communicate with the server 120 via a network-based or dedicated connection. The databases 130 may be of different types. In some embodiments, the databases used by the server 120 may be, for example, relational databases. One or more of these databases may store, update, and retrieve data to and from the databases in response to commands.
[0035] In some embodiments, one or more of the databases 130 may also be used by applications to store application data. The databases used by the applications may be different types of databases, such as a key-value store, an object store, or a conventional store backed by a file system.
[0036] Figure 1The system 100 may be configured and operated in various ways to enable the application of various methods and apparatuses described in the present disclosure.
[0037] The natural language retrieval system in the related art usually adopts the following implementation schemes:
[0038] 1. Keyword matching: This is the most basic natural language search method. The system identifies keywords in user input and searches for matching records in the database. However, this method has limited understanding of complex queries and has difficulty handling polysemous words and context-related information.
[0039] 2. Rule-based natural language processing: This method uses predefined rules and patterns to parse natural language sentences input by users and then converts them into executable query statements. This method works well when processing queries in specific fields, but it lacks flexibility and is difficult to adapt to dynamically changing user needs.
[0040] 3. Machine learning and deep learning models: In recent years, many systems have begun to adopt machine learning and deep learning techniques to enhance natural language understanding capabilities. These models can learn language patterns by training large corpora, thereby more accurately parsing user queries and generating corresponding retrieval results. However, this approach requires a lot of data and computing resources.
[0041] 4. Traditional knowledge graph: Traditional knowledge graph uses natural language processing technology to parse queries into structured formats, identify and link entities, extract relationships, and convert them into query languages such as SPARQL for execution in graph databases to provide accurate semantic understanding and information retrieval.
[0042] However, the above methods in the related art have some defects.
[0043] For keyword matching methods, which only rely on simple string matching, they cannot understand the semantics of the query and easily lead to irrelevant or incomplete results. This retrieval method is difficult to handle complex query requirements, especially queries involving multiple conditions or relationships.
[0044] Rule-based methods are limited by predefined rules and patterns, making it difficult to handle unforeseen queries or complex semantic relationships. They can usually only handle information from a single source, making it difficult to associate and integrate multi-source data. Updates and extensions require redefinition of rules, which may result in high maintenance costs.
[0045] For traditional knowledge graph-based methods, more manual intervention and rule setting may be required when dealing with polysemous words and complex relationships. Relying on rules and predefined NLP techniques to parse and transform queries may be limited in complex semantic understanding.
[0046] Machine learning and deep learning model methods are usually good at pattern recognition and prediction, but may not be as intuitive and accurate as knowledge graphs when processing complex logical queries. Although patterns can be learned from big data, additional data preprocessing and feature engineering may be required when information sources are diverse. And the interpretability is low, especially deep learning models, which are often regarded as "black boxes" and it is difficult to explain their decision-making process and results.
[0047] In order to solve the problem of insufficient flexibility and accuracy in existing natural language retrieval systems, the embodiments of the present disclosure provide a new method for querying data. Traditional natural language retrieval tools often require a lot of model training, especially when involving large-scale data and multi-dimensional information, and their accuracy is also insufficient.
[0048] To this end, the present invention proposes a natural language retrieval system solution based on knowledge graph. Knowledge graph has significant advantages in semantic understanding, processing complex queries, information integration, interpretability and dynamic updating. These advantages make knowledge graph a solution in many application scenarios that require deep semantic understanding and complex information processing. The system according to the embodiment of the present disclosure utilizes large model technology and big data processing capabilities to significantly improve the accuracy and efficiency of information retrieval, and has good flexibility. Taking enterprise information query as an example, by constructing and applying enterprise knowledge graphs, the system can better understand and process users' natural language queries, thereby providing more comprehensive and accurate enterprise information.
[0049] The method according to the embodiment of the present disclosure can be applied to various information service platforms, such as enterprise information query tools, business information analysis systems, and other business application scenarios that require efficient information retrieval and data analysis. Using the method of the embodiment of the present disclosure, users can obtain the required information more quickly and improve the efficiency and accuracy of business decisions.
[0050] Figure 2 An exemplary flow chart of a method for querying data according to an embodiment of the present disclosure is shown.
[0051] In step S202, an input of a query statement is received.
[0052] In step S204, a predefined query example corresponding to the query statement and a processor executable statement corresponding to the query example are determined.
[0053] In step S206, the query statement, the predefined query examples corresponding to the query statement, and the processor executable statements corresponding to the query examples are input into the big model, so that the big model generates the processor executable statements corresponding to the query statement.
[0054] In step S208 , a processor executable statement corresponding to the query statement is executed to retrieve a query result corresponding to the query statement from a database.
[0055] By using the data query method provided by the embodiments of the present disclosure, the accuracy of data query and the processing capability of complex query tasks can be improved.
[0056] The principles of the present disclosure will be described in detail below.
[0057] In step S202, a query statement is inputted. In an example, a user may input a query statement such as "where is the registered address of Company A".
[0058] In some embodiments, after receiving the input of the query statement, the method 200 may further include: modifying the subject name in the query statement to replace the subject name in the query statement with a subject name predefined in the database.
[0059] In the method of querying data, the user inputs the query statement in natural language. For example, the query statement entered by the user is "Where is the registered address of Company A?" Due to the diversity of natural language expressions, there is uncertainty in the subject name in the query statement entered by the user. For example, some users may express Company A as "A Enterprise", while other users may directly express Company A as "A". Different users may use different abbreviations or other habitual expressions for the same subject. For another example, in a scenario of multiple rounds of conversations, the name of the subject being queried may be replaced by expressions such as pronouns and default words.
[0060] The above-mentioned uncertain subject name expression is disadvantageous for data query, because the database usually only stores one predetermined subject name for the stored data. Taking enterprise information query as an example, the enterprise name stored in the database is the standard name used in the enterprise registration information.
[0061] In order to improve the accuracy of the query, the method provided in the embodiment of the present disclosure improves the accuracy of the query statement by replacing the subject name in the query statement with the subject name predefined in the database.
[0062] In some examples, the subject name in the query statement can be modified by rewriting abbreviations, correcting typos, etc. In other examples, a large model can be used to process pronouns and / or default words in query questions in multi-round conversation scenarios. The named entity recognition (NER) model can be used to extract the subject name from the rewritten question, and the subject recall method based on natural language processing such as NLPC and retrieval services such as Elasticsearch can be used to identify the predefined subject names in the database, so as to accurately match the subjects in the database such as natural persons / enterprises. In the case of recall failure, the fuzzy search questioning logic can be triggered to guide the user to confirm from multiple possible matching candidate subjects.
[0063] The above method can pre-process the natural language query statement input by the user, thereby linking the query subject in the query statement to the database to be queried, thereby improving the accuracy and efficiency of the query.
[0064] In step S204, a predefined query example corresponding to the query statement and a processor executable statement corresponding to the query example are determined.
[0065] In step S206, the query statement, the predefined query examples corresponding to the query statement, and the processor executable statements corresponding to the query examples are input into the big model, so that the big model generates the processor executable statements corresponding to the query statement.
[0066] In the embodiment of the present disclosure, a large model is used to generate a corresponding processor executable statement for a query statement. In the example, the processor executable statement can be a gremlin statement. Any other form of processor executable machine language can also be selected as the implementation method of the processor executable statement according to actual conditions.
[0067] Large models generally refer to models with a large number of parameters in the field of machine learning and artificial intelligence. These models can capture and learn complex data patterns and relationships because of the large number of parameters. The large model used in the embodiments of the present disclosure may be a large language model. A large language model may be an artificial intelligence model with a large number of parameters for processing and understanding natural language. Exemplary large language models include BERT, GPT-4, etc. The large model used in the embodiments of the present disclosure is a model that has been trained with massive amounts of general data and has the ability to handle general problems.
[0068] In an embodiment of the present disclosure, by inputting a query statement, a predefined query example corresponding to the query statement, and a processor executable statement corresponding to the query example into a large model, the large model can be guided to output a corresponding processor executable statement for the query statement in a more accurate manner.
[0069] A plurality of query examples and processor executable statements corresponding to each query example may be predefined as a query example set. For example, a query example may include "where is the registered address of Company B" and a gremlin statement corresponding to "where is the registered address of Company B".
[0070] Step S204 may include determining a query example that matches the query statement from a query example set. In some embodiments, query examples that match the query statement and processor executable statements corresponding to the matched query examples may be recalled in a predefined example set by means of vector retrieval. For example, an embedding vector corresponding to the query statement may be determined and compared with the embedding vectors of the query examples predefined in the example set, and a result closest to the embedding vector corresponding to the query statement is determined as a query example that matches the query statement. The query example determined in this manner has similar natural language information to the input query statement, so the processor executable statement corresponding to the query example has a guiding role in generating a processor executable statement for the input query statement, and can help improve the accuracy of the processor executable statement for the input query statement output by the large model.
[0071] In step S206, the query statement input in step 202 can be input into the big model together with the query example determined in step S204 and the processor executable statement corresponding to the query example, and the big model can be controlled to generate a processor executable statement of the query statement using the query example and the processor executable statement corresponding to the query example as an example.
[0072] In some examples, the table structure information of the database, such as schema information, can also be provided to the big model, so that the big model can generate processor executable statements for querying while taking into account the structure of the database being queried, thereby making the processor executable statements for querying generated by the big model have a higher query success rate in the queried database, further improving query efficiency and accuracy.
[0073] In some embodiments, the processor executable statements generated by the large model can also be processed based on rules, so as to modify the results generated by the large model that obviously do not meet the requirements of the processing rules, thereby avoiding statement problems caused by unfavorable factors such as large model hallucinations and further improving the success rate of queries.
[0074] In step S208 , a processor executable statement corresponding to the query statement is executed to retrieve a query result corresponding to the query statement from a database.
[0075] In some embodiments, the queried database may be a graph database. An exemplary graph database may be a HugeGraph graph database. Taking enterprise information data as an example, the database may include billions of data volumes and hundreds of data dimensions. Most data dimensions are associated with enterprises and natural persons, including subject attributes such as registered address and establishment time, and subject associations such as personnel positions and foreign investments. Taking into account factors such as data modeling and query performance, a graph structure can be used to store nodes, edge relationships, and attribute relationships. The data flow link can be completed through scheduled big data analysis tasks, such as Spark tasks. Big data analysis tasks regularly pull data files from the data warehouse, generate graph structure result files through data conversion, aggregation and other processes, and finally import them into the HugeGraph database through the HugeGraph Loader loader. After the database is filled, data integrity and consistency verification will be performed through automated testing.
[0076] After retrieving the corresponding query results from the database, the big model can also be used to analyze and summarize the query results and user questions to generate response content as output to the user.
[0077] To further improve the effect of the data query task, method 200 may further include expanding the query example set according to the query history. The expansion task may be performed based on a predetermined time period, or in response to the query number reaching a predetermined threshold.
[0078] In some embodiments, the method 200 may further include: storing failed query records. Processing the failed query records using the large model to obtain updated processor executable statements corresponding to the query statements in the failed query records. Adding the query statements in the failed records and the corresponding updated processor executable statements to the predefined example set, thereby expanding the example set.
[0079] In some examples, failed query records may be stored in a MySQL database.
[0080] The failed query records can be read regularly, and the large model can be used to filter out the failed query records that failed because they did not meet the user's questions. Then, the large model can be used to regenerate updated processor executable statements for the query statements in the filtered failed query records.
[0081] In some embodiments, when expanding the example set, a large model that has been further trained and has stronger capabilities than the large model used in the query task can be used to generate updated processor executable statements. In some examples, the large model can be used to generate corresponding updated processor executable statements for the query statements in the failed query records according to a predetermined chain reasoning process. Among them, a predetermined chain reasoning process can be designed according to the characteristics of the query task, so as to guide the large model to gradually reason and obtain appropriate output results. For example, taking the enterprise information query task as an example, a chain reasoning process can be designed to control the large model to sequentially reason and obtain information such as the subject objects involved in the user query, the characteristics of the information to be queried by the user, and the relationship between the information queried by the user and the storage structure in the database. Through the intermediate reasoning steps of the predetermined chain reasoning process, the large model can be guided to generate output results in a desired manner.
[0082] In some examples, a large model can be used to perform multiple reasonings to generate multiple updated processor executable statements for query statements in failed query records. When multiple updated processor executable statements are consistent, the updated processor executable statements are determined as updated processor executable statements corresponding to the query statements in the failed query records. When the large model outputs consistent results multiple times, it can be considered that the results generated by the large model are self-consistent, so the output results are more reliable. The updated processor executable statements output by the large model can be added to the example set, or the updated processor executable statements output by the large model can be manually screened, and the updated processor executable statements that pass the screening can be added to the example set.
[0083] By using the above method, the query example set can be expanded and supplemented as the query task is continuously executed, and thus the historical query results can be used to improve the effect of subsequent query tasks.
[0084] The query method provided by the embodiments of the present disclosure has a wide range of application scenarios. Taking the enterprise information query scenario as an example, it can not only query basic industrial and commercial information, but also be applied to scenarios such as enterprise risk analysis and equity penetration analysis based on graph characteristics. At the same time, relying on the natural language understanding ability of the large model, the solution can adapt to the personalized needs of different users, and can assist in multi-field decision-making such as business cooperation, sales development, and investment and financial management based on user questions and data statistical analysis. In other query scenarios, the content of data analysis can also be expanded based on graph characteristics, and other analysis and decision-making requirements of users based on query data can be met.
[0085] Figure 3 An example of a natural language query system according to an embodiment of the present disclosure is shown. Figure 3 The natural language query system shown in FIG. Figure 2Method 200 is described.
[0086] Figure 3 It shows that the natural language query system consists of three parts, namely the online retrieval part, the data flywheel analysis part and the offline database filling part.
[0087] In step S301, the system receives a user's question input by the user and transmits the user's question to the backend 310. Figure 3 In the described example, the principle of the present disclosure will be described by taking user-questioned enterprise information query as an example.
[0088] In step S302, the input user question can be transmitted to the subject disambiguation module 320. Among them, the subject disambiguation module 320 may include a NER model, a subject recall service and a subject retrieval system. Subject disambiguation refers to linking the company and personnel names in the query statement to a unique node in the graph database, which includes both the replacement and supplement of the query subject in multiple rounds of conversations, as well as scenarios such as abbreviation rewriting and typo correction. First, a large model can be used to process the pronouns and default words in the query questions in the multi-round conversation scenario, and then the NER model can be used to extract the subject name from the rewritten question, and the subject recall service based on the NLPC+ES subject retrieval system can be used to identify the subject name and accurately match the corresponding natural person / enterprise subject. If the recall fails, the follow-up logic based on ES fuzzy search is triggered to guide the user to confirm the correct name of the subject object from multiple related subjects.
[0089] In step S303, the subject disambiguation module 320 may return the user question after subject disambiguation to the backend 310, wherein the user question after subject disambiguation contains the accurate name of the queried subject, such as the business registration name of the enterprise.
[0090] In step S304, the backend 310 may deliver the search content, i.e., the subject-disambiguated user question returned in step S303, to the text2gremlin module 330 for generating executable gremlin statements. In step S305, the example library may be queried for predefined examples matching the user question, and the big model may be used to generate a gremlin statement of the user question based on the user question and the matched examples.
[0091] In step S306 , the gremlin statement generated in step S305 may be executed to search in the graph database 340 .
[0092] In step S307, the query record may be stored in, for example, a MySQL database.
[0093] Figure 3The data flywheel analysis part shown in is used to expand the example library according to the stored historical query records.
[0094] In step S311 , the offline analysis module 350 may pull historical query records from the database.
[0095] In step S312, the pulled historical query records can be classified into failed records using the large model 2 to determine the partial records that do not satisfy the user's questions. The large model 2 can be the same model as the large model in the text2gremlin module of the online search part.
[0096] In step S313, the large model 1 can be used to generate updated Gremlin statements for the query statements in the failure records that do not meet the user's questions. The large model 1 can be a model that is more fully trained and has stronger capabilities than the large model 2.
[0097] In step S314, the example library can be supplemented according to the updated gremlin statements output by the large model 1. The large model 1 can be controlled to determine the reliability of the results output by the large model 1 according to a predefined chain reasoning process and / or by outputting consistent gremlin statements multiple times. The gremlin statements output by the large model 1 can be further added to the example library by manual screening.
[0098] Figure 3 The offline storage part shown in is used to store data in the graph database 340.
[0099] In step S321 , the spark task is started through the scheduled task, so as to start the data analysis on a scheduled basis to generate files to be stored in the graph database 340 .
[0100] In step S322, the Spark task loads the data source file from the data warehouse 360, and generates a graph structure result file through data conversion, aggregation and other processes.
[0101] In step S323, the data is loaded into the graph database HugeGraph through the loader HugeGraph Loader.
[0102] In step S324, after the database is loaded, data integrity and consistency verification will be performed through automated testing.
[0103] Figure 4 An exemplary block diagram of a device for querying data according to an embodiment of the present disclosure is shown. Figure 4 The device 400 shown in FIG. Figure 2 A method 200 for querying data is described.
[0104] like Figure 4 As shown, the apparatus 400 may include an input unit 410 , an example query unit 420 , a generation unit 430 , and a query result acquisition unit 440 .
[0105] The input unit 410 may be configured to receive an input of a query statement.
[0106] The example query unit 420 may be configured to determine a predefined query example corresponding to a query statement and a processor-executable statement corresponding to the query example.
[0107] The generation unit 430 may be configured to input a query statement, a predefined query example corresponding to the query statement, and a processor executable statement corresponding to the query example into the big model, so that the big model generates a processor executable statement corresponding to the query statement.
[0108] The query result acquisition unit 440 may be configured to execute a processor executable statement corresponding to a query statement to retrieve a query result corresponding to the query statement from a database.
[0109] In some embodiments, the apparatus 400 may further include: a subject name modification unit configured to modify the subject name in the query statement to replace the subject name in the query statement with a subject name predefined in the database.
[0110] In some embodiments, determining a predefined query example corresponding to a query statement and a processor executable statement corresponding to the query example may include: recalling query examples matching the query statement and processor executable statements corresponding to the matched query examples in a predefined example set by means of vector retrieval.
[0111] In some embodiments, the processor-executable statement may be a gremlin statement.
[0112] In some embodiments, the database may be a graph database.
[0113] In some embodiments, the device 400 may also include an example extension unit, which is configured to: store failed query records; process the failed query records using a large model to obtain updated processor executable statements corresponding to the query statements in the failed query records; and add the query statements in the failed records and the corresponding updated processor executable statements to a predefined example set.
[0114] In some embodiments, using a large model to process failed query records to obtain updated processor executable statements corresponding to the query statements in the failed query records may include: using the large model to generate corresponding updated processor executable statements for the query statements in the failed query records according to a predetermined chain reasoning process; or using the large model to perform multiple reasonings to generate multiple updated processor executable statements for the query statements in the failed query records, and when the multiple updated processor executable statements are consistent, determining the updated processor executable statements as updated processor executable statements corresponding to the query statements in the failed query records.
[0115] It should be understood that Figure 4 The various modules or units of the apparatus 400 shown in FIG. 4 can be used in conjunction with the reference Figure 2 The steps in the method 200 described above correspond to each other. Therefore, the operations, features and advantages described above for the method 200 are also applicable to the device 400 and the modules and units included therein. For the sake of brevity, some operations, features and advantages are not repeated here.
[0116] Although specific functionality is discussed above with reference to specific modules, it should be noted that the functionality of the various units discussed herein may be separated into multiple units, and / or at least some functionality of multiple units may be combined into a single unit.
[0117] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0118] According to an embodiment of the present disclosure, an electronic device is also provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described according to an embodiment of the present disclosure.
[0119] According to an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is further provided, wherein the computer instructions are used to enable a computer to execute the method according to the embodiment of the present disclosure.
[0120] According to an embodiment of the present disclosure, a computer program product is further provided, including a computer program, wherein when the computer program is executed by a processor, the method according to the embodiment of the present disclosure is implemented.
[0121] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0122] According to an embodiment of the present disclosure, an electronic device, a readable storage medium and a computer program product are also provided.
[0123] refer to Figure 5 , a block diagram of an electronic device 500 that can be used as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0124] like Figure 5 As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0125] Multiple components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, an output unit 507, a storage unit 508, and a communication unit 509. The input unit 506 can be any type of device that can input information to the electronic device 500. The input unit 506 can receive input digital or character information and generate key signal input related to user settings and / or function control of the electronic device, and can include but is not limited to a mouse, a keyboard, a touch screen, a track pad, a track ball, a joystick, a microphone, and / or a remote controller. The output unit 507 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 508 can include but is not limited to a disk, an optical disk. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth™ device, an 802.11 device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0126] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as method 200. For example, in some embodiments, the method 200 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the method 200 described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the method 200 in any other appropriate manner (e.g., by means of firmware).
[0127] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0128] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0129] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0130] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0131] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0132] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0133] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0134] Although the embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it should be understood that the above-mentioned methods, systems and devices are merely exemplary embodiments or examples, and the scope of the present invention is not limited by these embodiments or examples, but only by the claims after authorization and their equivalent scope. Various elements in the embodiments or examples can be omitted or replaced by their equivalent elements. In addition, each step can be performed in an order different from that described in the present disclosure. Further, the various elements in the embodiments or examples can be combined in various ways. It is important that with the evolution of technology, many elements described herein can be replaced by equivalent elements that appear after the present disclosure.
Claims
1. A method for querying data, comprising: Receive query statement input; Determining a predefined query example corresponding to the query statement and a processor executable statement corresponding to the query example; Inputting the query statement, a predefined query example corresponding to the query statement, and a processor executable statement corresponding to the query example into a large model, so that the large model generates a processor executable statement corresponding to the query statement; as well as The processor executable statement corresponding to the query statement is executed to retrieve the query result corresponding to the query statement from the database.
2. The method of claim 1, further comprising: The subject name in the query statement is modified to replace the subject name in the query statement with a subject name predefined in the database.
3. The method of claim 1, wherein: Determining a predefined query example corresponding to the query statement and a processor executable statement corresponding to the query example includes: By means of vector retrieval, query examples matching the query statement and processor executable statements corresponding to the matched query examples are recalled from a predefined set of examples. The method of claim 3 , wherein the processor-executable statement is a gremlin statement.
5. The method of claim 1, wherein: The database is a graph database.
6. The method according to any one of claims 1 to 5, further comprising: Store failed query records; Processing the failed query record using the large model to obtain an updated processor executable statement corresponding to the query statement in the failed query record; The query statements in the failure record and the corresponding updated processor executable statements are added to a predefined example set.
7. The method of claim 6, wherein: Processing the failed query record using the large model to obtain an updated processor executable statement corresponding to the query statement in the failed query record includes: Generate corresponding updated processor executable statements for the query statements in the failed query records according to a predetermined chain reasoning process using the large model; or Multiple inferences are performed using a large model to generate multiple updated processor executable statements for the query statements in the failed query record. When the multiple updated processor executable statements are consistent, the updated processor executable statements are determined as updated processor executable statements corresponding to the query statements in the failed query record.
8. A device for querying data, comprising: An input unit, configured to receive an input of a query statement; An example query unit configured to determine a predefined query example corresponding to the query statement and a processor executable statement corresponding to the query example; a generating unit configured to input the query statement, a predefined query example corresponding to the query statement, and a processor executable statement corresponding to the query example into a large model, so that the large model generates a processor executable statement corresponding to the query statement; and The query result acquisition unit is configured to execute a processor executable statement corresponding to the query statement to retrieve a query result corresponding to the query statement from a database.
9. The apparatus of claim 8, further comprising: The subject name modification unit is configured to modify the subject name in the query statement to replace the subject name in the query statement with a subject name predefined in the database.
10. The device of claim 8, wherein: Determining a predefined query example corresponding to the query statement and a processor executable statement corresponding to the query example includes: By means of vector retrieval, query examples matching the query statement and processor executable statements corresponding to the matched query examples are recalled from a predefined set of examples.
11. The apparatus of claim 10, wherein the processor-executable statement is a gremlin statement.
12. The device of claim 8, wherein: The database is a graph database.
13. The apparatus of any one of claims 8 to 12, further comprising an example extension unit, wherein the example extension unit is configured to: Store failed query records; Processing the failed query record using the large model to obtain an updated processor executable statement corresponding to the query statement in the failed query record; The query statements in the failure record and the corresponding updated processor executable statements are added to a predefined example set.
14. The device of claim 13, wherein: Processing the failed query record using the large model to obtain an updated processor executable statement corresponding to the query statement in the failed query record includes: Generate corresponding updated processor executable statements for the query statements in the failed query records according to a predetermined chain reasoning process using the large model; or Multiple inferences are performed using a large model to generate multiple updated processor executable statements for the query statements in the failed query record. When the multiple updated processor executable statements are consistent, the updated processor executable statements are determined as updated processor executable statements corresponding to the query statements in the failed query record.
15. An electronic device, comprising: at least one processor; as well as a memory communicatively coupled to the at least one processor; in The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
16. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.
17. A computer program product comprising a computer program, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.