Sentence category determination method and device, equipment, storage medium, program product
Patent Information
- Application Number
- CN202310288345.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-16
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-03-16
AI Technical Summary
[0019]根据本申请实施例的一个方面,还提供了一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现上述的语句类目的确定方法。
Smart Images

Figure CN118673141B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, specifically to a method, apparatus, device, storage medium, and program product for determining statement categories. Background Technology
[0002] Thematic categories represent the core theme of an article and are generally the basic basis for organizing and categorizing articles. They are also fundamental in many business applications. Especially in search scenarios, by identifying relevant terms in sentences, they provide users with the ability to retrieve articles with the corresponding thematic categories.
[0003] However, simply identifying categories based on relevant nouns in a sentence often results in incorrect or inaccurate classifications. Summary of the Invention
[0004] To address the aforementioned technical problems, embodiments of this application provide a method and apparatus for determining statement categories, an electronic device, a computer-readable storage medium, and a computer program product, respectively, to improve the accuracy of determining statement categories.
[0005] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0006] According to one aspect of the embodiments of this application, a method for determining a statement category is provided, comprising: inputting a statement to be processed into multiple network layers, and selecting multiple target network layers from the multiple network layers; obtaining feature vectors of the statement to be processed output by each target network layer, thereby obtaining multiple feature vectors; calculating the matching probability of the statement to be processed with each preset category based on the multiple feature vectors, thereby obtaining multiple probability parameters; and determining the target preset category to which the statement to be processed belongs based on the multiple probability parameters.
[0007] According to one aspect of the embodiments of this application, a statement category determination apparatus is provided, comprising: an extraction module configured to input a statement to be processed into multiple network layers and select multiple target network layers from the multiple network layers; an acquisition module configured to acquire feature vectors of the statement to be processed output by each target network layer, thereby obtaining multiple feature vectors; a calculation module configured to calculate the matching probability of the statement to be processed with each preset category based on the multiple feature vectors, thereby obtaining multiple probability parameters; and a determination module configured to determine the target preset category to which the statement to be processed belongs based on the multiple probability parameters.
[0008] In another exemplary embodiment, the determining module includes: a probability distribution matrix construction unit, configured to construct a probability distribution matrix of all preset categories corresponding to the statement to be processed based on multiple probability parameters; and a target preset category determining unit, configured to select the probability parameter with the largest value from the probability distribution matrix as the target probability parameter, and to take the preset category corresponding to the target probability parameter as the target preset category to which the statement to be processed belongs.
[0009] In another exemplary embodiment, the calculation module includes: a feature vector acquisition unit configured to acquire feature vectors for each preset category; a first calculation unit configured to perform quotient operations on the plurality of feature vectors and the feature vectors of the preset category for each preset category, obtain a plurality of calculation results, and use the plurality of calculation results as the matching probability of the plurality of feature vectors and the preset category; and a second calculation unit configured to calculate the matching probability of the statement to be processed and each preset category based on the matching probability of the plurality of feature vectors and each preset category, and obtain a plurality of probability parameters.
[0010] In another exemplary embodiment, the extraction module includes: a selection rule acquisition unit configured to acquire a preset network layer interval selection rule; wherein the network layer interval selection rule is used to characterize the number of network layers between which a target network layer is selected from the plurality of network layers; and a selection unit configured to select the plurality of target network layers from the plurality of network layers based on the preset network layer interval selection rule.
[0011] In another exemplary embodiment, the plurality of network layers are a plurality of network layers arranged in sequence; the extraction module includes: a feature vector output unit, configured to input the statement to be processed into the first network layer corresponding to the plurality of network layers arranged in sequence, and to perform feature extraction sequentially through the plurality of network layers to obtain the feature vector output by each network layer.
[0012] In another exemplary embodiment, the statement category determination device further includes: an input module configured to input sample statements into a training model containing multiple network layers and obtain sample feature vectors output by multiple target network layers among the multiple network layers; a loss function value calculation module configured to calculate a loss function value corresponding to all preset categories for each sample feature vector based on the multiple sample feature vectors; a target loss function value calculation module configured to calculate a target loss function value based on the loss function values corresponding to all preset categories for each sample feature vector; and a training module configured to train the training model based on the target loss function value to obtain a category classification model.
[0013] In another exemplary embodiment, the loss function value calculation module includes: a calculation unit configured to perform a calculation on the plurality of sample feature vectors and the preset category for each preset category to obtain the matching probability of each sample feature vector corresponding to the preset category; and a loss function value calculation unit configured to calculate the loss function value of each sample feature vector corresponding to all preset categories based on the matching probability of each sample feature vector corresponding to each preset category.
[0014] In another exemplary embodiment, the loss function value calculation unit includes: a first calculation module configured to calculate the loss function value of each sample feature vector corresponding to each preset category based on the matching probability of each sample feature vector corresponding to each preset category; and a second calculation module configured to calculate the loss function value of each sample feature vector corresponding to all preset categories based on the loss function value of each sample feature vector corresponding to each preset category.
[0015] In another exemplary embodiment, the target loss function value calculation module includes: a preset weight value unit configured to obtain a preset weight value corresponding to each loss function; and a target loss function value calculation unit configured to calculate the target loss function value based on the loss function values of all preset categories corresponding to each sample feature vector and the preset weight value corresponding to each loss function value.
[0016] In another exemplary embodiment, the target loss function value calculation unit includes: a product operation module, configured to multiply the loss function values corresponding to all preset categories of each sample feature vector and the weight values corresponding to each loss function value to obtain the product result corresponding to each sample feature vector; and a target loss function value module, configured to sum the product results corresponding to each training vector and use the sum result as the target loss function value.
[0017] According to one aspect of the embodiments of this application, an electronic device is provided, including: a controller; and a memory for storing one or more programs, which, when executed by the controller, perform the above-described method for determining statement categories.
[0018] According to one aspect of the embodiments of this application, a computer-readable storage medium is also provided, on which computer-readable instructions are stored, which, when executed by a computer's processor, cause the computer to perform the above-described method for determining statement categories.
[0019] According to one aspect of the embodiments of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the above-described method for determining statement categories.
[0020] In the technical solution provided by the embodiments of this application, the statement to be processed is input into multiple network layers, and multiple target network layers are selected from the multiple network layers; the feature vector of the statement to be processed output by each target network layer is obtained, resulting in multiple feature vectors; the matching probability between the statement to be processed and each preset category is calculated based on the multiple feature vectors, resulting in multiple probability parameters; and the target preset category to which the statement to be processed belongs is determined based on the multiple probability parameters. Because the multiple feature vectors in this application are extracted from different target network layers, there are feature differences between the multiple feature vectors. By introducing multiple feature vectors with feature differences, the semantic features of the statement to be processed can be more comprehensively represented, and the matching probability between the statement to be processed and each preset category calculated based on these multiple feature vectors is made more accurate, thereby accurately determining the target preset category to which the statement to be processed belongs.
[0021] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description
[0022] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:
[0023] Figure 1 This is a schematic diagram of one implementation environment involved in this application;
[0024] Figure 2 This is a flowchart illustrating a method for determining statement categories according to an exemplary embodiment of this application;
[0025] Figure 3 Based on Figure 2 The illustrated embodiment presents a flowchart of another method for determining statement categories;
[0026] Figure 4 Based on Figure 2 The illustrated embodiment presents a flowchart of another method for determining statement categories;
[0027] Figure 5 Based on Figure 2The illustrated embodiment presents a flowchart of another method for determining statement categories;
[0028] Figure 6 Based on Figure 2 The illustrated embodiment presents a flowchart of another method for determining statement categories;
[0029] Figure 7 This is a schematic diagram illustrating the processing flow of a sequence of input statements in multiple network layers, as shown in an exemplary embodiment of this application.
[0030] Figure 8 Based on Figures 2 to 6 A flowchart illustrating another method for determining statement categories is shown in any of the embodiments described above;
[0031] Figure 9 Based on Figure 8 The illustrated embodiment presents a flowchart of another method for determining statement categories;
[0032] Figure 10 Based on Figure 9 The illustrated embodiment presents a flowchart of another method for determining statement categories;
[0033] Figure 11 Based on Figure 8 The illustrated embodiment presents a flowchart of another method for determining statement categories;
[0034] Figure 12 Based on Figure 11 The illustrated embodiment presents a flowchart of another method for determining statement categories;
[0035] Figure 13 This is a schematic diagram illustrating the calculation process of the target loss function value according to an exemplary embodiment of this application;
[0036] Figure 14 This is a schematic diagram illustrating the structure of a statement category determination device according to an exemplary embodiment of this application;
[0037] Figure 15 This is a schematic diagram of the structure of a computer system for an electronic device, as illustrated in an exemplary embodiment of this application. Detailed Implementation
[0038] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0039] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0040] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0041] In this application, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0042] First, it should be noted that cloud technology refers to a hosting technology that unifies hardware, software, network, and other resources within a wide area network (WAN) or local area network (LAN) to achieve data computation, storage, processing, and sharing. The method illustrated in the embodiments of this application can perform audio processing in the cloud and store the processed music chorus in a remote database, which can then be directly sent to other ports.
[0043] Cloud technology is a collective term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form resource pools, providing flexible and convenient on-demand access. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will all require robust system support, which can only be achieved through cloud computing.
[0044] The method and apparatus for determining statement categories, electronic devices, computer-readable storage media, and computer program products proposed in this application relate to the cloud technology described above. These embodiments will be described in detail below.
[0045] In search scenarios, relevant nouns are typically extracted from the input statement to display category information matching those nouns. However, this often results in incorrect or inaccurate category information. Therefore, this application provides a method for determining statement categories to improve the accuracy of category determination.
[0046] Please see Figure 1 , Figure 1 This is a schematic diagram of one implementation environment involved in this application. For example... Figure 1 As shown, this implementation environment includes client 110 and server 120, which communicate with each other via wired or wireless network. The process for determining the relevant statement categories is illustrated in the following example:
[0047] For example, client 110 is used to collect the statement to be processed input by the operation object, and send the collected statement to server 120 for statement category determination. Server 120 inputs the statement to be processed into multiple network layers, and selects multiple target network layers from the multiple network layers; obtains the feature vector of the statement to be processed output by each target network layer, and obtains multiple feature vectors; calculates the matching probability of the statement to be processed with each preset category based on the multiple feature vectors, and obtains multiple probability parameters; determines the target preset category to which the statement to be processed belongs based on the multiple probability parameters; and sends the target preset category to client 110 so that client 110 can display the target preset category.
[0048] Client 110 is a device with data acquisition capabilities, which can be a smartphone, laptop, smart tablet, etc., without restriction. Server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. Multiple servers can form a blockchain, and the server is a node on the blockchain. Server 120 can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, without restriction.
[0049] Please see Figure 2 , Figure 2 This is a flowchart illustrating an exemplary embodiment of this application, showing a method for determining statement categories. The method can be... Figure 1 The method is specifically executed by server 120 in the illustrated implementation environment. Of course, this method can also be applied to other implementation environments and executed by server devices in other implementation environments; this embodiment does not limit this.
[0050] The method for determining statement categories provided in this embodiment will be described below, using a server as an example execution subject. For example... Figure 2 As shown, the method includes at least S210 to S240, which are described in detail below:
[0051] S210: Input the statement to be processed into multiple network layers, and select multiple target network layers from the multiple network layers.
[0052] The sentence to be processed is a sentence containing multiple nouns, verbs, adverbs, etc. For example, the sentence to be processed is: "This novel written by the famous author A was eventually adapted into a movie by director B."
[0053] Network layers are feature extraction layers used to extract the feature vectors corresponding to the statements to be processed. Each network layer can extract feature vectors from the statements to be processed.
[0054] In this embodiment, the feature vector output by the target network layer is selected for subsequent determination of the sentence category. The target network layer can be selected randomly or according to certain selection rules.
[0055] S220: Obtain the feature vector of the statement to be processed output by each target network layer, and obtain multiple feature vectors.
[0056] For example, there are 12 network layers in total. The 4th, 8th and 12th network layers are selected as target network layers, and the feature vectors of the statements to be processed output by these three network layers are obtained respectively.
[0057] In another example, there are a total of 12 network layers. The 3rd, 8th and 10th network layers are selected as target network layers, and the feature vectors of the statements to be processed output by these three network layers are obtained respectively.
[0058] S230: Calculate the matching probability between the statement to be processed and each preset category based on multiple feature vectors to obtain multiple probability parameters.
[0059] Match probability is a numerical value that represents the degree of matching between the statement to be processed and the preset category. The higher the match probability, the higher the degree of matching between the statement to be processed and the preset category, and vice versa.
[0060] The calculation process of matching probability is illustrated as follows: Multiple feature vectors are numerically converted with the preset feature vectors corresponding to each preset category. Then, the quotient of the numerical values corresponding to the multiple feature vectors is calculated with the numerical values corresponding to each preset feature vector. The quotient is used as multiple feature vectors to calculate the matching probability between the statement to be processed and each preset category. The probability parameter is then obtained based on the matching probability.
[0061] For example, multiple feature vectors, including a first feature vector, a second feature vector, and a third feature vector, are input into different classifiers for classification fitting, as follows:
[0062] Logits1=Classifier1(L1-emb);
[0063] The classifier Classifier1 consists of a fully connected layer and a softmax layer. The input dimension of the fully connected layer is the number of categories.
[0064] Logits2=Classifier2(L2-emb);
[0065] The classifier Classifier2 consists of a fully connected layer and a softmax layer. The input dimension of the fully connected layer is the number of categories.
[0066] Logits3=Classifier3(L3-emb);
[0067] The classifier Classifier3 consists of a fully connected layer and a softmax layer. The input dimension of the fully connected layer is the number of categories.
[0068] Inputting the above Logits into softmax yields the final multi-category probability distribution: A = softmax(Logits); where A = [a1, a2, ..., a...]. n ], a i This represents the probability of matching the preset category i, which is the probability parameter in this embodiment.
[0069] S240: Determine the target preset category to which the statement to be processed belongs based on multiple probability parameters.
[0070] The target preset category is a preset parameter, which refers to the preset category to which the statement to be processed belongs. It can be one or more of multiple preset categories, such as literature, philosophy, science, engineering, etc. This application does not limit the specific information of the category. For example, the statement to be processed may belong to the literature category and / or the philosophy category.
[0071] S240 is illustrated as follows: obtain the values corresponding to multiple probability parameters, and determine the preset category corresponding to the probability parameter with the largest value among the multiple probability parameters as the target preset category to which the statement to be processed belongs, thereby displaying relevant articles, information and other materials under the target preset category.
[0072] This embodiment inputs the statement to be processed into multiple network layers and selects multiple target network layers from these layers. It then obtains the feature vectors of the statement output by each target network layer, resulting in multiple feature vectors with distinct characteristics extracted from different target network layers. Based on these multiple feature vectors, it calculates the matching probability between the statement to be processed and each preset category, obtaining multiple probability parameters. This approach, by introducing multiple feature vectors with distinct characteristics, more comprehensively represents the semantic features of the statement to be processed, thus making the calculated matching probability more accurate. Finally, based on these multiple probability parameters, it determines the target preset category to which the statement to be processed belongs, thereby accurately and quickly identifying the target preset category to which the statement to be processed belongs.
[0073] This application provides a detailed explanation of how to determine the target preset category to which the statement to be processed belongs based on multiple probability parameters; please refer to [link to relevant documentation]. Figure 3 , Figure 3 Based on Figure 2 The illustrated embodiment presents a flowchart of another method for determining statement categories. The method in this embodiment, as shown in the example... Figure 2 The S240 shown also includes at least S310 to S320, which are described in detail below:
[0074] S310: Construct a probability distribution matrix for all preset categories corresponding to the statement to be processed based on multiple probability parameters.
[0075] For example, the multiple probability parameters in this embodiment include a first probability parameter, a second probability parameter, and a third probability parameter. The first probability parameter is the matching probability calculated between multiple feature vectors and a first preset category, and the first probability parameter represents the degree of matching between the statement to be processed and the first preset category; the second probability parameter is the matching probability calculated between multiple feature vectors and a second preset category, and the second probability parameter represents the degree of matching between the statement to be processed and the second preset category; the third probability parameter is the matching probability calculated between multiple feature vectors and a third preset category, and the third probability parameter represents the degree of matching between the statement to be processed and the third preset category. Based on the first probability parameter, the second probability parameter, and the third probability parameter of the first preset category, the constructed probability distribution matrix is [first probability parameter, second probability parameter, third probability parameter].
[0076] S320: Select the probability parameter with the largest value from the probability distribution matrix as the target probability parameter, and take the preset category corresponding to the target probability parameter as the target preset category to which the statement to be processed belongs.
[0077] For example, the probability distribution matrix is (0.45, 0.9, 0.12), where 0.45 represents the degree of matching between the statement to be processed and the first preset category, 0.9 represents the degree of matching between the statement to be processed and the second preset category, and 0.12 represents the degree of matching between the statement to be processed and the third preset category. Clearly, 0.9 is the probability parameter with the largest value, and it is used as the target probability parameter, with the second preset category being taken as the target preset category to which the statement to be processed belongs.
[0078] This embodiment constructs a probability distribution matrix of all preset categories corresponding to the statement to be processed based on multiple probability parameters. The probability distribution matrix clearly shows the degree of matching between the statement to be processed and each preset category. The probability parameter with the largest value in the probability distribution matrix is selected as the target probability parameter, and the preset category corresponding to the target probability parameter is taken as the target preset category to which the statement to be processed belongs, making the process of determining the target preset category more convenient and faster.
[0079] In another exemplary embodiment of this application, a method for calculating multiple probability parameters is illustrated; please refer to [link to relevant documentation] for details. Figure 4 , Figure 4 Based on Figure 2 The illustrated embodiment presents a flowchart of another method for determining statement categories. The method in this embodiment, as shown in the example... Figure 2 The S230 shown also includes at least S410 to S430, which are described in detail below:
[0080] S410: Obtain the feature vector for each preset category.
[0081] For example, as shown in Table 1, Table 1 contains feature vectors corresponding to preset category vectors. The feature vector corresponding to each preset category is obtained based on Table 1.
[0082] First Preset Category First eigenvector Second preset category Second eigenvector Third Preset Category Third eigenvector Fourth Preset Category Fourth eigenvector …… ……
[0083] Table 1
[0084] S420: For each preset category, perform quotient operations on multiple feature vectors and feature vectors of the preset category respectively to obtain multiple operation results, and use the multiple operation results as the matching probability of multiple feature vectors and preset categories.
[0085] For example, multiple feature vectors are feature vector A, feature vector B, and feature vector C. For a first preset category, the feature vector corresponding to it is determined by Table 1 as the first feature vector. Then, feature vector A, feature vector B, and feature vector C are divided by the first feature vector to obtain the first operation result (i.e., the matching probability of feature vector A with the first preset category), the second operation result (i.e., the matching probability of feature vector B with the first preset category), and the third operation result (i.e., the matching probability of feature vector C with the first preset category).
[0086] S430: Based on the matching probability of multiple feature vectors with each preset category, calculate the matching probability of the statement to be processed with each preset category to obtain multiple probability parameters.
[0087] For example, the first, second, and third calculation results in the above example are averaged, and the calculated average is used as the matching probability between the statement to be processed and the first preset category.
[0088] In another example, the first, second, and third calculation results in the above example are averaged to obtain their variance or standard deviation. If the variance or standard deviation is large, multiple calculation results are filtered out. After filtering out abnormal data, the average is calculated again, and the calculated average is used as the matching probability between the statement to be processed and the first preset category.
[0089] This embodiment provides a method for calculating the matching probability between a statement to be processed and each preset category. Multiple feature vectors are divided by the feature vectors of the preset categories to obtain multiple calculation results. These multiple calculation results are used as the matching probabilities between multiple feature vectors and the preset categories to accurately obtain multiple probability parameters.
[0090] How to select the target network layer is described in detail in another exemplary embodiment of this application; please refer to [link / reference needed]. Figure 5 , Figure 5 Based on Figure 2 The illustrated embodiment presents a flowchart of another method for determining statement categories. The method in this embodiment, as shown in the example... Figure 2 The S210 shown also includes at least S510 to S520, which are described in detail below:
[0091] S510: Obtain the preset network layer interval selection rule; wherein, the network layer interval selection rule is used to characterize the number of network layers between which a target network layer is selected from multiple network layers.
[0092] In some embodiments, a certain number of target network layers are randomly selected from multiple network layers.
[0093] S520: Select multiple target network layers from multiple network layers based on preset network layer interval selection rules.
[0094] For example, there are a total of 12 network layers. The preset network layer interval selection rule is to select a target network layer every 3 network layers. If the first network layer is the target network layer, then the fourth, seventh and tenth network layers are the target network layers.
[0095] In another example, there are a total of 12 network layers. The preset rule for selecting the network layer interval is to select a target network layer every 4 network layers. If the fourth network layer is the target network layer, then the eighth and twelfth network layers are the target network layers.
[0096] This embodiment provides a method for selecting target network layers based on network layer interval selection rules, which makes there a certain pattern among the selected target network layers and strengthens the connection between the feature vectors output by the multiple target network layers.
[0097] In another exemplary embodiment of this application, the multiple network layers are multiple network layers arranged in a sequential order. The method for inputting the statement to be processed into the multiple network layers is described in detail; please refer to [link to relevant documentation]. Figure 6 , Figure 6 Based on Figure 2 The illustrated embodiment presents a flowchart of another method for determining statement categories. The method in this embodiment, as shown in the example... Figure 2 S210 shown includes at least S610, which is described in detail below:
[0098] S610: Input the statement to be processed into the first network layer corresponding to multiple network layers arranged in sequence, and extract features through multiple network layers in sequence to obtain the feature vector output by each network layer.
[0099] For example, such as Figure 7 As shown, Figure 7 This is a schematic diagram illustrating the processing flow of multiple network layers in a sequential sequence of input statements, as shown in an exemplary embodiment of this application. The twelve network layers are arranged and combined in sequence. The statement to be processed, "This novel written by famous author A was ultimately adapted for the screen by director B," is input into the first network layer, which outputs a corresponding first feature vector. After passing through the first network layer, it is input into the second network layer, which outputs a corresponding second feature vector. This process continues until the twelfth network layer outputs a corresponding twelfth feature vector. If a certain network layer is selected as the target network layer, the feature vector output by that network layer is the feature vector used in this embodiment to determine the statement category.
[0100] This embodiment further illustrates that multiple network layers are arranged sequentially, and each network layer can promptly extract feature vectors from the statements to be processed after the feature vectors of the outputs of adjacent network layers, thus ensuring the continuity of the data processing process.
[0101] If the methods for determining statement categories in the above embodiments are applied to a category classification model, the category classification model needs to be trained beforehand. Therefore, another exemplary embodiment of this application provides a detailed description of this method; please refer to [link to relevant documentation]. Figure 8 , Figure 8 Based on Figures 2 to 6 The flowchart illustrates another method for determining statement categories in any of the embodiments shown. Before S210, the method in this embodiment includes at least S810 to S840, which are described in detail below:
[0102] S810: Input the sample statement into the training model containing multiple network layers, and obtain the sample feature vectors output by multiple target network layers.
[0103] Sample statements are statements used to train the model, which improve the accuracy of the model's output. These statements are input into multiple target network layers to obtain multiple sample feature vectors, which are then used to calculate the relevant loss function values.
[0104] S820: Calculate the loss function value for each sample feature vector corresponding to all preset categories based on multiple sample feature vectors.
[0105] For example, the sample feature vector includes a first sample feature vector, a second sample feature vector, and a third sample feature vector. A first loss function is calculated for the first sample feature vector corresponding to all preset categories, a second loss function is calculated for the second sample feature vector corresponding to all preset categories, and a third loss function is calculated for the third sample feature vector corresponding to all preset categories.
[0106] S830: Calculate the target loss function value based on the loss function values of all preset categories corresponding to the feature vector of each sample.
[0107] For example, the first loss function, the second loss function and the third loss function described in S820 are averaged, and the resulting average is used as the target loss function value.
[0108] S840: Train the model to be trained based on the target loss function value to obtain the category classification model.
[0109] The training parameters in the model to be trained are adjusted according to the target loss function value to complete the training of the model and obtain the category classification model.
[0110] In this embodiment, sample sentences are input into the target network layer as initial training parameters to obtain multiple sample feature vectors. The loss function values corresponding to all preset categories for each sample feature vector are then calculated. This allows for the accurate calculation of the target loss function value used to train the model to be trained, thereby completing the training and adjustment of the model and resulting in a more accurate category classification model.
[0111] In another exemplary embodiment of this application, the method for calculating the loss function values for all preset categories corresponding to each sample feature vector is described in detail. Please refer to [link to relevant documentation] for details. Figure 9 , Figure 9 Based on Figure 8 The illustrated embodiment presents a flowchart of another method for determining statement categories. The method in this embodiment, as shown in the example... Figure 8 The S820 shown includes at least S910 to S920, which are described in detail below:
[0112] S910: For each preset category, perform operations on multiple sample feature vectors with the preset category to obtain the matching probability of each sample feature vector corresponding to the preset category.
[0113] For example, the number of sample feature vectors is three, that is, it includes three sample feature vectors. For the first preset category, the three sample feature vectors are numerically processed and compared with the preset feature vectors corresponding to the preset category, and the matching probability of the preset category corresponding to each sample feature vector is calculated.
[0114] S920: Based on the matching probability of each sample feature vector corresponding to each preset category, calculate the loss function value of each sample feature vector corresponding to all preset categories.
[0115] In this embodiment, for each preset category, the matching probability of each sample feature vector corresponding to the preset category is calculated sequentially, thereby quickly and accurately calculating the loss function value of each sample feature vector corresponding to all preset categories.
[0116] In another exemplary embodiment of this application, the method for calculating the loss function values for all preset categories corresponding to each sample feature vector is described in detail. Please refer to [link to relevant documentation] for details. Figure 10 , Figure 10 Based on Figure 9 The illustrated embodiment presents a flowchart of another method for determining statement categories. The method in this embodiment, as shown in the example... Figure 9 The S920 shown includes at least S1010 to S1020, which are described in detail below:
[0117] S1010: Based on the matching probability of each sample feature vector corresponding to each preset category, calculate the loss function value of each sample feature vector corresponding to each preset category.
[0118] For example, the loss function value for each sample feature vector corresponding to each preset category is calculated according to the following formula:
[0119] B (n) =-(y i loga i );
[0120] Among them, B (n) This represents the loss function values for all preset categories corresponding to the feature vector of the nth sample; i represents the preset category order; y i It is 0 or 1; a i This represents the matching probability of the sample feature vector corresponding to the i-th preset category.
[0121] S1020: Based on the loss function value corresponding to each preset category for each sample feature vector, calculate the loss function value corresponding to all preset categories for each sample feature vector.
[0122] B above (n) Perform a summation operation, or calculate the loss function value for each sample feature vector corresponding to all preset categories according to the following formula:
[0123]
[0124] Where loss represents the loss function value for all preset categories corresponding to the feature vector of the nth sample; cls(n) represents the feature vector of the nth sample; n represents the number of preset categories; i represents the order of preset categories; y i It is 0 or 1; a i This represents the matching probability of the sample feature vector corresponding to the i-th preset category.
[0125] If the sample feature vectors are cls(1), cls(2), and cls(3), then the first sample feature vector corresponds to the loss function values of all preset categories. a i1 The first sample feature vector represents the matching probability of the i-th preset category; the second sample feature vector represents the loss function value of all preset categories. a i2 The second sample feature vector represents the matching probability of the i-th preset category; the third sample feature vector represents the loss function value of all preset categories. a i3This represents the matching probability of the third sample feature vector corresponding to the i-th preset category; that is, the loss function value of each sample feature vector corresponding to all preset categories is obtained.
[0126] This embodiment details how to quickly calculate the loss function value for each sample feature vector corresponding to all preset categories. By assigning each sample feature vector to the matching probability of each preset category, the loss function value for each sample feature vector corresponding to each preset category is calculated. The matching probability is linked to the loss function, and based on the loss function value for each sample feature vector corresponding to each preset category, the loss function value for each sample feature vector corresponding to all preset categories is accurately calculated.
[0127] In another exemplary embodiment of this application, the method for calculating the target loss function value is described in detail; please refer to [link to relevant documentation]. Figure 11 , Figure 11 Based on Figure 8 The illustrated embodiment presents a flowchart of another method for determining statement categories. The method in this embodiment, as shown in the example... Figure 8 The S830 shown includes at least S1110 to S1120, which are described in detail below:
[0128] S1110: Obtain the preset weight value corresponding to each loss function.
[0129] The preset weight value is used to calculate the target loss function value. The larger the weight value, the greater the weight of the corresponding loss function and the greater the impact on the target loss function value.
[0130] S1120: Calculate the target loss function value based on the loss function values of all preset categories corresponding to each sample feature vector and the preset weight value corresponding to each loss function value.
[0131] For example, the sample feature vector includes a first sample feature vector, a second sample feature vector, and a third sample feature vector. The first sample feature vector corresponds to the loss function value for all preset categories. cls(1) loss cls(1) The corresponding preset weight value is λ1; the loss function value for all preset categories corresponding to the second sample feature vector is loss. cls(2) loss cls(2) The corresponding preset weight value is λ2; the loss function value for the third sample feature vector corresponding to all preset categories is loss. cls(3) loss cls(3) The corresponding preset weight value is λ3. The target loss function value can be calculated using the following formula:
[0132]
[0133] Where, loss all This represents the target loss function; the values of λ1, λ2, and λ3 can be chosen according to the actual situation.
[0134] This embodiment further illustrates how to calculate the target loss function value. When calculating the target loss function value, a preset weight value corresponding to the relevant sample feature vector is introduced to refine the influence of each loss function on the target loss function, making the target loss function more accurate.
[0135] In another exemplary embodiment of this application, the above-described S1120 is described in detail; please refer to [link / reference needed]. Figure 12 , Figure 12 Based on Figure 11 The illustrated embodiment presents a flowchart of another method for determining statement categories. The method in this embodiment, as shown in the example... Figure 11 S1120 shown includes at least S1210 to S1220, which are described in detail below:
[0136] S1210: Multiply the loss function values of all preset categories corresponding to each sample feature vector and the weight values corresponding to each loss function value to obtain the product result corresponding to each sample feature vector.
[0137] For example, the loss function value for all preset categories corresponding to the feature vector of the first sample is loss. cls(1) loss cls(1) The corresponding preset weight value is λ1; λ1loss cls(1) This is the product result corresponding to the feature vector of the first sample, and so on, to obtain the product result corresponding to the feature vector of each sample.
[0138] S1220: Summate the product results of each training vector and use the sum as the target loss function value.
[0139] The target loss function value is the sum of the products of all training vectors, which is obtained by adding the products of each training vector and the sum is the target loss function value.
[0140] This embodiment is illustrated by way of example: the sample feature vector includes a first sample feature vector, a second sample feature vector, and a third sample feature vector. The first sample feature vector corresponds to the loss function value for all preset categories. cls(1) loss cls(1) The corresponding preset weight value is λ1; the loss function value for all preset categories corresponding to the second sample feature vector is loss. cls(2) loss cls(2)The corresponding preset weight value is λ2; the loss function value for the third sample feature vector corresponding to all preset categories is loss. cls(3) loss cls(3) The corresponding preset weight value is λ3, and the target loss function is calculated according to the following formula:
[0141] loss all =λ1loss cls(1) +λ2loss cls(2) +λ3loss cls(3) ;
[0142] Where, loss all The target loss function is represented by λ1:λ2:λ3. The ratio of λ1:λ2:λ3 can be adjusted according to the actual situation, but the sum of all weight values is 1. In the preferred embodiment, λ1:λ2:λ3 = 5:3:2. The target loss function calculated with this ratio is the most accurate, making the trained category classification model more accurate.
[0143] This embodiment provides a specific method for calculating the target loss function value. The loss function value corresponding to all preset categories for each sample feature vector is multiplied by the weight value corresponding to each loss function value to obtain the product result corresponding to each sample feature vector. The product results corresponding to each training vector are summed and the sum is used as the target loss function value. This refines the influence of each loss function on the target loss function, making the target loss function more accurate.
[0144] The method for determining statement categories in this application can be applied to multi-layer BERT models. Another exemplary embodiment of this application provides a detailed description of this method; please refer to [link / reference needed]. Figure 13 , Figure 13 This is a schematic diagram illustrating the calculation process of the target loss function value according to an exemplary embodiment of this application. The BERT model includes 12 consecutive network layers, with a target network layer selected every three layers, such as... Figure 13 As shown, the fourth, eighth, and twelfth network layers are the target network layers.
[0145] First, the sentence "This novel written by famous author A was eventually adapted into a film by director B" is input into the BERT model as a sample sentence. Each layer begins with the [CLS] token, which is considered a fusion of the entire sentence's semantics. After being processed by the first, second, and third network layers, it is input into the fourth network layer to obtain the first sample feature vector output by the fourth network layer: L1-emb = Bert-L4(Sententce). Similarly, the eighth and twelfth network layers are used to obtain the second sample feature vector: L2-emb = Bert-L8(Sententce) and the third sample feature vector: L3-emb = Bert-L12(Sententce).
[0146] In this embodiment, the first sample feature vector is a shallow feature vector, the second sample feature vector is a mid-level feature vector, and the third sample feature vector is a deep feature vector. Shallow network layers focus more on extracting the basic structure of the text, such as parts of speech and expressive structures, while deep network layers focus more on extracting abstract features, such as the model's semantic expression. However, basic features are also a crucial factor in text expression, especially when the structure is complex. Strengthening basic structural information can effectively improve classification accuracy. Therefore, this embodiment considers shallow, mid-level, and deep feature vectors during model training, enabling the trained model to more accurately determine the target preset category to which the sentence to be processed belongs.
[0147] The three sample feature vectors are fed into different classifiers for classification fitting, i.e. Figure 13 The specific classification fitting process for Classifier1, Classifier2, and Classifier3 is as follows:
[0148] Logits1 = Classifier(L1-emb); where the classifier Classifier1 consists of a fully connected layer and a softmax layer, and the input dimension of the fully connected layer is the number of categories.
[0149] Logits2 = ClassifierL2 - emb; where the classifier Classifier2 consists of a fully connected layer and a softmax layer, and the input dimension of the fully connected layer is the number of categories.
[0150] Logits3 = Classifier(L3-emb); where the classifier Classifier3 consists of a fully connected layer and a softmax layer, and the input dimension of the fully connected layer is the number of categories.
[0151] Then, input the above Logits into softmax to obtain the final multi-category probability distribution: A = softmax(Logits); where A = [a1, a2, ..., a...]. n ], a i This indicates the predicted matching probability for the preset category i.
[0152] Furthermore, the loss function value for each sample feature vector corresponding to all preset categories is calculated according to the following formula:
[0153]
[0154] Where loss represents the loss function value for all preset categories corresponding to the feature vector of the nth sample; cls(n) represents the feature vector of the nth sample; n represents the number of preset categories; i represents the order of preset categories; y i It is 0 or 1; a i This represents the matching probability of the sample feature vector corresponding to the i-th preset category.
[0155] Secondly, the loss function value for all preset categories corresponding to the first sample feature vector is loss. cls(1) loss cls(1) The corresponding preset weight value is λ1; the loss function value for all preset categories corresponding to the second sample feature vector is loss. cls(2) loss cls(2) The corresponding preset weight value is λ2; the loss function value for the third sample feature vector corresponding to all preset categories is loss. cls(3) loss cls(4) The corresponding preset weight value is λ3, and the target loss function is calculated according to the following formula:
[0156] loss all =λ1loss cls(1) +λ2loss cls(2) +λ3loss cls(3) ;
[0157] Where, loss all This represents the target loss function; the ratio of λ1:λ2:λ3 can be adjusted according to the actual situation, but the sum of all weight values is 1.
[0158] This embodiment introduces a multi-layer loss structure to fit the labels from different perspectives, thereby enhancing the training effect.
[0159] Finally, the BERT model is adjusted according to the objective loss function to make the sentence categories output by the BERT model more accurate.
[0160] The BERT model in this embodiment can acquire the semantic vector of the sentence to be processed and the grammatical information of the words in the sentence. The model, which integrates grammatical and semantic information, can better represent the core information in the sentence in experiments, thereby improving the classification accuracy. The semantics of the shallow network layers of the model focuses more on the sentence structure expression, while the deep network layers focus more on the abstract semantics of the sentence. Combining the two aspects of information can better express the completeness of semantics and can effectively improve the semantic expression of complex sentence structures. In addition, the multi-layer LOSS structure in this embodiment can fit the real labels to the feature vectors extracted from different network layers, thereby enhancing the training effect.
[0161] Another aspect of this application provides a device for determining statement categories, such as... Figure 14 As shown, Figure 14 This is a schematic diagram illustrating the structure of a statement category determination device according to an exemplary embodiment of this application. The statement category determination device includes:
[0162] Extraction module 1410 is configured to input the statement to be processed into multiple network layers and select multiple target network layers from the multiple network layers.
[0163] The acquisition module 1430 is configured to acquire the feature vector of the statement to be processed output by each target network layer, thereby obtaining multiple feature vectors.
[0164] The calculation module 1450 is configured to calculate the matching probability between the statement to be processed and each preset category based on multiple feature vectors, and obtain multiple probability parameters.
[0165] The determination module 1470 is configured to determine the target preset category to which the statement to be processed belongs based on multiple probability parameters.
[0166] In another exemplary embodiment, the determining module 1470 includes:
[0167] The probability distribution matrix construction unit is configured to construct a probability distribution matrix for all preset categories corresponding to the statement to be processed based on multiple probability parameters.
[0168] The target preset category determination unit is configured to select the probability parameter with the largest value from the probability distribution matrix as the target probability parameter, and to take the preset category corresponding to the target probability parameter as the target preset category to which the statement to be processed belongs.
[0169] In another exemplary embodiment, the computing module 1450 includes:
[0170] The feature vector acquisition unit is configured to acquire the feature vector for each preset category.
[0171] The first calculation unit is configured to perform quotient operations on multiple feature vectors and feature vectors of the preset category for each preset category, obtain multiple calculation results, and use the multiple calculation results as the matching probability of multiple feature vectors and preset categories.
[0172] The second calculation unit is configured to calculate the matching probability between the statement to be processed and each preset category based on the matching probability of multiple feature vectors and each preset category, and obtain multiple probability parameters.
[0173] In another exemplary embodiment, the extraction module 1410 includes:
[0174] The selection rule acquisition unit is configured to acquire a preset network layer interval selection rule; wherein, the network layer interval selection rule is used to characterize the number of network layers between which a target network layer is selected from multiple network layers.
[0175] The selection unit is configured to select multiple target network layers from multiple network layers based on a preset network layer interval selection rule.
[0176] In another exemplary embodiment, the plurality of network layers are a plurality of network layers arranged in a sequential order; the extraction module 1410 includes:
[0177] The feature vector output unit is configured to input the statement to be processed into the first network layer corresponding to multiple network layers arranged in sequence, and to extract features through multiple network layers in sequence to obtain the feature vector output by each network layer.
[0178] In another exemplary embodiment, the statement category determination device further includes:
[0179] The input module is configured to input sample statements into a training model containing multiple network layers and obtain sample feature vectors output by multiple target network layers.
[0180] The loss function value calculation module is configured to calculate the loss function value for each sample feature vector corresponding to all preset categories based on multiple sample feature vectors.
[0181] The target loss function value calculation module is configured to calculate the target loss function value based on the loss function values of all preset categories corresponding to the feature vector of each sample.
[0182] The training module is configured to train the model to be trained based on the target loss function value to obtain a category classification model.
[0183] In another exemplary embodiment, the loss function value calculation module includes:
[0184] The processing unit is configured to perform operations on multiple sample feature vectors with the preset category for each preset category, and obtain the matching probability of each sample feature vector corresponding to the preset category.
[0185] The loss function value calculation unit is configured to calculate the loss function value for each sample feature vector corresponding to all preset categories based on the matching probability of each sample feature vector corresponding to each preset category.
[0186] In another exemplary embodiment, the loss function value calculation unit includes:
[0187] The first calculation module is configured to calculate the loss function value for each sample feature vector corresponding to each preset category based on the matching probability of each sample feature vector corresponding to each preset category.
[0188] The second calculation module is configured to calculate the loss function value for each sample feature vector corresponding to all preset categories based on the loss function value for each preset category corresponding to each sample feature vector.
[0189] In another exemplary embodiment, the target loss function value calculation module includes:
[0190] The preset weight value unit is configured to obtain the preset weight value corresponding to each loss function.
[0191] The target loss function value calculation unit is configured to calculate the target loss function value based on the loss function values of all preset categories corresponding to each sample feature vector and the preset weight value corresponding to each loss function value.
[0192] In another exemplary embodiment, the target loss function value calculation unit includes:
[0193] The product operation module is configured to multiply the loss function values corresponding to all preset categories and the weight values corresponding to each loss function value for each sample feature vector to obtain the product result corresponding to each sample feature vector.
[0194] The target loss function value section is configured to sum the product results of each training vector and use the sum as the target loss function value.
[0195] It should be noted that the statement category determination device provided in the above embodiments and the statement category determination method provided in the foregoing embodiments belong to the same concept. The specific way in which each module and unit performs operations has been described in detail in the method embodiments, and will not be repeated here.
[0196] Another aspect of this application provides an electronic device, including: a controller; and a memory for storing one or more programs, which, when executed by the controller, perform the method for determining statement categories in the various embodiments described above.
[0197] Another aspect of this application provides a computer-readable storage medium storing computer-readable instructions that, when executed by a computer's processor, cause the computer to perform the aforementioned method. Additionally, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the aforementioned method for determining statement categories.
[0198] Please see Figure 15 , Figure 15 This is a schematic diagram of the structure of a computer system for an electronic device, illustrating an exemplary embodiment of this application. It shows a schematic diagram of the structure of a computer system suitable for implementing the embodiments of this application.
[0199] It should be noted that, Figure 15 The computer system 1500 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0200] like Figure 15 As shown, the computer system 1500 includes a Central Processing Unit (CPU) 1501, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on a program stored in Read-Only Memory (ROM) 1502 or a program loaded from storage portion 1508 into Random Access Memory (RAM) 1503. The RAM 1503 also stores various programs and data required for system operation. The CPU 1501, ROM 1502, and RAM 1503 are interconnected via a bus 1504. An Input / Output (I / O) interface 1505 is also connected to the bus 1504.
[0201] The following components are connected to I / O interface 1505: an input section 1506 including a keyboard, mouse, etc.; an output section 1507 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1508 including a hard disk, etc.; and a communication section 1509 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 1509 performs communication processing via a network such as the Internet. A drive 1510 is also connected to I / O interface 1505 as needed. Removable media 1511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1510 as needed so that computer programs read from them can be installed into storage section 1508 as needed.
[0202] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1509, and / or installed from removable medium 1511. When the computer program is executed by central processing unit (CPU) 1501, it performs various functions defined in the system of this application.
[0203] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. The transmitted data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0204] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0205] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.
[0206] Another aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the statement category determination method described above. This computer-readable storage medium may be included in the electronic device described in the above embodiments, or it may exist independently and not assembled into the electronic device.
[0207] Another aspect of this application provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the statement category determination method provided in the various embodiments described above.
[0208] According to one aspect of the embodiments of this application, a computer system is also provided, including a Central Processing Unit (CPU), which can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) or a program loaded from storage into random access memory (RAM), such as performing the methods described above. Various programs and data required for system operation are also stored in the RAM. The CPU, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.
[0209] The following components are connected to the I / O interface: input components including keyboards, mice, etc.; output components including cathode ray tubes (CRTs), liquid crystal displays (LCDs), and speakers; storage components including hard drives; and communication components including network interface cards such as LAN (Local Area Network) cards and modems. The communication components perform communication processing via networks such as the Internet. Drives are also connected to the I / O interface as needed. Removable media, such as disks, optical discs, magneto-optical discs, semiconductor memories, etc., are installed on the drive as needed so that computer programs read from them can be installed into the storage components as required.
[0210] The above description is merely a preferred exemplary embodiment of this application and is not intended to limit the implementation of this application. Those skilled in the art can easily make corresponding modifications or alterations based on the main concept and spirit of this application. Therefore, the scope of protection of this application should be determined by the scope of protection claimed in the claims.
Claims
1. A method for determining statement categories, characterized in that, include: The statement to be processed is input into the first network layer corresponding to a plurality of network layers arranged in sequence, and features are extracted sequentially through the plurality of network layers to obtain a preset network layer interval selection rule; wherein, the network layer interval selection rule is used to characterize the number of network layers that are separated from selecting a target network layer from the plurality of network layers; multiple target network layers are selected from the plurality of network layers based on the preset network layer interval selection rule; Obtain the feature vector of the statement to be processed output by each target network layer to obtain multiple feature vectors; Each feature vector is input into its corresponding classifier to obtain the output of each classifier; The outputs of each classifier are input into the softmax layer to obtain a multi-category probability distribution including multiple probability parameters. The target preset category to which the statement to be processed belongs is determined based on the multiple probability parameters.
2. The method according to claim 1, characterized in that, The step of determining the target preset category to which the statement to be processed belongs based on the plurality of probability parameters includes: The probability distribution matrix of all preset categories corresponding to the statement to be processed is constructed based on multiple probability parameters; The probability parameter with the largest value is selected from the probability distribution matrix as the target probability parameter, and the preset category corresponding to the target probability parameter is taken as the target preset category to which the statement to be processed belongs.
3. The method according to any one of claims 1 to 2, characterized in that, Before inputting the statement to be processed into the first network layer corresponding to a plurality of sequentially arranged network layers, the method further includes: The sample statement is input into the model to be trained, which contains multiple network layers, and the sample feature vectors output by multiple target network layers are obtained. The loss function value for each sample feature vector corresponding to all preset categories is calculated based on multiple sample feature vectors; The target loss function value is calculated based on the loss function values of all preset categories corresponding to the feature vector of each sample. The model to be trained is trained based on the target loss function value to obtain a category classification model.
4. The method according to claim 3, characterized in that, The step of calculating the loss function value for each sample feature vector corresponding to all preset categories based on multiple sample feature vectors includes: For each preset category, the multiple sample feature vectors are processed with the preset category to obtain the matching probability of each sample feature vector corresponding to the preset category; Based on the matching probability of each sample feature vector corresponding to each preset category, the loss function value of each sample feature vector corresponding to all preset categories is calculated.
5. The method according to claim 4, characterized in that, The step of calculating the loss function value for all preset categories corresponding to each sample feature vector based on the matching probability of each preset category for each sample feature vector includes: Based on the matching probability of each sample feature vector corresponding to each preset category, the loss function value of each sample feature vector corresponding to each preset category is calculated. Based on the loss function value corresponding to each preset category for each sample feature vector, the loss function value corresponding to all preset categories for each sample feature vector is calculated.
6. The method according to claim 3, characterized in that, The step of calculating the target loss function value based on the loss function values of all preset categories corresponding to each sample feature vector includes: Obtain the preset weight value corresponding to each loss function value; The target loss function value is calculated based on the loss function values of all preset categories corresponding to each sample feature vector and the preset weight value corresponding to each loss function value.
7. The method according to claim 6, characterized in that, The step of calculating the target loss function value based on the loss function values of all preset categories corresponding to each sample feature vector and the preset weight value corresponding to each loss function value includes: The loss function values corresponding to all preset categories for each sample feature vector are multiplied by the preset weight values corresponding to each loss function value to obtain the product result corresponding to each sample feature vector. The product of each sample feature vector is summed, and the sum is used as the target loss function value.
8. A device for determining statement categories, characterized in that, include: The extraction module is configured to input the statement to be processed into the first network layer corresponding to a plurality of network layers arranged in sequence, and to extract features sequentially through the plurality of network layers, and to obtain a preset network layer interval selection rule; wherein, the network layer interval selection rule is used to characterize the number of network layers that are separated from selecting a target network layer from the plurality of network layers; and to select multiple target network layers from the plurality of network layers based on the preset network layer interval selection rule; The acquisition module is configured to acquire the feature vector of the statement to be processed output by each target network layer, thereby obtaining multiple feature vectors; The calculation module is configured to input each feature vector into the corresponding classifier to obtain the output of each classifier; and input the output of each classifier into the softmax layer to obtain a multi-category probability distribution including multiple probability parameters. The determination module is configured to determine the target preset category to which the statement to be processed belongs based on the plurality of probability parameters.
9. An electronic device, characterized in that, include: Controller; A memory for storing one or more programs, which, when executed by the controller, cause the controller to implement the statement category determination method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores computer-readable instructions that, when executed by the computer's processor, cause the computer to perform the statement category determination method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the method for determining statement categories as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Semantic analysis method and device based on human-computer interaction, equipment and storage medium
CN113408265A