Case and law article matching method, device and equipment and medium
The semantic extraction model is used to extract context and local semantics from the content of cases and legal provisions, and construct a semantic vector sequence for matching, which solves the problem of matching errors between cases and legal provisions in the existing technology and improves the accuracy of matching.
Patent Information
- Application Number
- CN202411255166.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-10-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing technology ignores the semantic connection between relevant keywords in the case description text when matching cases and legal articles, resulting in matching errors and reducing the matching accuracy.
The semantic extraction model is used to extract contextual semantics and local semantics from the content text of cases and legal articles, construct a semantic vector sequence, and perform matching by calculating the similarity of the semantic vector sequence.
By fully extracting the semantic information of cases and legal provisions, the matching accuracy of cases and legal provisions is improved, and the possibility of matching errors is reduced.
Smart Images

Figure CN118780290A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of text processing technology, and in particular to a method, device, equipment and medium for matching cases and legal provisions. Background Art
[0002] With the continuous development of natural language technology, especially the development of pre-trained language models, the application of natural language processing technology in the legal field has developed. For example, it is used for case classification, regulation matching, etc., mainly based on the keywords in the case and regulations to determine the case or legal provisions corresponding to the case.
[0003] However, matching the case description text with the corresponding regulations based on the keywords in the legal provisions ignores the semantic connection between the relevant keywords in the case description text, which may cause the case to be matched with other categories of regulations, increasing the possibility of mismatching the case description text with the corresponding regulations. Summary of the invention
[0004] The purpose of this application is to provide a method, device, equipment and medium for matching cases and legal provisions, which can improve the accuracy of matching cases and legal provisions by combining the semantic information of both cases and legal provisions.
[0005] The present application embodiment provides a method for matching cases and legal provisions, including: Obtain the case content text and legal content text; Inputting the case content text into a first semantic extraction model, performing contextual semantic extraction and local semantic extraction based on the contextual semantic extraction results on the case content text, and obtaining a first semantic vector sequence; the first semantic vector sequence includes contextual temporal information and local semantic information of both the dispute focus content and the fact finding content in the case content text; Input the legal article content text into a second semantic extraction model, perform local semantic extraction on the legal article content text, and perform contextual semantic extraction and global semantic extraction based on the local semantic extraction results to obtain a second semantic vector sequence; the second semantic vector sequence includes local semantic information, contextual time sequence information and global semantic information of the legal article content in the legal article content text; According to the first semantic vector sequence and the second semantic vector sequence, the corresponding legal provisions in the legal provision content text are matched with the cases in the case content text.
[0006] In some embodiments, the first semantic extraction model includes a first contextual semantic extraction layer and a first convolutional network layer, and the case content text is input into the first semantic extraction model, contextual semantic extraction and local semantic extraction based on the contextual semantic extraction result are performed on the case content text to obtain a first semantic vector sequence, including: Embed the case content text with word vectors to obtain a case word vector sequence; Inputting the case word vector sequence into the first context semantic extraction layer, performing context semantic extraction on the case word vector sequence, and obtaining a first context semantic vector sequence; Inputting the first context semantic vector sequence into the first convolutional network layer, performing a convolution operation on the first context semantic vector sequence to obtain a first local semantic vector sequence; The first context semantic vector sequence and the first local semantic vector sequence are concatenated to obtain the first semantic vector sequence.
[0007] In some embodiments, the step of inputting the case word vector sequence into the first context semantic extraction layer, performing context semantic extraction on the case word vector sequence, and obtaining a first context semantic vector sequence includes: Calling the forward encoding network in the first context semantic extraction layer to encode the case word vector sequence to obtain a forward implicit state sequence; Calling the backward encoding network in the first context semantic extraction layer to encode the case word vector sequence to obtain a backward implicit state sequence; The forward implicit state sequence and the backward implicit state sequence are concatenated to obtain a first context semantic vector, and the first context semantic vectors are summarized to obtain the first context semantic vector sequence.
[0008] In some embodiments, the second semantic extraction model includes a second convolutional network layer, a second contextual semantic extraction layer, and a global semantic extraction layer. The step of inputting the legal content text into the second semantic extraction model, performing local semantic extraction on the legal content text, and performing contextual semantic extraction and global semantic extraction based on the local semantic extraction results to obtain a second semantic vector sequence includes: Embed the legal article content text with word vectors to obtain a legal article word vector sequence; Inputting the legal article word vector sequence into the second convolutional network layer, performing a convolution operation on the legal article word vector sequence to obtain a second local semantic vector sequence; Inputting the second local semantic vector sequence into the second context semantic extraction layer, performing context semantic extraction on the second local semantic vector sequence, and obtaining a second context semantic vector sequence; Inputting the second context semantic vector sequence into the global semantic extraction layer, performing an attention weight operation on the second context semantic vector sequence, and obtaining a global semantic vector sequence; The second context semantic vector sequence is concatenated with the global semantic vector sequence to obtain the second semantic vector sequence.
[0009] In some embodiments, inputting the second local semantic vector sequence into the second context semantic extraction layer, performing context semantic extraction on the second local semantic vector sequence, and obtaining a second context semantic vector sequence includes: The second local semantic vectors in the second local semantic vector sequence are respectively input into each semantic encoding network in the second contextual semantic extraction layer, and the encoding output of the above-mentioned semantic encoding network and the second local semantic vector are used as input and encoded to obtain the second contextual semantic vector, and the second contextual semantic vectors are summarized to obtain the second contextual semantic vector sequence.
[0010] In some embodiments, matching the corresponding legal articles in the legal article content text with the cases in the case content text according to the first semantic vector sequence and the second semantic vector sequence includes: Calculating sequence similarity between the first semantic vector sequence and the second semantic vector sequence; When the sequence similarity is greater than a preset similarity threshold, the legal provision corresponding to the sequence similarity is matched with the case in the case content text.
[0011] In some embodiments, the method for matching cases with laws further includes: Constructing a training sample pair; the training sample pair includes a sample case semantic vector sequence, a first sample legal provision semantic vector sequence, and a second sample legal provision semantic vector sequence, the sample case semantic vector sequence is obtained by inputting a sample case content text into a preset first original model, the first sample legal provision semantic vector sequence and the second sample legal provision semantic vector sequence are both obtained by inputting corresponding sample legal provision content text into a preset second original model, the sequence similarity between the sample case semantic vector sequence and the first sample legal provision semantic vector sequence is greater than a preset similarity threshold, and the sequence similarity between the sample case semantic vector sequence and the second sample legal provision semantic vector sequence is not greater than a preset similarity threshold; Calculating a triplet loss value of the training sample pair; The gradient descent method is used to update the weight parameters of the first original model and the second original model based on the triplet loss value, and when the triplet loss value meets the end condition, the first semantic extraction model and the second semantic extraction model are obtained.
[0012] The present application also provides a device for matching cases and legal provisions, including: The first module is used to obtain the case content text and the legal content text; The second module is used to input the case content text into a first semantic extraction model, perform contextual semantic extraction on the case content text and local semantic extraction based on the contextual semantic extraction results, and obtain a first semantic vector sequence; the first semantic vector sequence contains contextual temporal information and local semantic information of both the dispute focus content and the fact determination content in the case content text; The third module is used to input the legal content text into a second semantic extraction model, perform local semantic extraction on the legal content text, and contextual semantic extraction and global semantic extraction based on the local semantic extraction results to obtain a second semantic vector sequence; the second semantic vector sequence contains local semantic information, contextual time sequence information and global semantic information of the legal content in the legal content text; The fourth module is used to match the corresponding legal provisions in the legal provision content text with the cases in the case content text according to the first semantic vector sequence and the second semantic vector sequence.
[0013] An embodiment of the present application also provides an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned method of matching cases and laws when executing the computer program.
[0014] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned method of matching cases and laws.
[0015] The beneficial effects of the present application are as follows: using the first semantic extraction model, contextual semantic extraction and local semantic extraction based on the results of the contextual semantic extraction are performed on the case content text to obtain a first semantic vector sequence; using the second semantic extraction model, local semantic extraction and contextual semantic extraction and global semantic extraction are performed on the legal content text based on the results of the local semantic extraction to obtain a second semantic vector sequence; according to the first semantic vector sequence and the second semantic vector sequence, the corresponding legal articles in the legal content text are matched with the cases in the case content text. Since the first semantic vector sequence is constructed by extracting the contextual timing information and local semantic information of both the dispute focus content and the fact finding content in the case content text, and the second semantic vector sequence is constructed by extracting the local semantic information, contextual timing information and global semantic information of the legal content in the legal content text, the semantic information of both the case content text and the legal content text is fully extracted, and then the case and the legal article are matched according to the first semantic vector sequence and the second semantic vector sequence, the accuracy of matching cases with legal articles can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a flowchart of the method for matching cases and legal provisions provided in an embodiment of the present application.
[0017] Figure 2 It is a flowchart of the specific method of step S102 provided in an embodiment of the present application.
[0018] Figure 3 It is a flowchart of the specific method of step S103 provided in an embodiment of the present application.
[0019] Figure 4 It is a flowchart of the method for training the first semantic extraction model and the second semantic extraction model provided in an embodiment of the present application.
[0020] Figure 5 It is a schematic diagram of the structure of the device for matching cases and legal provisions provided in an embodiment of the present application.
[0021] Figure 6 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0023] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown can be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second" and the like in the specification, claims and drawings are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0025] See also Figure 1 , Figure 1 is a flow chart of a method for matching cases and legal provisions provided in an embodiment of the present application. In some embodiments of the present application, Figure 1 The method may specifically include but is not limited to steps S101 to S104. Figure 1 These four steps are introduced in detail.
[0026] Step S101, obtaining the case content text and the legal provision content text.
[0027] To obtain the case content text and the legal article content text, the original legal document and the original legal article text may be subjected to legal information extraction. The legal information includes relevant information such as laws and regulations, judicial interpretations, departmental regulations, local regulations, and case guidance opinions. The extracted legal information is summarized to obtain the case content text and the legal article content text. In a specific implementation, for the original legal documents, including but not limited to the indictment, the defense statement, and the trial record, the case text information is extracted, including the case number, the case content, and related metadata, to obtain the case content text containing the case number, content, and metadata. For the original legal article text, when extracting legal information, the original legal article text needs to be segmented according to the corresponding legal articles, and the article number, article content, article source, and related metadata are recorded to obtain a legal article content text containing the article number, content, source, and metadata.
[0028] Step S102: Input the case content text into the first semantic extraction model, perform contextual semantic extraction on the case content text and local semantic extraction based on the contextual semantic extraction result, and obtain a first semantic vector sequence.
[0029] Among them, the first semantic vector sequence contains the contextual temporal information and local semantic information of both the dispute focus content and the fact determination content in the case content text. The first semantic vector sequence contains two vector sequences. The first vector sequence contains the contextual temporal information between the dispute focus content and the fact determination content in the case content text, which is obtained by contextual semantic extraction of the case content text, and the second vector sequence contains the local semantic information of both the dispute focus content and the fact determination content, which is obtained by local semantic extraction of the first vector sequence.
[0030] In the embodiment of the present application, the first semantic vector sequence is obtained by performing contextual semantic extraction on the case content text and local semantic extraction based on the contextual semantic extraction results. In the specific implementation, the case content text is input into the first semantic extraction model, and the first semantic extraction model is used to extract the bidirectional temporal information and contextual information between each characteristic word in the case content text to obtain the contextual semantic extraction result of the case content text, that is, the first vector sequence in the first semantic vector sequence, and then the contextual semantic extraction result of the case content text is subjected to local semantic extraction, and the local semantic information of both the bidirectional temporal information and the contextual information of the characteristic words in the contextual semantic extraction result of the case content text is extracted to obtain the local semantic extraction result of the case content text, that is, the second vector sequence in the first semantic vector sequence, and the two vector sequences are summarized to obtain the first semantic vector sequence.
[0031] See also Figure 2 , Figure 2is a flowchart of a specific method of step S102 provided in an embodiment of the present application. In some embodiments of the present application, the first semantic extraction model includes a first contextual semantic extraction layer and a first convolutional network layer, and step S102 includes but is not limited to steps S201 to S204. Figure 2 These four steps are introduced in detail.
[0032] Step S201, embedding the case content text into word vectors to obtain a case word vector sequence.
[0033] The case word vector sequence contains the word vector of each feature word in the case content text.
[0034] In the specific implementation, for the case content text, punctuation marks are deleted and corresponding word segmentation is performed. After the word vector embedding processing is performed on the segmented case content text through the vector embedding network, the case content text is mapped into a vector sequence composed of word vectors of multiple feature words, namely, the case word vector sequence.
[0035] Step S202: input the case word vector sequence into the first context semantic extraction layer, perform context semantic extraction on the case word vector sequence, and obtain a first context semantic vector sequence.
[0036] Step S202 is executed by calling the first context semantic extraction layer in the first semantic extraction model. In the specific implementation, the case word vector sequence is input into the first context semantic extraction layer, the first context semantic extraction layer is used to extract features of the case word vector sequence, the word vectors of multiple feature words in the case word vector sequence are subjected to context semantic encoding processing to obtain the first context semantic feature vector, and the first context semantic feature vectors are summarized to obtain the first context semantic vector sequence.
[0037] In a specific embodiment, the first context semantic extraction layer is a bidirectional long short-term memory network structure, including a forward encoding network and a backward encoding network. Step S202 specifically includes: calling the forward encoding network in the first context semantic extraction layer to encode the case word vector sequence to obtain a forward implicit state sequence; calling the backward encoding network in the first context semantic extraction layer to encode the case word vector sequence to obtain a backward implicit state sequence; splicing the forward implicit state sequence and the backward implicit state sequence to obtain a first context semantic vector, summarizing the first context semantic vector, and obtaining a first context semantic vector sequence.
[0038] In the specific implementation, the word vectors of the characteristic words in the case word vector sequence are encoded through a forward encoding network to obtain a forward implicit state sequence, and the word vectors of the characteristic words in the case word vector sequence are encoded through a backward encoding network to obtain a backward implicit state sequence. The vectors encoded at the same time step of the forward implicit state sequence and the backward implicit state sequence are concatenated to obtain the first context semantic vector of the time step, and the first context semantic vectors concatenated at each time step are summarized to obtain a first context semantic vector sequence.
[0039] Step S203: input the first context semantic vector sequence into the first convolutional network layer, perform a convolution operation on the first context semantic vector sequence, and obtain a first local semantic vector sequence.
[0040] Step S203 is executed by calling the first convolutional network layer in the first semantic extraction model. In the specific implementation, the first context semantic vector sequence is input into the first convolutional network layer, and the first convolutional network layer is used to perform convolution operations on each first context semantic vector in the first context semantic vector sequence. Each convolution operation generates a corresponding first local semantic vector, and the first local semantic vectors are summarized to obtain the first local semantic vector sequence. The convolution operation formula is: , Among them, c i is the output of the i-th convolution window of the first convolutional network layer, that is, the i-th first local semantic vector, W c and b c are the weight and bias of the convolution kernel of the i-th convolution window in the first convolutional network layer, k is the size of the convolution kernel, and h i+k-1 is the i+k-1th first context semantic vector, is the activation function.
[0041] Step S204 , concatenating the first context semantic vector sequence and the first local semantic vector sequence to obtain a first semantic vector sequence.
[0042] Step S103: input the legal content text into the second semantic extraction model, perform local semantic extraction on the legal content text, and perform contextual semantic extraction and global semantic extraction based on the local semantic extraction results to obtain a second semantic vector sequence.
[0043] Among them, the second semantic vector sequence contains the local semantic information, contextual temporal information and global semantic information of the legal content in the legal content text. The second semantic vector sequence contains two vector sequences. The first vector sequence contains the local semantic information of the legal content in the legal content text and the contextual temporal information between the legal content, which is obtained by performing local semantic extraction on the legal content text and contextual semantic extraction based on the local semantic extraction result. The second vector sequence contains the global semantic information of the legal content in the legal content text, which is obtained by performing global semantic extraction on the first vector sequence.
[0044] In the embodiment of the present application, the second semantic vector sequence is obtained by performing local semantic extraction on the legal content text, as well as contextual semantic extraction and global semantic extraction based on the local semantic extraction results. In the specific implementation, the legal content text is input into the second semantic extraction model, and the local semantic information of each characteristic word in the legal content text is extracted using the second semantic extraction model to obtain the local semantic extraction result of the legal content text, and then contextual semantic extraction is performed on the local semantic extraction result of the legal content text to extract the timing information and context information between each characteristic word in the legal content text to obtain the contextual semantic extraction result of the legal content text, that is, the first vector sequence in the second semantic vector sequence, and the association information between the characteristic words at different positions in the contextual semantic extraction result of the legal content text is extracted to obtain the global semantic extraction result of the legal content text, that is, the second vector sequence in the second semantic vector sequence, and the two vector sequences are summarized to obtain the second semantic vector sequence.
[0045] See also Figure 3 , Figure 3 is a flowchart of a specific method of step S103 provided in an embodiment of the present application. In some embodiments of the present application, the second semantic extraction model includes a second convolutional network layer, a second contextual semantic extraction layer, and a global semantic extraction layer. Step S103 includes but is not limited to steps S301 to S305. Figure 3 These five steps are introduced in detail.
[0046] Step S301, embed the legal article content text into word vectors to obtain a legal article word vector sequence.
[0047] The legal article word vector sequence contains the word vector of each characteristic word in the legal article content text.
[0048] In the specific implementation, for the legal article content text, punctuation marks are deleted and corresponding word segmentation is performed. After the word segmentation legal article content text is processed by word vector embedding through the vector embedding network, the legal article content text is mapped into a vector sequence composed of word vectors of multiple feature words, namely, the legal article word vector sequence.
[0049] Step S302: input the legal word vector sequence into the second convolutional network layer, perform a convolution operation on the legal word vector sequence, and obtain a second local semantic vector sequence.
[0050] Step S302 is executed by calling the second convolutional network layer in the second semantic extraction model. In the specific implementation, the legal word vector sequence is input into the second convolutional network layer, and the second convolutional network layer is used to perform convolution operations on the word vectors of each characteristic word in the legal word vector sequence. Each convolution operation generates a corresponding second local semantic vector, and the second local semantic vectors are summarized to obtain a second local semantic vector sequence. The convolution operation formula is: , Among them, d i is the output of the i-th convolution window of the second convolutional network layer, that is, the i-th second local semantic vector, W d and b d are the weight and bias of the convolution kernel of the i-th convolution window in the second convolutional network layer, k is the size of the convolution kernel, x i+k-1 is the word vector of the i+k-1th feature word, is the activation function.
[0051] Step S303: input the second local semantic vector sequence into a second contextual semantic extraction layer, perform contextual semantic extraction on the second local semantic vector sequence, and obtain a second contextual semantic vector sequence.
[0052] Step S303 is executed by calling the second context semantic extraction layer in the second semantic extraction model. In the specific implementation, the second local semantic vector sequence is input into the second context semantic extraction layer, the second context semantic extraction layer is used to extract features of the second local semantic vector sequence, multiple second local semantic vectors in the second local semantic vector sequence are subjected to context semantic encoding processing to obtain a second context semantic feature vector, and each second context semantic feature vector is summarized to obtain a second context semantic vector sequence.
[0053] In a specific embodiment, the second contextual semantic extraction layer is a recurrent neural network structure, and step S303 specifically includes: inputting the second local semantic vectors in the second local semantic vector sequence into each semantic encoding network in the second contextual semantic extraction layer respectively, using the encoding output of the previous semantic encoding network and the second local semantic vector as input and encoding to obtain the second contextual semantic vector, summarizing the second contextual semantic vectors to obtain a second contextual semantic vector sequence.
[0054] In a specific implementation, the second local semantic vectors in the second local semantic vector sequence are encoded by each semantic encoding network in the second contextual semantic extraction layer. The first semantic encoding network encodes the first second local semantic vector and outputs the first second contextual semantic vector. Starting from the second second local semantic vector, the encoding output of the previous semantic encoding network and the second local semantic vector are used as input and encoded, and the corresponding second contextual semantic vector is output. For example, the second semantic encoding network encodes the first second contextual semantic vector and the second second local semantic vector and outputs the second second contextual semantic vector. The third semantic encoding network encodes the second second contextual semantic vector and the third second local semantic vector and outputs the third second contextual semantic vector. And so on. The second contextual semantic vectors are summarized to obtain a second contextual semantic vector sequence.
[0055] Step S304: input the second context semantic vector sequence into the global semantic extraction layer, perform attention weight operation on the second context semantic vector sequence, and obtain a global semantic vector sequence.
[0056] Step S304 is executed by calling the global semantic extraction layer in the second semantic extraction model. In the specific implementation, after obtaining the second context semantic vector sequence, the second context semantic vector sequence is input into the global semantic extraction layer, and each second context semantic vector in the second context semantic vector sequence is subjected to linear transformation processing, and each word vector after the linear transformation processing is subjected to attention weight operation to obtain the corresponding global semantic vector, which represents the correlation strength between the second context semantic vectors, and the global semantic vectors are summarized to obtain the global semantic vector sequence.
[0057] Step S305 , concatenating the second context semantic vector sequence and the global semantic vector sequence to obtain a second semantic vector sequence.
[0058] Step S104, matching the corresponding legal provisions in the legal provision content text with the cases in the case content text according to the first semantic vector sequence and the second semantic vector sequence.
[0059] In a specific implementation, the sequence similarity between the first semantic vector sequence and the second semantic vector sequence is calculated to determine the difference between the first semantic vector sequence and the second semantic vector sequence, so that when the column similarity meets the similarity requirement, the corresponding legal provisions in the legal content text are matched with the cases in the case content text.
[0060] In a specific embodiment, step S104 specifically includes: calculating the sequence similarity between the first semantic vector sequence and the second semantic vector sequence; when the sequence similarity is greater than a preset similarity threshold, matching the legal provisions corresponding to the sequence similarity with the cases in the case content text.
[0061] In some embodiments, the similarity can be obtained by calculating the angular distance, cosine distance, Euclidean distance or Manhattan distance between the first semantic vector sequence and the second semantic vector sequence, and the calculated result is used as the sequence similarity between the first semantic vector sequence and the second semantic vector sequence.
[0062] In the embodiment of the present application, the cosine distance between the first semantic vector sequence and the second semantic vector sequence is calculated as the sequence similarity. In the specific implementation, the calculation formula of the cosine distance is: , , , in, is the cosine distance between the first semantic vector sequence and the second semantic vector sequence, is the first semantic vector sequence, is the second semantic vector sequence, is the modulus of the first semantic vector sequence, is the modulus of the second semantic vector sequence, h i is the i-th first context semantic vector, c i is the first local semantic vector of the ith element, g i is the i-th second context semantic vector, d i is the i-th second local semantic vector, i∈[1,T], T is the number of first context semantic vectors, and mean() is the averaging operation.
[0063] See also Figure 4 , Figure 4 is a flowchart of a method for training a first semantic extraction model and a second semantic extraction model provided in an embodiment of the present application. In some embodiments of the present application, Figure 4 The method specifically includes but is not limited to steps S401 to S403. Figure 4 These three steps are introduced in detail.
[0064] Step S401, constructing training sample pairs.
[0065] Among them, the training sample pairs include a sample case semantic vector sequence, a first sample law article semantic vector sequence and a second sample law article semantic vector sequence. The sample case semantic vector sequence is obtained by inputting the sample case content text into a preset first original model. The first sample law article semantic vector sequence and the second sample law article semantic vector sequence are both obtained by inputting the corresponding sample law article content text into a preset second original model. The sequence similarity between the sample case semantic vector sequence and the first sample law article semantic vector sequence is greater than a preset similarity threshold, and the sequence similarity between the sample case semantic vector sequence and the second sample law article semantic vector sequence is not greater than a preset similarity threshold.
[0066] The sample case content text is essentially the case content text, and the sample legal provision content text is essentially the legal provision content text. The sample case content text and the sample legal provision content text serve as training materials for the first semantic extraction model and the second semantic extraction model. The specific process of generating the sample case semantic vector sequence, the first sample legal provision semantic vector sequence and the second sample legal provision semantic vector sequence is essentially the same as the specific process of generating the first semantic vector sequence and the second semantic vector sequence in the above-mentioned embodiment, and will not be repeated here.
[0067] Step S402, calculating the triplet loss value of the training sample pair.
[0068] The calculation formula for the triplet loss value is: , in, is the triple loss value, is the sample case semantic vector sequence, is the first sample legal clause semantic vector sequence, is the second sample semantic vector sequence, α is the threshold parameter, d() is the distance operation, and max() is the maximum element operation.
[0069] Step S403, using the gradient descent method, based on the triplet loss value, update the weight parameters of the first original model and the second original model, and when the triplet loss value meets the end condition, obtain the first semantic extraction model and the second semantic extraction model.
[0070] In the specific implementation, the gradient of the triplet loss value with respect to the weight parameters of the first original model and the weight parameters of the second original model is calculated, and the weight parameters of the first original model and the weight parameters of the second original model are iteratively updated according to the preset learning rate and the calculated gradient until the triplet loss value meets the loss condition (the loss value no longer decreases significantly) or the number of iterations reaches the threshold number, then the training is terminated to obtain the trained first semantic extraction model and the second semantic extraction model.
[0071] See also Figure 5The embodiment of the present application also provides a device for matching cases and legal provisions, which can implement the above-mentioned method for matching cases and legal provisions, and the device includes: The first module 501 is used to obtain the case content text and the legal content text; The second module 502 is used to input the case content text into the first semantic extraction model, perform contextual semantic extraction on the case content text and local semantic extraction based on the contextual semantic extraction result, and obtain a first semantic vector sequence; the first semantic vector sequence includes contextual time sequence information and local semantic information of both the dispute focus content and the fact determination content in the case content text; The third module 503 is used to input the legal content text into the second semantic extraction model, perform local semantic extraction on the legal content text, and perform contextual semantic extraction and global semantic extraction based on the local semantic extraction results to obtain a second semantic vector sequence; the second semantic vector sequence includes local semantic information, contextual time sequence information and global semantic information of the legal content in the legal content text; The fourth module 504 is used to match the corresponding legal provisions in the legal provision content text with the cases in the case content text according to the first semantic vector sequence and the second semantic vector sequence.
[0072] The specific implementation of the device for matching cases and legal provisions is basically the same as the specific implementation of the method for matching cases and legal provisions described above, and will not be repeated here.
[0073] Figure 6 It is a block diagram of an electronic device according to an exemplary embodiment.
[0074] Refer to the following Figure 6 The electronic device 600 according to this embodiment of the present disclosure is described. Figure 6 The electronic device 600 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0075] like Figure 6 As shown, the electronic device 600 is in the form of a general computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610), a display unit 640, etc.
[0076] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 executes the steps according to various exemplary embodiments of the present disclosure described in the method part of matching cases and legal provisions above in this specification.
[0077] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .
[0078] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0079] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0080] The electronic device 600 may also communicate with one or more external devices 600' (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 600, and / or communicate with any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 660. The network adapter 660 may communicate with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0081] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned method of matching cases and laws.
[0082] The method, device, equipment and storage medium for matching cases and legal provisions provided in the embodiments of the present application use a first semantic extraction model to perform contextual semantic extraction and local semantic extraction based on the results of the contextual semantic extraction on the case content text to obtain a first semantic vector sequence, use a second semantic extraction model to perform local semantic extraction on the legal provision content text and contextual semantic extraction and global semantic extraction based on the results of the local semantic extraction to obtain a second semantic vector sequence, and match the corresponding legal provisions in the legal provision content text with the cases in the case content text according to the first semantic vector sequence and the second semantic vector sequence. Since the first semantic vector sequence is constructed by extracting the contextual timing information and local semantic information of both the dispute focus content and the fact finding content in the case content text, and the second semantic vector sequence is constructed by extracting the local semantic information, contextual timing information and global semantic information of the legal provision content in the legal provision content text, the semantic information of both the case content text and the legal provision content text is fully extracted, and then the case and the legal provision are matched according to the first semantic vector sequence and the second semantic vector sequence, the accuracy of matching the case with the legal provision can be improved.
[0083] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, or a network device, etc.) to execute the above method according to the implementation of the present disclosure.
[0084] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0085] Computer readable storage media may include data signals propagated in baseband or as part of a carrier wave, wherein readable program codes are carried. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program codes contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination thereof.
[0086] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0087] Those skilled in the art will appreciate that the above modules can be distributed in the device according to the description of the embodiment, or can be changed accordingly and only used in one or more devices different from the embodiment. The modules of the above embodiments can be combined into one module, or further divided into multiple sub-modules.
[0088] The exemplary embodiments of the present disclosure are specifically shown and described above. It should be understood that the present disclosure is not limited to the detailed structures, configurations or implementations described herein; on the contrary, the present disclosure is intended to cover various modifications and equivalent configurations included in the spirit and scope of the appended claims.
Claims
1. A method for matching cases and legal provisions, characterized in that: include: Obtain the case content text and legal content text; Inputting the case content text into a first semantic extraction model, performing contextual semantic extraction and local semantic extraction based on the contextual semantic extraction results on the case content text, and obtaining a first semantic vector sequence; the first semantic vector sequence includes contextual temporal information and local semantic information of both the dispute focus content and the fact finding content in the case content text; Input the legal article content text into a second semantic extraction model, perform local semantic extraction on the legal article content text, and perform contextual semantic extraction and global semantic extraction based on the local semantic extraction results to obtain a second semantic vector sequence; the second semantic vector sequence includes local semantic information, contextual time sequence information and global semantic information of the legal article content in the legal article content text; According to the first semantic vector sequence and the second semantic vector sequence, the corresponding legal provisions in the legal provision content text are matched with the cases in the case content text.
2. The method for matching cases and legal provisions according to claim 1, characterized in that: The first semantic extraction model includes a first contextual semantic extraction layer and a first convolutional network layer. The case content text is input into the first semantic extraction model, contextual semantic extraction and local semantic extraction based on the contextual semantic extraction result are performed on the case content text to obtain a first semantic vector sequence, including: Embed the case content text with word vectors to obtain a case word vector sequence; Inputting the case word vector sequence into the first context semantic extraction layer, performing context semantic extraction on the case word vector sequence, and obtaining a first context semantic vector sequence; Inputting the first context semantic vector sequence into the first convolutional network layer, performing a convolution operation on the first context semantic vector sequence to obtain a first local semantic vector sequence; The first context semantic vector sequence and the first local semantic vector sequence are concatenated to obtain the first semantic vector sequence.
3. The method for matching cases and legal provisions according to claim 2, characterized in that: The step of inputting the case word vector sequence into the first context semantic extraction layer, performing context semantic extraction on the case word vector sequence, and obtaining a first context semantic vector sequence includes: Calling the forward encoding network in the first context semantic extraction layer to encode the case word vector sequence to obtain a forward implicit state sequence; Calling the backward encoding network in the first context semantic extraction layer to encode the case word vector sequence to obtain a backward implicit state sequence; The forward implicit state sequence and the backward implicit state sequence are concatenated to obtain a first context semantic vector, and the first context semantic vectors are summarized to obtain the first context semantic vector sequence.
4. The method for matching cases and legal provisions according to claim 1, characterized in that: The second semantic extraction model includes a second convolutional network layer, a second contextual semantic extraction layer and a global semantic extraction layer. The legal content text is input into the second semantic extraction model, local semantic extraction is performed on the legal content text, and contextual semantic extraction and global semantic extraction are performed based on the local semantic extraction results to obtain a second semantic vector sequence, including: Embed the legal article content text with word vectors to obtain a legal article word vector sequence; Inputting the legal article word vector sequence into the second convolutional network layer, performing a convolution operation on the legal article word vector sequence to obtain a second local semantic vector sequence; Inputting the second local semantic vector sequence into the second context semantic extraction layer, performing context semantic extraction on the second local semantic vector sequence, and obtaining a second context semantic vector sequence; Inputting the second context semantic vector sequence into the global semantic extraction layer, performing an attention weight operation on the second context semantic vector sequence, and obtaining a global semantic vector sequence; The second context semantic vector sequence is concatenated with the global semantic vector sequence to obtain the second semantic vector sequence.
5. The method for matching cases and legal provisions according to claim 4, characterized in that: The step of inputting the second local semantic vector sequence into the second context semantic extraction layer, performing context semantic extraction on the second local semantic vector sequence, and obtaining a second context semantic vector sequence includes: The second local semantic vectors in the second local semantic vector sequence are respectively input into each semantic encoding network in the second contextual semantic extraction layer, and the encoding output of the above-mentioned semantic encoding network and the second local semantic vector are used as input and encoded to obtain the second contextual semantic vector, and the second contextual semantic vectors are summarized to obtain the second contextual semantic vector sequence.
6. The method for matching cases and legal provisions according to claim 1, characterized in that: The matching of the corresponding legal articles in the legal article content text with the cases in the case content text according to the first semantic vector sequence and the second semantic vector sequence includes: Calculating sequence similarity between the first semantic vector sequence and the second semantic vector sequence; When the sequence similarity is greater than a preset similarity threshold, the legal provision corresponding to the sequence similarity is matched with the case in the case content text.
7. The method for matching cases and legal provisions according to any one of claims 1 to 6, characterized in that: The method for matching cases and legal provisions also includes: Constructing a training sample pair; the training sample pair includes a sample case semantic vector sequence, a first sample legal provision semantic vector sequence, and a second sample legal provision semantic vector sequence, the sample case semantic vector sequence is obtained by inputting a sample case content text into a preset first original model, the first sample legal provision semantic vector sequence and the second sample legal provision semantic vector sequence are both obtained by inputting corresponding sample legal provision content text into a preset second original model, the sequence similarity between the sample case semantic vector sequence and the first sample legal provision semantic vector sequence is greater than a preset similarity threshold, and the sequence similarity between the sample case semantic vector sequence and the second sample legal provision semantic vector sequence is not greater than a preset similarity threshold; Calculating a triplet loss value of the training sample pair; The gradient descent method is used to update the weight parameters of the first original model and the second original model based on the triplet loss value, and when the triplet loss value meets the end condition, the first semantic extraction model and the second semantic extraction model are obtained.
8. A device for matching cases and legal provisions, characterized in that: include: The first module is used to obtain the case content text and the legal content text; The second module is used to input the case content text into a first semantic extraction model, perform contextual semantic extraction on the case content text and local semantic extraction based on the contextual semantic extraction results, and obtain a first semantic vector sequence; the first semantic vector sequence contains contextual temporal information and local semantic information of both the dispute focus content and the fact determination content in the case content text; The third module is used to input the legal content text into a second semantic extraction model, perform local semantic extraction on the legal content text, and contextual semantic extraction and global semantic extraction based on the local semantic extraction results to obtain a second semantic vector sequence; the second semantic vector sequence contains local semantic information, contextual time sequence information and global semantic information of the legal content in the legal content text; The fourth module is used to match the corresponding legal provisions in the legal provision content text with the cases in the case content text according to the first semantic vector sequence and the second semantic vector sequence.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the method for matching cases and legal provisions as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for matching cases and legal provisions described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Case fact and law article matching method and device
CN114461760A
Text classification method and device, equipment and storage medium
CN115757786A
Text overlapping relation extraction network training method and device, equipment and medium
CN115859960A
Attribute emotion tetrad extraction method based on grid marking scheme
CN116451679A
