Large model knowledge base question and answer method and system with timeliness atlas

By building a large-model knowledge base question and answer system for timeliness maps, the problem of the lack of time expression capabilities and timing functions of knowledge graphs in the existing technology is solved, and the timeliness update and efficient query of knowledge graph data are realized, which improves the overall performance of the question and answer system.

CN119669486APending Publication Date: 2025-03-21COLASOFT

Patent Information

Application Number
CN202510154346.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-12
Publication Date
2025-03-21

AI Technical Summary

Technical Problem

The existing big model question and answer systems have limitations in knowledge graph retrieval, timing search and text retrieval, and are unable to effectively compatible with timing query, semantic logic understanding and knowledge graph retrieval, resulting in difficulty in information update and timeliness management.

Method used

The big model knowledge base question and answer method with timely map is adopted. By building a graph database that can timely update data and clean up timely data in a regular manner, and combining natural language big models for triple extraction and query results processing, the timely update of the knowledge graph and expired data cleaning are realized.

Benefits of technology

It improves the timeliness value of knowledge graph data, ensures that the data in the knowledge graph is updated with time changes, and timely deletes expired data, which improves the answer quality and query hit rate of the Q&A system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119669486A_ABST
    Figure CN119669486A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of deep learning, in particular to a large model knowledge base question answering method and system with a timeliness map. The method comprises the following specific steps: constructing a graph database capable of updating data in time and regularly performing timeliness data cleaning; inputting contents in a natural language, and performing triple extraction through a natural language large model; obtaining a specific query result from a graph database and a vector library according to the obtained triple result; the natural language large model carries out reference answering according to the graph data and the query result of the vector library; the method has the advantages that the data in the knowledge graph has the capacity of updating along with time change, the expired data in the knowledge graph can be deleted in time, and the timeliness value of the graph data is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep learning technology, and in particular to a large model knowledge base question and answer method and system with a time-sensitive graph. Background Art

[0002] In order to improve the accuracy and professionalism of existing large-model question-answering systems, three types of systems, namely knowledge graph retrieval systems, time series retrieval systems and text retrieval systems, are widely used in large-model question-answering.

[0003] The knowledge graph in the knowledge graph retrieval system is a knowledge graph that can reflect the weights of entities, relationships and their attributes in the knowledge system. Unlike traditional databases, knowledge graphs can capture and represent the relationships between specific entity objects and other entities, provide multi-dimensional information, and enable knowledge information to better adapt to dynamic scenarios in the real world. Knowledge graphs generally use graph databases as data storage dependencies. By storing data in nodes and edges, they can intuitively reflect information such as the relationships, correlations and weights between data, and play an important role in graph applications.

[0004] The time series retrieval in the time series retrieval system is a data retrieval system that is strongly bound to time. The "addition", "deletion", "modification" and "query" of data are all associated with time. When querying data, it can intuitively reflect the relationship between data and time and display the time value of the current data query results. Therefore, it has a very good effect in time-sensitive applications.

[0005] Text retrieval systems are systems that search through natural language, including articles, reports, image OCR content, etc. When searching, they can perform well in terms of text similarity and semantic similarity through keyword matching, word vector query, association query, or semantic search based on deep learning, but they have a great disadvantage in terms of content understanding.

[0006] The above three retrieval systems all have certain disadvantages. For example, the relational query method of the knowledge graph is not compatible with the temporal query method and lacks temporal function. The temporal retrieval system provides a temporal function, but still lacks a query method that is as convenient as the knowledge graph to extract the relationship between nodes and other nodes. The text retrieval system has a disadvantage in content understanding compared to the first two retrieval methods. Therefore, there is an urgent need for a large-model knowledge base question and answer method and system that can provide temporal functions, have strong semantic logic understanding capabilities, and provide knowledge graph retrieval methods.

[0007] There is a Chinese patent with application number CN202410144156.0 and application date 2024.02.01. The patent name is "Temporal Knowledge Graph Question and Answer Mining Method Based on Question Calibration and Multi-hop Modeling". The technical solution is: a temporal knowledge graph question and answer mining method based on question calibration and multi-hop modeling, including: embedding time position coding, training to obtain a temporal knowledge graph embedded with time position coding, obtaining candidate knowledge subject, predicate and object SPO groups related to the question, designing a question calibration mechanism, calibrating the question according to the candidate knowledge SPO groups in the temporal knowledge graph embedded with time position coding, and obtaining the final question coding; extracting multi-hop subgraphs according to the temporal knowledge graph and the final question coding, and performing multi-hop modeling and training, and outputting the final question representation; according to the final question representation, obtaining predictions of entities and timestamps and scores of entities and timestamps respectively, and establishing a cross-entropy loss objective function to obtain the correct answer corresponding to the question.

[0008] The above patent can obtain the prediction of entities and timestamps, as well as the scores of entities and timestamps according to the final question, establish a cross-entropy loss objective function, and obtain the correct answer corresponding to the question. However, the above patent cannot update the latest information stored at the corresponding time, nor can it implement regular time-sensitive data cleaning. Summary of the invention

[0009] In order to solve the problems existing in the prior art, the present application provides a large-model knowledge base question-answering method and system with a time-sensitive graph that can provide timing functions, have strong semantic logic understanding capabilities, and can also provide a knowledge graph retrieval method.

[0010] In order to achieve the above technical effects, the technical solution of this application is as follows: In a first aspect, a large model knowledge base question answering method with a time-sensitive graph specifically comprises the following steps: Step 1: Build a graph database that can update data in a timely manner and regularly clean up time-sensitive data; Step 2: Input the content in natural language and extract triples through the natural language large model; Step 3: Obtain specific query results from the obtained triple results in the graph database and vector library; Step 4: The natural language model provides reference answers based on the query results of the graph database and vector library.

[0011] Furthermore, the construction of a graph database that can update data in a timely manner and regularly clean up time-sensitive data includes the following specific steps: Step a: input the required natural language information and extract the time in the natural language information content; Step b: The natural language model understands the natural language text content, extracts the relationship, and outputs it in the form of a triple list; Step c: After obtaining the output result of the natural language large model understanding the natural language text content and extracting the relationship, extract the nodes and relationships in the result; Step d: storing the nodes and relationships in the extracted results as data in the cache; Step e: input the data stored in the cache into the graph database for storage, completing the construction of the graph database; In step a, the specific method of extracting time from the natural language information content is: by classifying the article itself, matching the natural language big model prompt words according to the type of article, and by editing the prompt words for the big model, the natural language big model can determine the time information contained in the current content and sort out the time information.

[0012] Furthermore, the natural language big model parses the obtained time information, determines the output mode according to the prompt word, outputs the time information in the specified format, and then uses the time parser to uniformly convert it into a 13-bit timestamp format; if the natural language big model fails to parse the content time, then specify a time and let the natural language information content use the specified time or unspecified time, and directly let the natural language information content use the current time; the specified format of the time information is the international standard ISO 8601 format; the time parser is the datetime library in Python, which is used to process date and time and convert date and time into timestamp.

[0013] Furthermore, in step e, the database will periodically clean up the time-sensitive data; the specific method of periodically cleaning up the time-sensitive data is to set a timer program to delete the data that exceeds the set time; the specific steps of setting a timer program to delete the data that exceeds the set time are as follows: Step a1: Set a timer to periodically execute the data cleaning task; Step b1: Establish a connection between the timing program and the graph database; Step c1: perform a query operation to retrieve data that has exceeded the set expiration time, and then delete the retrieved data that has exceeded the set expiration time; Step d1: clean up the data in the vector library that has exceeded the set expiration time.

[0014] Furthermore, the timer setting in step a1 is implemented through the schedule library or APScheduler library, and the data cleaning task is triggered by setting the time interval; the retrieval and deletion operations in step c1 are completed by executing SQL statements or the query language Cypher for Neo4j of the graph database; the step d1 uses Faiss or Annoy vector library tools to complete the cleaning of data in the vector library that has exceeded the set expiration time; during the running of the timing program, in order to track the running status and historical operations of the program, the program will record logs when executing key operations, and the logging is implemented by Python's logging module; in steps b1, c1 and d1, when executing database operations, the error handling mechanism is used to ensure that error information can be recorded when problems occur, and the execution is re-executed or stopped.

[0015] Furthermore, the specific method of the error handling mechanism is as follows: when an error exception occurs, the program will first try to execute database operations. When executing these operations, the try statement block is used to capture possible error exceptions, and the value returned by the database is used to determine whether the operation result is completed normally. When an error exception is triggered, the program will identify it through the except statement or the specified error code, and both will capture the error exception together; for each error exception captured, the program will record the error exception information in a log file; the log file records the error type, error message, occurrence time and stack trace information; for some recoverable error exceptions, the program sets a retry strategy to implement retry and re-execution; when the error exception still exists after retrying and re-execution, if the error exception does not affect the normal execution of the program, the program will directly ignore the error and continue to execute subsequent operations; if the error exception affects the normal execution of the program, the program will record the error and stop execution; finally, regardless of whether the program continues to execute or not, it is necessary to ensure that all resources are properly cleaned and released to avoid resource leakage.

[0016] Furthermore, in step e, the data input into the graph database is judged to determine whether the data is constant data. If it is constant data, there is no need to store the updated data; if it is not constant data, the data is judged to be repeated. If the data is found to have no repeated data through repeated judgment, it is directly stored in the data warehouse and then stored in the graph database; if the data is found to have repeated data through repeated judgment, it is judged whether the data is the latest data. If the data is not the latest data, the data is abandoned to be stored in the graph database; if the data is the latest data, the original old data is overwritten, and the current new data is stored in the data warehouse, and then stored in the graph database and the vector library from the data warehouse at the same time; the data warehouse operation adopts the transaction management method to ensure the consistency of the data, which specifically includes the following steps: Step a2: When data is ready to be stored in the database, a database transaction is started; Step b2: In the database transaction, verify the data to ensure that the data meets the storage standards; Step c2: Write the data into the graph database. If the writing is successful, proceed to the next step; if it fails, record the error information; Step d2: Write the data into the vector library at the same time. If the writing is successful, proceed to the next step; if it fails, record the error information; Step e2: If the data is successfully written into both the graph database and the vector database, the transaction is committed to ensure that all operations are persisted; if an error occurs when writing to either database, the transaction is not committed but a rollback is performed; The specific method of performing the rollback operation in step e2 is: canceling the operation that has been performed to ensure data consistency; after the rollback operation is completed, retrying, logging and sending an alarm according to the error information.

[0017] Furthermore, in step b2, verifying the data includes the following specific steps: Step a3: The verification program receives a data structure containing fields, where the fields of the data structure include a start node, an end node, a relationship type, a start time, and an end time; Step b3: The verification program starts to check whether the data structure is missing a start node, an end node, a relationship type, a start time, and an end time. If at least one field is missing, the verification program discards the data; Step c3: The verification program further checks whether its value is empty; if the value of at least one field is empty, the verification program will identify it as dirty data and discard the data; the verification program further checks whether the value of the field contains characters that affect the normal operation of the program. If characters that affect the normal operation of the program appear, the verification program will directly discard the data; Step d3: The verification program checks the values ​​of the start time and end time fields to see if the date and time conform to the ISO8601 format; Step e3: If the data structure passes the verification procedures of step b3, step c3 and step d3, the data is valid and is subsequently processed and stored; if the data structure fails to pass the verification procedures of step b3, step c3 and step d3, the program will provide corresponding error information and uniformly discard the data to ensure the quality and consistency of the data.

[0018] In the second aspect, a large model knowledge base question answering system with a time-sensitive graph specifically includes: The time content analysis module is used to judge the time of the stored data to ensure data refresh; the time content analysis module sets the expiration time of the data according to the natural language content; the specific method of setting the data expiration time is: when the content contains time information, the time in the content is used; when the content does not contain time information or the time cannot be extracted, the user's self-set time or the current time is selected as the effective time of the data; The time filtering module is used to update the time attribute field of the data stored in the graph database; the specific method of updating the time attribute field of the data in the graph database is: when the data in the graph database is constant data without time properties, these constant data will not be updated with time and will not be stored; when the data in the graph database is non-constant data, it is determined whether the time is the latest, if it is the latest time, the data is updated, if it is not the latest time, the data insertion is abandoned; Data cleaning module, used to delete expired data; Triple extraction module, used to extract and expand triples from input content; The data time weight query module is used to select the query algorithm according to the query method during the graph database query process; The word vector library management module stores the nodes and relationships extracted from the natural language big model as data for query expansion; the specific working method of the word vector library management module is: first, all the triple relationship data extracted by the big model is stored, and when input, the data processed by the big model is expanded twice through the word vector library to find the qualified relationship data for the final graph database query.

[0019] Furthermore, the triple extraction module extracts the triple relationship in the input content by setting prompt words for the natural language model, and then queries through the word vector database to expand the single relationship into multiple semantic data; the query method includes deep query, single node query and breadth query; the query algorithm of the deep query method is the deep query algorithm; the deep query algorithm is specifically that there are multiple node associations between nodes, and two sorting methods are set up for weighted sorting. First, the intermediate nodes and the effective time and expiration time of the relationship are comprehensively sorted as the sorting basis, and then the progressive relationship of time is used to judge The query weight is confirmed by whether the relationship time is gradually increasing or gradually decreasing, and the two are calculated together to obtain the final result; the algorithm of the single-node query method is a single-node query algorithm; the single-node query algorithm specifically directly lists the expiration time and effective time of each node, and sorts them from small to large to filter out the most valuable data; the algorithm of the breadth query method is specifically a breadth query algorithm; the breadth query algorithm specifically combines the relationship time of each node and the effective expiration time of the node to perform weighted sorting to obtain the final result; the deep query algorithm, the single-node query algorithm and the breadth query algorithm collaborate to filter the query.

[0020] According to the above technical solution, the present application has the following beneficial effects: 1. The present invention adopts a large-model knowledge base question-answering method with a time-sensitive graph. Compared with the prior art, the knowledge graph in the prior art lacks the ability to express time, and the nodes and relationships as data cannot change with time. The data storage and expression method of this method enables the data in the knowledge graph to be updated with time, and can delete expired data in the knowledge graph in a timely manner, thereby improving the timeliness value of the graph data.

[0021] 2. The present invention adopts a large model knowledge base question and answer method with a time-sensitive graph. The data of this method carries time attribute information. By inputting the time information into the natural language large model, the answers obtained in the question and answer process are of higher quality and more meaningful for reference.

[0022] 3. The present invention adopts a large-model knowledge base question-answering method with a time-sensitive graph. The method uses a vector library in the data storage method, can perform similar semantic searches, and provide more approximate search options other than nodes, so that the query hit rate of the large model of natural language is higher.

[0023] 4. The present invention adopts a large-model knowledge base question-and-answer system with a timeliness graph. The system adopts a time filtering module, a data cleaning module and a time content parsing module to achieve timely updating of time and deletion of expired time, thereby ensuring the accuracy of time information carried by the data.

[0024] 5. The present invention adopts a large-model knowledge base question-answering system with a timeliness graph. The system adopts different query algorithms according to different situations, optimizes the weight of time query, and ensures the timeliness of query results.

[0025] 6. The present invention adopts a large-model knowledge base question-and-answer system with a time-sensitive graph. The system adopts a word vector library management module. Compared with the graph query in the prior art that relies on the quality of transmitted data, the prior art cannot accurately hit nodes or relationships in the actual query process. In the system of the present invention, the word vector library management module performs query assistance, so that the query content can be expanded with data similar to the data through the word vector library, thereby greatly improving the query hit rate. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 It is a schematic diagram of the process of constructing hybrid storage of graph database and vector library; Figure 2 It is a schematic diagram of the knowledge base question and answer process. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments.

[0028] Example 1 like Figure 1 and Figure 2 As shown, a large model knowledge base question answering method with a time-sensitive graph specifically includes the following steps: Step 1: Build a graph database that can update data in a timely manner and regularly clean up time-sensitive data; Step 2: Input the content in natural language and extract triples through the natural language large model; Step 3: Obtain specific query results from the obtained triple results in the graph database and vector library; Step 4: The natural language big model provides reference answers based on the query results of the graph database and vector library. The natural language big model includes GPT, GLM, QWEN and LLaMA.

[0029] like Figure 1 As shown in the figure, the construction of a graph database that can update data in a timely manner and regularly clean up time-sensitive data includes the following specific steps: Step a: input the required natural language information and extract the time in the natural language information content; Step b: The natural language model understands the natural language text content, extracts the relationship, and outputs it in the form of a triple list; Step c: After obtaining the output result of the natural language large model understanding the natural language text content and extracting the relationship, extract the nodes and relationships in the result; Step d: The nodes and relationships in the extracted results are stored in the cache as data. In the process of extracting node relationships in long articles, the same relationship will appear repeatedly in the text. Therefore, when dealing with the same redundant data, a dictionary cache object can be established by using the memory cache method to perform a simple filtering on the collected data. Step e: Input the data stored in the cache into the graph database for storage, completing the construction of the graph database.

[0030] In step a, the specific method of extracting time from the natural language information content is: by classifying the article itself, matching the natural language big model prompt words according to the type of article, and by editing the prompt words for the big model, the natural language big model can determine the time information contained in the current content and sort out the time information.

[0031] The natural language model parses the obtained time information, determines the output method according to the prompt word, outputs the time information in the specified format, and then uses the time parser to uniformly convert it into a 13-bit timestamp format; if the natural language model fails to parse the content time, specify a time and let the natural language information content use the specified time or unspecified time, and directly let the natural language information content use the current time; the specified format of the time information is the international standard ISO 8601 format, and the specific format is: %Y-%m-%d %H:%M:%S; the time parser is the datetime library in Python, which is used to process date and time and convert date and time into timestamp; the datetime class in the datetime library in python provides a method called fromisoformat, which is used to parse date and time strings that conform to the ISO8601 format. When using this method, the string can be converted into a datetime object; through timestamp() The method converts a datetime object into a timestamp; a timestamp is the number of seconds since January 1, 1970, and is often used to represent a date and time as a single value for ease of calculation and comparison; the specific steps for using the current time or a specified time are as follows: a user uploads a text, such as a news report; the program automatically analyzes the text content and attempts to extract time information from it, which may include a specific date (such as "October 9, 2024"), and the time is output in the specified format as "2024-10-09"; the user can choose to provide a custom time when uploading the text, which can be a specific date and time, or other forms of time representation; if the program successfully parses the time information from the text, it uses this time as the effective time of the text; if the program does not parse the time from the text, but the user provides a custom time when uploading the text, the program uses the time specified by the user; if the program does not parse the time and the user does not provide a custom time, the program uses the system preset time or the current system display time; the program uses the determined time as the effective time of the text and outputs it.

[0032] In step e, the Chinese Library Database will periodically clean up the time-sensitive data. The specific method of periodically cleaning up the time-sensitive data is to set a timing program to delete the data that exceeds the set time. The specific steps of setting a timing program to delete the data that exceeds the set time are as follows: Step a1: Set a timer to periodically execute the data cleaning task; Step b1: Establish a connection between the timing program and the graph database; Step c1: perform a query operation to retrieve data that has exceeded the set expiration time, and then delete the retrieved data that has exceeded the set expiration time; Step d1: clean up the data in the vector library that has exceeded the set expiration time; In step a1, the timer is set through the schedule library or APScheduler library to trigger the data cleaning task by setting the time interval; the retrieval and deletion operations in step c1 are completed by executing SQL statements or the query language Cypher for Neo4j of the graph database; step d1 uses Faiss or Annoy vector library tools to clean up the data in the vector library that has exceeded the set expiration time; during the running of the timer program, in order to track the running status and historical operations of the program, the program will record logs when executing key operations, and the logs are recorded through Python's logging module; in steps b1, c1 and d1, when executing database operations, the error handling mechanism is used to ensure that error information can be recorded when problems occur, and the execution can be re-executed or stopped; the specific method of the error handling mechanism is as follows: when an error exception occurs, the program will first try to execute the database operation. When executing these operations, the try statement block is used to capture possible error exceptions, and the value returned by the database is used to determine whether the operation result is completed normally. When an error exception is triggered, the program will identify it through the except statement or the specified error code, and both will capture the error exception together; for each error exception captured, the program will record the error exception information in the log file The log file records the error type, error message, occurrence time and stack trace information. For some recoverable error exceptions, the program sets a retry strategy to implement retry execution. If the error exception still exists after retry, if the error exception does not affect the normal execution of the program, the program will ignore the error and continue to execute subsequent operations. If the error exception affects the normal execution of the program, the program will record the error and stop execution. Regardless of whether the program continues to execute, it is necessary to ensure that all resources are properly cleaned and released to avoid resource leakage. In order to keep the program running in the background, you can use tools such as supervisor or systemd to set the Python program as a daemon process to ensure that the program continues to run even if the terminal is closed.

[0033] In step e, the data input into the graph database is judged to determine whether the data is constant data. If it is constant data, there is no need to store the updated data. If it is not constant data, the data is judged to be repeated. If it is found that there is no repeated data through repeated judgment, it is directly stored in the data storage, and then stored in the graph database. If the data is found to have repeated data through repeated judgment, it is judged whether the data is the latest data. If the data is not the latest data, the data is abandoned to be stored in the graph database. If the data is the latest data, the original old data is overwritten, and the current new data is stored in the data storage, and then stored in the graph database and the vector library from the data storage at the same time. Figure 1 and Figure 2 As shown, since the vector library includes a variety of vector library technologies, the optional meaning of the vector library is that the vector library technology itself can select a variety of types of vector libraries. The vector library technology in the present invention is a retrieval enhancement generation technology. Since the graph database cannot realize semantic similarity search, it can only search by matching keywords. Therefore, the reason for using a vector library is that the vector library can realize semantic similarity query and can provide similar auxiliary search based on the current search options, thereby expanding the search scope.

[0034] like Figure 1 and Figure 2 As shown in the figure, the workflow of the above graph database and vector database in the question-answering method can be divided into three main parts: data entry, query and result processing. The following is the detailed workflow: data entry process, the user prepares the data to be entered into the database, verifies the integrity and format of the data to ensure that it meets the entry standards, converts the data into vector representation (such as using a word embedding model), and stores the vector in the vector database to ensure the uniqueness and retrievability of the vector; stores the original data and its related information (such as metadata, relationships, etc.) into the graph database to ensure the structured storage of data in the graph database, and uses transaction management to ensure that the entry operations of the vector library and the graph database either succeed at the same time or fail at the same time; query process, The user inputs the query keyword, and the program converts the keyword entered by the user into a vector representation, performs a similarity query in the vector library, finds the vector related to the input keyword, obtains the related keywords from the vector library, forms a keyword set, and then uses the derived keyword set to query in the graph database, and obtains the nodes and relationships related to the keyword through the relationship and structure of the graph database; the result processing flow integrates the results obtained from the graph database to form the final query result, sorts and filters the results according to relevance, timestamp or other standards, and finally returns the final result to the user. The information returned to the user may include related node information, relationship diagrams and text descriptions.

[0035] The above judgment on constant data and the definition of constant vocabulary are an effective way to deal with vocabulary whose information value does not change over time; constant data usually has the following characteristics: stability, the meaning and use of constant data vocabulary remain unchanged over a long period of time; professionalism, constant data vocabulary is usually related to a specific field or profession, such as science, technology, medicine, etc.; objectivity, constant data vocabulary describes objectively existing things or concepts and does not contain subjective emotions or evaluations; there are two sources of constant data: the first is professional vocabulary, and these words are extracted from professional vocabulary in various fields. These vocabularies may come from academic databases, professional organizations or standardization agencies; the second is manual addition, allowing users or experts to manually add new constant words to the list; constant data can be used as keywords or tags in text analysis, data mining or natural language processing to help identify and classify information, and can be used as fixed nodes, edges and labels when building knowledge graphs or semantic networks; in the actual judgment of the program, first, the natural language model will extract a vocabulary list from the text. According to the constant vocabulary list that has been pre-defined by the program, the program will traverse the vocabulary list extracted from the text by the natural language model, and check whether each word is in the constant vocabulary list, so as to determine whether these words change over time. If a word is found to be a constant word, it will be removed from the list.

[0036] The above data storage operation adopts transaction management to ensure data consistency, which specifically includes the following steps: Step a2: When data is ready to be stored in the database, a database transaction is started; Step b2: In the database transaction, verify the data to ensure that the data meets the storage standards; Step c2: Write the data into the graph database. If the writing is successful, proceed to the next step; if it fails, record the error information; Step d2: Write the data into the vector library at the same time. If the writing is successful, proceed to the next step; if it fails, record the error information; Step e2: If the data is successfully written into both the graph database and the vector database, the transaction is committed to ensure that all operations are persisted; if an error occurs when writing to either database, the transaction is not committed but a rollback is performed; The specific method of performing the rollback operation in step e2 is: canceling the operation that has been performed to ensure the consistency of the data; after the rollback operation is completed, retrying, logging and sending an alarm according to the error information; in step b2, verifying the data includes the following specific steps: Step a3: The verification program receives a data structure containing specific fields, where the specific fields of the data structure include a start node, an end node, a relationship type, a start time, and an end time; Step b3: The verification program starts to check whether the data structure is missing a start node, an end node, a relationship type, a start time, and an end time. If at least one field is missing, the verification program discards the data; Step c3: The verification program further checks whether its value is empty; if the value of at least one field is empty, the verification program will identify it as dirty data and discard the data; the verification program further checks whether the value of the field contains special characters that affect the normal operation of the program. If special characters that affect the normal operation of the program appear, the verification program directly discards the data; Step d3: The verification program checks the values ​​of the start time and end time fields to see if the date and time conform to the ISO8601 format; Step e3: If the data structure passes the verification procedures of step b3, step c3 and step d3, the data is valid and is subsequently processed and stored; if the data structure fails to pass the verification procedures of step b3, step c3 and step d3, the program will provide corresponding error information and uniformly discard the data to ensure the quality and consistency of the data.

[0037] Regardless of whether the above data entry operation succeeds or fails, a detailed operation log will be recorded. The operation log includes time, operation type, data content, results and error information. The above data entry can also be monitored. When there is an abnormality in the data entry, such as continuous failure, an alarm mechanism is triggered to notify relevant personnel to intervene. When data is entered into the warehouse, it can also be optimized according to the actual situation, such as optimization strategies such as current limiting and load balancing.

[0038] Example 2 like Figure 1 and Figure 2 As shown, a large model knowledge base question answering system with a time-sensitive graph specifically includes: The time content analysis module is used to judge the time of the stored data to ensure data refresh; the time content analysis module sets the expiration time of the data according to the natural language content; the specific method of setting the data expiration time is: when the content contains time information, the time in the content is used; when the content does not contain time information or the time cannot be extracted, the user's self-set time or the current time is selected as the effective time of the data; The time filtering module is used to update the time attribute field of the data stored in the graph database; the specific method of updating the time attribute field of the data in the graph database is: when the data in the graph database is constant data without time properties, these constant data will not be updated with time and will not be stored; when the data in the graph database is non-constant data, it is determined whether the time is the latest, if it is the latest time, the data is updated, if it is not the latest time, the data insertion is abandoned; Data cleaning module, used to delete expired data; Triple extraction module, used to extract and expand triples from input content; The data time weight query module is used to select the query algorithm according to the query method during the graph database query process; The word vector library management module stores the nodes and relationships extracted from the natural language big model as data for query expansion; the specific working method of the word vector library management module is: first, all the triple relationship data extracted by the big model is stored, and when input, the data processed by the big model is expanded twice through the word vector library to find the qualified relationship data for the final graph database query.

[0039] like Figure 2 As shown, the triple extraction module extracts the triple relationship in the input content by setting prompt words for the natural language model, and then queries through the word vector database to expand a single relationship into multiple semantically similar data; the query method includes deep query, single node query and breadth query; the query algorithm of the deep query method is the deep query algorithm; the deep query algorithm is specifically that there are multiple node associations between nodes, and two sorting methods are set up for weighted sorting. First, the intermediate nodes and the effective time and expiration time of the relationship are used as the sorting basis for comprehensive sorting, and then the progressive relationship of time is used. , determine whether the relationship time is gradually increasing or decreasing to confirm the query weight, and the two are calculated together to get the final result; the algorithm of the single-node query method is the single-node query algorithm; the single-node query algorithm is specifically to directly list the expiration time and effective time of each node, and sort them from small to large to filter out the most valuable data; the algorithm of the breadth query method is specifically the breadth query algorithm; the breadth query algorithm is specifically to combine the relationship time of each node and the effective expiration time of the node, perform weighted sorting, and get the final result; the deep query algorithm, the single-node query algorithm and the breadth query algorithm can collaboratively filter queries.

[0040] The above description is a detailed description of the preferred feasible embodiment of the present application, but the embodiment is not intended to limit the patent application scope of the present application. All equivalent changes or modified changes made under the technical spirit suggested by the present application should fall within the patent scope covered by the present application.

Claims

1. A large model knowledge base question answering method with a time-sensitive graph, characterized in that: The specific steps include: Step 1: Build a graph database that can update data in a timely manner and regularly clean up time-sensitive data; Step 2: Input the content in natural language and extract triples through the natural language large model; Step 3: Obtain specific query results from the obtained triple results in the graph database and vector library; Step 4: The natural language model provides reference answers based on the query results of the graph database and vector library.

2. The large model knowledge base question answering method with time-sensitive graph according to claim 1 is characterized by: The construction of a graph database that can update data in a timely manner and regularly clean up time-sensitive data includes the following specific steps: Step a: input the required natural language information and extract the time in the natural language information content; Step b: The natural language model understands the natural language text content, extracts the relationship, and outputs it in the form of a triple list; Step c: After obtaining the output result of the natural language large model understanding the natural language text content and extracting the relationship, extract the nodes and relationships in the result; Step d: storing the nodes and relationships in the extracted results as data in the cache; Step e: input the data stored in the cache into the graph database for storage, completing the construction of the graph database; In step a, the specific method of extracting time from the natural language information content is: by classifying the article itself, matching the natural language big model prompt words according to the type of article, and by editing the prompt words for the big model, the natural language big model can determine the time information contained in the current content and sort out the time information.

3. The large model knowledge base question answering method with time-sensitive graph according to claim 2 is characterized by: The natural language big model parses the obtained time information, determines the output mode according to the prompt word, outputs the time information in the specified format, and then uses the time parser to uniformly convert it into a 13-bit timestamp format; if the natural language big model fails to parse the content time, specify a time and let the natural language information content use the specified time or unspecified time, directly let the natural language information content use the current time; the specified format of the time information is the international standard ISO 8601 format; the time parser is the datetime library in Python, which is used to process date and time and convert date and time into timestamp.

4. The large model knowledge base question answering method with time-sensitive graph according to claim 2 is characterized by: In step e, the Chinese Library Database will periodically clean up the time-sensitive data. The specific method of periodically cleaning up the time-sensitive data is to set a timing program to delete the data that exceeds the set time. The specific steps of setting a timing program to delete the data that exceeds the set time are as follows: Step a1: Set a timer to periodically execute the data cleaning task; Step b1: Establish a connection between the timing program and the graph database; Step c1: perform a query operation to retrieve data that has exceeded the set expiration time, and then delete the retrieved data that has exceeded the set expiration time; Step d1: clean up the data in the vector library that has exceeded the set expiration time.

5. The large model knowledge base question answering method with time-sensitive graph according to claim 4 is characterized by: The timer setting in step a1 is implemented through the schedule library or APScheduler library, and the data cleaning task is triggered by setting the time interval; the retrieval and deletion operations in step c1 are completed by executing SQL statements or the query language Cypher for Neo4j of the graph database; the step d1 uses Faiss or Annoy vector library tools to complete the cleaning of data in the vector library that has exceeded the set expiration time; during the operation of the timing program, in order to track the running status and historical operations of the program, the program will record logs when executing key operations, and the logging is implemented by Python's logging module; in steps b1, c1 and d1, when executing database operations, the error handling mechanism is used to ensure that error information can be recorded when problems occur, and the execution is re-executed or stopped.

6. The large model knowledge base question answering method with time-sensitive graph according to claim 5 is characterized by: The specific method of the error handling mechanism is as follows: when an error exception occurs, the program will first try to perform database operations. When performing these operations, the try statement block is used to capture possible error exceptions, and the value returned by the database is used to determine whether the operation result is completed normally. When an error exception is triggered, the program will identify it through the except statement or the specified error code, and both capture the error exception; For each error exception captured, the program will record the error exception information in the log file; The log file records the error type, error message, occurrence time and stack trace information; for some recoverable error exceptions, the program sets a retry strategy to implement retry execution; when the error exception still exists after retry, if the error exception does not affect the normal execution of the program, the program will directly ignore the error and continue to execute subsequent operations; if the error exception affects the normal execution of the program, the program will record the error and stop execution; finally, regardless of whether the program continues to execute, it is necessary to ensure that all resources are properly cleaned and released to avoid resource leakage.

7. The large model knowledge base question answering method with time-sensitive graph according to claim 2 is characterized by: In step e, the data input into the graph database is judged to determine whether the data is constant data. If it is constant data, there is no need to store the updated data; If it is not a constant amount of data, then perform a duplicate judgment on the data. If the data is found to have no duplicate data through the duplicate judgment, then directly store it in the data warehouse and then store it in the graph database. If the data is found to have duplicate data through the duplicate judgment, then determine whether the data is the latest data. If the data is not the latest data, then give up storing the data in the graph database. If the data is the latest data, then overwrite the original old data, store the current new data in the data warehouse, and then store it in the graph database and vector database at the same time from the data warehouse. The data warehouse operation adopts transaction management to ensure data consistency, which specifically includes the following steps: Step a2: When data is ready to be stored in the database, a database transaction is started; Step b2: In the database transaction, verify the data to ensure that the data meets the storage standards; Step c2: Write the data into the graph database. If the writing is successful, proceed to the next step; if it fails, record the error information; Step d2: Write the data into the vector library at the same time. If the writing is successful, proceed to the next step; if it fails, record the error information; Step e2: If the data is successfully written into both the graph database and the vector database, the transaction is committed to ensure that all operations are persisted; if an error occurs when writing to either database, the transaction is not committed but a rollback is performed; The specific method of performing the rollback operation in step e2 is: canceling the operation that has been performed to ensure data consistency; after the rollback operation is completed, retrying, logging and sending an alarm according to the error information.

8. The large model knowledge base question answering method with time-sensitive graph according to claim 7 is characterized by: In step b2, the data is verified, including the following specific steps: Step a3: The verification program receives a data structure containing fields, where the fields of the data structure include a start node, an end node, a relationship type, a start time, and an end time; Step b3: The verification program starts to check whether the data structure is missing a start node, an end node, a relationship type, a start time, and an end time. If at least one field is missing, the verification program discards the data; Step c3: The verification program further checks whether its value is empty; if the value of at least one field is empty, the verification program will identify it as dirty data and discard the data; the verification program further checks whether the value of the field contains characters that affect the program. If characters that affect the normal operation of the program appear, the verification program will directly discard the data; Step d3: The verification program checks the values ​​of the start time and end time fields to see if the date and time conform to the ISO8601 format; Step e3: If the data structure passes the verification procedures of step b3, step c3 and step d3, the data is valid and is subsequently processed and stored; if the data structure fails to pass the verification procedures of step b3, step c3 and step d3, the program will provide corresponding error information and uniformly discard the data to ensure the quality and consistency of the data.

9. A large model knowledge base question answering system with a time-sensitive graph, characterized in that: Specifically include: The time content analysis module is used to judge the time of the stored data to ensure data refresh; the time content analysis module sets the expiration time of the data according to the natural language content; the specific method of setting the data expiration time is: when the content contains time information, the time in the content is used; when the content does not contain time information or the time cannot be extracted, the user's self-set time or the current time is selected as the effective time of the data; The time filtering module is used to update the time attribute field of the data stored in the graph database; the specific method of updating the time attribute field of the data in the graph database is: when the data in the graph database is constant data without time properties, these constant data will not be updated with time and will not be stored; when the data in the graph database is non-constant data, it is determined whether the time is the latest, if it is the latest time, the data is updated, if it is not the latest time, the data insertion is abandoned; Data cleaning module, used to delete expired data; Triple extraction module, used to extract and expand triples from input content; The data time weight query module is used to select the query algorithm according to the query method during the graph database query process; The word vector library management module stores the nodes and relationships extracted from the natural language big model as data for query expansion; the specific working method of the word vector library management module is: first, all the triple relationship data extracted by the big model is stored, and when input, the data processed by the big model is expanded twice through the word vector library to find the qualified relationship data for the final graph database query.

10. The large model knowledge base question answering system with time-effectiveness graph according to claim 9 is characterized in that: The triple extraction module extracts the triple relationship in the input content by setting prompt words for the natural language model, and then queries the word vector database to expand a single relationship into multiple semantic data; the query method includes deep query, single node query and breadth query; the query algorithm of the deep query method is a deep query algorithm; the deep query algorithm is specifically that there are multiple node associations between nodes, and two sorting methods are set up for weighted sorting. First, the intermediate nodes and the effective time and expiration time of the relationship are comprehensively sorted as the sorting basis, and then the relationship is judged by the progressive relationship of time. The query weight is confirmed by whether the time is gradually increasing or decreasing, and the two are calculated together to obtain the final result; the algorithm of the single-node query method is a single-node query algorithm; the single-node query algorithm specifically directly lists the expiration time and effective time of each node, and sorts them from small to large to filter out the most valuable data; the algorithm of the breadth query method is specifically a breadth query algorithm; the breadth query algorithm specifically combines the relationship time of each node and the effective expiration time of the node to perform weighted sorting to obtain the final result; the deep query algorithm, the single-node query algorithm and the breadth query algorithm are collaborative filtering queries.

Citation Information

Patent Citations

  • Time sequence knowledge graph question and answer mining method based on question calibration and multi-hop modeling

    CN118014066A

Cited By

  • Financial information management method based on knowledge graph

    CN121456043A