A legal text generation system and method based on intelligent interaction
By optimizing the label and keyword correlation of historical legal texts, building a legal text template database, and using large language models to generate legal texts, the problem of legal text not matching user needs in the existing system is solved, and a higher level is achieved user experience and system efficiency.
Patent Information
- Application Number
- CN202410946144.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-07-15
AI Technical Summary
When the existing legal text generation system generates legal text, it is difficult to ensure that the generated text fits with the topics required by the user, resulting in a reduced user experience.
By collecting application data of historical legal texts, extracting the usage scenarios of each legal text, calculating the labels of each legal text, and classifying and marking the legal texts. Use the correlation between keywords and legal tags to optimize, remove keywords with low correlation, build a template database of legal texts, and use a large language model to generate legal texts that match user needs.
The adaptability of generated legal texts to user needs is improved, the user experience is enhanced, and the system's work efficiency is improved through the optimization of the correlation between labels and keywords.
Smart Images

Figure CN118886406B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text analysis, and in particular to a legal text generation system and method based on intelligent interaction. Background Art
[0002] With the rapid development and progress of science and technology, artificial intelligence technology has become more and more mature, and has gradually realized functions such as intelligent question answering and human-computer interaction. In the early days, text generation systems used predefined rules and templates to generate text. These methods rely on rules written by experts and are highly controllable, but lack flexibility and generation diversity. With the improvement of computing power, statistical methods have begun to be applied to language modeling. The n-gram model generates text by counting the frequency of occurrence of word sequences, which has better flexibility than the rule method. With the rapid development of computer programming languages and algorithms, algorithms for text generation are emerging one after another, such as Naive Bayes, Support Vector Machines, Hidden Markov Models, etc.; with the explosive growth of data volume and the improvement of computing power, deep learning technology has been rapidly developed, thus promoting the progress in the field of large language models. When automatically generating legal texts required by users, the algorithm will perform a large amount of computational analysis on the words of historical legal texts. However, as the amount of analyzed word data increases, it contains more words with low relevance and stop words that are not extracted, which makes the legal text generated by the system have certain errors and are not in line with the user's requirements. The theme is not in line with the user's requirements, which greatly reduces the user experience. Therefore, it is crucial to make the generated legal text more in line with the theme. Summary of the invention
[0003] The purpose of the present invention is to provide a legal text generation system and method based on intelligent interaction to solve the problems raised in the above background technology.
[0004] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0005] A legal text generation method based on intelligent interaction, the method comprising the following steps:
[0006] S100, collecting application data of historical legal texts, generating legal tags based on the application data of historical legal texts to mark the legal texts;
[0007] Furthermore, the specific steps of generating legal tags based on the application data of historical legal texts to mark the legal texts are as follows:
[0008] S101, collect application data of historical legal texts, extract the application scenario of each historical legal text as {C1, C2, C3, ..., C n}, C1, C2, C3, ..., Cn Indicates the 1st, 2nd, 3rd, ..., nth application scenarios of each extracted legal text, where n is a positive integer; the number of different application scenarios of each legal text is counted to obtain the number of times each legal text is used in different application scenarios, and the proportion of different scenarios in the total number of scenarios is calculated. The formula is: In the formula, T represents the proportion of each application scenario of the calculated legal text in the total number of scenarios, S i Indicates the number of each application scenario of the legal text, S 总 Represents the total number of application scenarios of legal texts, i∈(1,n); extracts the application scenarios with the largest proportion as the application features of legal texts;
[0009] S102: After statistics are collected on the application scenarios of each legal text in history, the application features of each legal text are obtained as {T_ap1, T_ap2, T_ap3, ..., T_ap m}, T_ap1, T_ap2, T_ap3,..., T_ap m represents the application features of the 1st, 2nd, 3rd, ..., mth legal texts in the collected history. The application features of each legal text are compared, and the legal texts with the same application features are classified into the same category of legal texts. Finally, the legal texts in the history are divided into {Tp1, Tp2, Tp3, ..., Tp h}, Tp1, Tp2, Tp3,..., Tp h It means that the legal texts in history are divided into the 1st, 2nd, 3rd, ..., hth categories, where h is a positive integer;
[0010] S103. After classifying the legal texts in history, the application features of each type of legal text are used as labels for labeling the legal texts, and the specific labels of each legal text are obtained as follows: Represents the label of the 1st, 2nd, 3rd, ..., jth legal text in the collected history, where j is a positive integer.
[0011] After collecting the legal texts in history, extract the usage scenarios of each legal text, calculate the labels of each legal text, and classify and label the legal texts; when reviewing or analyzing the legal texts, you can quickly search based on the labels of different types of legal texts;
[0012] S200, searching for keywords in the historical legal texts and removing stop words in the legal texts, converting the extracted keywords and legal labels into feature vectors, and calculating the correlation between each keyword and legal label;
[0013] Furthermore, the specific steps for calculating the relevance between each keyword and legal tag are as follows:
[0014] S201, after labeling the collected history with tags, extract the words in the legal text with the same tag, and obtain the words under each tag as {Z1, Z2, Z3, ..., Z k}, Z1, Z2, Z3, ..., Z k represents the 1st, 2nd, 3rd, ..., kth words in the legal text under each label extracted, where k is a positive integer; the semantic contribution of each word in the legal text is calculated, and the number and information content of each word in the legal text are extracted. The formula is:
[0015]
[0016] In the formula, Se represents the calculated phonetic contribution of each word, qu represents the number of each word in the legal text, and am represents the information content of each word;
[0017] S202, the semantic contribution of all types of words under each extracted label is calculated, and the semantic contribution of each word is obtained as {Se1, Se2, Se3, ..., Se k}, Se1, Se2, Se3,..., Se k The semantic contribution of the 1st, 2nd, 3rd, ..., kth words in the legal text is represented. The calculated phonetic contribution of the k words is sorted from small to large, and the difference in the semantic contribution of two adjacent words after sorting is calculated. The formula is:
[0018] Se_c=Se after -Se before
[0019] In the formula, Se_c represents the difference in semantic contribution between two adjacent words, Se after Indicates the semantic contribution of the latter word between two adjacent words, Se before It represents the semantic contribution of the previous word in two adjacent words. After calculation, the difference of the phonetic contribution of all words is
[0020] {Se_c1, Se_c2, Se_c3,..., Se_c k-1}, Se_c1, Se_c2, Se_c3,..., Se_c k-1 represents the calculated semantic contribution difference between the 1st, 2nd, 3rd, ..., k-1th two adjacent words, compares the calculated k-1 semantic contribution difference, and selects the semantic contribution of the two words corresponding to the maximum value as the transition point (Ju before , Ju after ), Ju beforeIndicates the previous transition point corresponding to the maximum difference in semantic contribution, Ju after Indicates the next transition point corresponding to the maximum difference in semantic contribution; when Se≤Ju before When Se≥Ju after When the corresponding word is a stop word, the corresponding word is judged as a stop word; the keywords of the legal text under each label are searched;
[0021] When extracting words from legal texts, there are many stop words such as modal particles and conjunctions. These words have no specific meaning and cannot reflect the content and meaning of the legal text. Therefore, when analyzing the words in the legal text, it is necessary to find such stop words and remove them. This can reduce errors in the analysis of the content of the legal text and avoid large deviations in the generated legal text.
[0022] S203. After finding the keywords in the legal text, the word frequency vectors of all types of keywords in the legal text are calculated. The formula is:
[0023]
[0024] In the formula, Ve represents the calculated word frequency vector of each keyword, qu represents the number of each word in the legal text, and qu_key represents the number of each keyword in the legal text; the word frequency vector of each keyword is calculated;
[0025] Convert each label text into a vector value, extract S100 the proportion T of all usage scenarios of each label in the legal text, and use the proportion of all usage scenarios of each label in the legal text as the frequency vector of the label;
[0026] S204, extract the frequency vector of each label and the word frequency vector of different keywords under each label, use the frequency vector of each label as an independent variable, and the word frequency vector of the keyword as a variable to draw a curve graph, calculate the linear regression equation of each curve graph, and assume that the linear regression equation expression of each keyword is Ve=a×T+b, where Ve represents the word frequency vector of each keyword of the variable, T represents the frequency vector of the independent variable label, a represents the slope of the linear regression, and b represents the intercept of the linear regression; calculate the values of a and b in the expression, and the formula is:
[0027]
[0028] b=Ve pi -a×T pi
[0029] In the formula, R represents the number of legal texts contained in each label; T pi Ve represents the average frequency vector of the same label in R legal texts; pirepresents the average frequency vector of keywords in R legal texts;
[0030] S205, after calculation, a linear regression equation is obtained in the curve graph of the tag and different keywords, and the slope a in the linear regression equation is used as the correlation between different keywords and the corresponding tag. The different keywords in each tag are plotted and calculated to obtain the correlation between each tag and the keywords contained in the tag, specifically Tp e →{a1, a2, a3, ..., a g}, a1, a2, a3, ..., a g Indicates the label Tp e The relevance of the 1st, 2nd, 3rd, ..., gth keywords included in the h tags and the relevance of the corresponding tags are calculated.
[0031] S300, extracting the label and keyword data in each legal text, and calculating the correlation threshold between the keyword and the legal label;
[0032] Furthermore, the specific steps for calculating the relevance threshold between keywords and legal tags are as follows:
[0033] S301, extracting the calculated relevance between each keyword and tag, and calculating the relevance threshold between each tag and the corresponding keyword, the formula is:
[0034]
[0035] In the formula, a_y represents the calculated association threshold between each tag and the corresponding keyword, a represents the association between the extracted tag and each keyword, st_a represents the standard deviation of g associations, and g represents the number of associations between the extracted tags and keywords. After calculating the association threshold between each tag and the corresponding keyword, the h association thresholds are obtained, which are {a_y1, a_y2, a_y3, ..., a_y h}, a_y1, a_y2, a_y3,..., a_y h Indicates the relevance threshold between the 1st, 2nd, 3rd, ..., hth tags and keywords.
[0036] S400, using the calculated relevance threshold to screen and optimize the relevance between each keyword and the legal tag, and removing keywords with low relevance in each tag;
[0037] Furthermore, the specific steps to remove keywords with low relevance in each tag are:
[0038] S401, using the correlation threshold of each tag calculated in S300 to judge and filter the correlation between the calculated tags and keywords, specifically: when a>a_y, it is judged that the correlation between the corresponding keyword and the tag is close; when a≤a_y, it is judged that the correlation between the corresponding keyword and the tag is weak, and the keywords with weak correlation in the tag are removed;
[0039] S402: The keywords contained in each tag are judged, and after screening, the keywords contained in the filtered tags are {key1, key2, key3, ..., key f},key1,key2,key3,...,key f It represents the 1st, 2nd, 3rd, ..., fth keywords with close correlation contained in the labels after screening, where f is a positive integer; the template database of legal texts is constructed using the screened keywords and labels.
[0040] After calculating the correlation between the keywords and tags of the legal text, the correlation threshold in the history can be used to search for keywords with low correlation, further remove keywords in the legal text that have little correlation with the main content, and further enhance the fit between the generated legal text and user needs.
[0041] S500. The filtered keywords are trained using a large language model to generate a corresponding legal text template for each label. The user provides the requirements for the legal text to be generated, and the labels of the legal text in the database are matched according to the user's needs. The large language model is used to infer and predict each keyword in the legal text under the corresponding label to generate a semantically coherent legal text.
[0042] Furthermore, the specific steps for matching the labels of legal texts in the database according to user requirements are as follows:
[0043] S501, collect the user's requirement statements for the legal text, extract the words in the requirement statements, compare the words in the user's requirements with the template database, find the keywords in each tag that are the same as the user's requirement words, and calculate the similarity between the user's requirements and different tags in the template database. The formula is:
[0044]
[0045] In the formula, Si represents the similarity between the user's requirements and each tag, a same represents the relevance of keywords in each tag that are the same as the words required by the user, and q represents the number of keywords in each tag that are the same as the words required by the user;
[0046] The system collects the user's requirements for the legal text to be generated, extracts the words in the requirements, and uses the similarity between the words and the keywords contained in each label to determine the type of legal text with the label that meets the user's requirements; ensuring that the generated legal text meets user needs and enhances the user experience.
[0047] S502: After calculating, the similarity between each tag and the user's requirement is obtained, all similarities are compared, and the tag with the highest similarity is selected and the corresponding keywords are used to generate the legal text required by the user.
[0048] A legal text generation system based on intelligent interaction, the legal text generation system includes a data collection module, a marking module, a correlation calculation module, a screening module and a generation module;
[0049] The data collection module is used to collect data on historical legal texts, including usage scenario data and text data of legal texts;
[0050] The labeling module is used to analyze the legal texts collected in history, calculate the label of each legal text, and label the legal text with the label;
[0051] The association calculation module is used to perform vector conversion on the keywords and tags contained in each tag, draw a curve graph, and calculate the linear regression equation of each keyword and tag;
[0052] The screening module is used to calculate the relevance threshold of each tag using historical data, and use the relevance threshold to judge the relevance between each tag and the keyword, and remove keywords with low relevance;
[0053] The generation module is used to extract words from the user's requirement statement, calculate the similarity between the user's requirement and each tag, select the tag with the highest similarity and use the keyword to generate the legal text.
[0054] The labeling module includes a label calculation unit and a labeling unit;
[0055] The label calculation unit is used to analyze the usage scenario data of the historical legal texts and select the scenario with the largest usage percentage as the label;
[0056] The marking unit is used to mark each legal text in the history using the calculated label.
[0057] The relevance calculation module includes a stop word removal unit, a text conversion unit and a linear regression equation calculation unit;
[0058] The stop word removal unit is used to extract the words in the legal text in the history, calculate the semantic contribution of each word, and find the stop words with low semantic contribution to remove;
[0059] The text conversion unit is used to calculate word frequency vectors for keywords in the legal text, calculate frequency vectors for tags, and convert text data into vector data;
[0060] The linear regression equation calculation unit is used to extract the vectors after the tags and keywords are converted, draw a curve graph, calculate the linear regression equation using the data in the curve graph, and use the slope in the equation as the correlation between the tags and keywords.
[0061] The screening module includes a threshold calculation unit and a judgment unit;
[0062] The threshold calculation unit is used to calculate the relevance threshold of each tag according to the calculated relevance between each tag and the corresponding keyword;
[0063] The judgment unit is used to judge the relevance between each tag and the corresponding keyword by using the calculated relevance threshold of each tag, and remove keywords with low relevance.
[0064] Compared with the prior art, the beneficial effects achieved by the present invention are:
[0065] 1. The present invention calculates the labels of legal texts by using the usage scenarios of legal texts in history, and classifies and marks the legal texts by using the labels. When reviewing or analyzing the legal texts, fast searches can be performed based on the labels of different types of legal texts, thereby enhancing the working efficiency of the system.
[0066] 2. When the present invention extracts words from legal texts, it calculates the semantic contribution of each word, searches for stop words in the legal texts and removes them, thereby obtaining keywords in the legal texts, and using the keywords to reflect the theme of the legal texts.
[0067] 3. The present invention further calculates the relevance of the optimized legal text, and optimizes the keywords of the legal text according to the relevance threshold in the history, so as to enhance the fit between the generated legal text and the user's needs when the system generates the legal text. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0069] Figure 1 It is a module distribution diagram of a legal text generation system based on intelligent interaction of the present invention;
[0070] Figure 2 It is a schematic diagram of the steps of a legal text generation method based on intelligent interaction of the present invention;
[0071] Figure 3 It is a keyword-label curve diagram of a legal text generation method based on intelligent interaction of the present invention. DETAILED DESCRIPTION
[0072] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0073] See also Figure 1-Figure 3 , the present invention provides a technical solution:
[0074] A legal text generation method based on intelligent interaction, the method comprising the following steps:
[0075] S100, collecting application data of historical legal texts, generating legal tags based on the application data of historical legal texts to mark the legal texts;
[0076] The specific steps for generating legal tags based on the application data of historical legal texts and marking legal texts are as follows:
[0077] S101, collect application data of historical legal texts, extract the application scenario of each historical legal text as {C1, C2, C3, ..., C n}, C1, C2, C3, ..., C n Indicates the 1st, 2nd, 3rd, ..., nth application scenarios of each extracted legal text, where n is a positive integer; the number of different application scenarios of each legal text is counted to obtain the number of times each legal text is used in different application scenarios, and the proportion of different scenarios in the total number of scenarios is calculated. The formula is: In the formula, T represents the proportion of each application scenario of the calculated legal text in the total number of scenarios, S i Indicates the number of each application scenario of the legal text, S 总 Represents the total number of application scenarios of legal texts, i∈(1,n); extracts the application scenarios with the largest proportion as the application features of legal texts;
[0078] S102, after statistics are collected on the application scenarios of each legal text in history, the application features of each legal text are obtained as {T_ap1, T_ap2, T_ap3, ..., T_apm}, T_ap1, T_ap2, T_ap3,..., T_ap m represents the application features of the 1st, 2nd, 3rd, ..., mth legal texts in the collected history. The application features of each legal text are compared, and the legal texts with the same application features are classified into the same category of legal texts. Finally, the legal texts in the history are divided into {Tp1, Tp2, Tp3, ..., Tp h}, Tp1, Tp2, Tp3,..., Tp h It means that the legal texts in history are divided into the 1st, 2nd, 3rd, ..., hth categories, where h is a positive integer;
[0079] S103. After classifying the legal texts in history, the application features of each type of legal text are used as labels for labeling the legal texts, and the specific labels of each legal text are obtained as follows: Represents the label of the 1st, 2nd, 3rd, ..., jth legal text in the collected history, where j is a positive integer.
[0080] After collecting the legal texts in history, extract the usage scenarios of each legal text, calculate the labels of each legal text, and classify and label the legal texts; when reviewing or analyzing the legal texts, you can quickly search based on the labels of different types of legal texts;
[0081] S200, searching for keywords in the historical legal texts and removing stop words in the legal texts, converting the extracted keywords and legal labels into feature vectors, and calculating the correlation between each keyword and legal label;
[0082] The specific steps for calculating the relevance between each keyword and legal tag are as follows:
[0083] S201, after labeling the collected history with tags, extract the words in the legal text with the same tag, and obtain the words under each tag as {Z1, Z2, Z3, ..., Z k}, Z1, Z2, Z3, ..., Z k represents the 1st, 2nd, 3rd, ..., kth words in the legal text under each label extracted, where k is a positive integer; the semantic contribution of each word in the legal text is calculated, and the number and information content of each word in the legal text are extracted. The formula is:
[0084]
[0085] In the formula, Se represents the calculated phonetic contribution of each word, qu represents the number of each word in the legal text, and am represents the information content of each word;
[0086] S202, the semantic contribution of all types of words under each extracted label is calculated, and the semantic contribution of each word is obtained as {Se1, Se2, Se3, ..., Se k}, Se1, Se2, Se3,..., Se k The semantic contribution of the 1st, 2nd, 3rd, ..., kth words in the legal text is represented. The calculated phonetic contribution of the k words is sorted from small to large, and the difference in the semantic contribution of two adjacent words after sorting is calculated. The formula is:
[0087] Se_c=Se after -Se before
[0088] In the formula, Se_c represents the difference in semantic contribution between two adjacent words, Se after Indicates the semantic contribution of the latter word between two adjacent words, Se before It represents the semantic contribution of the previous word in two adjacent words. After calculation, the difference of the phonetic contribution of all words is
[0089] {Se_c1, Se_c2, Se_c3,..., Se_c k-1}, Se_c1, Se_c2, Se_c3,..., Se_c k-1 represents the calculated semantic contribution difference between the 1st, 2nd, 3rd, ..., k-1th two adjacent words, compares the calculated k-1 semantic contribution difference, and selects the semantic contribution of the two words corresponding to the maximum value as the transition point (Ju before , Ju after ), Ju bef ore Indicates the previous transition point corresponding to the maximum difference in semantic contribution, Ju after Indicates the next transition point corresponding to the maximum difference in semantic contribution; when Se≤Ju before When Se≥Ju after When the corresponding word is a stop word, the corresponding word is judged as a stop word; the keywords of the legal text under each label are searched;
[0090] When extracting words from legal texts, there are many stop words such as modal particles and conjunctions. These words have no specific meaning and cannot reflect the content and meaning of the legal text. Therefore, when analyzing the words in the legal text, it is necessary to find such stop words and remove them. This can reduce errors in the analysis of the content of the legal text and avoid large deviations in the generated legal text.
[0091] S203. After finding the keywords in the legal text, the word frequency vectors of all types of keywords in the legal text are calculated. The formula is:
[0092]
[0093] In the formula, Ve represents the calculated word frequency vector of each keyword, qu represents the number of each word in the legal text, and qu_key represents the number of each keyword in the legal text; the word frequency vector of each keyword is calculated;
[0094] Convert each label text into a vector value, extract S100 the proportion T of all usage scenarios of each label in the legal text, and use the proportion of all usage scenarios of each label in the legal text as the frequency vector of the label;
[0095] S204, extract the frequency vector of each label and the word frequency vector of different keywords under each label, use the frequency vector of each label as an independent variable, and the word frequency vector of the keyword as a variable to draw a curve graph, calculate the linear regression equation of each curve graph, and assume that the linear regression equation expression of each keyword is Ve=a×T+b, where Ve represents the word frequency vector of each keyword of the variable, T represents the frequency vector of the independent variable label, a represents the slope of the linear regression, and b represents the intercept of the linear regression; calculate the values of a and b in the expression, and the formula is:
[0096]
[0097] b=Ve pi -a×T pi
[0098] In the formula, R represents the number of legal texts contained in each label; T pi Ve represents the average frequency vector of the same label in R legal texts; pi represents the average frequency vector of keywords in R legal texts;
[0099] S205, after calculation, a linear regression equation is obtained in the curve graph of the tag and different keywords, and the slope a in the linear regression equation is used as the correlation between different keywords and the corresponding tag. The different keywords in each tag are plotted and calculated to obtain the correlation between each tag and the keywords contained in the tag, specifically Tp e →{a1, a2, a3, ..., a g}, a1, a2, a3, ..., a g Indicates the label Tp e The relevance of the 1st, 2nd, 3rd, ..., gth keywords included in the h tags and the relevance of the corresponding tags are calculated.
[0100] S300, extracting the label and keyword data in each legal text, and calculating the correlation threshold between the keyword and the legal label;
[0101] The specific steps for calculating the relevance threshold between keywords and legal tags are as follows:
[0102] S301, extracting the calculated relevance between each keyword and tag, and calculating the relevance threshold between each tag and the corresponding keyword, the formula is:
[0103]
[0104] In the formula, a_y represents the calculated association threshold between each tag and the corresponding keyword, a represents the association between the extracted tag and each keyword, st_a represents the standard deviation of g associations, and g represents the number of associations between the extracted tags and keywords. After calculating the association threshold between each tag and the corresponding keyword, the h association thresholds are obtained, which are {a_y1, a_y2, a_y3, ..., a_y h}, a_y1, a_y2, a_y3,..., a_y h Indicates the relevance threshold between the 1st, 2nd, 3rd, ..., hth tags and keywords.
[0105] S400, using the calculated relevance threshold to screen and optimize the relevance between each keyword and the legal tag, and removing keywords with low relevance in each tag;
[0106] The specific steps to remove keywords with low relevance in each tag are:
[0107] S401, using the correlation threshold of each tag calculated in S300 to judge and filter the correlation between the calculated tags and keywords, specifically: when a>a_y, it is judged that the correlation between the corresponding keyword and the tag is close; when a≤a_y, it is judged that the correlation between the corresponding keyword and the tag is weak, and the keywords with weak correlation in the tag are removed;
[0108] S402: The keywords contained in each tag are judged, and after screening, the keywords contained in the filtered tags are {key1, key2, key3, ..., key f},key1,key2,key3,...,key f It represents the 1st, 2nd, 3rd, ..., fth keywords with close correlation contained in the labels after screening, where f is a positive integer; the template database of legal texts is constructed using the screened keywords and labels.
[0109] After calculating the correlation between the keywords and tags of the legal text, the correlation threshold in the history can be used to search for keywords with low correlation, further remove keywords in the legal text that have little correlation with the main content, and further enhance the fit between the generated legal text and user needs.
[0110] S500. The filtered keywords are trained using a large language model to generate a corresponding legal text template for each label. The user provides the requirements for the legal text to be generated, and the labels of the legal text in the database are matched according to the user's needs. The large language model is used to infer and predict each keyword in the legal text under the corresponding label to generate a semantically coherent legal text.
[0111] Furthermore, the specific steps for matching the labels of legal texts in the database according to user requirements are as follows:
[0112] S501, collect the user's requirement statements for the legal text, extract the words in the requirement statements, compare the words in the user's requirements with the template database, find the keywords in each tag that are the same as the user's requirement words, and calculate the similarity between the user's requirements and different tags in the template database. The formula is:
[0113]
[0114] In the formula, Si represents the similarity between the user's requirements and each tag, a same represents the relevance of keywords in each tag that are the same as the words required by the user, and q represents the number of keywords in each tag that are the same as the words required by the user;
[0115] The system collects the user's requirements for the legal text to be generated, extracts the words in the requirements, and uses the similarity between the words and the keywords contained in each label to determine the type of legal text with the label that meets the user's requirements; ensuring that the generated legal text meets user needs and enhances the user experience.
[0116] S502, after calculating, the similarity between each tag and the user's requirement is obtained, all similarities are compared, the tag with the highest similarity is selected, and the corresponding keywords are used to generate the legal text required by the user. When generating the legal text, the large language model is used to infer the sentences of the legal text, and the next word is predicted according to the keyword semantics and context information to generate a coherent text. The specific steps are:
[0117] S502-1. Input the keywords of each selected tag into the large language model, use the encoder to convert the keyword sequence into a fixed dimension vector X, and the large language model searches the input keywords in the cloud database through the network to calculate the position code of each keyword. The formula is:
[0118]
[0119] In the formula, PE represents position encoding, pos represents position, i represents dimension index, and d represents model Represents the dimension of the input keyword vector;
[0120] S502-2. The dimension vector of the keyword is transformed into three matrices of query, key and value using three linear transformations, and the attention score is calculated by scaling the dot product attention. The formula is:
[0121]
[0122] In the formula, Attention(α, β, γ) represents the attention score, α, β, and γ are the query, key, and value matrices respectively. Represents the dimension of the query and key vectors; the attention score of each keyword is calculated, and then the attention scores of multiple keywords are concatenated and linearly transformed. The formula is:
[0123] MultiHead(α,β,γ)=Concat(Attention1,...,Attention f )W
[0124] In the formula, MultiHead(α, β, γ) represents the result of concatenating the attention scores of multiple keywords and performing linear transformation, Attention represents the attention score of each keyword, and W represents linear transformation;
[0125] S502-3, after all keywords are concatenated, the concatenated results are processed by feedforward neural network, residual connection, and normalization in each layer, and finally decoded by a decoder to output the text result. The formula is:
[0126] Output = softmax(Wh)
[0127] In the formula, Output represents the predicted output result, and Wh represents the encoded data before the output; the method of S502 is used to deduce and predict the coherent words after each keyword when the legal text is generated, and step S502 is repeated to finally obtain the complete and coherent legal text required by the user.
[0128] A legal text generation system based on intelligent interaction, the legal text generation system includes a data collection module, a marking module, a correlation calculation module, a screening module and a generation module;
[0129] The data collection module is used to collect data on historical legal texts, including usage scenario data and text data of legal texts;
[0130] The labeling module is used to analyze the legal texts collected in history, calculate the label of each legal text, and label the legal text with the label;
[0131] The association calculation module is used to perform vector conversion on the keywords and tags contained in each tag, draw a curve graph, and calculate the linear regression equation of each keyword and tag;
[0132] The screening module is used to calculate the relevance threshold of each tag using historical data, and use the relevance threshold to judge the relevance between each tag and the keyword, and remove keywords with low relevance;
[0133] The generation module is used to extract words from the user's requirement statement, calculate the similarity between the user's requirement and each tag, select the tag with the highest similarity and use the keyword to generate the legal text.
[0134] The labeling module includes a label calculation unit and a labeling unit;
[0135] The label calculation unit is used to analyze the usage scenario data of the historical legal texts and select the scenario with the largest usage percentage as the label;
[0136] The marking unit is used to mark each legal text in the history using the calculated label.
[0137] The relevance calculation module includes a stop word removal unit, a text conversion unit and a linear regression equation calculation unit;
[0138] The stop word removal unit is used to extract the words in the legal text in the history, calculate the semantic contribution of each word, and find the stop words with low semantic contribution to remove;
[0139] The text conversion unit is used to calculate word frequency vectors for keywords in the legal text, calculate frequency vectors for tags, and convert text data into vector data;
[0140] The linear regression equation calculation unit is used to extract the vectors after the tags and keywords are converted, draw a curve graph, calculate the linear regression equation using the data in the curve graph, and use the slope in the equation as the correlation between the tags and keywords.
[0141] The screening module includes a threshold calculation unit and a judgment unit;
[0142] The threshold calculation unit is used to calculate the relevance threshold of each tag according to the calculated relevance between each tag and the corresponding keyword;
[0143] The determination unit is used to determine the relevance degrees of each calculated tag and the corresponding keywords by using the calculated relevance degree thresholds of each tag, and remove the keywords with low relevance degrees.
[0144] Embodiment 1: Collect and analyze the usage scenarios of legal texts in history, and calculate to obtain tags such as finance, contract, civil, and criminal; extract the words and phrases from the financial legal texts in history, and obtain the words and phrases including amount, fee, both parties, of, and; calculate the semantic contribution amounts of each word and phrase. The formula is:
[0145]
[0146] After calculation, the semantic contribution amounts of the four words and phrases are 3, 8, 10, 23, and 19 respectively. After judgment, the stop words are of and and; the keywords are amount, fee, and both parties; calculate the word frequency vectors of each keyword and the frequency vectors of the tags, and convert the text data into vector data;
[0147] Use the vector data to draw the curve graphs of the finance tag and each keyword as Figure 3 shown. Through calculation, the relevance degrees of the three keywords are 8.7, 5.7, and 1 respectively; after calculation, the relevance degree threshold is 2. After judgment, the relevance degree of "both parties" and finance is low and it is removed;
[0148] The requirements collected from the user are "Write a rental contract, which needs to include fees and amounts". After calculating the similarity, it is judged that the user needs a legal text with the tag "finance", and use the keywords included in the tag "finance" to automatically generate a legal text.
[0149] It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprises", "comprising" or any other variation thereof is intended to cover a non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device.
[0150] Finally, it should be noted that the above are only the preferred embodiments of the present invention and are not used to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, for those skilled in the art, they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A legal text generation method based on intelligent interaction, characterized by: The method comprises the following steps: S100, collecting application data of historical legal texts, generating legal tags based on the application data of historical legal texts to mark the legal texts; S200, searching for keywords in historical legal texts and removing stop words in the legal texts, converting the extracted keywords and legal labels into vector data, and calculating the correlation between each keyword and legal label; The specific steps for calculating the relevance between each keyword and legal tag are as follows: S201, after labeling the collected history with tags, extract the words in the legal text with the same tag, and obtain the words under each tag as {Z1, Z2, Z3, ..., Z k }, Z1, Z2, Z3, ..., Z k represents the 1st, 2nd, 3rd, ..., kth words in the legal text under each label extracted, where k is a positive integer; the semantic contribution of each word in the legal text is calculated, and the number and information content of each word in the legal text are extracted. The formula is: In the formula, Se represents the calculated phonetic contribution of each word, qu represents the number of each word in the legal text, and am represents the information content of each word; S202, the semantic contribution of all types of words under each extracted label is calculated, and the semantic contribution of each word is obtained as {Se1, Se2, Se3, ..., Se k }, Se1, Se2, Se3,..., Se k Indicates the semantic contribution of the 1st, 2nd, 3rd, ..., kth words in the legal text. The calculated phonetic contributions of the k words are sorted from small to large, and the difference in the semantic contribution of two adjacent words after sorting is calculated. The formula is: Se_c=Se after -Se before In the formula, Se_c represents the difference in semantic contribution between two adjacent words, Se after Indicates the semantic contribution of the latter word between two adjacent words, Se before It represents the semantic contribution of the previous word in two adjacent words. After calculation, the difference of the phonetic contribution of all words is {Se_c1, Se_c2, Se_c3, ..., Se_c k-1 }, Se_c1, Se_c2, Se_c3,..., Se_c k-1 represents the calculated semantic contribution difference between the 1st, 2nd, 3rd, ..., k-1th two adjacent words, compares the calculated k-1 semantic contribution difference, and selects the semantic contribution of the two words corresponding to the maximum value as the transition point (Ju before , Ju after ), Ju before Indicates the previous transition point corresponding to the maximum difference in semantic contribution, Ju after Indicates the next transition point corresponding to the maximum difference in semantic contribution; when Se≤Ju before When Se≥Ju after When the corresponding word is a stop word, the corresponding word is judged as a stop word; the keywords of the legal text under each label are searched; S203. After finding the keywords in the legal text, the word frequency vectors of all types of keywords in the legal text are calculated. The formula is: In the formula, Ve represents the calculated word frequency vector of each keyword, qu represents the number of each word in the legal text, and qu_key represents the number of each keyword in the legal text; the word frequency vector of each keyword is calculated; Convert each label text into a vector value, extract S100 the proportion T of all usage scenarios of each label in the legal text, and use the proportion of all usage scenarios of each label in the legal text as the frequency vector of the label; S204, extract the frequency vector of each label and the word frequency vector of different keywords under each label, use the frequency vector of each label as an independent variable, and the word frequency vector of the keyword as a variable to draw a curve graph, calculate the linear regression equation of each curve graph, and assume that the linear regression equation expression of each keyword is Ve=a×T+b, where Ve represents the word frequency vector of each keyword of the variable, T represents the frequency vector of the independent variable label, a represents the slope of the linear regression, and b represents the intercept of the linear regression; calculate the values of a and b in the expression, and the formula is: b=And pi -a×T pi In the formula, R represents the number of legal texts contained in each label; T pi Ve represents the average frequency vector of the same label in R legal texts; pi represents the average frequency vector of keywords in R legal texts; S205, after calculation, a linear regression equation is obtained in the curve graph of the tag and different keywords, and the slope a in the linear regression equation is used as the correlation between different keywords and the corresponding tag. The different keywords in each tag are plotted and calculated to obtain the correlation between each tag and the keywords contained in the tag, specifically Tp e →{a1, a2, a3, ..., a g }, a1, a2, a3, ..., a g Indicates the label Tp e The correlations of the 1st, 2nd, 3rd, ..., gth keywords included in the tag are calculated for the correlations of the keywords included in the h tags and the corresponding tags; S300, extracting the correlation data between the label and the keyword in each legal text, and calculating the correlation threshold between the keyword and the legal label; S400, using the calculated relevance threshold to screen and optimize the relevance between each keyword and the legal tag, and removing keywords with low relevance in each tag; S500. The filtered keywords are trained using a large language model to generate a corresponding legal text template for each label. The user provides the requirements for the legal text to be generated, and the labels of the legal text in the database are matched according to the user's needs. The large language model is used to infer and predict each keyword in the legal text under the corresponding label to generate a semantically coherent legal text.
2. The method for generating legal texts based on intelligent interaction according to claim 1, characterized in that: The specific steps of generating legal tags and marking legal texts according to the application data of historical legal texts in S100 are: S101, collect application data of historical legal texts, extract the application scenario of each historical legal text as {C1, C2, C3, ..., C n }, C1, C2, C3, ..., C n Indicates the 1st, 2nd, 3rd, ..., nth application scenarios of each extracted legal text, where n is a positive integer; the number of different application scenarios of each legal text is counted to obtain the number of times each legal text is used in different application scenarios, and the proportion of different scenarios in the total number of scenarios is calculated. The formula is: In the formula, T represents the proportion of each application scenario of the calculated legal text in the total number of scenarios, S i Indicates the number of each application scenario of the legal text, S 总 Represents the total number of application scenarios of legal texts, i∈(1,n); extracts the application scenarios with the largest proportion as the application features of legal texts; S102, after statistics are collected on the application scenarios of each legal text in history, the application features of each legal text are obtained as {T_ap1, T_ap2, T_ap3, ..., T_ap m }, T_ap1, T_ap2, T_ap3,..., T_ap m represents the application features of the 1st, 2nd, 3rd, ..., mth legal texts in the collected history. The application features of each legal text are compared, and the legal texts with the same application features are classified into the same category of legal texts. Finally, the legal texts in the history are divided into {Tp1, Tp2, Tp3, ..., Tp h }, Tp1, Tp2, Tp3,..., Tp h It means that the legal texts in history are divided into the 1st, 2nd, 3rd, ..., hth categories, where h is a positive integer; S103. After classifying the legal texts in history, the application features of each type of legal text are used as labels for labeling the legal texts, and the specific labels of each legal text are obtained as follows: Represents the label of the 1st, 2nd, 3rd, ..., jth legal text in the collected history, where j is a positive integer.
3. The method for generating legal texts based on intelligent interaction according to claim 1, characterized in that: The specific steps of calculating the relevance threshold between keywords and legal tags in S300 are: S301, extracting the calculated relevance between each keyword and tag, and calculating the relevance threshold between each tag and the corresponding keyword, the formula is: In the formula, a_y represents the calculated association threshold between each tag and the corresponding keyword, a represents the association between the extracted tag and each keyword, st_a represents the standard deviation of g associations, and g represents the number of associations between the extracted tags and keywords. After calculating the association threshold between each tag and the corresponding keyword, the h association thresholds are obtained, which are {a_y1, a_y2, a_y3, ..., a_y h }, a_y1, a_y2, a_y3,..., a_y h Indicates the relevance threshold between the 1st, 2nd, 3rd, ..., hth tags and keywords.
4. The method for generating legal texts based on intelligent interaction according to claim 3 is characterized in that: The specific steps of removing keywords with low relevance in each tag in S400 are: S401, using the correlation threshold of each tag calculated in S300 to judge and filter the correlation between the calculated tags and keywords, specifically: when a>a_y, it is judged that the correlation between the corresponding keyword and the tag is close; when a≤a_y, it is judged that the correlation between the corresponding keyword and the tag is weak, and the keywords with weak correlation in the tag are removed; S402: The keywords contained in each tag are judged, and after screening, the keywords contained in the filtered tags are {key1, key2, key3, ..., key f },key1,key2,key3,...,key f It indicates the 1st, 2nd, 3rd, ..., fth keywords with close correlation contained in the tags after screening, where f is a positive integer.
5. The method for generating legal texts based on intelligent interaction according to claim 4, characterized in that: The specific steps of matching the labels of the legal texts in the database according to the user's needs in S500 are: S501, collect the user's requirement statements for the legal text, extract the words in the requirement statements, compare the words in the user's requirements with the template database, find the keywords in each tag that are the same as the user's requirement words, and calculate the similarity between the user's requirements and different tags in the template database. The formula is: In the formula, Si represents the similarity between the user's requirements and each tag, a same represents the relevance of keywords in each tag that are the same as the words required by the user, and q represents the number of keywords in each tag that are the same as the words required by the user; S502: After calculating, the similarity between each tag and the user's requirement is obtained, all similarities are compared, and the tag with the highest similarity is selected and the corresponding keywords are used to generate the legal text required by the user.
6. A legal text generation system based on intelligent interaction, characterized by: The legal text generation system includes a data collection module, a marking module, a relevance calculation module, a screening module and a generation module; The data collection module is used to collect data on historical legal texts, including usage scenario data and text data of legal texts; The labeling module is used to analyze the legal texts collected in history, calculate the label of each legal text, and label the legal text with the label; The association calculation module is used to perform vector conversion on the keywords and tags contained in each tag, draw a curve graph, and calculate the linear regression equation of each keyword and tag; The relevance calculation module includes a stop word removal unit, a text conversion unit and a linear regression equation calculation unit; The stop word removal unit is used to extract the words in the legal text in the history, calculate the semantic contribution of each word, and find the stop words with low semantic contribution to remove; The text conversion unit is used to calculate word frequency vectors for keywords in the legal text, calculate frequency vectors for tags, and convert text data into vector data; The linear regression equation calculation unit is used to extract the vectors after the tags and keywords are converted, draw a curve graph, calculate the linear regression equation using the data in the curve graph, and use the slope in the equation as the correlation between the tags and keywords; The screening module is used to calculate the relevance threshold of each tag using historical data, and use the relevance threshold to judge the relevance between each tag and the keyword, and remove keywords with low relevance; The generation module is used to extract words from the user's requirement statement, calculate the similarity between the user's requirement and each tag, select the tag with the highest similarity and use the keyword to generate the legal text.
7. The legal text generation system based on intelligent interaction according to claim 6 is characterized by: The marking module includes a label calculation unit and a marking unit; The label calculation unit is used to analyze the usage scenario data of the historical legal texts and select the scenario with the largest usage percentage as the label; The marking unit is used to mark each legal text in the history using the calculated label.
8. The legal text generation system based on intelligent interaction according to claim 6 is characterized by: The screening module includes a threshold calculation unit and a judgment unit; The threshold calculation unit is used to calculate the relevance threshold of each tag according to the calculated relevance between each tag and the corresponding keyword; The judgment unit is used to judge the relevance between each tag and the corresponding keyword by using the calculated relevance threshold of each tag, and remove keywords with low relevance.
Citation Information
Patent Citations
Legal opinion consulting database and construction method thereof
CN108920706A
A method and system for constructing a judicial text labeling system
CN109543178A