Method and device for generating a contract knowledge graph

By transforming contract text into a structured knowledge graph, extracting clause elements and explanatory entities using a large model, and generating a multi-level graph, the problems of low response efficiency and insufficient accuracy in existing technologies are solved, achieving efficient and accurate contract text processing.

CN121119095BActive Publication Date: 2026-04-07ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-14
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing technologies have low response efficiency and insufficient accuracy when processing contract texts, especially when processing long texts, resulting in high computational load and difficulty in meeting the needs of real-time interaction.

Method used

The contract text is transformed into a structured knowledge graph. By extracting clause elements and clause description entities from paragraphs through a large model, a multi-level contract knowledge graph is generated. Graph neural networks are then used for embedding processing to improve retrieval efficiency and response accuracy.

Benefits of technology

It significantly improves the generation and retrieval efficiency of contract knowledge graphs, enables rapid response to user questions, and enhances the accuracy and applicability of answers, making it suitable for applications in multiple scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121119095B_ABST
    Figure CN121119095B_ABST
Patent Text Reader

Abstract

The embodiment of the specification provides a method for generating a contract knowledge graph, comprising: inputting each paragraph contained in a contract text into a large model respectively, and making the large model extract a first type of entity corresponding to a clause element. Inputting any first entity belonging to the clause element and a target paragraph to which the first entity belongs into the large model, and making the large model analyze the first entity based on the target paragraph to obtain a second type of entity corresponding to a clause description. Based on the first type of entity, the second type of entity and a third type of entity corresponding to a single paragraph, a multi-level contract knowledge graph is generated. The root level of the contract knowledge graph corresponds to the first type of entity, and in each level, in addition to the connection between the corresponding entities of adjacent levels, the corresponding entities in the root level are also connected.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] One or more embodiments of the present specification relate to the technical field of computer technology, and particularly relate to a method and device for generating a contract knowledge graph. BACKGROUND

[0002] Currently, the main reply method for user questions about contract texts (such as consumer finance contracts) is based on vector retrieval. The specific process is as follows: first, the contract text is divided into multiple text blocks, and the vectorized representation is stored in the knowledge base; after receiving the user question, the most relevant text segment is recalled from the knowledge base by calculating the similarity between the user question and the vectors of each text block; finally, a large language model is used to generate a corresponding reply based on the recalled content. However, the effectiveness of this method is heavily dependent on the text block division strategy, and inappropriate division strategies can significantly reduce the accuracy of the reply. In addition, when the length of the text block processed by this method is too long, the computational load is high, and the time taken to generate a reply is significantly increased, making it difficult to meet the needs of real-time interaction scenarios.

[0003] Therefore, there is an urgent need for an efficient and reliable reply scheme for questions about contract texts to improve response speed and reply accuracy. SUMMARY

[0004] One or more embodiments of the present specification describe a method and device for generating a contract knowledge graph, which uses a large model to convert a contract text into a structured knowledge graph. This can significantly compress text data, thereby significantly improving retrieval efficiency and further improving response speed and reply accuracy for related questions.

[0005] In a first aspect, a method for generating a contract knowledge graph is provided, comprising:

[0006] inputting each paragraph contained in the contract text into a large model to extract a first type of entity corresponding to a clause element;

[0007] inputting any first entity belonging to a clause element and the target paragraph to which it belongs into a large model to analyze the first entity based on the target paragraph, and obtain a second type of entity corresponding to a clause explanation;

[0008] generating a multi-level contract knowledge graph based on the first type of entity, the second type of entity, and a third type of entity corresponding to a single paragraph; the root level of the contract knowledge graph corresponds to the first type of entity, and in addition to being connected to the corresponding entity of the adjacent level, the entities in each level are also connected to the corresponding entity in the root level.

[0009] In a second aspect, a method for generating a reply to a user question is provided, comprising:

[0010] obtaining a contract knowledge graph, the contract knowledge graph being generated according to the method of the first aspect;

[0011] determining, based on a hierarchical path of the contract knowledge graph, a plurality of entities associated with the user question and entering the plurality of entities into a candidate entity list;

[0012] determining, according to the user question and the candidate entity list, reply content corresponding to the user question.

[0013] In a third aspect, a device for generating a contract knowledge graph is provided, comprising:

[0014] an input unit configured to input each paragraph contained in a contract text into a large model to extract a first type of entity corresponding to a clause element;

[0015] The input unit is further configured to input any first entity belonging to a clause element and a target paragraph to which the first entity belongs into the large model to analyze the first entity based on the target paragraph and obtain a second type of entity corresponding to a clause description;

[0016] a generation unit configured to generate a multi-level contract knowledge graph based on the first type of entity, the second type of entity, and a third type of entity corresponding to a single paragraph; a root level of the contract knowledge graph corresponds to the first type of entity, and in each level, an entity is connected to a corresponding entity in the root level in addition to being connected to a corresponding entity in an adjacent level.

[0017] In a fourth aspect, a device for generating a reply to a user question is provided, comprising:

[0018] an obtaining unit configured to obtain a contract knowledge graph, the contract knowledge graph being generated according to the method of the first aspect;

[0019] a determination unit configured to determine, based on a hierarchical path of the contract knowledge graph, a plurality of entities associated with the user question and enter the plurality of entities into a candidate entity list;

[0020] The determination unit is further configured to determine, according to the user question and the candidate entity list, reply content corresponding to the user question.

[0021] In a fifth aspect, a computer-readable storage medium having a computer program stored thereon is provided, when the computer program is executed in a computer, the computer program causes the computer to execute the method of the first aspect.

[0022] In a sixth aspect, a computing device is provided, comprising a memory and a processor, the memory having executable code stored therein, and the processor, when executing the executable code, implements the method of the first aspect.

[0023] The method for generating a contract knowledge graph provided by one or more embodiments of the present specification first extracts clause element class entities from each paragraph contained in the contract text through a large model, then acquires clause description class entities based on the clause element class entities and the paragraphs to which the clause element class entities belong by using the large model, and finally generates a multi-level contract knowledge graph based on the clause element class entities, the clause description class entities, and the paragraph class entities. That is, the present scheme can fully utilize the capabilities of the large model to automatically convert the contract text into a structured knowledge graph, thereby effectively improving the generation efficiency of the contract knowledge graph. In addition, after converting the contract text into a knowledge graph, the text data can be greatly compressed, which not only can significantly improve the retrieval efficiency, but also can further speed up the response speed and reply accuracy of related questions. BRIEF DESCRIPTION OF DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present specification, the drawings needed in the embodiment description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present specification, and other drawings can also be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0025] Figure 1 The schematic diagram of the implementation scene of an embodiment disclosed in the present specification;

[0026] Figure 2 The method flowchart for generating a contract knowledge graph according to an embodiment of the present specification is shown;

[0027] Figure 3 The schematic diagram of a contract knowledge graph in an example of the present specification is shown;

[0028] Figure 4 The method schematic diagram for generating a contract knowledge graph in an example of the present specification is shown;

[0029] Figure 5 The method flowchart for generating a reply to a user question according to an embodiment of the present specification is shown;

[0030] Figure 6 The method schematic diagram for generating a reply to a user question in an example of the present specification is shown;

[0031] Figure 7 The device schematic diagram for generating a contract knowledge graph according to an embodiment of the present specification is shown;

[0032] Figure 8 The device schematic diagram for generating a reply to a user question according to an embodiment of the present specification is shown. DETAILED DESCRIPTION

[0033] The solution provided in this specification will now be described with reference to the accompanying drawings.

[0034] As mentioned earlier, traditional solutions for responding to questions about contract texts suffer from low response efficiency and low accuracy. This solution considers the "finite set" characteristic of contract texts (i.e., stable clauses and controllable versions), making it suitable for improving response efficiency and accuracy through preprocessing and structuring. Specifically, this solution proposes processing the contract text into a structured knowledge graph. However, current knowledge graph construction mainly relies on manual annotation and expert rules, which is extremely time-consuming.

[0035] To this end, this solution will leverage the capabilities of a large model to generate a contract knowledge graph. Specifically, firstly, the large model extracts clause element entities from each paragraph contained in the contract text. Then, based on the clause element entities and their respective paragraphs, the large model obtains clause description entities. Finally, based on the clause element entities, clause description entities, and paragraph entities, a multi-level contract knowledge graph is generated. The root level of this contract knowledge graph corresponds to the clause element entities, and entities in other levels are connected not only to their corresponding entities in adjacent levels but also to their corresponding entities in the root level.

[0036] Figure 1 This is a schematic diagram illustrating an implementation scenario of one of the embodiments disclosed in this specification. Figure 1 First, the contract text is segmented into multiple paragraphs. Then, each paragraph is input into a larger model, which extracts clause element entities. For any entity belonging to a clause element, the larger model parses the entity based on its target paragraph to obtain the corresponding clause description entity. Finally, a multi-level contract knowledge graph is generated based on the clause element entities, clause description entities, and paragraph entities. The clause element entities, clause description entities, and paragraph entities correspond to different levels within the multi-level graph, with the clause element entities corresponding to the root level.

[0037] It should be understood that Figure 1 This is merely an illustrative example. In practice, a large model can be used to output corresponding reference question-type entities for any entity based on the target paragraph mentioned above. Furthermore, the hierarchical levels corresponding to the clause description entities, paragraph entities, and reference question-type entities are respectively further away from the root level and closer to the leaf level.

[0038] Figure 2 This diagram illustrates a method for generating a contract knowledge graph according to one embodiment of this specification. This method can be executed by any apparatus, device, platform, or cluster of devices with computing and processing capabilities. Figure 2 As shown, the method may include the following steps:

[0039] Step S202: Input each paragraph contained in the contract text into the large model and let it extract the clause element class entities.

[0040] It should be understood that the contract text here refers to a contract template without the names and dates of both parties to the agreement, and it can belong to any of the following types: sales contract, service contract, lease contract, employment contract, consumer finance contract, insurance contract, etc.

[0041] The above-mentioned clause element type entities can be understood as a type of entity belonging to clause elements, and the number of such entities can be one or more.

[0042] Taking consumer finance contracts as an example, the terms and conditions extracted from them may include, but are not limited to: loan amount (i.e., the specific principal amount of the loan), loan term (i.e., the total duration of the loan and the specific start and end dates), loan purpose (e.g., for personal consumption), loan interest rate (i.e., the annualized interest rate), and repayment method (e.g., equal principal and interest payments, equal principal payments, interest-only payments followed by principal payments, etc.).

[0043] Typically, contract texts contain tens of thousands of words, making them long texts. Therefore, directly inputting the entire contract text into a large model would result in wasted resources and slow response times. To address this, this solution divides the contract text into paragraphs, and then inputs each paragraph separately into the model. Of course, in practice, contract texts can also be divided according to headings or clauses; this specification does not impose this limitation.

[0044] Specifically, the prompt word `propmt1` can be input into the large model to extract clause element entities. Here, `propmt1` can include: the model's role (e.g., "You are a senior legal document analysis expert, skilled at accurately extracting key information from contracts"), instruction description (e.g., "Your task is to identify and extract all mentioned entities from the text paragraphs provided by the user"), entity definitions (i.e., clearly listing the types of entities to be extracted (e.g., loan interest rates, etc.) and describing the characteristics of each type of entity), reference examples, input text (i.e., paragraphs in the contract text), and output format (e.g., JSON format) and constraints (e.g., requiring the output to not contain any explanatory text, only returning results), etc.

[0045] It should be understood that this is only an illustrative example, and in practice, the prompt word propmt1 may include more or less content, which is not limited in this specification.

[0046] Step S204: Input any entity e1 belonging to the clause element and its target paragraph into the large model, and let it parse entity e1 based on the target paragraph to obtain the clause description class entity corresponding to entity e1.

[0047] Here, "terms and conditions descriptions" can be understood as a type of entity that belongs to the terms and conditions descriptions, and the number of such entities can be one or more.

[0048] Specifically, the prompt word "prompt2" can be input into the large model, causing it to output a clause description entity. Here, "prompt2" can include: the model's role (e.g., "You are an experienced technical documentation engineer, skilled at interpreting contract clause elements based on context"), the instruction description (e.g., "Your task is to interpret the marked clause elements based on the provided paragraph"), a reference example, input text (including entity e1 and its target paragraph), and output format (e.g., JSON format) and requirements (e.g., requiring the output of the explanation basis).

[0049] It should be noted that, in order to help the model accurately identify the information source, the above input text can also be structured, for example, by using delimiters (""") to separate the entity e1 to be explained and the target paragraph.

[0050] It should be understood that this is only an illustrative example, and in practice, the prompt word propmt2 may include more or less content, which is not limited in this specification.

[0051] Taking any of the above entities e1 as an example of loan interest rate, the terms and conditions for any entity could include phrases such as "interest calculated daily, compounded monthly," etc. Taking any entity e1 as an example of loan purpose, the terms and conditions could include phrases such as "funds must be used for personal consumption (such as shopping, travel, education, etc.) and may not be used for investment, home purchase, stock speculation, or other non-consumption purposes," etc.

[0052] Similarly, we can obtain the clause description entities corresponding to each entity that belongs to the clause elements.

[0053] Step S206: Generate a multi-level contract knowledge graph based on clause element entities, clause description entities, and paragraph entities.

[0054] That is, based on the entities that belong to the clause elements, the entities that belong to the clause description, and the entities corresponding to each paragraph, a multi-level contract knowledge graph is generated according to the correspondence between the entities.

[0055] Here, the correspondence between entities can include, but is not limited to, generation relationships and ownership relationships. For example, suppose we use the large model to output the entity belonging to the clause element: clause element a1, and the target paragraph to which it belongs: paragraph b1, and the clause description e1. Then, clause element a1 and clause description e1 have a generation relationship, clause element a1 and paragraph b1 have an ownership relationship, and clause description e1 and paragraph b1 have both generation and ownership relationships.

[0056] Regarding the aforementioned multi-level contract knowledge graph, the root level corresponds to the clause element type entity, while the other levels correspond to the clause description type entity and the paragraph type entity, respectively. In addition to being connected to the corresponding entities in adjacent levels, the entities in the other levels are also connected to the corresponding entities in the root level.

[0057] In one example, the description category entity is at a higher level than the paragraph category entity.

[0058] Of course, in practice, the level of paragraph-type entities can be higher than the level of clause description-type entities.

[0059] Furthermore, the aforementioned contract knowledge graph can also include reference question entities, which are entities belonging to the category of reference questions. Taking the reference question entity corresponding to any entity e1 as an example, this reference question entity can be generated using the large model based on entity e1 and the target paragraph.

[0060] Taking any of the above entities e1 as an example of loan interest rate, a possible reference question for any entity could be: "How is the interest calculated?" Taking any entity e1 as an example of loan purpose, a possible reference question for any entity could be: "In which areas of consumption can the funds be used?"

[0061] In one example, the reference question type entity mentioned above corresponds to the leaf level. That is, the terms description type entity, paragraph type entity, and reference question type entity each correspond to a level from high to low (i.e., from further away from the root level to closer to the leaf level).

[0062] Of course, in practice, the levels corresponding to clause description entities, paragraph entities, and reference question entities can be interchanged, and this manual does not impose any restrictions on this.

[0063] Figure 3 This specification shows a schematic diagram of a contract knowledge graph in one example. Figure 3The contract knowledge graph comprises four levels from high to low, corresponding to clause element entities, clause description entities, paragraph entities, and reference question entities, respectively. Specifically, clause element entities include clause element a1 and clause element a2; paragraph entities include paragraph b1 and paragraph b2; clause description entities include clause description c1 and clause description c2; and reference question entities include reference question d1, reference question d2, and reference question d3.

[0064] Figure 3 In this context, clause element a1 is extracted from paragraph b1, thus establishing a dependency relationship between the two. Similarly, clause element a2 also has a dependency relationship with paragraph b2. Furthermore, clause description c1 is generated based on paragraph b1 and clause element a1, thus exhibiting a generative relationship between clause description c1 and both paragraph b1 and clause element a1. Likewise, clause description c2 exhibits a generative relationship between clause description c2 and both paragraph b2 and clause element a2. Moreover, reference questions d1 and d2 are generated based on paragraph b1 and clause element a1, thus exhibiting generative relationships between reference question d1 and both paragraph b1 and clause element a1, and similarly, reference question d2 exhibits a generative relationship between reference question 3 and both paragraph b2 and clause element a2.

[0065] from Figure 3 As can be seen, the entities in the contract knowledge graph are distributed in a tree-like manner around the clause element entities, and each entity belonging to the clause description or reference question can be traced back to a certain paragraph, that is, it can be anchored to the contract text, thereby avoiding misinterpretation of the contract text.

[0066] Additionally, after obtaining the aforementioned contract knowledge graph, a graph neural network can be used to embed each entity based on the correspondence between them, thereby obtaining and storing the vector representation of each entity for use in generating answers to user questions later.

[0067] Figure 4 This diagram illustrates a method for generating a contract knowledge graph in one example of this specification. Figure 4 First, the complete contract text is obtained and segmented into paragraphs. Then, each paragraph is input into a larger model to obtain clause element entities. Next, based on each entity belonging to a clause element and its corresponding paragraph, the larger model generates clause description entities and reference question entities. This results in four types of entities corresponding to the four levels of the contract knowledge graph: clause element entities, clause description entities, paragraph entities, and reference question entities. Finally, a four-level contract knowledge graph is generated based on these four types of entities.

[0068] It should be understood thatFigure 4 This is merely an illustrative example. In practice, the contract knowledge graph may have more or fewer levels, and this specification does not limit this.

[0069] In summary, the method for generating contract knowledge graphs provided in this specification can fully utilize the capabilities of large models to more accurately and automatically process contract text into structured contract knowledge graphs, thereby improving the efficiency of contract knowledge graph construction and saving labor costs. Furthermore, the automated construction of contract knowledge graphs can efficiently adapt to frequent iterations of the same version, exhibiting strong practicality and scalability. In addition, the contract knowledge graph constructed based on this solution can effectively represent the relationships between complex contract clauses and effectively address the issues of missed and false recalls caused by ambiguous user question expressions, significantly improving retrieval accuracy and coverage. Finally, this solution can be quickly extended to multiple scenarios such as wealth management, insurance, and e-commerce without refactoring the underlying logic.

[0070] The above explains the generation process of the contract knowledge graph. The following explains the method for answering questions about contract texts based on the contract knowledge graph.

[0071] Figure 5 This diagram illustrates a method for generating answers to user questions according to one embodiment of this specification. This method can be executed by any apparatus, device, platform, or cluster of devices with computing and processing capabilities. Figure 5 As shown, the method may include the following steps:

[0072] Step S502: Obtain the contract knowledge graph.

[0073] This contract knowledge graph can be based on Figure 2 It is generated by the steps shown in the diagram.

[0074] Step S504: Based on the hierarchical path of the contract knowledge graph, identify several entities associated with the user's question and add them to the candidate entity list.

[0075] The user questions here refer to inquiries raised regarding the aforementioned contract text. These inquiries can be prepared in advance based on expert experience (corresponding to an offline response process) or received through real-time interaction (corresponding to an online response process).

[0076] Specifically, firstly, the similarity between the user's question and various entities in the contract knowledge graph can be calculated to identify similar entities from the contract knowledge graph. Then, the entities covered by the longest path from the level of the similar entity to the root level in the contract knowledge graph are identified as the aforementioned entities.

[0077] Of course, in practice, the entities covered by other paths (such as intermediate paths) from the level where similar entities are located to the root level can also be identified as the aforementioned entities, and this specification does not limit this.

[0078] The similarity calculations mentioned above may include, but are not limited to, keyword matching (also known as full-text retrieval) and vector similarity calculation (also known as vector-based retrieval).

[0079] Taking vector-based retrieval as an example, a representation model can be used to process user questions, thereby obtaining a vector representation of the user question. Then, based on the vector representation of the user question and the vector representations of various entities in the knowledge graph, vector similarity is calculated. Afterwards, one or more entities with a similarity greater than a preset threshold can be identified as the aforementioned similar entities. Alternatively, the entity with the highest similarity can also be identified as the aforementioned similar entity.

[0080] Here, the representation model can be implemented as a pre-trained generative large model (e.g., GPT).

[0081] The aforementioned similarity can be, for example, cosine similarity, Euclidean distance, Manhattan distance, and Pearson correlation coefficient, etc.

[0082] by Figure 3 For example, if the similarity between the user's question and the reference question d2 is greater than a preset threshold, that is, the reference question d2 is a similar entity, then the entities in the path: clause element a1 -> clause description c1 -> paragraph b1 -> reference question d2 can be included in the candidate entity list.

[0083] It should be understood that the above is the process of selecting candidate entities from the contract knowledge graph based on user questions, that is, recalling relevant knowledge based on user questions. In practice, the above user questions can also be used to identify intent, and candidate entities can be selected from the contract knowledge graph based on the identified target intent, that is, recalling relevant knowledge based on target intent, so as to improve the comprehensiveness of the recalled knowledge.

[0084] In practice, recall based on user questions and recall based on target intent can be used in combination or separately, and this manual does not limit this.

[0085] The target intent mentioned above can be obtained through the following steps: input the prompt word prompt3 into a large model, allowing it to select the target intent that matches the user's question from several intent categories. Here, the prompt word prompt3 can include: the role the model plays (e.g., "You are a professional customer service robot assistant"), the instruction description (e.g., "Your task is to analyze the user's input and determine their intent"), a list of intents (e.g., "greet or say hello", "complaint", "book service", etc.), a reference example, the input text (i.e., the user's question), and the output format (e.g., JSON format) and requirements (e.g., requiring no other explanatory or redundant content to be output).

[0086] It should be understood that this is only an illustrative example, and in practice, the prompt word propmt3 may include more or less content, which is not limited in this specification.

[0087] After obtaining the target intent, similar to the process of selecting candidate entities based on user questions, candidate entities can be selected from the contract knowledge graph based on the target intent and added to the candidate entity list.

[0088] It should be noted that this solution is based on the hierarchical path of the contract knowledge graph to determine the candidate entity list. It can selectively recall the complete information chain of the corresponding clause, thereby realizing the leap from fuzzy search to graph navigation, significantly improving the recall accuracy, and supporting result traceability and compliance verification.

[0089] Step S506: Determine the response content corresponding to the user's question based on the user's question and the candidate entity list.

[0090] The response here can be explanatory.

[0091] In one embodiment, a different similarity calculation method than that used in the knowledge recall phase can be employed to recalculate the similarity between the user question and each candidate entity in the candidate entity list, and the candidate entity with the highest similarity can be identified as the target entity. Then, based on the user question and the target entity, the corresponding response content for the user question is determined.

[0092] In another embodiment, the user question and a list of candidate entities can be input into a reordering model to obtain a reordering of the candidate entities in the candidate entity list, and the top-ranked candidate entity from the reordered candidate entities can be selected as the target entity. Then, based on the user question and the target entity, the corresponding response content for the user question is determined.

[0093] The aforementioned reordering model can be implemented as a feature-engineered machine learning model (such as LambdaMART, RankSVM, and RankNet), a deep semantic model based on a cross-encoder, a model based on a dual-tower encoder, or a pre-trained generative large model.

[0094] Taking a pre-trained generative large model as an example, the prompt word prompt4 can be input into the reordering model, which will output the reordering of each candidate entity in the candidate entity list.

[0095] In one example, the prompt word "prompt4" could be: "You are a search engine reorderer. Please determine the relevance of each candidate entity in the following candidate entity list to the user's question, and output a sorted list of candidate entities from most relevant to least relevant."

[0096] After selecting the target entity, the corresponding response can be prepared based on expert experience.

[0097] Of course, large models can also be used to generate corresponding responses. Specifically, user questions and target entities can be input into a large model, which will then perform a contextual suitability analysis on the target entities based on the user question (i.e., determine whether the target entity is suitable for the current user's specific context), and generate the response content corresponding to the user question based on the suitability analysis results.

[0098] Here, when using a large model to perform contextual suitability analysis on a target entity, the prompt5 input to the large model can include: the role the model plays (e.g., "You are a legal document review expert"), instruction description (e.g., "Your task is to perform contextual suitability analysis on the target entity"), reference examples, input text (including user questions, target entities, and expert experience descriptions to guide the large model in performing suitability analysis), and output format (e.g., JSON format) and requirements (e.g., requiring the output of explanatory basis), etc.

[0099] It should be understood that this is only an illustrative example, and in practice, the prompt word propmt5 may include more or less content, which is not limited in this specification.

[0100] It should be noted that this solution, by conducting contextual applicability analysis on the target entity, can avoid the problem of the knowledge recalled during the recall phase not matching the user's question, thus preventing irrelevant answers.

[0101] It should also be noted that when the user questions are pre-selected based on expert experience, the user questions and answers can be added to a standard question-and-answer database for subsequent responses to user questions received in real time. Conversely, when the user questions are received through real-time interaction, the answers can be returned to the user.

[0102] Furthermore, after determining the corresponding response to a user's question, this solution can also utilize a large-scale model to perform a compliance check on that response. Specifically, the response content and compliance check rules can be input into the large-scale model, which will then determine whether the response content is compliant based on the compliance check rules and output a compliant target response.

[0103] Here, when using a large model to perform compliance checks on the response content, the prompt word prompt6 input to the large model can include: the role played by the model (e.g., "You are a professional legal compliance officer"), the instruction description (e.g., "Your task is to conduct a comprehensive compliance check on the response content in strict accordance with the compliance check rules"), reference examples, input text (including the response content and compliance check rules), and output format (e.g., JSON format) and requirements (e.g., requiring the output of the explanation basis), etc.

[0104] It should be noted that this plan ensures the compliance and accuracy of the responses by conducting compliance checks on the content of the responses.

[0105] Finally, this solution can also utilize large-scale models to analyze user sentiment and, based on the sentiment analysis results, rewrite compliant target responses to obtain the final answer.

[0106] When using a large model for user sentiment analysis, the prompt word prompt7 input to the large model can include: the role of the model (e.g., "You are a professional psychologist who is good at analyzing people's emotional states through text"), instruction description (e.g., "Please analyze the emotions contained in the following user questions"), emotion category (e.g., "mild dissatisfaction", "intense emotions", "abusive and offensive", etc.), reference example, input text (i.e., user questions), and output format (e.g., JSON format) and requirements (e.g., requiring no other explanatory or redundant content to be output).

[0107] It should be understood that this is only an illustrative example, and in practice, the prompt word propmt7 may include more or less content, which is not limited in this specification.

[0108] Afterwards, the target response and sentiment analysis results can be input into the large model, which will then rewrite the target response based on the response wording that matches the sentiment analysis results, thus obtaining the final response.

[0109] When rewriting the target response using a large model, the prompt8 input to the large model can include: the role of the model (e.g., "You are a professional customer service script optimization assistant"), the instruction description (e.g., "Your task is to adjust the tone of the response based on the user's emotions, rewrite the following target response, and the final output of the rewritten content must match the user's emotions, be logically coherent, and have no missing information."), the emotion category (e.g., "mild dissatisfaction"), a reference example, the input text (i.e., the target response to be rewritten), the rewriting constraints (e.g., tone matching, information retention, style preference, and scenario adaptation), and the output format (e.g., JSON format) and requirements (e.g., requiring no other explanatory or redundant content to be output).

[0110] It should be understood that this is only an illustrative example, and in practice, the prompt word propmt8 may include more or less content, which is not limited in this specification.

[0111] Taking the above sentiment analysis result of "mild dissatisfaction" as an example, the corresponding response could be "empathetic expression"; taking the above sentiment analysis result of "intense emotion" as another example, the corresponding response could be "expressing apology" or similar.

[0112] It should be understood that, upon receiving the aforementioned final response, the user's question and final response can be added to the standard question and answer database, or the final response can be returned to the user.

[0113] It should be noted that, in addition to establishing a standard question-and-answer database in this solution, for real-time questions received in real time, the real-time question can be matched with user questions in the standard question-and-answer database, and the corresponding answer or final answer for the matching user question can be returned to the user. This can greatly improve the response speed and avoid the problem of inaccurate answers due to model illusion.

[0114] Figure 6 This document illustrates a method for generating answers to user questions in one example. Figure 6 First, the system acquires the user's question and uses a large-scale model to identify the user's intent, thus obtaining the target intent. Then, based on both the user's question and the target intent, it queries the contract knowledge graph to obtain a list of candidate entities. Next, a re-ranking model is used to re-rank the candidate entities in the list, and the target entity is selected from the re-ranked candidates. Furthermore, the large-scale model performs contextual adaptability analysis on the target entity, generating an initial response to the user's question based on the results. Finally, the large-scale model first performs a compliance check on the initial response and outputs a compliant target response. Then, using the large-scale model, the target response is rewritten based on a response phrase that matches the user's sentiment, resulting in the final response.

[0115] In summary, the method for generating answers to user questions provided in the embodiments of this specification can efficiently and accurately recall knowledge content related to user questions by relying on the hierarchical path of the contract knowledge graph, thereby significantly improving the efficiency and accuracy of answer generation and making it applicable to high-concurrency application scenarios. Furthermore, in the process of knowledge retrieval based on the contract knowledge graph, this method can avoid the need to understand complex contract clauses, further reducing processing difficulty and implementation costs. Finally, the above-mentioned solution for generating answers to user questions is actually an automated process of interpreting contract text, which can improve the efficiency of contract text interpretation.

[0116] In this specification, the large model is also referred to as the large language model (LLM). A large language model is a natural language processing model based on deep learning techniques, typically with billions to hundreds of billions or even more parameters, possessing powerful language understanding and generation capabilities. Large language models can employ the Transformer architecture or its variants (such as GPT, BERT, etc.), which utilizes an attention mechanism to globally model sequential data, efficiently handling long-distance dependencies and thus performing exceptionally well in natural language tasks. Large language models learn the statistical features and semantic relationships of language through pre-training on large-scale corpora, giving them strong generalization capabilities. The core capabilities of large language models include, but are not limited to: understanding contextual semantics, generating coherent and grammatically correct text, performing logical reasoning, and handling multi-task scenarios. Their usage typically includes two modes: direct inference and fine-tuning. In direct inference mode, the user guides the large language model to generate specific outputs by designing prompts. Cue words can be task descriptions or instructions in text form, used to stimulate the semantic understanding and generation capabilities of large language models. In fine-tuning mode, large language models are further trained on small-scale datasets in specific domains to optimize their performance on specific tasks. The powerful generalization ability and flexibility of large language models make them an important tool in the field of artificial intelligence, providing efficient and accurate solutions for automated text generation and understanding.

[0117] In some embodiments, large language models can also understand and generate data from other modalities (such as visual and audio data). In this case, large language models can also be called multimodal large language models (MLLMs). MLLMs provide a richer and more natural interactive experience by integrating multiple types of input and output, such as text, images, and sound. The core advantage of MLLMs lies in their ability to process and understand information from different modalities and fuse this information to complete complex tasks. For example, MLLMs can analyze an image and generate descriptive text, or generate a corresponding image based on a text description. This cross-modal understanding and generation capability makes MLLMs widely applicable across multiple fields.

[0118] It should be noted that the key technologies of large language models can be found in the detailed description in the paper "A Survey of Large Language Models" (paper number: arXiv:2303.18223v16, published on March 11, 2025), and will not be repeated here.

[0119] Furthermore, the underlying models used in each processing step (such as parsing of clause element entities, user intent identification, and applicability analysis) may be the same or different, and this specification does not impose any restrictions on this.

[0120] Corresponding to the above-described method for generating a contract knowledge graph, one embodiment of this specification also provides an apparatus for generating a contract knowledge graph, such as... Figure 7 As shown, the device may include:

[0121] Input unit 702 is used to input each paragraph contained in the contract text into the large model, so that it can extract the first type of entity corresponding to the clause element;

[0122] The input unit 702 is also used to input any first entity belonging to the clause element and the target paragraph to which it belongs into the large model, so that the model can parse the first entity based on the target paragraph to obtain the second type of entity corresponding to the clause description.

[0123] The generation unit 704 is used to generate a multi-level contract knowledge graph based on the first type of entity, the second type of entity, and the third type of entity corresponding to a single paragraph. The root level of the contract knowledge graph corresponds to the first type of entity, and the entities in other levels are connected to the corresponding entities in the root level, in addition to being connected to the corresponding entities in the adjacent levels.

[0124] In one embodiment, the contract knowledge graph further includes a fourth type of entity corresponding to the reference question; the fourth type of entity corresponding to the first entity is generated using a large model based on the first entity and the aforementioned target paragraph.

[0125] In one embodiment, the levels corresponding to the second, third, and fourth types of entities are respectively further away from the root level and closer to the leaf level.

[0126] The functions of each functional unit of the apparatus in the above embodiments of this specification can be implemented through the steps of the above method embodiments. Therefore, the specific working process of the apparatus provided in one embodiment of this specification will not be repeated here.

[0127] The apparatus for generating contract knowledge graphs provided in one embodiment of this specification can fully utilize the capabilities of large models to automatically transform contract text into structured knowledge graphs, thereby effectively improving the generation efficiency of contract knowledge graphs.

[0128] Corresponding to the above-described method for generating answers to user questions, one embodiment of this specification also provides an apparatus for generating answers to user questions, such as... Figure 8 As shown, the device may include:

[0129] Acquisition unit 802 is used to acquire a contract knowledge graph, which is based on... Figure 2 It is generated by the steps shown in the diagram;

[0130] Unit 804 is used to determine several entities associated with the user's question based on the hierarchical path of the contract knowledge graph and add them to the candidate entity list.

[0131] The determining unit 804 is also used to determine the response content corresponding to the user question based on the user question and the candidate entity list.

[0132] In one embodiment, the determining unit 804 includes:

[0133] The calculation submodule 8042 is used to calculate the similarity between the user's question and various entities in the contract knowledge graph, and to identify similar entities from the contract knowledge graph.

[0134] The determination submodule 8044 is used to identify several entities in the contract knowledge graph that are covered by the longest path from the level of similar entities to the root level.

[0135] In one embodiment, the candidate entity list may further include other entities retrieved from the contract knowledge graph based on the target intent, which is obtained by using a large model to identify the intent of the user question.

[0136] In one embodiment, the device further includes:

[0137] Input unit 806 is used to input the user question and the candidate entity list into the reordering model to obtain the reordering of each candidate entity in the candidate entity list;

[0138] Selection unit 808 is used to select the target entity from the reordered candidate entities;

[0139] Unit 804 is specifically used for:

[0140] Based on the user's question and the target entity, determine the corresponding response content for the user's question.

[0141] In one embodiment, the above reordering model is implemented as a pre-trained generative large model.

[0142] In one embodiment, the determining unit 804 is further specifically used for:

[0143] Input the user question and the target entity into the large model, and let it perform a contextual suitability analysis on the target entity based on the user question. Based on the suitability analysis results, generate the corresponding response content for the user question.

[0144] In one embodiment, the input unit 806 is further configured to input the response content and compliance check rules into the large model, so that the model can determine whether the response content is compliant based on the compliance check rules and output a compliant target response.

[0145] In one embodiment, the input unit 806 is also used to input user questions into a large model, enabling the model to perform sentiment analysis on the user questions and obtain sentiment analysis results;

[0146] The target response and sentiment analysis results are input into a large model, which then rewrites the target response based on the response wording that matches the sentiment analysis results, thus obtaining the final response.

[0147] In one embodiment, the device further includes:

[0148] Add unit 810 to add user questions and answers to the standard question and answer library.

[0149] The functions of each functional unit of the apparatus in the above embodiments of this specification can be implemented through the steps of the above method embodiments. Therefore, the specific working process of the apparatus provided in one embodiment of this specification will not be repeated here.

[0150] One embodiment of this specification provides an apparatus for generating answers to user questions, which can efficiently and accurately recall knowledge content related to user questions by relying on the hierarchical path of the contract knowledge graph, thereby significantly improving the efficiency and accuracy of answer generation.

[0151] According to another embodiment, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed in a computer, causes the computer to perform a combination Figure 2 or Figure 5 The method described.

[0152] According to another embodiment, a computing device is also provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements a combination... Figure 2 or Figure 5 The method described.

[0153] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the medium or device embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0154] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0155] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of this specification. It should be understood that the above description is only a specific embodiment of this specification and is not intended to limit the scope of protection of this specification. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of this specification should be included within the scope of protection of this specification.

Claims

1. A method for generating a contract knowledge graph, comprising: Each paragraph in the contract text is input into the large model, which then extracts the first type of entity corresponding to the clause element. Input any first entity belonging to the clause element and its corresponding target paragraph into the large model, and let it perform interpretive parsing of the first entity based on the target paragraph to obtain a second type of entity corresponding to the clause description; Based on the first type of entity, the second type of entity, and the third type of entity corresponding to a single paragraph, a multi-level contract knowledge graph is generated. The root level of the contract knowledge graph corresponds to the first type of entity. In addition to being connected to the corresponding entities in adjacent levels, entities in other levels are also connected to the corresponding entities in the root level, so that any entity in the contract knowledge graph can be directly traced back to its corresponding clause element.

2. The method according to claim 1, wherein, The contract knowledge graph also includes a fourth type of entity corresponding to the reference question; the fourth type of entity corresponding to the first entity is generated using a large model based on the first entity and the target paragraph.

3. The method according to claim 2, wherein, The levels corresponding to the second, third, and fourth types of entities are respectively further away from the root level and closer to the leaf level.

4. A method for generating answers to user questions, comprising: Obtain a contract knowledge graph, which is generated according to the method described in claim 1; Based on the hierarchical path of the contract knowledge graph, several entities associated with the user's question are identified and included in the candidate entity list. Based on the user question and the candidate entity list, determine the corresponding response content for the user question.

5. The method according to claim 4, wherein, Based on the hierarchical path of the contract knowledge graph, several entities associated with the user's question are identified, including: The similarity between the user question and each entity in the contract knowledge graph is calculated to identify similar entities from the contract knowledge graph. The entities covered by the longest path from the level of the similar entity to the root level in the contract knowledge graph are identified as the several entities.

6. The method according to claim 4, wherein, The candidate entity list also includes other entities retrieved from the contract knowledge graph based on the target intent, which is obtained by using a large model to identify the intent of the user question.

7. The method according to claim 4, further comprising: Input the user question and the candidate entity list into the reordering model to obtain the reordering of each candidate entity in the candidate entity list; Select the target entity from the reordered candidate entities; Determining the response content corresponding to the user's question includes: Based on the user question and the target entity, determine the response content corresponding to the user question.

8. The method according to claim 7, wherein, The reordering model is implemented as a pre-trained generative large model.

9. The method according to claim 7, wherein, The step of determining the response content corresponding to the user question based on the user question and the target entity includes: The user question and the target entity are input into a large model, which then performs a contextual suitability analysis on the target entity based on the user question. Based on the suitability analysis results, the model generates the corresponding response content for the user question.

10. The method of claim 4, further comprising: The response content and compliance check rules are input into the large model, which then determines whether the response content is compliant based on the compliance check rules and outputs a compliant target response.

11. The method of claim 10, further comprising: The user question is input into a large model, which performs sentiment analysis on the user question to obtain the sentiment analysis results. The target response and sentiment analysis results are input into a large model, which then rewrites the target response based on response phrases that match the sentiment analysis results, thus obtaining the final response.

12. The method according to claim 4, further comprising: Add the user's question and the answer to the standard question and answer database.

13. An apparatus for generating a contract knowledge graph, comprising: The input unit is used to input each paragraph contained in the contract text into the large model, so that it can extract the first type of entity corresponding to the clause element; The input unit is also used to input any first entity belonging to the clause element and its target paragraph into the large model, so that the model can perform interpretive parsing on the first entity based on the target paragraph to obtain a second type of entity corresponding to the clause description. The generation unit is used to generate a multi-level contract knowledge graph based on the first type of entity, the second type of entity, and the third type of entity corresponding to a single paragraph. The root level of the contract knowledge graph corresponds to the first type of entity, and the entities in other levels are connected to the corresponding entities in the root level, in addition to being connected to the corresponding entities in the adjacent levels, so that any entity in the contract knowledge graph can be directly traced back to its corresponding clause element.

14. An apparatus for generating answers to user questions, comprising: The acquisition unit is used to acquire a contract knowledge graph, which is generated according to the method described in claim 1; The determining unit is used to determine several entities associated with the user's question based on the hierarchical path of the contract knowledge graph and add them to the candidate entity list; The determining unit is further configured to determine the response content corresponding to the user question based on the user question and the candidate entity list.

15. A computer-readable storage medium having a computer program stored thereon, wherein, When the computer program is executed in the computer, it causes the computer to perform the method according to any one of claims 1-12.

16. A computing device comprising a memory and a processor, wherein, The memory stores executable code, and when the processor executes the executable code, it implements the method of any one of claims 1-12.

Citation Information

Patent Citations

  • Contract relation graph construction method and electronic equipment

    CN120067292A

  • Document understanding method and device based on knowledge graph, equipment and storage medium

    CN120257993A