Model training method, contract term retrieval method and related equipment
By training the target retrieval model and using historical contracts and question and answer data, the problem of low efficiency and low accuracy in contract clause retrieval is solved, and efficient and accurate contract clause retrieval is achieved.
Patent Information
- Application Number
- CN202410691976.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-17
AI Technical Summary
The existing contract clause retrieval system is inefficient and inaccurate, making it difficult to quickly and accurately find contract clauses that meet the needs of the enterprise.
By collecting historical contract and question and answer data, a training sample data set is generated, the precision and frequency parameters of the information tuples are calculated, the model parameters are adjusted, the target retrieval model is trained, and the model is used to perform high-accuracy retrieval of the target questions input by the user.
The accuracy and efficiency of contract clause retrieval are significantly improved, and contract clauses that match user needs can be found more quickly.
Smart Images

Figure CN118656380A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a model training method, a contract terms retrieval method, and related equipment. Background Art
[0002] With the development of the economy and society, a large number of economic activities in enterprises require contracts to establish relationships and clarify the rights and obligations of both parties. The counterparties of the contract include both individuals and corporate legal persons. Each contract clause has a very important impact and significance on the future performance of the contract. Enterprises often need to draft different contracts according to different business scenarios. In order to quickly draft a contract that meets the needs of the enterprise, historical contract information can be referred to during the process of drafting the contract, so historical contracts need to be retrieved. Summary of the invention
[0003] The embodiments of the present application disclose a model training method, a contract terms retrieval method and related equipment, which solve the technical problems of low efficiency and low accuracy in contract terms retrieval.
[0004] In the first aspect, the present application provides a model training method, which includes: calculating the precision parameter and frequency parameter of the information tuple of a training sample data set; determining a first target value corresponding to the true answer of the information tuple based on the initial precision parameter and initial frequency parameter of the information tuple and the calculated precision parameter and frequency parameter; predicting the question in the information tuple using the initial model to obtain the corresponding predicted answer; determining a second target value corresponding to the predicted answer based on the precision parameter and the frequency parameter and the initial precision parameter and the initial frequency parameter; determining a loss value based on the difference between the first target value and the second target value, adjusting the initial precision parameter and the initial frequency parameter based on the loss value, and training the initial model using the adjusted initial precision parameter and the adjusted initial frequency parameter.
[0005] In one possible implementation, the method includes: collecting question and answer data to generate a question and answer data set; obtaining a first data set based on the question and answer data set, wherein the first data set includes a first information tuple, and the first information tuple includes a question and a corresponding true answer; obtaining a second data set based on the first data set, wherein the second data set includes a second information tuple, and the second information tuple includes multiple questions and corresponding multiple true answers; and obtaining the training sample data set based on the first data set and the second data set.
[0006] In one possible implementation, calculating the precision parameter and frequency parameter of the information tuple of the training sample data set includes: calculating a first precision parameter and a first frequency parameter of the first information tuple; and calculating a second precision parameter and a second frequency parameter of the second information tuple.
[0007] In one possible implementation, the calculation of the first precision parameter and the first frequency parameter of the first information tuple includes: matching the first information tuple with the questions in the question and answer data set and the corresponding true answers to obtain a first probability that the first information tuple appears in the question and answer data set; determining the first probability as the first precision parameter corresponding to the first information tuple; matching the questions in the first data set with the questions in the question and answer data set and the corresponding true answers to obtain a second probability that the questions in the first data set appear in the question and answer data set; determining the second probability as the first frequency parameter corresponding to the first information tuple.
[0008] In one possible implementation, the calculating the second precision parameter and the second frequency parameter of the second information tuple includes: determining the first information tuple corresponding to each question in the second information tuple, and the first precision parameter corresponding to the determined first information tuple; determining the second precision parameter based on the determined first precision parameter; determining the first information tuple corresponding to each question in the second information tuple, and the first frequency parameter corresponding to the determined first information tuple; and determining the second frequency parameter based on the determined first frequency parameter.
[0009] In one possible implementation, determining the first target value corresponding to the true answer of the information tuple based on the initial precision parameter and the initial frequency parameter of the information tuple and the calculated precision parameter and the frequency parameter includes: obtaining a first product based on the first precision parameter and the initial precision parameter; obtaining a second product based on the first frequency parameter and the initial frequency parameter; and determining the first target value based on the first product and the second product.
[0010] In one possible implementation, determining the second target value corresponding to the predicted answer based on the precision parameter and the frequency parameter and the initial precision parameter and the initial frequency parameter includes: obtaining a third product based on the second precision parameter and the initial precision parameter; obtaining a fourth product based on the second frequency parameter and the initial frequency parameter; and determining the second target value based on the third product and the fourth product.
[0011] In one possible implementation, the information tuple also includes a type tag, and the type tag indicates the type of contract to which the clause corresponding to the question in the information tuple belongs. The using of the initial model to predict the question in the information tuple to obtain the corresponding predicted answer includes: determining the corresponding type tag and a set of feature vectors based on the question in the information tuple; and obtaining the predicted answer corresponding to the question in the information tuple using the initial retrieval model based on the feature vector set and the type tag.
[0012] In a second aspect, the present application provides a contract terms retrieval method, the method comprising: receiving a target question, wherein the target question is used to retrieve terms in a contract; using a target retrieval model to obtain a target answer corresponding to the terms in the target question, the target retrieval model being obtained by executing the model training method described above.
[0013] In a possible implementation, the target question includes a prompt word related to the clause.
[0014] In one possible implementation, the use of a target retrieval model to obtain a target answer corresponding to the target question includes: determining a feature vector set and a corresponding type label based on the target question; based on the feature vector set and the type label, using the target retrieval model to obtain a target value set corresponding to the target question; and determining a target answer corresponding to the target question based on the target value set.
[0015] In a possible implementation, obtaining a feature vector set based on the target problem includes: obtaining a feature data set based on the target problem; and mapping feature data in the feature data set to a vector space to obtain the feature vector set.
[0016] In one possible implementation, the method of obtaining a target value set corresponding to the target question using the target retrieval model based on the feature vector set and the type label includes: obtaining at least one target predicted answer corresponding to a contract clause in the contract type to which the target question belongs based on the type label; and determining a target value set corresponding to the at least one target predicted answer.
[0017] In one possible implementation, determining the target answer corresponding to the target question based on the target value set includes: sorting all target values in the target value set to obtain a target value list; determining an information tuple corresponding to the largest target value based on the target value list; and determining the true answer corresponding to the information tuple corresponding to the largest target value as the target answer.
[0018] In the third aspect, the present application provides a model training device, comprising: a processing module, which is used to calculate the precision parameter and frequency parameter of the information tuple of the training sample data set; a determination module, which is used to determine the first target value corresponding to the true answer of the information tuple based on the initial precision parameter and initial frequency parameter of the information tuple and the calculated precision parameter and frequency parameter; the processing module is also used to use the initial model to predict the question in the information tuple to obtain the corresponding predicted answer; the determination module is also used to determine the second target value corresponding to the predicted answer based on the precision parameter and the frequency parameter and the initial precision parameter and the initial frequency parameter; the determination module is also used to determine the loss value based on the difference between the first target value and the second target value; the processing module is also used to adjust the initial precision parameter and the initial frequency parameter based on the loss value, and train the initial model using the adjusted initial precision parameter and the adjusted initial frequency parameter.
[0019] In a fourth aspect, the present application provides a contract terms retrieval device, comprising: a receiving module for receiving a target question, wherein the target question is used to retrieve terms in a contract; and a processing module for using a target retrieval model to obtain a target answer corresponding to the terms in the target question.
[0020] In a fifth aspect, the present application provides a computer device, comprising a processor and a memory, wherein the processor implements the model training method as described above, or the contract terms retrieval method as described above, when executing a computer program stored in the memory.
[0021] In a sixth aspect, the present application provides a computer-readable storage medium, which stores at least one instruction, and when the at least one instruction is executed by a processor, implements the model training method as described above, and implements the contract terms retrieval method as described above.
[0022] In the model training method provided in the present application, the first target value corresponding to the true answer of the information tuple is calculated by determining the initial precision parameter and initial frequency parameter as well as the precision parameter and frequency parameter of the information tuple in the training sample data set, and after the initial model is used to predict the question in each information tuple to obtain the corresponding predicted answer, the second target value corresponding to the predicted answer is determined. The loss value of the initial model is determined based on the difference between the first target value and the second target value, the initial precision parameter and the initial frequency parameter are adjusted based on the loss value, and the initial model is trained using the adjusted initial precision parameter and the adjusted initial frequency parameter. The target retrieval model thus obtained has a high accuracy, and the target question input by the user for retrieving the terms in the contract is retrieved using the target retrieval model to obtain the target answer corresponding to the term. Retrieving the terms in the historical contracts corresponding to the target question through the target retrieval model can effectively improve the accuracy and efficiency of contract term retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic diagram of an application scenario of the model training method provided in an embodiment of the present application.
[0024] Figure 2 It is a flow chart of the model training method provided in the embodiment of the present application.
[0025] Figure 3 It is a structural diagram of the initial model in the embodiment of the present application.
[0026] Figure 4 It is a flowchart of a method for obtaining a training sample data set in an embodiment of the present application.
[0027] Figure 5 It is a flowchart of the contract terms retrieval method provided in the embodiment of the present application.
[0028] Figure 6 It is a structural diagram of the model training device in an embodiment of the present application.
[0029] Figure 7 It is a structural diagram of a contract terms retrieval device provided in an embodiment of the present application.
[0030] Figure 8 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] To facilitate understanding, some illustrations of concepts related to the embodiments of the present application are given by way of example for reference.
[0032] It should be noted that in this application, "at least one" means one or more, and "more than one" means two or more than two. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The terms "first", "second", "third", "fourth", etc. (if any) in the specification, claims and drawings of this application are used to distinguish similar objects, rather than to describe a specific order or sequence.
[0033] In the related art, a contract clause retrieval system can be used to assist users in retrieving historical contracts. The contract clause retrieval system mainly relies on keyword search and text matching technology. For example, by entering keywords or phrases, relevant clauses in related contracts can be retrieved. However, the existing contract clause retrieval system has the problems of low retrieval efficiency and low accuracy.
[0034] Based on the above technical problems, this application obtains a training sample data set based on historical contract data and contract terms related question and answer data, and trains an initial model based on the training sample data set to obtain a target retrieval model. When receiving a user's target question to query contract terms, the target retrieval model is used to obtain the corresponding target answer, which can effectively improve the accuracy and efficiency of contract terms retrieval.
[0035] In order to better understand the model training method, contract terms retrieval method and related products provided in the embodiments of the present application, the application scenario of the model training method of the present application is first described below.
[0036] Figure 1 Schematic diagram of the implementation environment of the model training method provided in the embodiment of the present application. Figure 1 As shown, in some embodiments of the present application, the model training method can be applied to a computer device 1 (such as a server), and the computer device 1 can be connected to an external database 2, or the database 2 can be constructed in a storage device in the computer device 1. A training sample data set is stored in the database 2, and the training sample data set can include at least two types of training samples, namely a first data set and a second data set. Among them, the first data set includes a plurality of first information tuples, and the first information tuple includes a question for consulting on contract terms and a corresponding true answer; the second data set includes a plurality of second information tuples, and the second information tuple includes a plurality of questions for consulting on contract terms and a corresponding plurality of true answers. The computer device 1 can obtain the first information tuple in the first data set and the second information tuple in the second data set from the database 2, and then input the first information tuple and / or the second information tuple into the initial model for training to obtain the target retrieval model.
[0037] In addition, the training sample data set may also be stored in the cloud, and the computer device 1 may directly obtain the training sample data set from the cloud, and train the initial model according to the obtained training sample data set.
[0038] The technical solution of the present application is described in detail below with specific embodiments. The specific embodiments described below may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0039] Figure 2 This is a flow chart of the model training method provided in the embodiment of the present application. The method of this embodiment can be executed by a computer device, and an initial model can be deployed in the computer device. Figure 2 As shown, the method of this embodiment may include:
[0040] S201: Calculate the precision parameter and frequency parameter of the information tuple of the training sample data set.
[0041] In an embodiment of the present application, before calculating the precision parameter and frequency parameter of the information tuple of the training sample data set, the model training method also includes: obtaining the training sample data set, wherein the training sample data set includes an information tuple, and the information tuple includes a question and a corresponding true answer; and setting an initial precision parameter and an initial frequency parameter of the information tuple.
[0042] In this embodiment, before training the initial model, a training sample data set may be obtained first, and the initial model may be trained based on the obtained training sample data set. Figure 3 .
[0043] In one implementation, the training sample data set may be pre-stored in a database or in the cloud.
[0044] In an embodiment of the present application, a training sample data set can be obtained by collecting historical contracts and question-and-answer data related to contract terms in historical contracts. The training sample data set includes a first data set and a second data set. The first data set includes multiple first information tuples, and the first information tuple includes two information elements. For example, the two information elements can be questions and answers, respectively. The questions are questions asked by users when searching for contract terms in historical contracts; the answers are real answers corresponding to the questions asked by users when searching for contract terms in historical contracts.
[0045] In an embodiment of the present application, before inputting the information tuple in the training sample data set into the initial model, it is necessary to set an initial precision parameter and an initial frequency parameter for the information tuple. Since the first information tuple in the first data set and the second information tuple in the second data set have different importance and influence in training the initial model, different initial precision parameters and initial frequency parameters can be set for the first information tuple and the second information tuple, respectively.
[0046] In one embodiment of the present application, the initial precision parameter corresponding to the second information tuple is greater than the initial precision parameter corresponding to the first information tuple; the initial frequency parameter corresponding to the second information tuple is greater than the initial frequency parameter corresponding to the first information tuple. Since the second information tuple is more important in the prediction process, a larger initial precision parameter and initial frequency parameter can be set for the second information tuple. Then, during the training process, the initial model will pay more attention to the learning and optimization of the second information tuple, thereby improving the prediction ability of the model in complex situations.
[0047] In an embodiment of the present application, the precision parameter and frequency parameter of the information tuple can be calculated based on the question-answer data set and the initial precision parameter and initial frequency parameter set for the information tuple. Specifically, calculating the precision parameter and frequency parameter of the information tuple includes: calculating the first precision parameter and the first frequency parameter of the first information tuple; and calculating the second precision parameter and the second frequency parameter of the second information tuple.
[0048] In an embodiment of the present application, calculating the first precision parameter and the first frequency parameter of the first information tuple includes: matching the first information tuple with the questions in the question and answer dataset and the corresponding true answers to obtain a first probability of the first information tuple appearing in the historical question and answer dataset, and determining the first probability as the first precision parameter corresponding to the first information tuple; matching the questions in the first dataset with the questions in the question and answer dataset and the corresponding true answers to obtain a second probability of the questions in the first dataset appearing in the question and answer dataset, and determining the second probability as the first frequency parameter corresponding to the first information tuple.
[0049] In an embodiment of the present application, calculating the second precision parameter and the second frequency parameter of the second information tuple includes: determining the first information tuple corresponding to each question in the second information tuple, and the first precision parameter corresponding to the determined first information tuple; determining the second precision parameter based on the determined first precision parameter; determining the first information tuple corresponding to each question in the second information tuple, and the first frequency parameter corresponding to the determined first information tuple; and determining the second frequency parameter based on the determined first frequency parameter.
[0050] In the embodiment of the present application, the second precision parameter can be obtained by accumulating the sum of the first precision parameters corresponding to each question in the second information tuple, or by calculating the first precision parameter corresponding to each question in the second information tuple by weighted average calculation to obtain the second precision parameter. This application does not limit this.
[0051] In the embodiment of the present application, the second frequency parameter can be obtained by accumulating the sum of the first frequency parameters corresponding to each question in the second information tuple, or by calculating the first frequency parameter corresponding to each question in the second information tuple by weighted average calculation to obtain the second frequency parameter. This application does not limit this.
[0052] S202: Determine a first target value corresponding to a true answer of the information tuple based on an initial precision parameter and an initial frequency parameter of the information tuple and the calculated precision parameter and frequency parameter.
[0053] In an embodiment of the present application, in order to subsequently evaluate the accuracy of the predicted answer output by the initial model, the first target value corresponding to the true answer of the information tuple may be determined first. In an embodiment of the present application, based on the initial precision parameter and the initial frequency parameter of the information tuple and the calculated precision parameter and frequency parameter, determining the first target value corresponding to the true answer of the information tuple includes: obtaining a first product based on the first precision parameter and the initial precision parameter; obtaining a second product based on the first frequency parameter and the initial frequency parameter; and determining the first target value based on the first product and the second product.
[0054] In the embodiment of the present application, the first target value may be determined by accumulating the sum of the first product and the second product, or the first product and the second product may be calculated by weighted average calculation to obtain the first target value. The present application does not limit this.
[0055] S203: Use the initial model to predict the questions in the information tuple to obtain corresponding predicted answers.
[0056] In the embodiment of the present application, the initial model may be a Transformer model, which includes an encoder and a decoder. Figure 3 As shown, the initial model includes three encoders and three decoders. In an embodiment of the present application, the encoder generally includes multiple stacked recurrent neural networks (RNN) and / or attention mechanisms. The decoder generally also includes multiple stacked recurrent neural networks and / or attention mechanisms. The attention mechanism can enable the initial model to focus on the key information in the question when generating the answer.
[0057] In an embodiment of the present application, the encoder in the initial model is used to process the question in the information tuple to obtain a feature vector set corresponding to the question, wherein the feature vector set contains the semantic information of the question; the type label corresponding to the question is determined; the decoder in the initial model is continued to process the feature vector set and the type label, and the predicted answer corresponding to the question is output. The encoder in the initial model is used to process the question in the information tuple to obtain a feature vector set corresponding to the question, including: obtaining a feature data set based on the question in the information tuple; mapping the feature data in the feature data set to the vector space to obtain a feature vector set.
[0058] In an embodiment of the present application, before using the initial model, the model training method also includes the step of initializing the parameters in the initial model. Specifically, the parameters such as the weights and biases of the initial model can be randomly initialized. By initializing the weights of the initial model, the training process can be accelerated and the model performance can be improved.
[0059] In an embodiment of the present application, in order to make the predicted answer obtained by the initial model correspond to the question in the information tuple, the type label in the information tuple can be input into the initial model at the same time as the question, so that the contract type corresponding to the predicted answer output by the initial model is the same as the contract type corresponding to the type label of the question, thereby improving the accuracy of the initial model.
[0060] S204: Determine a second target value corresponding to the predicted answer based on the accuracy parameter and the frequency parameter as well as the initial accuracy parameter and the initial frequency parameter.
[0061] In the embodiment of the present application, in order to measure the difference between the predicted answer and the true answer, the predicted answer can be compared with the true answer when the initial model is used to predict the question in the information tuple. Specifically, the second target value corresponding to the predicted answer is determined based on the accuracy parameter and the frequency parameter as well as the initial accuracy parameter and the initial frequency parameter; the difference between the predicted answer and the true answer is measured by comparing the difference between the first target value corresponding to the true answer and the second target value corresponding to the predicted answer.
[0062] In an embodiment of the present application, determining the second target value corresponding to the predicted answer based on the accuracy parameter and the frequency parameter as well as the initial accuracy parameter and the initial frequency parameter includes: obtaining a third product based on the second accuracy parameter and the initial accuracy parameter; obtaining a fourth product based on the second frequency parameter and the initial frequency parameter; and determining the second target value based on the third product and the fourth product.
[0063] In the embodiment of the present application, the second target value may be determined by accumulating the sum of the third product and the fourth product, or the third product and the fourth product may be calculated by weighted average calculation to obtain the second target value. The present application does not limit this.
[0064] S205: Determine a loss value based on the difference between the first target value and the second target value.
[0065] In an embodiment of the present application, during the training process of the initial model, the second target value reflects the model's comprehensive consideration of the prediction accuracy and frequency of the answers in the information tuple. The first target value and the second target value corresponding to the information tuple are calculated by the accuracy parameter and the frequency parameter as well as the corresponding initial accuracy parameter and the initial frequency parameter. The goal of training the initial model is to optimize the second target value so that the difference between the second target value and the first target value becomes smaller and smaller. This enables the initial model to more accurately match the correct answer corresponding to the question, and when faced with questions corresponding to new contracts, it can predict the most accurate answer to the question.
[0066] In the embodiment of the present application, the difference between the first target value and the second target value can be calculated by a cross entropy loss function or a mean square error loss function, etc. According to the loss value calculated by the cross entropy loss function or the mean square error loss function, the initial model can be guided to update parameters during the iterative training process, thereby gradually improving the prediction accuracy of the initial model.
[0067] In the embodiment of the present application, the loss value can be determined by calculating the difference between the first target value and the second target value through the cross entropy loss function. Assuming that after inputting the question to the initial model, the initial model outputs k predicted answers corresponding to the question, then the cross entropy loss function can be expressed as the following formula:
[0068]
[0069] Among them, 1≤k≤n, L is the loss value, y n is the first target value corresponding to the true answer, p n is the second target value corresponding to the nth predicted answer among the k predicted answers. When the predicted answer is getting closer and closer to the true answer, the second target value is getting closer and closer to the first target value, and the loss value L is small; when the predicted answer is far from the true answer, the second target value is getting farther and farther away from the first target value, and the loss value L is large. Based on the loss value, the parameters of the model can be adjusted during the training of the initial model to better fit the training data. This allows the trained model to output predicted answers that are getting closer and closer to the true answer.
[0070] S206: Adjusting the initial precision parameter and the initial frequency parameter based on the loss value, and training the initial model using the adjusted initial precision parameter and the adjusted initial frequency parameter.
[0071] In the embodiment of the present application, after determining the loss value, it is also necessary to adjust the parameters of the initial model to optimize the initial model. The parameters of the initial model include initial accuracy parameters and initial frequency parameters, as well as parameters such as weights and biases randomly initialized. In some embodiments, the parameters of the initial model can be adjusted using a back propagation algorithm, and the gradient descent algorithm is used to evaluate whether the loss value obtained after training the initial model according to the adjusted parameters tends to a preset range.
[0072] In an embodiment of the present application, the initial precision parameters and the initial frequency parameters are adjusted based on the loss value, and the initial model is trained using the adjusted initial precision parameters and the adjusted initial frequency parameters, including: adjusting the initial precision parameters and the initial frequency parameters based on the loss value, returning to execute the calculation of the precision parameters and the frequency parameters of each information tuple until the determined loss value is within a preset range, thereby obtaining a target retrieval model.
[0073] In an embodiment of the present application, after determining the loss value based on the difference between the first target value and the second target value, it is necessary to iteratively train the initial model. Continue to iteratively train the initial model based on the training sample data set, and when the initial model converges after the Nth iterative training, the initial model after the Nth iterative training is determined as the target retrieval model. Specifically, continuing to iteratively train the initial model based on the training sample data set includes: adjusting the initial precision parameter and the initial frequency parameter, returning to calculate the precision parameter and frequency parameter of each information tuple, until the determined loss value is within a preset range.
[0074] It should be noted that in each iterative training process, the predicted answer output by the initial model can be compared with the true answer, and the difference between the first target value and the second target value and the gradient of the initial model can be calculated. Then, the initial model is updated by adjusting the initial precision parameter and the initial frequency parameter until the determined loss value is within the preset range, and the target retrieval model is obtained. In this way, the second target value corresponding to the predicted answer output by the initial model in the subsequent iterative training process can infinitely approach the first target value corresponding to the true answer. The target retrieval model can be obtained when the initial model outputs a predicted answer that is infinitely close to the true answer based on the input question.
[0075] Figure 4 A flow chart of a method for obtaining a training sample data set provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the method for obtaining a training sample data set may include the following steps:
[0076] S401: Collect question and answer data and generate a question and answer dataset.
[0077] In an embodiment of the present application, historical contract data and question-and-answer data related to contract terms can be collected within a preset time period. For example, questions related to contract terms raised by users for historical contracts and answers to questions related to the contract terms are collected. A question-and-answer dataset is generated based on the questions related to the contract terms and the corresponding answers.
[0078] In the embodiment of the present application, the question-answering data set includes a question information set and an answer information set. For example, the question information set is defined as {q1, q2, q3…qn}; the answer information set is defined as {a1, a2, a3…am}. The historical contract data includes the original data of various contract types, such as contract type, contract text, contract number, signing date, partner, and contract amount.
[0079] In the embodiment of the present application, after the historical contract data and the contract clause related question and answer data are obtained, the historical contract data and the contract clause related question and answer data can also be processed. Specifically, the historical contract data can be cleaned to obtain contract data with invalid and duplicate data removed; the contract clause related question and answer data can be classified and marked to obtain the classified and marked question and answer data to ensure that the questions and answers are consistent with the corresponding contract type; and key information such as keywords and phrases in the questions and answers in the contract clause related question and answer data can be extracted for subsequent model training and retrieval.
[0080] S402: Obtain a first data set based on the question-answer data set, wherein the first data set includes a first information tuple, and the first information tuple includes a question and a corresponding true answer.
[0081] In an embodiment of the present application, obtaining a first data set based on a question-and-answer data set includes: matching each question in a question information set with each answer in an answer information set to obtain a plurality of first information tuples; and classifying the plurality of first information tuples according to contract type to obtain the first data set.
[0082] For example, each question in the question information set {q1, q2, q3…qn} is matched with each answer in the answer information set {a1, a2, a3…am} to obtain multiple first information tuples. The multiple first information tuples include: {q1, a1}, {q1, a2}, {q1, a3}…{q1, am}; {q2, a1}, {q2, a2}, {q2, a3}…{q2, am}; …{qn, a1}, {qn, a2}, {qn, a3}…{qn, am}.
[0083] After classifying multiple first information tuples according to contract type, the first data set is obtained as follows:
[0084] [[{q1,a1},{q1,a2},{q1,a3},…{q1,am}],
[0085] [{q2,a1},{q2,a2},{q2,a3},…{q2,am}],
[0086] …
[0087] [{qn,a1},{qn,a2},{qn,a3},…{qn,am}]].
[0088] Wherein, {qn,am} represents the first information tuple in the first data set, and each first information tuple includes a question and a true answer corresponding to the question.
[0089] In the embodiment of the present application, after the multiple first information tuples are classified according to the contract type, a type label can be marked for each first information tuple.
[0090] S403: Obtain a second data set based on the first data set, wherein the second data set includes a second information tuple, and the second information tuple includes a plurality of questions and a plurality of corresponding true answers.
[0091] In the embodiment of the present application, in order to enrich the sample data set and improve the accuracy of model training, the first data set can be expanded to obtain a second data set. For example, multiple related questions are derived from a question in each first information tuple in the first data set, so that the multiple related questions form a tree structure; then each question in the multiple related questions in the tree structure is matched with a corresponding real answer to obtain multiple second information tuples; and the multiple second information tuples are classified according to the contract type to obtain the second data set. For example, after the first information tuple in the first data set is expanded by two layers, the second data set obtained is:
[0092] [[{q1,a1,q2,a1},{q1,a1,q2,a2},…,{q1,a1,q2,am},…,{q1,a2,q2,a1},{q1,a2, q2,a2},…,{q1,a2,q2,am},…,{q1,am,q2,a1},{q1,am,q2,a2},…,{q1,am,q2,am}],
[0093] …
[0094] [{qn-1,a1,qn,a1},{qn-1,a1,qn,a2},…,{qn-1,a1,qn,am},…,{qn-1,a2,qn,a1},{qn-1,a2, qn,a2},…,{qn-1,a2,qn,am},…,{qn-1,am,qn,a1},{qn-1,am,qn,a2},…,{qn-1,am,qn,am}]].
[0095] Wherein: {qn-1,am,qn,am} represents the second information tuple in the second data set, and each second information tuple includes two questions and two true answers corresponding to the two questions.
[0096] In an embodiment of the present application, after the plurality of second information tuples are classified according to the contract type, a type label may be marked for each second information tuple. It should be noted that if the contract type corresponding to the question and answer in the first information tuple is the same as the contract type corresponding to the question and answer in the second information tuple, then the type label marked for the first information tuple is the same as the type label marked for the second information tuple.
[0097] In the embodiment of the present application, the first information tuple in the first data set can be expanded in multiple layers, and the present application does not limit this. The more levels of expansion of the first information tuple in the first data set, the wider the range of questions that can be predicted when the trained target retrieval model is used later, and the more accurate the answers obtained will be.
[0098] S404: Obtain a training sample data set based on the first data set and the second data set.
[0099] In the embodiment of the present application, the first data set and the second data set are merged to obtain a training sample data set. For example, when the first data set is:
[0100] [[{q1,a1},{q1,a2},{q1,a3},…{q1,am}],
[0101] [{q2,a1},{q2,a2},{q2,a3},…{q2,am}],
[0102] …
[0103] [{qn,a1},{qn,a2},{qn,a3},…{qn,am}]].
[0104] The second data set is:
[0105] [[{q1,a1,q2,a1},{q1,a1,q2,a2},…,{q1,a1,q2,am},…,{q1,a2,q2,a1},{q1,a2,q2,a2},…,{q1,a2,q2,am},…,{q1,am,q2,a1},{q1,am,q2,a2},…,{q1,am,q2,am}]],
[0106] ……
[0107] [{qn-1,a1,qn,a1},{qn-1,a1,qn,a2},…,{qn-1,a1,qn,am},…,{qn-1,a2,qn,a1},{qn-1,a2,qn,a2},…,{qn-1,a2,qn,am},…,{qn-1,am,qn,a1},{qn-1,am,qn,a2},…,{qn-1,am,qn,am}]]。
[0108] Then the obtained training sample data set is:
[0109] [[{q1,a1},{q1,a2},{q1,a3},…{q1,am}]],
[0110] [{q2,a1},{q2,a2},{q2,a3},…{q2,am}]],
[0111] ……
[0112] [{qn,a1},{qn,a2},{qn,a3},…{qn,am}]],
[0113] [[{q1,a1,q2,a1},{q1,a1,q2,a2},…,{q1,a1,q2,am},…,{q1,a2,q2,a1},{q1,a2,q2,a2},…,{q1,a2,q2,am},…,{q1,am,q2,a1},{q1,am,q2,a2},…,{q1,am,q2,am}]],
[0114] ……
[0115] [{qn-1,a1,qn,a1},{qn-1,a1,qn,a2},…,{qn-1,a1,qn,am},…,{qn-1,a2,qn,a1},{qn-1,a2,qn,a2},…,{qn-1,a2,qn,am},…,{qn-1,am,qn,a1},{qn-1,am,qn,a2},…,{qn-1,am,qn,am}]]。
[0116] In the embodiment of the present application, data enhancement and feature extraction may also be performed on the training sample data set.
[0117] See also Figure 5 , Figure 5 A flowchart of a contract clause retrieval method provided in an embodiment of the present application. The contract clause retrieval method includes:
[0118] S501: Receive a target question, where the target question is used to retrieve clauses in a contract.
[0119] In an embodiment of the present application, when a user needs to retrieve contract terms, a contract term retrieval request is input through a user terminal, and the contract term retrieval request includes a target question. The user terminal sends the contract term retrieval request to a computer device, so that the computer device uses a target retrieval model to retrieve relevant answers for the target question in the contract term retrieval request.
[0120] In an embodiment of the present application, in order to optimize the performance of the target retrieval model, the target retrieval model can output an answer that has a high degree of match with the target question. After receiving the target question, a prompt word can be added to the target question so that the target retrieval model can better understand the target question and guide the target retrieval model to extract relevant information from the training sample data set. For example, if the target question entered by the user is about the breach of contract clause in the contract, the prompt word may include keywords such as "breach of contract" and "liability". Then, the keywords included in the prompt word can help the target retrieval model quickly locate the relevant contract terms and give an accurate answer.
[0121] In the embodiment of the present application, the prompt words may include task description, background knowledge, search path, task instruction, etc. When using the target search model to retrieve the answer corresponding to the target question, the prompt words can be used to guide the model to output the expected answer by adjusting the prompt words without changing the model structure or retraining the model.
[0122] S502: Obtain a target answer corresponding to the target question using the target retrieval model.
[0123] In the embodiment of the present application, the target retrieval model is Figure 2 The model obtained by the model training method shown. Using the target retrieval model to obtain the target answer corresponding to the target question includes: determining a feature vector set and a corresponding type label based on the target question; based on the feature vector set and the type label, using the target retrieval model to obtain a target value set corresponding to the target question; and determining the target answer corresponding to the target question based on the target value set.
[0124] In an embodiment of the present application, obtaining a feature vector set based on the target problem includes: obtaining a feature data set based on the target problem; and mapping feature data in the feature data set to a vector space to obtain a feature vector set.
[0125] In an embodiment of the present application, based on a feature vector set and a type label, a target value set corresponding to a target question is obtained using a target retrieval model, including: obtaining at least one target predicted answer corresponding to a contract clause in a contract type to which the target question belongs based on the type label; and determining a target value set corresponding to at least one target predicted answer.
[0126] In an embodiment of the present application, obtaining a target answer corresponding to a target question based on a target value set includes: sorting all target values in the target value set to obtain a target value list; determining an information tuple corresponding to the largest target value based on the target value list; and determining the true answer corresponding to the information tuple corresponding to the largest target value as the target answer.
[0127] In an embodiment of the present application, before using the target retrieval model, the contract clause retrieval method also includes a step of preprocessing historical contract data.
[0128] In the embodiment of the present application, in order to limit the search scope of the target search model, the historical contract data can be pre-vectorized to construct an index, and the processed historical contract data can be stored in the database. Preprocessing the historical contract data includes: loading the historical contract data to obtain contract text data; preprocessing the contract text data; extracting contract metadata; obtaining a contract clause text set based on the contract text data; and obtaining a corresponding vector feature set based on the contract clause text set.
[0129] In an embodiment of the present application, historical contract data in a private domain may be loaded. The historical contract data includes contract data in multiple formats. In order to facilitate subsequent processing, the contract data in multiple formats may be processed into contract data in the same format to obtain contract text data.
[0130] In an embodiment of the present application, preprocessing the contract text data includes filtering, compressing and formatting the contract text data to ensure the quality of the contract text data.
[0131] In an embodiment of the present application, obtaining a contract clause text set based on the contract text data includes segmenting the contract text into a contract clause text set. For example, the contract text data is segmented by a segmentation character to obtain a plurality of contract clause texts. Common segmentation characters include: a period, an exclamation mark, a question mark, a line break, etc.
[0132] In an embodiment of the present application, obtaining a corresponding vector feature set based on a contract clause text set includes: adding a type label to the contract clause; preprocessing the contract clause to obtain a corresponding feature data set; mapping the feature data in the feature data set to a vector space to obtain a feature vector set; and using a target retrieval model based on the feature vector set and the contract type label to obtain a vector feature value set corresponding to the contract clause text.
[0133] Specifically, after adding a type label to the contract terms, a feature data set is obtained by replacing the target words (such as pronouns, Party A, Party B) in the contract terms text with the extracted contract metadata (such as contract name, signing time, contract storage path, paragraph number, "Party A" and its name, "Party B" and its name); the feature data in the feature data set is mapped to the vector space to obtain a feature vector set. Based on the feature vector set and the contract type label, a target retrieval model is used to obtain a set of vector feature values corresponding to the contract terms text. In an embodiment of the present application, the use of extracted contract metadata can improve the accuracy of contract terms retrieval; by using the target retrieval model, the contract terms text can be converted into a vector of preset dimensions, which can capture the semantic relationship between the target question and the target answer, providing a basis for subsequent terms retrieval.
[0134] In the embodiment of the present application, an index can also be constructed for the contract terms in the preprocessed historical contract data and the contract terms can be stored in the database. Specifically, define the index structure; create an index according to the index structure; write the contract terms into the index. For example, based on a comprehensive consideration of multiple factors such as business scenarios, hardware, and performance requirements, Elasticsearch is selected as a vector database for storing a vector feature set corresponding to a contract terms text set, MySQL is selected as a relational database for storing structured data of contract text, and XSK object storage is selected as contract file storage.
[0135] For example, in the embodiment of the present application, the index structure may be defined as follows:
[0136] Field Name type Remark contractClause text Contract terms text contractClauseVector keyword Contract terms text vector contractName text Contract Name clauseOrder date Signing time companyName text Partners fileName text Reference contract document name filePath keyword Contract file storage path
[0137] And create the above indexes in Elasticsearch according to the above index structure, specify the index name as contract-clause, set the number of shards and replicas, etc. Sharding is the basis for Elasticsearch to distribute and expand data. Each index can be divided into multiple shards, and each shard is an independent index. Sharding allows Elasticsearch to share data and load by adding more nodes, thereby improving processing capabilities. Replicas are copies of shards, which can improve data availability and concurrent processing capabilities of search queries. Each shard can have one or more replicas, which are distributed on different nodes, to ensure that data will not be lost and improve query throughput and response speed.
[0138] Figure 6 600 may include a plurality of functional modules composed of computer program segments. The computer programs of the various program segments in the model training device 600 may be stored in a memory of a computer device and executed by at least one processor to perform (see Figure 2 Description) Function for model training.
[0139] In this embodiment, the model training device 600 can be divided into multiple functional modules according to the functions it performs. The functional modules may include: a processing module 601 and a determination module 602. The module referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the model training device 600 can be used to implement the following Figure 2 The model training method shown in Figure 6 As shown, the model training device 600 is applied to a computer device (such as Figure 1 In the computer device shown in FIG. 1 , the model training device 600 includes:
[0140] The processing module 601 is used to obtain a training sample data set, wherein the training sample data set includes a plurality of information tuples, each of which includes a question and a corresponding true answer;
[0141] Processing module 601, used to calculate the accuracy parameter and frequency parameter of the information tuple of the training sample data set;
[0142] A determination module 602, configured to determine a first target value corresponding to a true answer of the information tuple based on an initial precision parameter and an initial frequency parameter of the information tuple and the calculated precision parameter and frequency parameter;
[0143] The processing module 601 is also used to predict the questions in the information tuple using the initial model to obtain corresponding predicted answers;
[0144] The determination module 602 is further used to determine a second target value corresponding to the predicted answer based on the accuracy parameter and the frequency parameter and the initial accuracy parameter and the initial frequency parameter;
[0145] The determination module 602 is further configured to determine a loss value based on a difference between the first target value and the second target value;
[0146] The processing module 601 is further used to adjust the initial accuracy parameter and the initial frequency parameter based on the loss value, and train the initial model using the adjusted initial accuracy parameter and the adjusted initial frequency parameter.
[0147] In an embodiment of the present application, the processing module 601 is also used to collect question and answer data and generate a question and answer data set; obtain a first data set based on the question and answer data set, wherein the first data set includes a first information tuple, and the first information tuple includes a question and a corresponding true answer; obtain a second data set based on the first data set, wherein the second data set includes a second information tuple, and the second information tuple includes multiple questions and corresponding multiple true answers; and obtain the training sample data set based on the first data set and the second data set.
[0148] In the embodiment of the present application, the processing module 601 is further used to calculate a first precision parameter and a first frequency parameter of the first information tuple; and to calculate a second precision parameter and a second frequency parameter of the second information tuple.
[0149] In an embodiment of the present application, the processing module 601 is also used to match the first information tuple with the questions in the question and answer data set and the corresponding true answers to obtain a first probability that the first information tuple appears in the question and answer data set; determine the first probability as a first precision parameter corresponding to the first information tuple; match the questions in the first data set with the questions in the question and answer data set and the corresponding true answers to obtain a second probability that the questions in the first data set appear in the question and answer data set; and determine the second probability as a first frequency parameter corresponding to the first information tuple.
[0150] In an embodiment of the present application, the processing module 601 is also used to determine the first information tuple corresponding to each question in the second information tuple, and the first precision parameter corresponding to the determined first information tuple; determine the second precision parameter based on the determined first precision parameter; determine the first information tuple corresponding to each question in the second information tuple, and the first frequency parameter corresponding to the determined first information tuple; and determine the second frequency parameter based on the determined first frequency parameter.
[0151] In an embodiment of the present application, the processing module 601 is also used to obtain a first product based on the first precision parameter and the initial precision parameter; obtain a second product based on the first frequency parameter and the initial frequency parameter; and determine the first target value based on the first product and the second product.
[0152] In an embodiment of the present application, the processing module 601 is also used to obtain a third product based on the second precision parameter and the initial precision parameter; obtain a fourth product based on the second frequency parameter and the initial frequency parameter; and determine the second target value based on the third product and the fourth product.
[0153] In an embodiment of the present application, each information tuple also includes a type tag, and the type tag indicates the contract type to which the clause corresponding to the question in each information tuple belongs. The processing module 601 is also used to determine the corresponding type tag and feature vector set based on the question in the information tuple; based on the feature vector set and the type tag, the initial retrieval model is used to obtain the predicted answer corresponding to the question in the information tuple.
[0154] Figure 7 700 may include a plurality of functional modules composed of computer program segments. The computer programs of the various program segments in the contract clause retrieval device 700 may be stored in a memory of a computer device and executed by at least one processor to perform (see Figure 5 Description) Contract terms retrieval function.
[0155] In this embodiment, the contract clause retrieval device 700 can be divided into multiple functional modules according to the functions it performs. The functional modules may include: a receiving module 701 and a processing module 702. The module referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the contract clause retrieval device 700 can be used to implement the following Figure 5 The contract terms retrieval method shown in the figure. Figure 7 As shown, the contract clause retrieval device 700 is applied to a computer device (such as Figure 1 In the computer device shown in FIG. 1 , the contract clause retrieval device 700 includes:
[0156] The receiving module 701 is used to receive a target question, wherein the target question is used to retrieve clauses in a contract;
[0157] The processing module 702 is used to obtain a target answer corresponding to the terms in the target question using a target retrieval model.
[0158] In the embodiment of the present application, the target question includes prompt words related to the clause.
[0159] In an embodiment of the present application, the processing module 702 is also used to determine a feature vector set and a corresponding type label based on the target question; based on the feature vector set and the type label, use the target retrieval model to obtain a target value set corresponding to the target question; and determine a target answer corresponding to the target question based on the target value set.
[0160] In the embodiment of the present application, the processing module 702 is further used to obtain a feature data set based on the target problem; and map the feature data in the feature data set to a vector space to obtain the feature vector set.
[0161] In an embodiment of the present application, based on the feature vector set and the type label, the processing module 702 is also used to obtain at least one target predicted answer corresponding to the contract clause in the contract type to which the target question belongs based on the type label; and determine a target value set corresponding to the at least one target predicted answer.
[0162] In an embodiment of the present application, the processing module 702 is also used to sort all target values in the target value set to obtain a target value list; determine the information tuple corresponding to the largest target value based on the target value list; and determine the true answer corresponding to the information tuple corresponding to the largest target value as the target answer.
[0163] Figure 8 1 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. As shown in the figure, the computer device 1 can be a server, for example, the computer device 1 can be a central server, an edge server, or a local server in a local data center. Each computer device 1 may include a communication module 101, a memory 102, a processor 103, an input / output (I / O) interface 104 and a bus 105. The processor 103 is coupled to the communication interface 101, the memory 102, and the I / O interface 104 respectively through the bus 105.
[0164] The communication module 101 may include a wired communication module and / or a wireless communication module. The wired communication module may provide one or more wired communication solutions such as universal serial bus (USB), controller area network bus (CAN, Controller Area Network). The wireless communication module may provide one or more wireless communication solutions such as wireless fidelity (wireless fidelity, Wi-Fi), bluetooth (bluetooth, BT), mobile communication network, frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR), etc.
[0165] The memory 102 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM). The random access memory can be directly read and written by the processor 103, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data. The random access memory may include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), etc.
[0166] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 103. The non-volatile memory may include a disk storage device and a flash memory.
[0167] The memory 102 is used to store one or more computer programs. The one or more computer programs are configured to be executed by the processor 103. The one or more computer programs include multiple instructions, and when the multiple instructions are executed by the processor 103, the model training method and the contract clause retrieval method executed on the computer device 1 can be implemented.
[0168] In other embodiments, the computer device 1 further includes an external memory interface for connecting to an external memory to expand the storage capacity of the computer device 1 .
[0169] The processor 103 may include one or more processing units, for example, the processor 103 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0170] The processor 103 provides computing and control capabilities. For example, the processor 103 is used to execute computer programs stored in the memory 102 .
[0171] The I / O interface 104 is used to provide a channel for user input or output. For example, the I / O interface 104 can be used to connect various input and output devices, such as a mouse, keyboard, touch device, display screen, etc., so that the user can enter information or visualize information.
[0172] The bus 105 is at least used to provide a channel for mutual communication among the communication module 101 , the memory 102 , the processor 103 , and the I / O interface 104 in the computer device 1 .
[0173] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the computer device 1. In other embodiments of the present application, the computer device 1 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0174] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. The computer program includes program instructions. The method implemented when the program instructions are executed can refer to the methods in the above-mentioned embodiments of the present application.
[0175] The computer-readable storage medium may be an internal memory of the electronic device described in the above embodiment, such as a hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device.
[0176] In some embodiments, the computer-readable storage medium may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the electronic device, etc.
[0177] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0178] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0179] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0180] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0181] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A model training method, characterized in that: The method comprises: Calculate the precision parameter and frequency parameter of the information tuple of the training sample data set; Determine a first target value corresponding to a true answer of the information tuple based on an initial precision parameter and an initial frequency parameter of the information tuple and the calculated precision parameter and frequency parameter; Using the initial model to predict the questions in the information tuple, and obtaining corresponding predicted answers; Determining a second target value corresponding to the predicted answer based on the accuracy parameter and the frequency parameter as well as the initial accuracy parameter and the initial frequency parameter; A loss value is determined based on the difference between the first target value and the second target value, the initial precision parameter and the initial frequency parameter are adjusted based on the loss value, and the initial model is trained using the adjusted initial precision parameter and the adjusted initial frequency parameter.
2. The model training method according to claim 1, characterized in that: The method comprises: Collect question-answering data and generate question-answering datasets; Obtaining a first data set based on the question-answer data set, wherein the first data set includes a first information tuple, and the first information tuple includes a question and a corresponding true answer; Obtaining a second data set based on the first data set, wherein the second data set includes a second information tuple, and the second information tuple includes a plurality of questions and a plurality of corresponding true answers; and The training sample data set is obtained based on the first data set and the second data set.
3. The model training method according to claim 2, characterized in that: The calculation of the accuracy parameter and frequency parameter of the information tuple of the training sample data set includes: calculating a first precision parameter and a first frequency parameter of the first information tuple; and A second precision parameter and a second frequency parameter of the second information tuple are calculated.
4. The model training method according to claim 3, characterized in that: The calculating of the first precision parameter and the first frequency parameter of the first information tuple comprises: Matching the first information tuple with questions in the question-and-answer dataset and corresponding true answers to obtain a first probability of the first information tuple appearing in the question-and-answer dataset; Determine the first probability as a first precision parameter corresponding to the first information tuple; Matching the questions in the first data set with the questions in the question-and-answer data set and the corresponding true answers to obtain a second probability that the questions in the first data set appear in the question-and-answer data set; Determine the second probability as a first frequency parameter corresponding to the first information tuple.
5. The model training method according to claim 4, characterized in that: The calculating of the second precision parameter and the second frequency parameter of the second information tuple comprises: Determine a first information tuple corresponding to each question in the second information tuple, and a first precision parameter corresponding to the determined first information tuple; determining the second precision parameter based on the determined first precision parameter; Determine a first information tuple corresponding to each question in the second information tuple, and a first frequency parameter corresponding to the determined first information tuple; and The second frequency parameter is determined based on the determined first frequency parameter.
6. The model training method according to claim 4, characterized in that: Determining the first target value corresponding to the true answer of the information tuple based on the initial precision parameter and the initial frequency parameter of the information tuple and the calculated precision parameter and the frequency parameter comprises: Obtaining a first product based on the first precision parameter and the initial precision parameter; obtaining a second product based on the first frequency parameter and the initial frequency parameter; and The first target value is determined based on the first product and the second product.
7. The model training method according to claim 5, characterized in that: The determining the second target value corresponding to the predicted answer based on the accuracy parameter and the frequency parameter and the initial accuracy parameter and the initial frequency parameter comprises: Obtaining a third product based on the second precision parameter and the initial precision parameter; obtaining a fourth product based on the second frequency parameter and the initial frequency parameter; and The second target value is determined based on the third product and the fourth product.
8. The model training method according to claim 1, characterized in that: The information tuple also includes a type tag, which indicates the type of contract to which the clause corresponding to the question in the information tuple belongs. The using of the initial model to predict the question in the information tuple to obtain the corresponding predicted answer includes: Based on the questions in the information tuple, determining corresponding type labels and feature vector sets; Based on the feature vector set and the type label, the initial retrieval model is used to obtain a predicted answer corresponding to the question in the information tuple.
9. A contract clause retrieval method, characterized in that: The method comprises: receiving a target question, wherein the target question is used to retrieve clauses in a contract; A target answer corresponding to the terms in the target question is obtained by using a target retrieval model, wherein the target retrieval model is obtained by executing the model training method described in any one of claims 1 to 8.
10. The contract clause retrieval method according to claim 9, characterized in that: The target question includes prompt words related to the clause.
11. The contract clause retrieval method according to claim 9 or 10, characterized in that: The obtaining of a target answer corresponding to the target question by using the target retrieval model comprises: Determine a set of feature vectors and corresponding type labels based on the target problem; Based on the feature vector set and the type label, using the target retrieval model to obtain a target value set corresponding to the target question; A target answer corresponding to the target question is determined based on the target value set.
12. The contract clause retrieval method according to claim 11, characterized in that: The obtaining of a feature vector set based on the target problem comprises: Obtain a feature data set based on the target problem; The feature data in the feature data set is mapped to a vector space to obtain the feature vector set.
13. The contract clause retrieval method according to claim 11, characterized in that: The obtaining of a target value set corresponding to the target question by using the target retrieval model based on the feature vector set and the type label includes: Acquire at least one target predicted answer corresponding to a contract clause in the contract type to which the target question belongs based on the type label; Determine a target value set corresponding to the at least one target prediction answer.
14. The contract clause retrieval method according to claim 13, characterized in that: Determining the target answer corresponding to the target question based on the target value set includes: Sort all target values in the target value set to obtain a target value list; Determine the information tuple corresponding to the maximum target value based on the target value list; The true answer corresponding to the information tuple corresponding to the maximum target value is determined as the target answer.
15. A model training device, characterized in that: include: A processing module, used for calculating the precision parameter and frequency parameter of the information tuple of the training sample data set; A determination module, configured to determine a first target value corresponding to a true answer of the information tuple based on an initial precision parameter and an initial frequency parameter of the information tuple and the calculated precision parameter and frequency parameter; The processing module is further used to predict the questions in the information tuple using the initial model to obtain corresponding predicted answers; The determination module is further used to determine a second target value corresponding to the predicted answer based on the accuracy parameter and the frequency parameter and the initial accuracy parameter and the initial frequency parameter; The determination module is further configured to determine a loss value based on a difference between the first target value and the second target value; The processing module is further used to adjust the initial accuracy parameter and the initial frequency parameter based on the loss value, and train the initial model using the adjusted initial accuracy parameter and the adjusted initial frequency parameter.
16. A contract clause retrieval device, characterized in that: include: A receiving module, used for receiving a target question, wherein the target question is used for retrieving clauses in a contract; The processing module is used to obtain a target answer corresponding to the terms in the target question by using a target retrieval model.
17. A computer device, characterized in that: The computer device includes a processor and a memory, and when the processor executes the computer program stored in the memory, it implements the model training method as described in any one of claims 1 to 8, or the contract clause retrieval method as described in any one of claims 9 to 14.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and when the at least one instruction is executed by the processor, it implements the model training method as described in any one of claims 1 to 8, and implements the contract clause retrieval method as described in any one of claims 9 to 14.
