Composition detection method, device, storage medium and electronic device
By obtaining the keyword correlation between the composition topic and the composition content, splicing it in columns and reducing the dimension, the problem of vector-based orthogonality limitation in the existing technology is solved, and the accuracy and applicability of composition detection are improved.
Patent Information
- Application Number
- CN202111232625.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-22
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2041-10-22
AI Technical Summary
The existing composition detection methods need to ensure that the vector bases represented by semantic representation are orthogonal and isotropic, resulting in a decrease in detection accuracy, especially the poor application of multi-dimensional vectors.
By obtaining the keyword correlation between the composition topic and the composition content, splicing it in columns and adjusting the correlation degree, and then dimensionality reduction processing is performed to obtain a two-dimensional matrix to detect the correlation between the composition topic and the composition content.
The accuracy of the correlation detection of composition topics and composition content is improved, the limitations on orthogonal and isotropic conditions are avoided, and it is applicable to any question-type composition, and the subjective influence is reduced.
Smart Images

Figure CN116029276B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular, to a composition detection method, device, storage medium, and electronic device. Background Art
[0002] Currently, based on the application of various algorithms, it is possible to achieve off-topic detection of compositions. Based on the semantic relevance between the content of the composition and the topic, it is determined whether the composition title and the composition content are relevant, which reduces the burden on teachers for correcting students' compositions. Summary of the Invention
[0003] Embodiments of the present application provide a composition detection method, device, storage medium, and electronic device. Based on obtaining the relevance between each keyword in the composition title of the target composition and each keyword in the composition content, as well as the relevance between each keyword in the composition content and each keyword in the composition title, the two relevances are concatenated by column and the relevance is adjusted to obtain a new matrix. The matrix is processed by dimensionality reduction to obtain a two-dimensional matrix. Based on the two-dimensional matrix, it is detected whether the composition title and the composition content of the target composition are relevant. Based on this solution, it is possible to detect whether the composition title and the composition content of the target composition are relevant without being limited by the condition that the basis of the vector whose relevance needs to be guaranteed is orthogonal and isotropic, and the accuracy of detecting whether the composition title and the composition content of the target composition are relevant is improved. The technical solution is as follows:
[0004] In a first aspect, embodiments of the present application provide a composition detection method, the method including:
[0005] Obtain each first keyword in the composition title of the target composition, and obtain each second keyword in the composition content of the target composition;
[0006] Calculate the relevance between each first keyword and each second keyword to obtain a first matrix, and calculate the relevance between each second keyword and each first keyword to obtain a second matrix;
[0007] Concatenate the first matrix and the second matrix by column to obtain a third matrix;
[0008] Adjust the relevances in the third matrix to obtain a fourth matrix, where each relevance in the fourth matrix represents the relevance between the composition content and the composition title;
[0009] Perform dimensionality reduction processing on the fourth matrix to obtain a two-dimensional fifth matrix, and output a result indicating whether the composition title and the composition content are relevant based on the fifth matrix.
[0010] In a second aspect, embodiments of the present application provide a composition detection device, the device including:
[0011] A keyword acquisition module for acquiring each first keyword in the composition title of the target composition and each second keyword in the composition content of the target composition;
[0012] A matrix acquisition module for calculating the relevance between each of the first keywords and each of the second keywords to obtain a first matrix, and calculating the relevance between each of the second keywords and each of the first keywords to obtain a second matrix;
[0013] A matrix splicing module for splicing the first matrix and the second matrix by columns to obtain a third matrix;
[0014] A relevance adjustment module for adjusting each relevance in the third matrix to obtain a fourth matrix, wherein each relevance in the fourth matrix represents the relevance between the composition content and the composition title;
[0015] A result output module for performing dimensionality reduction processing on the fourth matrix to obtain a two-dimensional fifth matrix, and outputting a result indicating whether the composition title and the composition content are relevant based on the fifth matrix.
[0016] In a third aspect, an embodiment of the present application provides a computer storage medium storing multiple instructions adapted to be loaded and executed by a processor to perform the above method steps.
[0017] In a fourth aspect, an embodiment of the present application provides an electronic device, which may include: a processor and a memory; wherein, the memory stores a computer program adapted to be loaded and executed by the processor to perform the above method steps.
[0018] The beneficial effects brought by the technical solution provided by the embodiment of the present application at least include:
[0019] By adopting the embodiment of the present application, by obtaining the relevance between each keyword in the composition title of the target composition and each keyword in the composition content, as well as the relevance between each keyword in the composition content and each keyword in the composition title, splicing the two relevances by columns and performing relevance adjustment to obtain a new matrix, performing dimensionality reduction processing on the matrix to obtain a two-dimensional matrix, and detecting whether the composition title and the composition content of the target composition are relevant based on the two-dimensional matrix. Based on this solution, it is possible to determine whether the composition title and the composition content of the target composition are relevant without being limited by the condition that the basis of the vector whose relevance needs to be guaranteed is orthogonal and isotropic, and improve the accuracy of determining whether the composition title and the composition content of the target composition are relevant. Description of the Drawings
[0020] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0021] Figure 1 It is a system architecture diagram of a composition detection method provided by an embodiment of the present application;
[0022] Figure 2 It is a flowchart of a composition detection method provided by an embodiment of the present application;
[0023] Figure 3 It is an example diagram of a composition detection result provided by an embodiment of the present application;
[0024] Figure 4 It is a flowchart of a composition detection method provided by an embodiment of the present application;
[0025] Figure 5 It is an example diagram of a composition detection result provided by an embodiment of the present application;
[0026] Figure 6 It is an example diagram of another composition detection result provided by an embodiment of the present application;
[0027] Figure 7 It is a flowchart of a composition detection method provided by an embodiment of the present application;
[0028] Figure 8 It is an example diagram of a composition detection result provided by an embodiment of the present application;
[0029] Figure 9 It is an example diagram of a composition detection result provided by an embodiment of the present application;
[0030] Figure 10 It is a structural diagram of a composition detection device provided by an embodiment of the present application;
[0031] Figure 11 It is a structural diagram of a matrix acquisition module provided by an embodiment of the present application;
[0032] Figure 12 It is a structural diagram of a composition detection device provided by an embodiment of the present application;
[0033] Figure 13 It is a structural diagram of a relevance adjustment module provided by an embodiment of the present application;
[0034] Figure 14It is a schematic structural diagram of a result output module provided by an embodiment of the present application;
[0035] Figure 15 It is a schematic structural diagram of a content keyword output module provided by an embodiment of the present application;
[0036] Figure 16 It is a schematic structural diagram of a topic keyword output module provided by an embodiment of the present application;
[0037] Figure 17 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0038] To make the objectives, technical solutions and advantages of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the accompanying drawings.
[0039] When the following description involves the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0040] In the description of the present application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be construed as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to specific circumstances. In addition, in the description of the present application, unless otherwise specified, "a plurality of" means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after.
[0041] The existing method for detecting a target composition mainly performs semantic representation on the composition title and the composition content of the target composition respectively, and then calculates the correlation degree of the vectors obtained by the semantic representation, and judges whether the composition title and the composition content of the target composition are relevant by artificially presetting a threshold.
[0042] When performing semantic representation and calculating the correlation degree on the composition title and the composition content, this method needs to ensure that the basis of the vectors represented by the semantic representation is orthogonal and isotropic. It is meaningless to calculate the vectors with non-orthogonal bases. Most of the vectors obtained by the existing algorithms with good semantic representation are multi-dimensional. If the target composition is detected based on the vectors obtained in this way, the accuracy will be reduced.
[0043] Based on this, an embodiment of the present application provides an essay detection method. It can be based on obtaining the relevance between each keyword in the essay title of the target essay and each keyword in the essay content, as well as the relevance between each keyword in the essay content and each keyword in the essay title. Concatenate the two relevances column by column and perform relevance adjustment to obtain a new matrix. Perform dimensionality reduction processing on the matrix to obtain a two-dimensional matrix. Based on the two-dimensional matrix, detect whether the essay title and the essay content of the target essay are relevant. Based on this solution, it can be unrestricted by the condition that the basis of the vector for ensuring relevance is orthogonal and isotropic, detect whether the essay title and the essay content of the target essay are relevant, and improve the accuracy of detecting whether the essay title and the essay content of the target essay are relevant.
[0044] The following will describe the present application in detail with specific embodiments.
[0045] Please refer to Figure 1 , which is the system structure diagram of an essay detection method provided by an embodiment of the present application. Figure 1 It includes a user, a mobile terminal, and a target essay. When the user wants to detect whether the essay title and the essay content of the target essay are relevant, only need to use the mobile terminal to obtain the target essay, and then can use the mobile terminal to achieve the detection of whether the essay title and the essay content of the target essay are relevant.
[0046] After the mobile terminal obtains the target essay, it obtains the keywords of the essay title and the essay content of the target essay, and respectively obtains the matrix corresponding to the relevance of the essay title to the essay content and the matrix corresponding to the relevance of the essay content to the essay title based on the keywords. Concatenate the two matrices column by column and adjust the relevance of the concatenated matrix to obtain a new matrix. Perform dimensionality reduction processing on the new matrix to obtain a two-dimensional matrix, and based on the two-dimensional matrix, detect whether the essay title and the essay content of the target essay are relevant.
[0047] The above method is based on obtaining the relevance between each keyword in the essay title of the target essay and each keyword in the essay content, as well as the relevance between each keyword in the essay content and each keyword in the essay title. Concatenate the two relevances column by column and perform relevance adjustment to obtain a new matrix. Perform dimensionality reduction processing on the matrix to obtain a two-dimensional matrix. Based on the two-dimensional matrix, identify whether the essay title and the essay content of the target essay are relevant. Based on this solution, it can be unrestricted by the condition that the basis of the vector for ensuring relevance is orthogonal and isotropic, detect whether the essay title and the essay content of the target essay are relevant, and improve the accuracy of detecting whether the essay title and the essay content of the target essay are relevant.
[0048] The above method can run on a composition detection device, which can be the above-mentioned mobile terminal, including but not limited to: intelligent interactive flat panel, personal computer, tablet computer, handheld device, computing device, or other processing devices connected to a wireless modem, etc. In different networks, the user terminal can be called by different names. For example: user equipment, access terminal, user unit, user station, mobile station, mobile unit, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent or user device, cellular phone, cordless phone, Personal Digital Assistant (PDA), terminal device in a 5G network or future evolved network, etc.
[0049] Please refer to Figure 2 , which is a schematic flowchart of a composition detection method provided by an embodiment of the present application. The embodiment of the present application is described by taking a mobile terminal as an example. The composition detection method may include the following steps:
[0050] S101, obtain each first keyword in the composition title of the target composition, and obtain each second keyword in the composition content of the target composition;
[0051] As Figure 1 shown, obtain the target composition that needs to be detected, use a pre-trained language model to obtain the words in the composition title of the target composition, and use all the words as each first keyword in the composition title of the target composition. Use a pre-trained language model to obtain the words in the composition content of the target composition, and use all the words as each second keyword in the composition content of the target composition.
[0052] Among them, the method for obtaining the target composition can be to use the camera on the mobile terminal to take pictures of the paper composition, or to directly call it from the composition database, etc.
[0053] Among them, the target composition can be an article in any language. For example, it can be a Chinese composition or an English composition.
[0054] Among them, each first keyword and each second keyword are in the form of vectors obtained after using a pre-trained language model for the words in the composition content and composition title of the target composition.
[0055] Among them, the pre-trained language model adopted in the embodiment of the present application is the ELECTRA pre-trained language model. Through this model, vectors of each word can be obtained. The dimension of the vector can be as high as hundreds or thousands of dimensions. It is an improved version of the relatively common BERT pre-trained language model at present and has a stronger and more accurate semantic representation effect.
[0056] S102, calculate the relevance between each of the first keywords and each of the second keywords to obtain a first matrix, and calculate the relevance between each of the second keywords and each of the first keywords to obtain a second matrix;
[0057] Calculate the relevance between each first keyword and each second keyword, that is, calculate the relevance between the words in the composition content of the target composition and the words in the composition title. The higher the relevance, the higher the correlation between the words in the composition content and the composition title, and the more in line with the theme of the composition title. The specific method for obtaining the relevance and the first matrix can adopt formula (1) and formula (2).
[0058]
[0059]
[0060] Among them, in formula (1), P is the matrix composed of each first keyword corresponding to the composition title of the target composition, C is the matrix composed of each second keyword corresponding to the composition content of the target composition, and W is the weight coefficient used to calculate the relevance between the words in the composition content and the words in the composition title. The relevance between the words in the composition content and the words in the composition title of the target composition is calculated through formula (1).
[0061] Among them, formula (2) performs a weighted sum of each first keyword based on the weight coefficient corresponding to each first keyword obtained through formula (1), so as to obtain the first matrix. The first matrix includes each first keyword added with the corresponding relevance weight.
[0062] Calculate the relevance between each second keyword and each first keyword, that is, calculate the relevance between the words in the composition title of the target composition and the words in the composition content. The higher the relevance, the higher the correlation between the words in the composition title and the composition content, and the more in line with the theme of the composition content. The specific method for obtaining the relevance and the second matrix can adopt formula (3) and formula (4).
[0063]
[0064]
[0065] Among them, in formula (3), P is the matrix composed of each first keyword corresponding to the composition title of the target composition, C is the matrix composed of each second keyword corresponding to the composition content of the target composition, and W is the weight coefficient used to calculate the relevance between the words in the composition content and the words in the composition title. The relevance between the words in the composition title and the words in the composition content of the target composition is calculated through formula (3).
[0066] Among them, formula (4) performs weighted summation on each second keyword based on the weight coefficients corresponding to each second keyword obtained through formula (3), so as to obtain a second matrix, and the second matrix includes each second keyword added with the corresponding relevance weight.
[0067] S103, splice the first matrix and the second matrix column by column to obtain a third matrix;
[0068] Connect the first column of the second matrix behind the last column of the first matrix to obtain a third matrix, that is, merge two matrices into a new matrix. Splicing the first matrix and the second matrix is to prepare for subsequent fusion of the two matrices to determine whether the composition title and the composition content of the target composition are relevant.
[0069] The specific connection method can refer to the generation method of expression (3), that is, splice the first column of expression (2) behind the last column of expression (1).
[0070]
[0071]
[0072]
[0073] S104, adjust the relevance in the third matrix to obtain a fourth matrix, where the relevance in the fourth matrix represents the relevance between the composition content and the composition title;
[0074] Use the pre-trained weight parameters to evaluate the importance of the relevance in the third matrix, determine the importance weights of the relevance through formula (5), and multiply the obtained importance weights with each element according to formula (6) to obtain a fourth matrix, and the relevance in the fourth matrix represents the relevance between the composition content and the composition title of the target composition.
[0075] g = sigmoid(UM) formula (5)
[0076]
[0077] Among them, U is the pre-trained weight parameter for evaluating the importance of the relevance, M is the third matrix, g is the importance weight of the relevance calculated through formula (5), the range of g can be between 0 and 1, the larger the value, the higher the importance of the corresponding relevance, and for the relevance with smaller importance, the corresponding g is smaller or even directly assigned to zero, so as to discard the unimportant relevance.
[0078] G in formula (6) is to weight the third matrix M and adjust the fourth matrix of the relevance.
[0079] S105. Perform dimensionality reduction on the fourth matrix to obtain a two-dimensional fifth matrix, and output the result of whether the composition title is relevant to the composition content based on the fifth matrix.
[0080] Since the number of columns of the fourth matrix is too large, it is necessary to perform dimensionality reduction on the fourth matrix to obtain a two-dimensional matrix - the fifth matrix, and output the result of whether the composition title is relevant to the composition content based on the obtained fifth matrix.
[0081] Among them, the method of performing dimensionality reduction on the matrix can be to gradually perform dimensionality reduction using 2 fully connected layers (dense). The reason for using 2 layers is to make the dimension reduction slower, ensuring that too much information will not be lost during the dimensionality reduction process of the matrix.
[0082] Among them, the fifth matrix outputs the result of whether the composition title is relevant to the composition content. A feasible method is that if the output result is 0, the composition title of the target composition is not relevant to the composition content; if the output result is 1, the composition title of the target composition is relevant to the composition content.
[0083] As Figure 3 shown, after detecting the target composition through the mobile terminal, the detection result is reflected in the upper right corner of the target composition.
[0084] Through the embodiments of the present application, based on obtaining the relevance between each keyword in the composition title of the target composition and each keyword in the composition content, as well as the relevance between each keyword in the composition content and each keyword in the composition title, the two relevances are concatenated by column and the relevance is adjusted to obtain a new matrix. Dimensionality reduction processing is performed on the matrix to obtain a two-dimensional matrix. Based on the two-dimensional matrix, it is determined whether the composition title of the target composition is relevant to the composition content. By using the embodiments of the present application, it is possible to be unrestricted by the condition that the basis of the vector whose relevance needs to be guaranteed is orthogonal and isotropic, detect whether the composition title of the target composition is relevant to the composition content, and improve the accuracy of detecting whether the composition title of the target composition is relevant to the composition content.
[0085] Please refer to Figure 4 , which is a schematic flowchart of a composition detection method provided by the embodiments of the present application. The embodiments of the present application are described by taking a mobile terminal as an example. The composition detection method may include the following steps:
[0086] S201. Obtain each first keyword in the composition title of the target composition, and obtain each second keyword in the composition content of the target composition.
[0087] Specifically, refer to S101, which will not be elaborated here.
[0088] S202. Calculate the relevance between each first keyword and each second keyword.
[0089] For details, please refer to S102, which will not be elaborated here.
[0090] S203. Normalize the relevance and perform weighted summation on each of the first keywords based on the normalized relevance to obtain a first matrix.
[0091] Through step S102, the relevance S between the words in the composition content of the target composition and the words in the composition title is obtained. i , and then normalize S according to formula (7). i Perform weighted summation on the normalized relevance and each of the first keywords according to formula (8) to obtain a first matrix.
[0092]
[0093]
[0094] Among them, α in formula (7) i is P i the weight coefficient corresponding to this word. Through formula (7), S obtained from formula (1) can be i normalized, so that the weight coefficients are sorted into a probability distribution with the sum of the weights of all elements being 1.
[0095] Among them, formula (8) performs weighted summation on the weight coefficients corresponding to each of the first keywords obtained from formula (1) and formula (7) to obtain a first matrix. The first matrix includes each of the first keywords with the corresponding relevance weights added.
[0096] S204. Add the first matrix to each of the first keywords to obtain a sixth matrix, and perform layer normalization on the sixth matrix to obtain a seventh matrix.
[0097] To avoid errors in the process of determining the relevance in step S202, which may lead to calculation errors and affect the accuracy of the final result, add each of the first keywords to the first matrix to obtain a sixth matrix, and then perform layer normalization on the sixth matrix to obtain a seventh matrix for more convenient subsequent calculations.
[0098] Among them, the method of adding each of the first keywords to the first matrix is a common basic addition operation method in linear algebra, that is, adding the value in the first row and first column to the corresponding value in the first row and first column, adding the value in the first row and second column to the value in the first row and second column, and so on.
[0099] Among them, the method of performing layer normalization on the sixth matrix can adopt formula (9):
[0100] M p= LayNorm(P + A p ) Formula (9)
[0101] where M p is the seventh matrix, and the specific calculation formula of LayNorm() is as shown in Formula (10).
[0102]
[0103] where α and β represent the parameter vectors for scaling and translation, which are fixed values, u and σ represent the mean and variance of each column of (P + A p ) in Formula (9), ε is a very small value used to avoid the denominator being zero, and the value is small enough to minimize the impact caused by errors. m i is (P + A p ) in Formula (9), that is, the current relevance of the sixth matrix.
[0104] S205. Calculate the relevance between each of the second keywords and each of the first keywords;
[0105] Specifically, refer to S102, which will not be elaborated here.
[0106] S206. Normalize the relevance and perform weighted summation on each of the second keywords based on the normalized relevance to obtain the second matrix;
[0107] Through step S102, obtain the relevance S i between the words in the composition title and the words in the composition content of the target composition, then normalize S i according to Formula (11), and perform weighted summation on the normalized relevance and each second keyword according to Formula (12) to obtain the second matrix.
[0108]
[0109]
[0110] where α i in Formula (11) is the weight coefficient corresponding to the word P i . Through Formula (11), S i obtained from Formula (3) can be normalized, so that the weight coefficients are sorted into a probability distribution where the sum of the weights of all elements is 1.
[0111] where Formula (12) performs weighted summation on the weight coefficients corresponding to each second keyword obtained from Formula (3) and Formula (12), thereby obtaining the second matrix, and the second matrix includes each second keyword with the corresponding relevance weight added.
[0112] S207. Add the second matrix to each of the second keywords to obtain an eighth matrix, and perform layer normalization on the eighth matrix to obtain a ninth matrix;
[0113] To avoid errors during the process of determining the relevance in step S206, which may lead to calculation errors and affect the accuracy of the final result, add each second keyword to the second matrix to obtain an eighth matrix, and then perform layer normalization on the eighth matrix to obtain a ninth matrix, so as to facilitate subsequent calculations.
[0114] Among them, the method of adding each second keyword to the second matrix is a common basic addition operation method in linear algebra, that is, the value in the first row and first column is added to the corresponding value in the first row and first column, the value in the first row and second column is added to the value in the first row and second column, and so on.
[0115] Among them, the method of performing layer normalization on the eighth matrix can adopt formula (11):
[0116] M c = LayNorm(C + A c ) Formula (11)
[0117] Among them, M C is the ninth matrix, and the specific calculation formula of LayNorm() is as shown in formula (12).
[0118]
[0119] Among them, α and β represent the parameter vectors of scaling and translation, which are fixed values, u and σ represent the mean and variance of each column in (C + A c ) in formula (11), ε is a very small value used to avoid the denominator being zero, and the value is small enough to minimize the impact caused by errors, and m i is (C + A c ) in formula (11), that is, the current relevance of the eighth matrix.
[0120] S208. Concatenate the seventh matrix and the ninth matrix column by column to obtain a third matrix;
[0121] Concatenate the seventh matrix and the ninth matrix column by column to obtain a third matrix. The specific method of column concatenation of the matrix can refer to S103 and will not be elaborated here.
[0122] S209. Based on the pre-trained weight parameters, adjust the relevances in the third matrix;
[0123] Based on the pre-trained weight coefficients for evaluating the importance of relevance, evaluate the importance of each relevance in the third matrix, determine the importance weights of each relevance through formula (5), and the obtained weight values can be in the range of 0-1. If the importance of the relevance is higher, the assigned weight is larger; if the importance is smaller, the assigned weight is smaller or even directly assigned zero. Determine the importance of each relevance by adjusting the relevance, and discard the unimportant relevance.
[0124] S210. Based on each of the relevances, weight each element in the third matrix to obtain the fourth matrix;
[0125] After obtaining each adjusted relevance, weight the corresponding elements in the third matrix with the obtained weights. For details, refer to S104, which will not be elaborated here.
[0126] S211. Add the third matrix and the fourth matrix to obtain the tenth matrix;
[0127] Add the third matrix and the fourth matrix to obtain the tenth matrix. For details, refer to S204, which will not be elaborated here.
[0128] S212. Perform layer normalization on the tenth matrix to obtain the eleventh matrix, and perform a reduction in the fitting degree on the eleventh matrix to obtain the twelfth matrix;
[0129] Perform layer normalization on the tenth matrix to obtain the eleventh matrix. For the specific steps of layer normalization, refer to S207, which will not be elaborated here. Then perform a reduction in the fitting degree on the eleventh matrix to obtain the twelfth matrix. The purpose of performing a reduction in the fitting degree on the eleventh matrix is to prevent the neural network from overfitting and ensure the normal operation of the algorithm.
[0130] Among them, the method for reducing the fitting degree can be to reduce the fitting degree through a dropout layer. Specifically, a certain number of values in the matrix are randomly set to zero. For example, after expression (4) undergoes the reduction in the fitting degree, expression (5) is obtained. The zeroing target is random, and only the number of zeroing is set during the processing. For example, 10% of the values in the matrix are set to zero.
[0131]
[0132]
[0133] S213. Perform dimensionality reduction on the twelfth matrix to obtain the two-dimensional fifth matrix;
[0134] The number of columns in the obtained twelfth matrix is too large. In order to detect whether the composition title and the composition content of the target composition are relevant in the subsequent process, it is necessary to perform dimensionality reduction on the matrix to obtain a two-dimensional fifth matrix.
[0135] Among them, the dimensionality reduction method can adopt two fully connected layers (dense) to gradually reduce the dimension. One layer of dense can achieve the dimensionality reduction of the matrix, but too much information will be lost. Therefore, two layers of dense are adopted to gradually reduce the dimension, so that the dimension can be reduced more slowly and ensure that too much information will not be lost during the dimensionality reduction process of the matrix.
[0136] S214, if the output result of the fifth matrix through the sigmoid function layer is the first value, then output the result that the composition title is not relevant to the composition content;
[0137] The obtained fifth matrix is a two-dimensional matrix, but the elements in the matrix are relatively complex and need to be simplified for binary classification prediction. If the output result is the first value, then output the result that the composition title is not relevant to the composition content. As Figure 5 shown, output the recognition result at the upper right corner of the target composition.
[0138] Among them, the simplification method can be simplified through the sigmoid function layer. The simplified value is within the preset value range, for example, 0 and 1, and the value specified as not relevant is the first value. If the output value is the first value, then determine that the composition title of the target composition is not relevant to the composition content.
[0139] It should be noted that when the embodiments of the present application identify whether the composition title of the target composition is relevant to the composition content, there is no need to artificially preset a threshold. Artificially presetting a threshold is easily affected by subjectivity, and using the same threshold to detect different compositions is likely to result in a low detection success rate. In order to avoid reducing the detection accuracy due to subjectivity and be applicable to the detection of any composition, the final recognition basis of the embodiments of the present application is the output result of the finally obtained fifth matrix.
[0140] S215, if the output result of the fifth matrix through the sigmoid function layer is the second value, then output the result that the composition title is relevant to the composition content;
[0141] The obtained fifth matrix is a two-dimensional matrix, but the elements in the matrix are relatively complex and need to be simplified for binary classification prediction. If the output result is the second value, then output the result that the composition title is relevant to the composition content. As Figure 6 shown, output the recognition result at the upper right corner of the target composition.
[0142] Among them, the simplification method can be simplified through the sigmoid function layer. The simplified value is within the preset value range, for example, 0 and 1, and the value specified as relevant is the second value. If the output value is the second value, then determine that the composition title of the target composition is relevant to the composition content.
[0143] In the embodiments of the present application, the relevance between each keyword in the composition content of the target composition and each keyword in the composition title, as well as the relevance between each keyword in the composition title and each keyword in the composition content, are respectively obtained. Based on the two relevances, corresponding matrices are respectively obtained. The two relevances are concatenated by columns and the relevance is adjusted to obtain a new matrix. The matrix is processed for dimensionality reduction to obtain a two-dimensional matrix. Based on the two-dimensional matrix, it is detected whether the composition title of the target composition is relevant to the composition content. By adopting the embodiments of the present application, not only the condition restrictions that the basis of the vector obtained by semantic representation needs to be orthogonal and isotropic are overcome, but also it is applicable to compositions of any question types. At the same time, the reduction of the recognition accuracy rate due to subjective reasons is avoided, and the accuracy rate of whether the composition title of the target composition is relevant to the composition content is improved.
[0144] Please refer to Figure 7 , which is a schematic flowchart of a composition detection method provided by the embodiments of the present application. The embodiments of the present application are described by taking the example that the composition title of the target composition is not relevant to the composition content. The composition detection method may further include the following steps:
[0145] S301, output the result of whether the composition title is relevant to the composition content based on the fifth matrix;
[0146] Through the above two embodiments, the relevance of the target composition is detected to identify whether the composition title of the target composition is relevant to the composition content. The existing composition detection methods only detect whether the composition title of the target composition is relevant to the composition content and do not provide other explanations, which cannot bring convenience to the graders for manual inspection of compositions whose composition titles are not relevant to the composition content.
[0147] In the technical solution provided by the embodiments of the present application, if the composition title of the target composition is not relevant to the composition content, in order to explain the reason why the composition title of the target composition is not relevant to the composition content, the composition title of the target composition and the topic words of the composition content may be extracted, and the topic sentences in the composition content that are consistent with the topic of the composition content are selected as the reasons for explaining why the composition title of the target composition is not relevant to the composition content.
[0148] S302, if it is determined that the composition title of the target composition is not relevant to the composition content, then obtain the first set of topic words of the composition content under different topic categories based on the trained topic word recognition model;
[0149] If it is determined that the composition title of the target composition is not relevant to the composition content, in order to extract the topic words in the composition content to explain why the composition title of the target composition is not relevant to the composition content, the first set of topic words of the composition content under different topic categories can be obtained based on the pre-trained and completed topic word recognition model, and each topic category has a corresponding confidence level.
[0150] Among them, the pre-trained topic word recognition model can be a Latent Dirichlet Allocation (LDA) topic model trained based on a corpus, and the number of topic categories is determined. The number of topic categories is manually adjusted through the training results to select the most suitable parameters.
[0151] Among them, for all topic categories in the composition content obtained through the topic word recognition model, each topic category has a corresponding first set of topic words. The first set of topic words includes all the words of that topic category, and each topic category has a corresponding confidence level. The greater the confidence level, the higher the degree of fit with the composition content.
[0152] S303, determine the topic category with the maximum confidence level;
[0153] Among all the topic categories of the composition content, determine the topic category with the maximum confidence level. Because the confidence level is the maximum, the degree of fit between this topic category and the topic of the composition content is the highest among all topic categories, and relatively speaking, it can best represent the topic of the composition content.
[0154] S304, if the maximum confidence level is greater than or equal to the first threshold, determine a preset number of first topic words in the first set of topic words corresponding to the topic category with the maximum confidence level, and output the first topic words;
[0155] To extract the topic words of the composition content, there is a preset first threshold for the confidence level. If the confidence level corresponding to the topic category with the maximum confidence level in the composition content is greater than or equal to the preset first threshold, it means that the words in the first set of topic words corresponding to this topic category can reflect the topic of the composition content. Select a preset number of words from the first set of topic words as the first topic words of the composition content, and output the first topic words.
[0156] For example, the preset first threshold is 0.5, and the preset number of words is 5. If the maximum confidence level is 0.6, then select the first 5 words in the first set of topic words corresponding to the topic category with the maximum confidence level as the first topic words.
[0157] S305, if the maximum confidence level is less than the first threshold, use the keyword extraction model to calculate the scores of each keyword in the composition content, and select a preset number of keywords with the top-ranked scores as the first topic words, and output the first topic words;
[0158] If the maximum confidence level is less than the first threshold, it means that even the topic category corresponding to the maximum confidence level cannot appropriately reflect the topic of the composition content. Therefore, use the keyword extraction model to calculate the scores of each keyword in the composition content, and select a preset number of keywords with the top-ranked scores as the first topic words, and output the first keyword.Figure 8 As shown, output the topic words below the target composition.
[0159] Among them, in the keyword extraction model, three methods are used to score all the keywords in the composition content from different perspectives, and the scores obtained by the three methods are weighted and summed to obtain the scores of each keyword in the composition content. The three methods can be the word frequency scores that use the Term Frequency–Inverse Document Frequency (TF-IDF) algorithm to obtain the importance of each keyword in the composition content in the corpus, the part-of-speech tagging scores that use the Part-Of-Speech (POS) algorithm to obtain the part-of-speech tags of each keyword in the composition content, and the keyword extraction scores that use the Yet Another Keyword Extractor (YAKE) algorithm to obtain each keyword in the composition content.
[0160] After obtaining the word frequency scores, part-of-speech tagging scores, and keyword extraction scores obtained by the three methods, the scores of each keyword are obtained by weighted summation of the three scores. The weights can be one-third each, or can be adjusted to a certain extent according to the actual situation, which is specifically determined according to the actual situation and is not limited here.
[0161] After obtaining the scores of each keyword by weighted summation of the three scores, the keywords are sorted based on the scores. The sorting order can be from high to low according to the scores, and a preset number of the top-ranked keywords are selected as the first keywords of the composition content, and the first keywords are output. The preset number can be 5, 10, 20, etc., and can be adjusted specifically according to the actual situation, which is not limited here.
[0162] S306, if it is determined that the composition title of the target composition is not relevant to the composition content, then based on the trained topic word recognition model, obtain the second set of topic words of the composition title under different topic categories;
[0163] Specifically, reference can be made to S302, which will not be elaborated here.
[0164] S307, determine the topic category with the maximum confidence;
[0165] Specifically, reference can be made to S303, which will not be elaborated here.
[0166] S308, if the maximum confidence is greater than or equal to the second threshold, then determine a preset number of second topic words in the first set of topic words corresponding to the topic category with the maximum confidence, and output the second topic words;
[0167] Specifically, reference can be made to S304, which will not be elaborated here
[0168] S309. If the maximum confidence level is less than the second threshold, use the keyword extraction model to calculate the scores of each keyword in the composition title, select the preset number of keywords with the top-ranked scores as the second topic words, and output the second topic words.
[0169] For details, please refer to S305, which will not be elaborated here.
[0170] S310. Obtain the first confidence levels of each topic word included in each sentence in the composition content.
[0171] After obtaining the topic words of the composition content and the composition title, extract the topic sentences in the composition content of the target composition as a further explanation of the reason why the composition title and the composition content of the target composition are not relevant. The specific method for extracting topic sentences is as follows: The first step is to perform LDA topic analysis on each sentence in the composition content to obtain the first confidence levels of each keyword in each sentence. In this step, each sentence in the composition content is regarded as a document, and each keyword is regarded as a sentence of the document for topic analysis to obtain the first confidence level of each keyword.
[0172] S311. Take the maximum first confidence level among the first confidence levels of the respective topic words as the second confidence level of the sentence.
[0173] After obtaining the first confidence levels of each keyword, select the maximum first confidence level in each sentence as the second confidence level of the corresponding sentence. For example, if the maximum confidence level in a sentence is 0.7, then the second confidence level of this sentence is 0.7.
[0174] S312. Select the sentence with the maximum second confidence level in the composition content as the topic sentence that is consistent with the topic of the composition content.
[0175] Through step S311, the second confidence levels of each sentence in the composition content can be obtained. Select the sentence corresponding to the maximum second confidence level as the topic sentence of the composition. The topic sentence is the sentence in each sentence of the composition content that is consistent with the topic of the composition content, that is, the sentence that best reflects the topic of the composition content. After determining the topic sentence of the composition, output the topic sentence. As Figure 9 shown, output the topic sentence below the topic word in the lower half of the target composition.
[0176] Through the embodiments of the present application, the topic words of the composition content of the target composition and the topic words of the composition title are obtained, and the topic sentences consistent with the theme of the composition content are extracted. Using the topic words and topic sentences as the reasons for the irrelevance between the composition title and the composition content of the target composition can not only detect whether the composition title and the composition content of the target composition are relevant, but also provide the reasons for the irrelevance between the composition title and the composition content of the target composition, facilitating the examiner to check the compositions with irrelevant composition titles and composition contents.
[0177] Please refer to Figure 10 , which shows a schematic structural diagram of a composition detection device provided by an exemplary embodiment of the present application. The composition detection device can be implemented in whole or in part as a terminal through software, hardware, or a combination of both. The device 1 includes a keyword acquisition module 11, a matrix acquisition module 12, a matrix splicing module 13, a relevance adjustment module 14, and a structure output module 15.
[0178] The keyword acquisition module 11 is configured to acquire each first keyword in the composition title of the target composition and each second keyword in the composition content of the target composition;
[0179] The matrix acquisition module 12 is configured to calculate the relevance between each of the first keywords and each of the second keywords to obtain a first matrix, and calculate the relevance between each of the second keywords and each of the first keywords to obtain a second matrix;
[0180] The matrix splicing module 13 is configured to splice the first matrix and the second matrix by columns to obtain a third matrix;
[0181] The relevance adjustment module 14 is configured to adjust each relevance in the third matrix to obtain a fourth matrix, where each relevance in the fourth matrix represents the relevance between the composition content and the composition title;
[0182] The result output module 15 is configured to perform dimensionality reduction processing on the fourth matrix to obtain a two-dimensional fifth matrix, and output the result of whether the composition title and the composition content are relevant based on the fifth matrix.
[0183] Optionally, as Figure 11 shown, the matrix acquisition module 12 includes:
[0184] The relevance calculation unit 121 is configured to calculate the relevance between each of the first keywords and each of the second keywords;
[0185] The first matrix acquisition unit 122 is configured to normalize the relevance and perform weighted summation on each of the first keywords based on the normalized relevance to obtain a first matrix;
[0186] The relevance calculation unit 121 is further configured to calculate the relevance between each of the second keywords and each of the first keywords;
[0187] The second matrix obtaining unit 123 is configured to normalize the relevance, and perform weighted summation on each of the second keywords based on the normalized relevance to obtain a second matrix.
[0188] Optionally, as Figure 12 shown, the composition detection device 1 further includes:
[0189] The seventh matrix obtaining module 16 is configured to add the first matrix and each of the first keywords to obtain a sixth matrix, and perform layer normalization on the sixth matrix to obtain a seventh matrix;
[0190] The ninth matrix obtaining module 17 is configured to add the second matrix and each of the second keywords to obtain an eighth matrix, and perform layer normalization on the eighth matrix to obtain a ninth matrix;
[0191] The matrix splicing module 13 is specifically configured to splice the seventh matrix and the ninth matrix by columns to obtain a third matrix.
[0192] Optionally, as Figure 13 shown, the relevance adjustment module 14 includes:
[0193] The relevance adjustment unit 141 is configured to adjust each relevance in the third matrix based on pre-trained weight parameters;
[0194] The fourth matrix obtaining unit 142 is configured to weight each element in the third matrix based on each relevance to obtain the fourth matrix.
[0195] Optionally, as Figure 12 shown, the composition detection device 1 further includes:
[0196] The matrix addition module 18 is configured to add the third matrix and the fourth matrix to obtain a tenth matrix;
[0197] The twelfth matrix obtaining module 19 is configured to perform layer normalization on the tenth matrix to obtain an eleventh matrix, and perform a fitting degree reduction process on the eleventh matrix to obtain a twelfth matrix;
[0198] The result output module 15 is specifically configured to perform dimensionality reduction processing on the twelfth matrix to obtain a two-dimensional fifth matrix.
[0199] Optionally, as Figure 14 shown, the result output module 15 further includes:
[0200] An irrelevant determination unit 152, configured to output a result that the composition title is irrelevant to the composition content if an output result of the fifth matrix through the sigmoid function layer is a first value;
[0201] A relevant determination unit 153, configured to output a result that the composition title is relevant to the composition content if an output result of the fifth matrix through the sigmoid function layer is a second value.
[0202] Optionally, as Figure 12 shown, the composition detection device 1 further includes:
[0203] A first set obtaining module 110, configured to obtain a first set of topic words of the composition content under different topic categories based on a trained topic word recognition model if it is determined that the composition title of the target composition is irrelevant to the composition content;
[0204] A content category determination module 111, configured to determine a topic category with the highest confidence;
[0205] A content topic word output module 112, configured to determine a preset number of first topic words in the first set of topic words corresponding to the topic category with the highest confidence and output the first topic words if the highest confidence is greater than or equal to a first threshold;
[0206] A content keyword output module 113, configured to calculate scores of each keyword in the composition content by using a keyword extraction model, select a preset number of keywords with the highest scores as the first topic words, and output the first topic words if the highest confidence is less than the first threshold.
[0207] Optionally, as Figure 15 shown, the content keyword output module 113 includes:
[0208] A term frequency score obtaining unit 1131, configured to obtain a term frequency score of the importance of each keyword in the composition content in a corpus by using a term frequency-inverse document frequency algorithm;
[0209] A part-of-speech score obtaining unit 1132, configured to obtain a part-of-speech tagging score of each keyword in the composition content by using a part-of-speech tagging algorithm;
[0210] An extraction score obtaining unit 1133, configured to obtain a keyword extraction score of each keyword in the composition content by using a single-document unsupervised keyword extraction algorithm;
[0211] A score determination unit 1134, configured to perform weighted summation on the term frequency score, the part-of-speech tagging score, and the keyword extraction score to obtain a score of each keyword in the composition content.
[0212] Optionally, as Figure 12 shown, the composition detection device 1 further includes:
[0213] A second set acquisition module 114, configured to, if it is determined that the composition title of the target composition is not relevant to the composition content, obtain a second set of topic words of the composition title under different topic categories based on the trained topic word recognition model;
[0214] A topic category determination module 115, configured to determine the topic category with the highest confidence;
[0215] A topic topic word output module 116, configured to, if the highest confidence is greater than or equal to a second threshold, determine a preset number of second topic words in the first set of topic words corresponding to the topic category with the highest confidence, and output the second topic words;
[0216] A topic keyword output module 117, configured to, if the highest confidence is less than the second threshold, calculate the scores of each keyword in the composition title by using a keyword extraction model, select a preset number of keywords with the top-ranked scores as the second topic words, and output the second topic words.
[0217] Optionally, as Figure 16 shown, the topic content keyword output module 117 includes:
[0218] A word frequency score acquisition unit 1171, configured to obtain the word frequency scores of the importance of each keyword in the composition title in the corpus by using the term frequency-inverse document frequency index algorithm;
[0219] A part-of-speech score acquisition unit 1172, configured to obtain the part-of-speech tag scores of each keyword in the composition content by using a part-of-speech tagging algorithm;
[0220] An extraction score acquisition unit 1173, configured to obtain the keyword extraction scores of each keyword in the composition content by using a single-document unsupervised keyword extraction algorithm;
[0221] A score determination unit 1174, configured to perform weighted summation on the word frequency scores, the part-of-speech tag scores, and the keyword extraction scores to obtain the scores of each keyword in the composition title.
[0222] Optionally, as Figure 12 shown, the composition detection device 1 further includes:
[0223] A first confidence acquisition module 118, configured to obtain the first confidence of each topic word included in each statement in the composition content;
[0224] The second confidence level obtaining module 119 is configured to use the maximum first confidence level among the first confidence levels of the respective subject words as the second confidence level of the statement;
[0225] The topic sentence selection module 120 is configured to select the statement with the maximum second confidence level in the composition content as the topic sentence consistent with the topic of the composition content.
[0226] In the embodiment of the present application, the relevance between each keyword in the composition content of the target composition and each keyword in the composition title, and the relevance between each keyword in the composition title and each keyword in the composition content are respectively obtained. Based on the two relevances, corresponding matrices are respectively obtained. The two relevances are concatenated by columns and the relevance is adjusted to obtain a new matrix. The matrix is subjected to dimensionality reduction processing to obtain a two-dimensional matrix. Based on the two-dimensional matrix, it is detected whether the composition title of the target composition is relevant to the composition content. By adopting the embodiment of the present application, not only the limitation that the basis of the vector obtained by semantic representation needs to be orthogonal and isotropic is overcome, but also it is applicable to compositions of any question types. At the same time, the reduction of the recognition accuracy due to subjective reasons is avoided, and the accuracy of detecting whether the composition title of the target composition is relevant to the composition content is improved; after determining that the composition title of the target composition is not relevant to the composition content, the subject words of the composition content of the target composition and the subject words of the composition title are obtained, and the topic sentence consistent with the theme of the composition content is extracted. The subject words and the topic sentence are used as the reasons for explaining that the composition title of the target composition is not relevant to the composition content. It can not only detect whether the composition title of the target composition is relevant to the composition content, but also provide the reasons for the irrelevance between the composition title of the target composition and the composition content, which provides convenience for the examiner to check the composition with the irrelevance between the composition title and the composition content.
[0227] It should be noted that when the composition detection device provided in the above embodiment executes the composition detection method, only the above-mentioned division of each functional module is used for illustration. In practical applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the composition detection device provided in the above embodiment and the composition detection method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be elaborated here.
[0228] The serial numbers of the above embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.
[0229] The embodiment of the present application further provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor to execute the method steps of the embodiment as shown above Figures 1 - 9 The specific execution process can refer to Figures 1 - 9 the specific description of the embodiment as shown, which will not be elaborated here.
[0230] The present application also provides an electronic device, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to perform the above Figures 1 - 9 detailed description of the illustrated embodiments, which will not be elaborated herein.
[0231] Please refer to Figure 17 , which is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As Figure 17 shown, the electronic device 1000 may include: at least one processor 1001, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002.
[0232] Among them, the communication bus 1002 is used to realize the connection and communication between these components.
[0233] Among them, the user interface 1003 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 1003 may further include a standard wired interface and a wireless interface.
[0234] Among them, the network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
[0235] Among them, the processor 1001 may include one or more processing cores. The processor 1001 connects various parts within the entire electronic device 1000 through various interfaces and lines, and by running or executing instructions, programs, code sets or instruction sets stored in the memory 1005, and by calling data stored in the memory 1005, it performs various functions of the electronic device 1000 and processes data. Optionally, the processor 1001 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 1001 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communication. It can be understood that the above modem may not be integrated into the processor 1001 and may be implemented separately by a single chip.
[0236] Among them, the memory 1005 may include a Random Access Memory (RAM), or may also include a Read-Only Memory. Optionally, the memory 1005 includes a non-transitory computer-readable storage medium. The memory 1005 can be used to store instructions, programs, codes, code sets, or instruction sets. The memory 1005 may include a program storage area and a data storage area. Among them, the program storage area can store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area can store the data involved in the above-mentioned various method embodiments. Optionally, the memory 1005 may also be at least one storage device located far from the aforementioned processor 1001. As Figure 17 shown, the memory 1005, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a composition detection application program.
[0237] In Figure 17 the electronic device 1000 shown, the user interface 1003 is mainly used to provide an input interface for the user to obtain the data input by the user; and the processor 1001 can be used to call the composition detection application program stored in the memory 1005 and specifically perform the following operations:
[0238] Obtain each first keyword in the composition title of the target composition, and obtain each second keyword in the composition content of the target composition;
[0239] Calculate the relevance between each of the first keywords and each of the second keywords to obtain a first matrix, and calculate the relevance between each of the second keywords and each of the first keywords to obtain a second matrix;
[0240] Concatenate the first matrix and the second matrix by columns to obtain a third matrix;
[0241] Adjust each relevance in the third matrix to obtain a fourth matrix, where each relevance in the fourth matrix represents the relevance between the composition content and the composition title;
[0242] Perform dimensionality reduction processing on the fourth matrix to obtain a two-dimensional fifth matrix, and output a result indicating whether the composition title and the composition content are relevant based on the fifth matrix.
[0243] In one embodiment, when the processor 1001 calculates the relevance between each of the first keywords and each of the second keywords to obtain a first matrix, and calculates the relevance between each of the second keywords and each of the first keywords to obtain a second matrix, the following operations are specifically performed:
[0244] Calculate the relevance between each of the first keywords and each of the second keywords;
[0245] Normalize the relevance, and perform weighted summation on each of the first keywords based on the normalized relevance to obtain a first matrix;
[0246] Calculate the relevance between each of the second keywords and each of the first keywords;
[0247] Normalize the relevance, and perform weighted summation on each of the second keywords based on the normalized relevance to obtain a second matrix.
[0248] In one embodiment, before the processor 1001 performs column-wise concatenation of the first matrix and the second matrix to obtain a third matrix, the following operations are also performed:
[0249] Add the first matrix to each of the first keywords to obtain a sixth matrix, and perform layer normalization on the sixth matrix to obtain a seventh matrix;
[0250] Add the second matrix to each of the second keywords to obtain an eighth matrix, and perform layer normalization on the eighth matrix to obtain a ninth matrix;
[0251] The column-wise concatenation of the first matrix and the second matrix to obtain a third matrix includes:
[0252] Perform column-wise concatenation of the seventh matrix and the ninth matrix to obtain a third matrix.
[0253] In one embodiment, when the processor 1001 adjusts the relevances in the third matrix to obtain a fourth matrix, the following operations are specifically performed:
[0254] Adjust the relevances in the third matrix based on pre-trained weight parameters;
[0255] Weight each element in the third matrix based on each of the relevances to obtain the fourth matrix.
[0256] In one embodiment, after the processor 1001 adjusts the relevances in the third matrix to obtain a fourth matrix, the following operations are also performed:
[0257] Add the third matrix and the fourth matrix to obtain a tenth matrix;
[0258] Perform layer normalization on the tenth matrix to obtain an eleventh matrix, and perform a process of reducing the goodness of fit on the eleventh matrix to obtain a twelfth matrix;
[0259] The process of performing dimensionality reduction on the fourth matrix to obtain a two-dimensional fifth matrix includes:
[0260] Perform dimensionality reduction on the twelfth matrix to obtain a two-dimensional fifth matrix.
[0261] In one embodiment, when the processor 1001 executes to output a result indicating whether the composition title is relevant to the composition content based on the fifth matrix, the following operations are specifically performed:
[0262] If the output result of the fifth matrix through the softmax layer is a first value, output a result indicating that the composition title is not relevant to the composition content;
[0263] If the output result of the fifth matrix through the softmax layer is a second value, output a result indicating that the composition title is relevant to the composition content.
[0264] In one embodiment, after the processor 1001 executes to output a result indicating whether the composition title is relevant to the composition content based on the fifth matrix, the following operations are further performed:
[0265] If it is determined that the composition title of the target composition is not relevant to the composition content, obtain a first set of topic words of the composition content under different topic categories based on the trained topic word recognition model;
[0266] Determine the topic category with the highest confidence;
[0267] If the highest confidence is greater than or equal to a first threshold, determine a preset number of first topic words in the first set of topic words corresponding to the topic category with the highest confidence, and output the first topic words;
[0268] If the highest confidence is less than the first threshold, calculate the scores of each keyword in the composition content using a keyword extraction model, select a preset number of keywords with the top-ranked scores as the first topic words, and output the first topic words.
[0269] In one embodiment, when the processor 1001 executes to calculate the scores of each keyword in the composition content using a keyword extraction model, the following operations are specifically performed:
[0270] Use the term frequency-inverse document frequency algorithm to obtain the term frequency scores of the importance of each keyword in the composition content in the corpus;
[0271] Use a part-of-speech tagging algorithm to obtain the part-of-speech tagging scores of each keyword in the composition content;
[0272] Use a single-document unsupervised keyword extraction algorithm to obtain the keyword extraction scores of each keyword in the composition content;
[0273] Perform a weighted sum of the word frequency scores, the part-of-speech tagging scores, and the keyword extraction scores to obtain the scores of each keyword in the composition content.
[0274] In one embodiment, after the processor 1001 executes to output the result of whether the composition title is relevant to the composition content based on the fifth matrix, the following operations are further performed:
[0275] If it is determined that the composition title of the target composition is not relevant to the composition content, then obtain a second set of topic words of the composition title under different topic categories based on the trained topic word recognition model;
[0276] Determine the topic category with the highest confidence;
[0277] If the highest confidence is greater than or equal to the second threshold, then determine a preset number of second topic words in the first set of topic words corresponding to the topic category with the highest confidence, and output the second topic words;
[0278] If the highest confidence is less than the second threshold, then use a keyword extraction model to calculate the scores of each keyword in the composition title, select a preset number of keywords with the top-ranked scores as the second topic words, and output the second topic words.
[0279] In one embodiment, when the processor 1001 executes to calculate the scores of each keyword in the composition title using a keyword extraction model, the following operations are specifically performed:
[0280] Use the term frequency-inverse document frequency index algorithm to obtain the word frequency scores of the importance of each keyword in the composition title in the corpus;
[0281] Use a part-of-speech tagging algorithm to obtain the part-of-speech tagging scores of each keyword in the composition title;
[0282] Use a single-document unsupervised keyword extraction technique to obtain the keyword extraction scores of each keyword in the composition title;
[0283] Add the word frequency scores, the part-of-speech tagging scores, and the keyword extraction scores to obtain the scores of each keyword in the composition title.
[0284] In one embodiment, after the processor 1001 executes to output a result on whether the composition topic is relevant to the composition content based on the fifth matrix, the processor 1001 further performs the following operations:
[0285] Obtain the first confidence levels of each topic word included in each sentence in the composition content;
[0286] Take the maximum first confidence level among the first confidence levels of each topic word as the second confidence level of the sentence;
[0287] Select the sentence with the maximum second confidence level in the composition content as the topic sentence that is consistent with the topic of the composition content.
[0288] In the embodiments of the present application, the relevance between each keyword in the composition content of the target composition and each keyword in the composition topic, as well as the relevance between each keyword in the composition topic and each keyword in the composition content, are respectively obtained. Based on the two relevances, corresponding matrices are respectively obtained. The two relevances are concatenated by column and the relevance is adjusted to obtain a new matrix. The matrix is processed by dimensionality reduction to obtain a two-dimensional matrix. Based on the two-dimensional matrix, it is detected whether the composition topic of the target composition is relevant to the composition content. By adopting the embodiments of the present application, not only the limitation that the basis of the vector obtained by semantic representation needs to be orthogonal and isotropic is overcome, but also it is applicable to compositions of any question types. At the same time, the reduction of the recognition accuracy due to subjective reasons is avoided, and the accuracy of detecting whether the composition topic of the target composition is relevant to the composition content is improved; after it is determined that the composition topic of the target composition is not relevant to the composition content, the topic words of the composition content of the target composition and the topic words of the composition topic are obtained, and the topic sentence that is consistent with the topic of the composition content is extracted. The topic words and the topic sentence are used as the reasons to explain that the composition topic of the target composition is not relevant to the composition content. It can not only detect whether the composition topic is relevant to the composition content, but also provide the reasons why the composition topic of the target composition is not relevant to the composition content, which provides convenience for the examiner to check the composition whose composition topic is not relevant to the composition content.
[0289] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a magnetic disk, an optical disc, a read-only memory or a random access memory, etc.
[0290] The above-disclosed are only the preferred embodiments of the present application. Of course, the scope of the rights of the present application cannot be limited thereby. Therefore, equivalent changes made according to the claims of the present application still fall within the scope covered by the present application.
Claims
1. A composition detection method, characterized in that, Including: Obtain each first keyword in the composition title of the target composition, and obtain each second keyword in the composition content of the target composition; Calculate the relevance between each of the first keywords and each of the second keywords; Normalize the relevance, and perform weighted summation on each of the first keywords based on the normalized relevance to obtain a first matrix; Calculate the relevance between each of the second keywords and each of the first keywords; Normalize the relevance, and perform weighted summation on each of the second keywords based on the normalized relevance to obtain a second matrix; Concatenate the first matrix and the second matrix by columns to obtain a third matrix; Adjust the relevances in the third matrix to obtain a fourth matrix, where the relevances in the fourth matrix represent the correlation between the composition content and the composition title; Perform dimensionality reduction on the fourth matrix to obtain a two-dimensional fifth matrix, and output the result of whether the composition title is relevant to the composition content based on the fifth matrix.
2. The method according to claim 1, wherein Before concatenating the first matrix and the second matrix by columns to obtain a third matrix, it further includes: Add the first matrix and each of the first keywords to obtain a sixth matrix, and perform layer normalization on the sixth matrix to obtain a seventh matrix; Add the second matrix and each of the second keywords to obtain an eighth matrix, and perform layer normalization on the eighth matrix to obtain a ninth matrix; The step of concatenating the first matrix and the second matrix by columns to obtain a third matrix includes: Concatenate the seventh matrix and the ninth matrix by columns to obtain a third matrix.
3. The method according to claim 1, characterized in that, The step of adjusting the relevances in the third matrix to obtain a fourth matrix includes: Adjust the relevances in the third matrix based on pre-trained weight parameters; Weight each element in the third matrix based on each of the relevances to obtain the fourth matrix.
4. The method according to claim 1, wherein After adjusting the relevances in the third matrix to obtain a fourth matrix, it further includes: Add the third matrix and the fourth matrix to obtain a tenth matrix; Perform layer normalization on the tenth matrix to obtain an eleventh matrix, and perform a fitting degree reduction process on the eleventh matrix to obtain a twelfth matrix; The step of performing dimensionality reduction on the fourth matrix to obtain a two-dimensional fifth matrix includes: Perform dimensionality reduction on the twelfth matrix to obtain a two-dimensional fifth matrix.
5. The method according to claim 1, wherein The step of outputting the result of whether the composition title is relevant to the composition content based on the fifth matrix includes: If the output result of the fifth matrix through the normalized exponential function layer is a first value, output the result that the composition title is not relevant to the composition content; If the output result of the fifth matrix through the normalized exponential function layer is a second value, output the result that the composition title is relevant to the composition content.
6. The method according to claim 1, characterized in that After outputting the result of whether the composition title is relevant to the composition content based on the fifth matrix, it further includes: If it is determined that the composition title of the target composition is not relevant to the composition content, obtain a first set of topic words of the composition content under different topic categories based on the trained topic word recognition model; Determine the topic category with the highest confidence; If the highest confidence is greater than or equal to the first threshold, determine a preset number of first topic words in the first set of topic words corresponding to the topic category with the highest confidence, and output the first topic words; If the highest confidence is less than the first threshold, calculate the scores of each keyword in the composition content using a keyword extraction model, select a preset number of keywords with the top-ranked scores as the first topic words, and output the first topic words.
7. The method according to claim 6, wherein The calculating the scores of each keyword in the composition content using the keyword extraction model includes: Obtain the word frequency scores of the importance of each keyword in the composition content in the corpus using the term frequency-inverse document frequency index algorithm; Obtain the part-of-speech tagging scores of each keyword in the composition content using the part-of-speech tagging algorithm; Obtain the keyword extraction scores of each keyword in the composition content using the single-document unsupervised keyword extraction algorithm; Perform a weighted sum of the word frequency scores, the part-of-speech tagging scores, and the keyword extraction scores to obtain the scores of each keyword in the composition content.
8. The method according to claim 1, characterized in that After outputting the result of whether the composition title is relevant to the composition content based on the fifth matrix, it further includes: If it is determined that the composition title of the target composition is not relevant to the composition content, obtain the second set of topic words of the composition title under different topic categories based on the trained topic word recognition model; Determine the topic category with the highest confidence; If the highest confidence is greater than or equal to the second threshold, determine a preset number of second topic words in the first set of topic words corresponding to the topic category with the highest confidence, and output the second topic words; If the highest confidence is less than the second threshold, calculate the scores of each keyword in the composition title using a keyword extraction model, select a preset number of keywords with the top-ranked scores as the second topic words, and output the second topic words.
9. The method according to claim 8, characterized in that The calculating the scores of each keyword in the composition title using the keyword extraction model includes: Obtain the word frequency scores of the importance of each keyword in the composition title in the corpus using the term frequency-inverse document frequency index algorithm; Obtain the part-of-speech tagging scores of each keyword in the composition title using the part-of-speech tagging algorithm; Obtain the keyword extraction scores of each keyword in the composition title using the single-document unsupervised keyword extraction algorithm; Add the word frequency scores, the part-of-speech tagging scores, and the keyword extraction scores to obtain the scores of each keyword in the composition title.
10. The method according to claim 1, wherein After outputting the result of whether the composition title is relevant to the composition content based on the fifth matrix, it further includes: Obtain the first confidence of each topic word included in each sentence in the composition content; Take the maximum first confidence among the first confidences of each topic word as the second confidence of the sentence; Select the sentence with the maximum second confidence in the composition content as the topic sentence consistent with the topic of the composition content.
11. A computer storage medium, characterized in that, The computer storage medium has multiple instructions, and the instructions are suitable for being loaded and executed by a processor to perform the method steps of any one of claims 1 to 10.
12. An electronic device, characterized in that, It includes: A processor and a memory; wherein, the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor to perform the method steps of any one of claims 1 to 10.
Citation Information
Patent Citations
Off-subject composition detection method and apparatus, and terminal device
CN107301169A
Theme correlation determination method and device, storage medium and terminal device
CN110222334A