A method of processing a sample and related apparatus

By calculating information gain and using a reconstruction optimization algorithm to determine sample weights, the overfitting problem in few-shot learning is solved, achieving efficient sample classification without training, which is suitable for user interaction scenarios such as chatbots.

CN114595798BActive Publication Date: 2025-11-28HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011373349.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-30
Publication Date
2025-11-28
Estimated Expiration
2040-11-30

AI Technical Summary

Technical Problem

Existing technologies suffer from overfitting in few-shot learning and do not support pre-trained representation learning on massive datasets, making it difficult to achieve simple and efficient sample classification in user interaction scenarios such as chatbots.

Method used

The sample representations of the support set and query set are determined by calculating information gain. Sample weights are determined by using a pre-set neural network and reconstruction optimization algorithm to achieve training-free small-sample learning, avoid overfitting, and directly determine the target support samples through the TOP-K model.

Benefits of technology

It enables rapid sample classification without training, avoids overfitting, simplifies the classification process, and improves the accuracy and efficiency of sample representation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114595798B_ABST
    Figure CN114595798B_ABST
Patent Text Reader

Abstract

The application discloses a sample processing method in the field of artificial intelligence and a related device, which does not need to re-learn parameters, avoids overfitting, does not need to make additional corrections to the second sample representation in the query set, does not need to specify the value of K in advance, and realizes classification of the query sample and continuous correction of the class representation of the support set by the second query sample representation. The foregoing method comprises the following steps: obtaining a support set and a query set; processing the support set and the query set by a preset neural network to obtain a first support sample representation of the support set and a first query sample representation; calculating a first information gain, which is used to reflect the contribution degree of each word in the support set to the class of the support set; determining a second support sample representation in the support set according to the first support sample representation and the first information gain, and determining a second query sample representation in the query set according to the first query sample representation and the first information gain.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the field of artificial intelligence, and in particular, to a sample processing method and related device. BACKGROUND

[0002] Artificial intelligence (AI) is the use of computers or computer-controlled machines to simulate, extend and expand human intelligence. Artificial intelligence includes the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making. At present, few-shot learning (FL) based on deep learning neural network is a feasible research direction of artificial intelligence.

[0003] To achieve training-free, a K-nearest neighbor (KNN) method based on metric based meta learning is adopted, that is, in the meta training phase, a support set and a query set are constructed using related tasks. Referring to Figure 1a , a schematic diagram of sample classification provided in the prior art is shown, which includes three support sets c1, c2 and c3, and a query set x. The average value directly represented by the support samples in each class support set is used as the class representation of the class, and the distance between the representation of each query sample in the query set and the class representation of the support set is calculated to realize the classification of the query sample in the query set x. Referring to Figure 1a , another schematic diagram of sample classification provided in the prior art is shown. From Figure 1b , it can be seen that the encoder module obtains the semantic representation of each support sample in each support set and the semantic representation of the query sample in the query set by means of neural networks such as LSTM and CNN; then the Induction module induces the class representation from the semantic representation of the support sample features of the support set, and the relation module measures the semantic relationship between the query sample in the query set and the class representation, and then completes the classification. However, a relatively complex long short-term memory (LSTM) network structure is used for training and prediction, the parameters are many, and it is easy to rely on a large number of meta tasks, leading to overfitting, and it also does not support pre-training representation learning of massive data. For more information, please refer to Figure 1b , another schematic diagram of sample classification provided in the prior art is shown. From Figure 1c , it can be seen that the encoder module obtains the semantic representation of each support sample in each support set and the semantic representation of the query sample in the query set by means of neural networks such as LSTM and CNN; then the Induction module induces the class representation from the semantic representation of the support sample features of the support set, and the relation module measures the semantic relationship between the query sample in the query set and the class representation, and then completes the classification. However, a relatively complex long short-term memory (LSTM) network structure is used for training and prediction, the parameters are many, and it is easy to rely on a large number of meta tasks, leading to overfitting, and it also does not support pre-training representation learning of massive data. For more information, please refer to Figure 1cIt can be seen that the deviation between the meta-task and the actual test task is solved by feature migration, and the deviation in the class representation caused by directly using the average is solved by pseudo-labeling, but Figure 1c It can also be seen that in the prediction stage, label propagation is first performed between the support samples of the support set and the query samples of the query set, that is, the meta-task is first learned, and then the deviation is corrected, but independent prediction of a single sample is not supported.

[0004] However, in user interaction scenarios such as chatbots (BOTs), users want to obtain greater benefits with less cost, and therefore, how to simply implement sample classification by means of deep learning, training-free, and small sample learning has become a problem to be solved. SUMMARY

[0005] Embodiments of the present application provide a sample processing method and related apparatus, which do not require re-learning of parameters, avoid overfitting in the process of training a large number of parameters, and determine the second sample representation in the support set and the second query sample representation in the query set with class boundary perception, without the need for additional correction of the second sample representation in the query set. In addition, the K target support samples are automatically determined by a reconstruction algorithm, without the need for specifying the value of K in advance and determining the target support samples by a TOP-K model, and the sample weights of the support set are determined, and thus the class representation of the support set is determined, so as to implement classification of the query samples, and the second query sample representation can be used to continuously correct the class representation of the support set.

[0006] In a first aspect, embodiments of the present application provide a sample classification method, which can include: obtaining a support set and a query set; processing the support set and the query set by a preset neural network to obtain a first support sample representation of the support set and a first query sample representation; calculating a first information gain, which is used to reflect the contribution degree of each word in the support set to the class of the support set; determining a second support sample representation in the support set according to the first support sample representation and the first information gain, and determining a second query sample representation in the query set according to the first query sample representation and the first information gain. By the above method, sample classification is quickly implemented in training-free small sample learning by means of deep learning, and the second query sample representation is determined without re-learning of parameters, which not only avoids overfitting in the process of training a large number of parameters, but also does not require additional correction of the second query sample representation.

[0007] In some embodiments, after determining the second support sample representation in the support set according to the first support sample representation and the first information gain, and determining the second query sample representation in the query set according to the first query sample representation and the first information gain, the method further comprises: processing the second support sample representation and the second query sample representation by a preset reconstruction optimization algorithm to obtain a sample weight of the support set; determining a class representation of the support set based on the sample weight of the support set and the second support sample representation; and calculating a sample similarity according to the class representation of the support set and the second query sample representation, the sample similarity being used to reflect a classification result of the query sample in the query set. In this way, the sample weight of the support set can be determined by the preset reconstruction optimization algorithm, and the class representation of the support set is determined accordingly, so that the similarity between the second query sample representation and the class representation of the support set is calculated to determine the classification result of the query sample, without the need for a complex classification process, and the classification process is relatively simple.

[0008] In some embodiments, the method further comprises: obtaining K target support samples, K > 1, and K being an integer. In this way, the K target support samples are directly determined by the preset reconstruction optimization algorithm, without the need to determine the value of K in advance and determine the K target samples by the TOP-K model.

[0009] In some embodiments, calculating the first information gain can comprise: calculating the information gain of each word of the support sample in the support set respectively to obtain the first information gain. In this way, the calculation manner of calculating the first information gain is increased, and the scene is enriched.

[0010] In some embodiments, calculating the first information gain can comprise: grouping any N adjacent words of the support sample in the support set to obtain a first word group set; and calculating the information gain of each word group in the first word group set for the support set to obtain the first information gain. In this way, the calculation manner of calculating the first information gain is increased, and the scene is enriched.

[0011] In some embodiments, calculating the first information gain can comprise: grouping any N non-adjacent words of the support sample in the support set to obtain a second word group set; and calculating the information gain of each word group in the second word group set for the support set to obtain the first information gain. In this way, the calculation manner of calculating the first information gain is increased, and the scene is enriched.

[0012] In a second aspect, an embodiment of the present application provides a sample processing apparatus, which can include: an acquisition unit configured to acquire a support set and a query set; a processing unit configured to process the support set and the query set by using a preset neural network to obtain a first support sample representation of the support set and a first query sample representation of the query set; the processing unit is configured to calculate a first information gain, the first information gain being used to reflect a contribution degree of each word in the support set to a category of the support set; the processing unit is configured to determine a second support sample representation in the support set according to the first support sample representation and the first information gain, and determine a second query sample representation in the query set according to the first query sample representation and the first information gain.

[0013] In some embodiments, the processing unit is further configured to:

[0014] After determining the second support sample representation in the support set according to the first support sample representation and the first information gain, and determining the second query sample representation in the query set according to the first query sample representation and the first information gain, the processing unit is configured to process the second support sample representation and the second query sample representation by using a preset reconstruction optimization algorithm to obtain a sample weight of the support set.

[0015] The processing unit is configured to determine a category representation of the support set based on the sample weight of the support set and the second support sample representation.

[0016] The processing unit is configured to calculate a sample similarity based on the category representation of the support set and the second query sample representation, the sample similarity being used to reflect a classification result of a query sample in the query set.

[0017] In some embodiments, the processing unit is further configured to obtain K target support samples, K≥1, and K is an integer.

[0018] In some embodiments, the processing unit is configured to calculate an information gain of each word of a support sample in the support set respectively to obtain the first information gain.

[0019] In some embodiments, the processing unit is configured to: group any N adjacent words of a support sample in the support set to obtain a first word group set, N≥2, and N is an integer; and calculate an information gain of each word group in the first word group set to the support set to obtain the first information gain.

[0020] In some embodiments, the processing unit is configured to: group any N non-adjacent words of a support sample in the support set to obtain a second word group set; and calculate an information gain of each word group in the second word group set to the support set to obtain the first information gain.

[0021] In a third aspect, an embodiment of the present application provides a sample processing apparatus, which can include a processor, and the processor is coupled with a memory, and the memory stores program instructions, and the program instructions stored in the memory, when executed by the processor, implement the sample processing method of the first aspect.

[0022] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, and the computer readable storage medium stores a computer program, and when the computer program is run on a computer, the computer program causes the computer to execute the sample processing method of the first aspect.

[0023] In a fifth aspect, an embodiment of the present application provides a computer program, and when the computer program is run on a computer, the computer program causes the computer to execute the sample processing method of the first aspect.

[0024] In a sixth aspect, an embodiment of the present application provides a chip system, which includes a processor, and the processor is configured to support the sample processing apparatus to implement the functions involved in the above aspects, for example, sending or processing the data and / or information involved in the above methods. In a possible design, the chip system further includes a memory, and the memory is configured to store the necessary program instructions and data of the server or the communication device. The chip system can be composed of a chip, or can include the chip and other discrete devices.

[0025] The technical effects brought by the second aspect to the sixth aspect can be understood with reference to the technical effects of the first aspect, which will not be repeated here.

[0026] As can be seen from the above technical solutions, the embodiments of the present application have the following advantages:

[0027] In the embodiments of the present application, with the help of deep learning, sample classification is quickly realized in the training-free small sample learning, and by calculating the first information gain and normalizing the first information gain as a weight, the second support sample representation in the support set is calculated, and the second query sample representation in the query set is calculated, without re-learning parameters, not only avoiding overfitting in the large parameter training process, but also determining the second query sample representation of the class boundary perception, without additional correction of the second query sample representation. BRIEF DESCRIPTION OF DRAWINGS

[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present application.

[0029] Figure 1a is a schematic diagram of sample classification provided in the prior art;

[0030] Figure 1bis another schematic diagram of sample classification provided in the prior art;

[0031] Figure 1c is another schematic diagram of sample classification provided in the prior art;

[0032] Figure 2 is a structural schematic diagram of an artificial intelligence main body framework provided in an embodiment of the present application;

[0033] Figure 3 is a system architecture diagram of a sample processing apparatus provided in an embodiment of the present application;

[0034] Figure 4 is a flowchart of a sample processing method provided in an embodiment of the present application;

[0035] Figure 5 is a flowchart of sample classification provided in an embodiment of the present application;

[0036] Figure 6 is a hardware structural schematic diagram of a sample processing apparatus provided in an embodiment of the present application;

[0037] Figure 7 is a structural schematic diagram of an execution device provided in an embodiment of the present application;

[0038] Figure 8 is a structural schematic diagram of a sample processing apparatus provided in an embodiment of the present application. DETAILED DESCRIPTION

[0039] The embodiments of the present application provide a sample processing method and related apparatus, without re-learning parameters, which not only avoids overfitting in a large parameter training process, but also determines a second sample representation in a support set and a second query sample representation in a query set, without performing additional correction on the second sample representation in the query set. In addition, K target support samples are automatically determined by a reconstruction algorithm, without determining the value of K in advance and determining the target support samples by a TOP-K model; and sample weights of the support set are determined, and then a class representation of the support set is determined, so as to realize classification of the query sample, and the second query sample representation can be used to correct the class representation of the support set.

[0040] The terms "first", "second", "third", "fourth" and the like in the description and in the claims of the present application, and above-mentioned drawings, if any, are used to distinguish between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of these terms here is not meant to limit the scope of the application to the precise terms used and that these terms are used to more clearly describe the exemplary embodiments of the application. Furthermore, the terms "comprising", "including", "containing", and "having" and any variations thereof are intended to cover a non-exclusive inclusion, for example, a process, method, system, product or apparatus that comprises a list of steps or units can not necessarily be limited to those specifically listed, but can include other steps or units not expressly listed or inherent to such process, method, product or apparatus.

[0041] The embodiments of the present application are described below in conjunction with the accompanying drawings. It is obvious to those skilled in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.

[0042] First, the overall workflow of the artificial intelligence system is described, please see Figure 2 , Figure 2 The structure of the artificial intelligence subject framework is shown, and the above-mentioned artificial intelligence subject framework is described from two dimensions of "intelligent information chain" (horizontal axis) and "IT value chain" (vertical axis). Among them, the "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it can be a general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, data undergoes a condensation process of "data-information-knowledge-wisdom". The "IT value chain" reflects the value brought by artificial intelligence to the information technology industry from the bottom infrastructure of human intelligence, information (provision and processing technology implementation) to the industrial ecological process of the system.

[0043] (1) Infrastructure

[0044] Infrastructure provides computing power support for artificial intelligence systems, realizes communication with the external world, and realizes support through the underlying platform. Communication with the outside world through sensors; computing power is provided by intelligent chips, including, as an example, central processing units (CPUs), neural-network processing units (NPUs), graphics processing units (GPUs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), and other hardware acceleration chips; the underlying platform includes distributed computing frameworks and related platform guarantees and support for networks, which can include cloud storage and computing, and interconnected networks. For example, sensors and external communication obtain data, which is provided to intelligent chips in the distributed computing system provided by the underlying platform for computing.

[0045] (2) Data

[0046] The data of the upper layer of the infrastructure indicates the data source in the field of artificial intelligence. The data relates to graphics, images, voice, text, and also relates to Internet of Things data of traditional devices, including business data of existing systems and sensing data such as force, displacement, liquid level, temperature, and humidity.

[0047] (3) Data processing

[0048] Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision making, and other methods.

[0049] Among them, machine learning and deep learning can model, extract, preprocess, and train symbolic and formalized intelligent information.

[0050] Reasoning refers to the process of simulating human intelligent reasoning methods in a computer or intelligent system, using formalized information to perform machine thinking and solve problems according to reasoning control strategies, and the typical function is search and matching.

[0051] Decision making refers to the process of making decisions after intelligent information has been reasoned, and usually provides functions such as classification, sorting, and prediction.

[0052] (4) General capabilities

[0053] After the data is processed by the above-mentioned data processing, some general capabilities can be formed based on the results of the data processing, which can be an algorithm or a general system, such as image classification, image personalized management, battery charging personalized management, text analysis, computer vision processing, speech recognition, etc.

[0054] (5) Intelligent product and industry application

[0055] Intelligent product and industry application refers to the product and application of artificial intelligence system in various fields, which is the packaging of the overall solution of artificial intelligence, and realizes the application of intelligent information decision productization. The application fields mainly include: intelligent terminal, intelligent manufacturing, intelligent transportation, smart home, intelligent medical treatment, intelligent security, automatic driving, safe city, voice assistant, BOT dialogue open platform, etc.

[0056] The embodiments of the present application are mainly applied to the application scene of small sample learning without training by using deep learning. As an example, in the BOT dialogue open platform, a pre-training model with large parameter quantity such as bidirectional encoder representation from transformers (BERT) can be used. The pre-training model performs fine tuning on the parameters in the original pre-training BERT in the meta learning stage by following the meta learning method. After the fine tuning in the meta learning stage, the prediction stage can no longer repeat the fine tuning to adapt to new data.

[0057] Based on the above-mentioned scene, the embodiments of the present application provide a sample processing method. In order to facilitate the understanding of the present scheme, first, the system architecture of the sample processing device provided by the embodiments of the present application will be introduced. Figure 3 The system architecture of the sample processing device provided by the embodiments of the present application will be introduced. Please refer to Figure 3 , Figure 3 A system architecture diagram of the sample processing device provided by the embodiments of the present application. In Figure 3 , the sample processing device 300 includes an execution device 310, a training device 320, a database 330 and a data storage system 340, and the execution device 310 includes a computing module 311.

[0058] In the training stage, the database 330 is configured to store a sample set for training, which can be divided into a support set and a query set. The training device 320 generates a target model / rule 301 for processing the sample, and iteratively trains the target model / rule 301 by using the sample set in the database to obtain a mature target model / rule 301, which is specifically a neural network. The neural network obtained by the training device 320 can be applied in different systems or devices.

[0059] In the inference stage, the execution device 310 can call data, code, etc. in the data storage system 340, or store data, instructions, etc. in the data storage system 340. The data storage system 340 can be placed in the execution device 310, or can be an external storage relative to the execution device 310. The computing module 311 can process the sample obtained by the execution device 310 through the neural network to obtain a prediction result, and the specific form of the prediction result is related to the function of the neural network.

[0060] In some embodiments of the present application, for example Figure 3 In the above embodiment, the "user" can directly interact with the execution device 310, that is, the execution device 310 and the client device are integrated in the same device. However Figure 3 The position relationship between the devices, components, modules, etc. shown in the figure is not intended to constitute any limitation. In another embodiment of the present application, the execution device 310 and the client device can be separate devices, and the execution device 310 is configured with an input / output interface to interact with the client device. The "user" can input the collected sample to the input / output interface through the client device, and the execution device 310 returns the prediction result to the client device through the input / output interface.

[0061] In order to better understand the scheme proposed in the embodiments of the present application, the specific process in the embodiments will be introduced as follows, for example Figure 4 As shown in FIG. 4, a flowchart of a sample processing method provided by the embodiment is shown, which specifically includes the following steps:

[0062] 401, obtaining a support set and a query set.

[0063] 402, processing the support set and the query set through a preset neural network to obtain a first support sample representation of the support set and a first query sample representation of the query set.

[0064] In an embodiment, the preset neural network can be understood as a BERT model or the like. Taking the BERT model as an example, the BERT model can continue in the manner of meta learning, that is, in the meta learning stage, the parameters in the original pre-trained BERT model are subjected to transfer learning, and after the transfer learning in the meta learning stage, the prediction stage of the BERT model can not repeat the transfer learning to adapt to new data. Therefore, by means of the training-free manner of the preset neural network, the support set is directly processed to obtain the first support sample representation of the support set; similarly, by means of the training-free manner of the preset neural network, the query set is directly processed to obtain the first query sample representation of the query set. The described first support sample representation can be understood as the initial sample feature of the support sample and can be represented by a vector, which can reflect the semantics of the support sample in the support set. The first query sample representation can be understood as the initial sample feature of the query sample and can also be represented by a vector, which can reflect the semantics of the query sample in the query set.

[0065] 403、Calculate the first information gain, which is used to reflect the contribution degree of each word in the support set to the category of the support set.

[0066] In an embodiment, although the BERT model is subjected to transfer learning in the meta learning stage, in order to narrow the gap between the actual scene and the target scene and the related task scene, and without the need to re-transfer the parameters in the BERT model, the contribution degree of each word in the support set to the category of the support set can be calculated, that is, the first information gain is calculated, so that the first information gain can be used as the weight for determining the first support sample representation, thereby determining the second support sample representation in the support set in combination with the first support sample representation, so that the finally obtained second support sample representation can more accurately reflect the real semantics of the support sample; and the first information gain is used as the weight for determining the first query sample representation, thereby determining the second query sample representation in the query set in combination with the first query sample representation, so that the finally obtained second query sample representation can more accurately reflect the real semantics of the query sample.

[0067] It can be understood that the described first information gain can be understood as the contribution degree of a certain word in the support sample in the support set to the category of the support set, and the contribution degree after excluding the certain word. For example, it is assumed that the categories of the support set include a "sending express" category and a "receiving express" category, and the support sample in the support set includes "I will go to send some items today". Then, the contribution degree of the word "send" to the "sending express" category and the contribution degree to the "receiving express" category can be calculated. The described contribution degree can be understood as the correlation degree.

[0068] The information gain can be calculated according to the following formula:

[0069]

[0070] where IG(X;Y) represents the first information gain, p(x,y) is a probability value when the word x and the class y of the support set exist simultaneously, p(x) is a probability value when the word x exists, and p(y) is a probability value when the class y of the support set exists.

[0071] IG(X;Y) = H(Y) - H(Y|X) (Formula Two)

[0072] where IG(X;Y) represents the first information gain, H(Y) is the information entropy, and H(Y|X) is the conditional entropy.

[0073] In some embodiments, the first information gain can be calculated in various ways, for example as follows:

[0074] First, the first information gain is calculated by calculating the information gain of each word in the support sample in the support set respectively to obtain the first information gain.

[0075] In an embodiment, the information gain of each word in the support sample can be calculated respectively to obtain the first information gain. For example, assuming that the classes of the support set include a "sending express delivery" class and a "receiving express delivery" class, and the support sample in the support set includes "I will go to send some articles today". Then the contribution of each of the words "I", "today", "will", "go", "send", "some", "articles", and "articles" to the "sending express delivery" class and the "receiving express delivery" class can be calculated respectively.

[0076] Second, the first information gain is calculated by grouping any N adjacent words in the support sample in the support set to obtain a first word group set, and calculating the information gain of each word group in the first word group set for the support set to obtain the first information gain.

[0077] In the embodiment, the N adjacent words in the support sample can be grouped as a group based on a preset n-gram, to obtain a first word group set. Then, the information gain of each word group in the first word group set for the support set is calculated, to obtain the first information gain described above. In this way, when the first information gain is used as the weight subsequently, the weight of each word belonging to the same word group in the first word group set is the same. For example, it is assumed that the categories of the support set include a "sending express" category and a "receiving express" category; and the support sample in the support set includes "I will go to send some articles today". Then, "I today", "today", "today will", and the like can be selected as the first word group set, and the contribution degree of each word group to the "sending express" category and the contribution degree of each word group to the "receiving express" category are calculated respectively.

[0078] In addition, N>2 and N is an integer.

[0079] Thirdly, the first information gain is calculated, including: grouping any N non-adjacent words in the support sample in the support set to obtain a second word group set; and calculating the information gain of the second word group set for the support set, to obtain the first information gain.

[0080] Similarly, any N non-adjacent words in the support sample can be grouped as a group based on a regular expression or the like, to obtain the second word group set. Then, the information gain of each word group in the second word group set for the support set is calculated, to obtain the first information gain described above. In this way, the first information gain can be used as the weight of the overall weighting. In addition, the N non-adjacent words in the support set can also use the average value or the like as the weight. For example, it is assumed that the support sample in the support set includes "I will go to send some articles today", and the second word group set can include but is not limited to "I will go to send some articles" and the like, which is not limited herein.

[0081] It should be noted that, in addition to the three ways of calculating the first information gain described above, in actual applications, the word group can also be extracted based on a generalized n-gram model of a syntax tree, to calculate the first information gain. The generalized n-gram model described herein can be understood as an n-gram model on a path of a syntax tree. It should be understood that, in actual applications, other methods for calculating the information gain can also be used, which are not limited herein.

[0082] 404. determining a second support sample representation in the support set according to the first support sample representation and the first information gain, and determining a second query sample representation in the query set according to the first query sample representation and the first information gain.

[0083] In the embodiment, after obtaining the first information gain, the first information gain can be taken as a weight and combined with the first support sample representation to perform weighted processing. In this way, after obtaining the second support sample representation in the support set, the second support sample representation with class boundary awareness can be completed, so that the second support sample representation can more accurately reflect the real semantics of the support sample; and the first information gain is taken as a weight for subsequent determination of the first query sample representation, so that the second query sample representation in the query set is determined in combination with the first query sample representation, so that the finally obtained second query sample representation can more accurately reflect the real semantics of the query sample.

[0084] In the embodiment of the present application, by directly calculating the first information gain and sharing the normalized first information gain as the weight of the first support sample representation and the first query sample representation, re-parameter learning is not required, overfitting in a large parameter training process is avoided, and the second support sample representation and the second query sample representation with class boundary awareness can be determined, without the need for additional correction of the second query sample representation, and the process is simple.

[0085] 405、processing the second support sample representation and the second query sample representation by a preset reconstruction optimization algorithm to obtain a sample weight of the support set.

[0086] In the embodiment, the preset reconstruction optimization algorithm can include but is not limited to a nonlinear least square method, and in actual application, as long as an algorithm that can be used for optimization reconstruction can be used, for example, a sparse L1 regularization, a reconstruction optimization algorithm that forces a weak weight to be 0, and the like, which are not limited in the embodiment of the present application.

[0087] After determining the second support sample representation in the support set according to the first support sample representation and the first information gain, and determining the second query sample representation in the query set according to the first query sample representation and the first information gain, the second support sample representation and the second query sample representation can also be processed by a preset reconstruction optimization algorithm, so as to obtain a sample weight in the support set, so that the sample weight of the support set can be weighted with the second support sample representation, so as to determine the class representation of the support set.

[0088] Optionally, by processing the second support sample representation and the second query sample representation by the preset reconstruction optimization algorithm, K target support samples can also be obtained, K≥1, and K is an integer.

[0089] That is, the preset reconstruction optimization algorithm can also obtain the K target support samples after processing the second support sample representation and the second query sample representation. That is, by processing the second support sample representation and the second query sample representation through the preset reconstruction optimization algorithm, the K target support samples can be directly obtained, without the need to extract the value of K and determine the target support samples through the TOP-K model, thereby avoiding the irrationality of the simple average assumption.

[0090] 406. Determine the class representation of the support set based on the sample weight of the support set and the second support sample representation.

[0091] The described class representation of the support set can reflect the label or annotation result of the support set, such as opening an application, playing music, etc., which is not limited here.

[0092] 407. Calculate the sample similarity based on the class representation of the support set and the second query sample representation, and the sample similarity is used to reflect the classification result of the query sample in the query set.

[0093] In the embodiment, after obtaining the class representation of the support set, the vector similarity calculation can be performed on the second query sample representation and the class representation of the support set to obtain the similarity between the query sample corresponding to the second query sample representation and the class of the support set, thereby determining the classification result of the query sample in the query set.

[0094] Reference can be made to Figure 5 , which is a flowchart of the sample classification provided in the embodiment of the present application. As shown in Figure 5 , after obtaining the second query sample representation of the query set, the weight of the support set can be determined in combination with the second support sample representation (such as support sample representation 1 to support sample representation K), and the vector product of the weight and the second support sample representation is obtained, thereby obtaining the class representation of the support set, and then the similarity calculation f is performed in combination with the second query sample representation, so that the classification result of the query sample can be obtained.

[0095] The above describes a sample classification method provided by an embodiment of the present application. With the scheme provided by the embodiment of the present application, sample classification can be quickly implemented in a small sample learning without training by means of deep learning. The first information gain is calculated, and the first information gain is normalized and shared as the weight of the first support sample representation and the first query sample representation, so that parameter learning does not need to be performed again. Not only is overfitting in a large parameter training process avoided, but also the second support sample representation and the second query sample representation of class boundary perception can be determined without additional correction. In addition, the second support sample representation and the second query sample representation can be processed by a preset reconstruction optimization algorithm, and K target support samples can be directly obtained without extracting the value of K and determining the target support samples by a TOP-K model, so that the irrationality of a simple average assumption is avoided.

[0096] It can be understood that, in order to implement the above functions, the sample processing apparatus includes hardware structures and / or software modules corresponding to the functions. Those skilled in the art should easily realize that, in combination with the modules and algorithm steps of the examples described in the embodiments disclosed in the present application, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is implemented in hardware or computer software driven hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0097] From the hardware structure, Figure 2 to Figure 5 The sample processing apparatus in the present application can be implemented by one physical device, or by multiple physical devices together, or by a logical functional module in one physical device, and the embodiments of the present application do not make specific limitations.

[0098] For example, the sample processing apparatus can be implemented by Figure 6 the computer device in the present application. Figure 6 As shown in the figure, the hardware structure of the sample processing apparatus provided by the embodiments of the present application includes a communication interface 601 and a processor 602, and can further include a memory 603.

[0099] The communication interface 601 can use any transceiver-like device for communicating with other devices or communication networks, such as an Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc.

[0100] The processor 602 includes, but is not limited to, one or more of a central processing unit (CPU), a network processing unit (NPU), an application-specific integrated circuit (ASIC), or a programmable logic device (PLD). The PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. The processor 602 is responsible for the communication line 604 and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. The memory 603 can be used to store data used by the processor 602 in executing operations.

[0101] The memory 603 can be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, a magnetic disk storage or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto. The memory 603 can exist independently of the processor 602 and be connected to the processor 602 via the communication line 604. The memory 603 can also be integrated with the processor 602. If the memory 603 and the processor 602 are independent devices, the memory 603 and the processor 602 are connected, for example, the memory 603 and the processor 602 can communicate via the communication line 604. The communication interface 601 and the processor 602 can communicate via the communication line 604, and the communication interface 601 can also be directly connected to the processor 602.

[0102] The communication line 604 can include any number of interconnected buses and bridges, the communication line 604 linking various circuitries including one or more processors 602 represented by the processor 602 and memories represented by the memory 603. The communication line 604 can also link various other circuitries such as peripheral devices, voltage stabilizers and power management circuitries, which are well known in the art, and thus, further description thereof will not be given herein.

[0103] In one specific implementation, the sample processing apparatus can include a memory for storing computer readable instructions. A communication interface coupled with the memory for obtaining a support set and a query set can also be included. A processor coupled with the communication interface for executing the computer readable instructions in the memory to perform the following operations can also be included: processing the support set and the query set through a preset neural network to obtain a first support sample representation of the support set and a first query sample representation of the query set; calculating a first information gain, the first information gain reflecting a contribution degree of each word in the support set to a category of the support set; determining a second support sample representation in the support set according to the first support sample representation and the first information gain, and determining a second query sample representation in the query set according to the first query sample representation and the first information gain.

[0104] Referring to Figure 7 is a structural schematic diagram of an execution device provided by an embodiment of the present application. As shown in Figure 7 , the execution device can include a processor 701, a memory 702, a communication bus 703, a communication interface 704, an artificial intelligence processor 705 connecting the memory 702 and the communication interface 704 through the communication bus 703.

[0105] The processor 701 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gates or transistor logic components, discrete hardware components, etc. The processor 701 can be a microprocessor or can also be any conventional processor.

[0106] The processor 701 can also be an integrated circuit chip with a processing capability of signals. In the implementation process, various steps of the neural network processing method of the present application can be completed by integrated logic circuits of hardware in the processor 701 or instructions in the form of software.

[0107] The memory 702 can be a read-only memory (ROM), a random access memory (RAM), or other memories. In the embodiments of the present application, the memory 702 is used to store data and various software programs.

[0108] Optionally, in the embodiments of the present application, the memory 702 can include a physical device for storing information, which is usually to digitize the information and then store it in a medium using electrical, magnetic, or optical methods. The memory 702 of the present embodiment can include: devices for storing information using electrical energy, such as RAM, ROM, etc.; devices for storing information using magnetic energy, such as hard disks, floppy disks, magnetic tapes, magnetic core memories, bubble memories, U disks; devices for storing information using optical methods, such as CDs or DVDs. Of course, there are other ways of memory, such as quantum memory, graphene memory, etc.

[0109] The communication interface 704 uses a transceiving device such as but not limited to a transceiver to realize the communication between the execution device and other devices or communication networks. For example, at least one input information can be received through the communication interface 704.

[0110] Optionally, the execution device can also include at least one artificial intelligence processor 705.

[0111] The artificial intelligence processor 705 can be mounted on the host CPU as a co-processor, and the host CPU allocates tasks for it. In actual application, the artificial intelligence processor 705 can implement one or more operations. For example, taking a neural network processor (NPU) as an example, the core part of the NPU is an operation circuit, which extracts matrix data in the memory 702 and performs multiplication and addition operation through the controller to control the operation circuit.

[0112] Optionally, the artificial intelligence processor 705 can include 8 clusters, and each cluster includes 4 artificial intelligence processor cores.

[0113] Optionally, the artificial intelligence processor 705 can be an artificial intelligence processor of a reconfigurable architecture. Here, the reconfigurable architecture refers to that if a certain artificial intelligence processor can utilize reusable hardware resources to flexibly change its own architecture according to different application requirements, so as to provide a matching architecture for each specific application requirement, the artificial intelligence processor is called a reconfigurable computing system, and the architecture is called a reconfigurable architecture.

[0114] It should be understood that the execution device is only an example provided by the embodiments of the present application, and the execution device can have more or fewer components than those shown, can combine two or more components, or can have a different configuration of components.

[0115] The sample processing device provided in the embodiments of the present application is mainly described from the perspective of entity functions. From the perspective of functional units, the present application can divide the sample processing device into functional units according to the above-mentioned method embodiments, for example, each functional unit can be divided according to each function, or two or more functions can be integrated into one functional unit. The integrated functional unit can be realized in the form of hardware or in the form of a software functional unit.

[0116] For example, in the case of dividing each functional unit in an integrated manner, Figure 8 A structural schematic diagram of a sample processing device provided by an embodiment of the present application is shown. As shown in Figure 8 An embodiment of the sample processing device of the present application can include:

[0117] The acquisition unit 801 is configured to acquire a support set and a query set.

[0118] The processing unit 802 is configured to process the support set and the query set through a preset neural network to obtain a first support sample representation of the support set and a first query sample representation of the query set.

[0119] The processing unit 802 is configured to calculate a first information gain, the first information gain being used to reflect a contribution degree of each word in the support set to the category of the support set.

[0120] The processing unit 802 is configured to determine a second support sample representation in the support set according to the first support sample representation and the first information gain, and determine a second query sample representation in the query set according to the first query sample representation and the first information gain.

[0121] In some embodiments, the processing unit 802 is further configured to:

[0122] After determining the second support sample representation in the support set according to the first support sample representation and the first information gain, and determining the second query sample representation in the query set according to the first query sample representation and the first information gain, the second support sample representation and the second query sample representation are processed by a preset reconstruction optimization algorithm to obtain the sample weight of the support set;

[0123] The category representation of the support set is determined based on the sample weight of the support set and the second support sample representation.

[0124] According to the category representation of the support set and the second query sample representation, the sample similarity is calculated, and the sample similarity is used to reflect the classification result of the query sample in the query set.

[0125] In some embodiments, the processing unit 802 is further configured to:

[0126] K target support samples are obtained, K≥1, and K is an integer.

[0127] In some embodiments, the processing unit 802 is specifically configured to calculate the information gain of each word of the support sample in the support set respectively to obtain the first information gain.

[0128] In some embodiments, the processing unit 802 is specifically configured to:

[0129] Any N adjacent words of the support sample in the support set are grouped to obtain a first word group set, N≥2, and N is an integer.

[0130] The information gain of each word group in the first word group set to the support set is calculated to obtain the first information gain.

[0131] In some embodiments, the processing unit 802 is specifically configured to:

[0132] Any N non-adjacent words of the support sample in the support set are grouped to obtain a second word group set.

[0133] The information gain of each word group in the second word group set to the support set is calculated to obtain the first information gain.

[0134] In the above embodiments, all or part of them can be realized by software, hardware, firmware or any combination thereof. When realized by software, all or part of them can be realized in the form of a computer program product.

[0135] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that the computer can store or be integrated into a data storage device such as a server, data center, etc. containing one or more available media sets. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)), etc.

[0136] Those of ordinary skill in the art can understand that all or part of the steps in the above-mentioned embodiments of the various methods can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer-readable storage medium, which can include ROM, RAM, magnetic or optical disks, etc.

[0137] The processing method of the neural network model and the related device provided by the embodiments of the present application are described in detail above, and the principles and implementation modes of the present application are described by applying specific examples. The above description of the embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed, and the above description of the embodiments should not be understood as a limitation of the present application.

Claims

1. A method for processing samples, characterized in that, include: Obtain a support set and a query set, wherein the support set and the query set are both graphics, images, voice, text, or IoT data. The support set and the query set are processed by a preset neural network to obtain a first support sample representation of the support set and a first query sample representation of the query set. Calculate a first information gain, which reflects the contribution of each word in the support set to the category of the support set; A second support sample representation in the support set is determined based on the first support sample representation and the first information gain, and a second query sample representation in the query set is determined based on the first query sample representation and the first information gain; The step of determining the second support sample representation in the support set based on the first support sample representation and the first information gain includes: weighting the first support sample representation with the first information gain as the weight to obtain the second support sample representation; The step of determining the second query sample representation in the query set based on the first query sample representation and the first information gain includes: weighting the first query sample representation with the first information gain as the weight to obtain the second query sample representation.

2. The method according to claim 1, characterized in that, After determining a second support sample representation in the support set based on the first support sample representation and the first information gain, and determining a second query sample representation in the query set based on the first query sample representation and the first information gain, the method further includes: The second support sample representation and the second query sample representation are processed by a preset reconstruction optimization algorithm to obtain the sample weights of the support set; The category representation of the support set is determined based on the sample weights of the support set and the second support sample representation; Based on the category representation of the support set and the second query sample representation, a sample similarity is calculated, which is used to reflect the classification result of the query samples in the query set.

3. The method according to claim 2, characterized in that, The method further includes: We obtain K target support samples, where K ≥ 1 and K is an integer.

4. The method according to any one of claims 1-3, characterized in that, The calculation of the first information gain includes: The information gain of each word in the support samples of the support set is calculated to obtain the first information gain.

5. The method according to any one of claims 1-3, characterized in that, The calculation of the first information gain includes: Group any N adjacent words of the support samples in the support set to obtain the first word group set; Calculate the information gain of each word in the first word set with respect to the support set to obtain the first information gain.

6. The method according to any one of claims 1-3, characterized in that, Calculating the first information gain includes: Group any N non-adjacent words from the support samples in the support set to obtain a second set of word groups; Calculate the information gain of each word in the second word set with respect to the support set to obtain the first information gain.

7. A sample processing device, characterized in that, include: The acquisition unit is used to acquire a support set and a query set, wherein the support set and the query set are both graphics, or graphics, or images, or voice, or text, or Internet of Things data. The processing unit is used to process the support set and the query set through a preset neural network to obtain a first support sample representation of the support set and a first query sample representation of the query set. The processing unit is configured to calculate a first information gain, which reflects the degree of contribution of each word in the support set to the category of the support set. The processing unit is configured to determine a second support sample representation in the support set based on the first support sample representation and the first information gain, and to determine a second query sample representation in the query set based on the first query sample representation and the first information gain; The step of determining the second support sample representation in the support set based on the first support sample representation and the first information gain includes: weighting the first support sample representation with the first information gain as the weight to obtain the second support sample representation; The step of determining the second query sample representation in the query set based on the first query sample representation and the first information gain includes: weighting the first query sample representation with the first information gain as the weight to obtain the second query sample representation.

8. The sample processing apparatus according to claim 7, characterized in that, The processing unit is further configured to: After determining the second support sample representation in the support set based on the first support sample representation and the first information gain, and determining the second query sample representation in the query set based on the first query sample representation and the first information gain, the second support sample representation and the second query sample representation are processed by a preset reconstruction optimization algorithm to obtain the sample weights of the support set. The category representation of the support set is determined based on the sample weights of the support set and the second support sample representation; Based on the category representation of the support set and the second query sample representation, a sample similarity is calculated, which is used to reflect the classification result of the query samples in the query set.

9. The sample processing apparatus according to claim 8, characterized in that, The processing unit is further configured to: We obtain K target support samples, where K ≥ 1 and K is an integer.

10. The sample processing apparatus according to any one of claims 7-9, characterized in that, The processing unit is configured to calculate the information gain of each word in the support samples of the support set to obtain the first information gain.

11. The sample processing apparatus according to any one of claims 7-9, characterized in that, The processing unit is used for: Group any N adjacent words of the support samples in the support set to obtain the first word group set, where N≥2 and N is an integer; Calculate the information gain of each word in the first word set with respect to the support set to obtain the first information gain.

12. The sample processing apparatus according to any one of claims 7-9, characterized in that, The processing unit is used for: Group any N non-adjacent words from the support samples in the support set to obtain a second set of word groups; Calculate the information gain of each word in the second word set with respect to the support set to obtain the first information gain.

13. A sample processing device, characterized in that, include: Memory, used to store computer-readable instructions; It also includes a processor coupled to the memory for executing computer-readable instructions in the memory to perform the method described in any one of claims 1 to 6.

14. A computer-readable storage medium, characterized in that, When the instructions are executed on a computer device, the computer device causes the computer device to perform the method described in any one of claims 1 to 6.

15. A computer program product, when run on a computer, enables the computer to perform the method described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Lexicon updating method and device

    CN107180084A

  • A monocular vision and deep learning-based road target detection and recognition method

    CN109766769A