WO2023284716A1 - 一种神经网络搜索方法及相关设备 - Google Patents

一种神经网络搜索方法及相关设备 Download PDF

Info

Publication number
WO2023284716A1
WO2023284716A1 PCT/CN2022/105115 CN2022105115W WO2023284716A1 WO 2023284716 A1 WO2023284716 A1 WO 2023284716A1 CN 2022105115 W CN2022105115 W CN 2022105115W WO 2023284716 A1 WO2023284716 A1 WO 2023284716A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
layer
neural network
network
operators
Prior art date
Application number
PCT/CN2022/105115
Other languages
English (en)
French (fr)
Inventor
徐航
任晓哲
尹伊淳
钱莉
李震国
蒋欣
高佳慧
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP22841352.2A priority Critical patent/EP4361843A1/en
Publication of WO2023284716A1 publication Critical patent/WO2023284716A1/zh
Priority to US18/411,616 priority patent/US20240152770A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/0985Hyperparameter optimisation; Meta-learning; Learning-to-learn
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • G06F40/295Named entity recognition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent

Definitions

  • This application relates to the field of artificial intelligence, in particular to a neural network search method and related equipment.
  • Artificial intelligence is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
  • artificial intelligence is the branch of computer science that attempts to understand the nature of intelligence and produce a new class of intelligent machines that respond in ways similar to human intelligence.
  • Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making.
  • the transformer structure has powerful semantic expression ability and can capture long-term dependencies of text. Since it was proposed, it has significantly surpassed the previous models in a series of natural language processing tasks represented by translation. The pre-trained language model based on the transformer structure has also achieved very good results in the fields of question answering systems and voice assistants.
  • NAS neural architecture search
  • the existing neural network search method for the transformer model has limited performance improvement for the transformer model.
  • the present application provides a neural network search method, the method comprising:
  • At least one candidate neural network in the plurality of candidate neural networks includes a target transformer layer, the target transformer layer includes a target attention head, and the target attention head includes a plurality of operators, and The multiple operators are obtained by sampling multiple candidate operators included in the first search space;
  • the type of the network layer in the candidate neural network can be determined as a transformer layer (in the embodiment of the present application, it can be called the target transformer layer) by sampling or fixed setting, and by performing the operator from the first search space Sampling method to determine the structure of the target attention head head in the target transformer layer;
  • the source of operator sampling can be the first search space, and the first search space can include multiple candidate operators.
  • the attention head When constructing the attention head, multiple candidate operators in the first search space can be sampled. Candidate operators, and combine the sampled candidate operators to obtain the attention head in a transformer layer. After multiple sampling, the attention heads in multiple transformer layers can be obtained; specifically, in a
  • the candidate operators of the first search space can be sampled to construct the target attention head, specifically, multiple operators can be sampled from the first search space, and the connection relationship between multiple operators can be sampled .
  • the type, quantity, and connection relationship of each operator included in the target attention head can be determined based on sampling, and further, multiple operators can be obtained based on sampling , and sampling the connection relationship between multiple operators to construct the target attention head;
  • sampling in the embodiments of the present application may be random sampling or non-random sampling, wherein random sampling may refer to a sampling method in which samples are drawn from the population in accordance with the principle of randomization.
  • Random sampling includes, for example but not limited to, simple random sampling, systematic sampling, cluster sampling, and stratified sampling.
  • Non-random sampling can be based on a certain probability distribution or other ways to guide the sampling process, so that different sampled information has different probability of being sampled in each sampling.
  • the sampling in the embodiment of the present application may include the sampling of the network layer type (the network layer type specifically includes the transformer layer and the target network layer), the sampling of multiple operators in the attention head head (specifically including the operator type, the number of operators, and Sampling of connection relations), sampling of the number of transformation matrices in the attention head head, and sampling of the size of the convolution kernel of the convolution layer in the target network layer.
  • the above sampling process can be realized partly based on random sampling and partly based on non-random sampling. It can also be implemented based entirely on random sampling, or all based on non-random sampling.
  • the sampling of the network layer type is used to determine the network type of each network layer connected serially in the candidate neural network (the network type may be a transformer layer or a target network layer, or other network types).
  • the sampling of multiple operators in the attention head head is used to determine the operator type, the number of operators and the connection relationship between operators included in the attention head head, where the operator type is the pair Multiple candidate operators in the first search space are sampled, and the number of operators is sampled from a preset range. For example, the number of operators between 5 and 20 is determined for the target head sampling.
  • the connection relationship is obtained by sampling based on the quantity flow between multiple operators obtained by sampling.
  • the multiple operators obtained by sampling include operator A and operator B, so whether operator A is connected to operator B can be It is determined based on sampling, and in the case of a connection relationship, whether the output of operator A is used as the input of operator B or the output of operator B is used as the input of operator A can also be determined based on sampling .
  • the sampling of the number of transformation matrices in the attention head head is used to determine how many transformation matrices are included in the attention head head, and the number of samples can have an upper limit and/or a lower limit, for example, sampling in the number interval of 1-4 To determine, or to determine by sampling within the number interval of 2-4, or to determine by sampling within the number interval of 2-3, which is not limited here.
  • a target neural network is selected from the plurality of candidate neural networks.
  • multiple neural networks can be trained to obtain the performance of each candidate neural network, and then the target neural network can be selected from the multiple candidate neural networks based on the performance of each candidate neural network.
  • Network wherein the number of the target neural network is at least one, when the number of the target neural network is one, the target neural network can be the model with the best performance among multiple candidate neural networks, when the number of the target neural network is multiple , the target neural network may be multiple models with the best performance among multiple candidate neural networks.
  • the first search space includes multiple candidate operators, where the candidate operators are unary operators or binary operators.
  • the unary operator refers to performing operations on only one data, such as negative operation (neg), square root operation (sqrt), transpose operation (transpose), softmax operation, logsigmoid operation, softsign operation, etc.
  • a binary operator refers to a rule that operates on two data to obtain a third data, such as an addition operation (add), a dot product operation (matmul), a cosine similarity operation, and an euclidean distance operation.
  • the types of the above candidate operators are more abundant than the existing attention head operator types, which greatly increases the structural types of the candidate transformer layers, thereby increasing the possibility of searching for a transformer model with better performance.
  • the multiple candidate operators include a softmax operator and a dot product operator.
  • the softmax operator and the point multiplication operator in the existing attention head head are retained. Since the softmax operator and the point multiplication operator are very important operators in the attention mechanism Subtype, when performing operator sampling for the attention head, the lack of these two operator types may cause the structural difference between the head of the searched attention head and the existing attention head to be too large. On the one hand, it is difficult to sample the attention head structure with excellent performance. On the other hand, it also increases the time and computing power of the search process.
  • the candidate operators of the first search space can be sampled to construct the target attention head.
  • multiple operators can be sampled from the first search space, and the connection relationship. That is to say, when constructing the target attention head, the type, quantity, and connection relationship of each operator included in the target attention head can be determined based on sampling, and further, multiple operators can be obtained based on sampling , and sampling the connections between multiple operators to construct the target attention head.
  • connection relationship between operators is also that the types of the above-mentioned candidate operators are more abundant than the existing operator types of the attention head, which greatly increases the structure types of the candidate transformer layer, and then increases the search results with The possibility of a transformer model with better performance.
  • the target attention head also includes a first linear transformation layer, the first linear transformation layer is used to process the input vector of the target attention head through the target transformation matrix, and the multiple operators It is used to perform operations on the data processing results of the first linear transformation layer.
  • the target transformation matrix only includes X transformation matrices, where X is a positive integer less than or equal to 4, and the number of X is determined based on sampling.
  • the target transformation matrix may only include one of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or, the target transformation matrix may only include two of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or,
  • the target transformation matrix includes a Q transformation matrix, a V transformation matrix and a K transformation matrix.
  • the target transformation matrix can include a Q transformation matrix, a V transformation matrix, and a K transformation matrix. At least one of matrix and P transformation matrix.
  • the matrix type of the transformation matrix included in the target transformation matrix can be determined based on sampling, and the matrix type is Q transformation matrix, K transformation matrix or V transformation matrix, or the target transformation matrix is preset
  • the matrix type of the transformation matrix included in the transformation matrix is not limited here.
  • the target attention head further includes a second linear transformation layer, and the second linear transformation layer is used to linearly transform the data processing results of the multiple operators to obtain the target attention head The output vector of .
  • the size of the input vector of the target attention head and the output vector of the target attention head are the same.
  • the input and output of the attention head head in the prior art can be retained
  • the relationship between the characteristics, that is, to ensure that the size of the input vector of the target attention head and the size of the output vector of the target attention head is the same.
  • the number of operators included in the target attention head is less than a preset value, for example, the preset value may be 10, 11, 12, 14, 15, 20, 21 and so on.
  • the upper limit of the number of operator samples is set to ensure that the size of the searched network will not be too large, and then it can be searched out under the premise of satisfying a certain model size constraint. better performing models.
  • the target transformer layer in the transformer model can be constructed by operator sampling.
  • the target attention head in the target transformer layer in the transformer model can be constructed by operator sampling.
  • the target transformer layer can include multiple attention heads, and the target attention head can be any one of the multiple attention heads.
  • each attention head in the multiple attention heads The structure between the heads is the same.
  • the at least one candidate neural network includes a plurality of network layers connected in series, the plurality of network layers includes the target transformer layer, and the position of the target transformer layer in the plurality of network layers is based on sampling determined in a manner.
  • the network type of the network layer is determined based on sampling (for example, the target transformer layer or the subsequent target network layer) , can greatly increase the structure type of the candidate transformer layer, thereby increasing the possibility of searching for a transformer model with better performance.
  • the at least one candidate neural network includes multiple network layers connected in series, where the multiple network layers include the target transformer layer and a target network layer, where the target network layer includes a convolutional layer.
  • the convolution kernels in the convolution layer may be obtained by sampling convolution kernels of multiple sizes included in the second search space.
  • the type of the network layer in the candidate neural network can be determined as the target network layer including the convolutional layer by sampling or fixed setting, and by sampling from the second search space to determine Determine the size of the convolution kernel in the convolution layer in the target network layer.
  • a diversified search space including both local (convolution kernel in the convolution layer) and global operators (operators in the transformer layer).
  • the global operator can combine mathematical basic operators to construct a new attention mechanism
  • the local operator contains a variety of convolution kernels of different sizes. Through the combination of global operators and local operators, it is possible to more effectively capture the relationship between words and sentences, and improve the performance of the searched model.
  • the neural network model in the embodiment of the present application can be used as a pre-training model and adapted to various downstream tasks.
  • the convolution kernel can use the lightweight convolution architecture to improve the performance of the model.
  • the target network layer also includes a first summation and normalization layer, a feedforward layer (feed forward net, FFN), a second summation and normalization layer, the first summation
  • the normalization layer is used to process the input vector of the target network layer and the output vector of the convolutional layer
  • the feed-forward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum The sum and normalization layer is used to process the output vector of the first sum and normalization layer and the output vector of the feedforward layer FFN.
  • the structure of the summation and normalization layer, FFN and residual connection in the existing transformer layer can be retained, and the attention head can be replaced by the convolution layer, and then the embodiment of the application can be obtained.
  • the target network layer of , where the replacement convolution layer type can be obtained by sampling the convolution kernel from the second search space.
  • the multiple candidate neural networks include a target candidate neural network; the acquiring multiple candidate neural networks specifically includes: constructing a target attention head in the target candidate neural network;
  • the construction of the target attention head in the target candidate neural network includes:
  • the first neural network includes a first transformer layer, the first transformer layer includes a first attention head, and the plurality of operators included in the first attention head include for the first search space It is obtained by sampling multiple candidate operators;
  • the replacement is determined from the M candidate operators operator, and replace the target operator in the first attention head with the replacement operator to obtain the target attention head.
  • multiple candidate neural networks can be constructed through sampling.
  • the number of candidate neural network samples is large, and the performance of multiple candidate neural networks can be determined through training, and based on The performance of multiple candidate neural networks, initially select a certain number of networks from multiple candidate neural networks as the parent network, and then replace the operator of the parent network (if it is a transformer layer, it is the calculation in the attention head.
  • Sub-network replacement if the target network layer, you can replace the convolution kernel), get multiple sub-networks, and train multiple sub-networks to determine the performance of multiple sub-networks, and based on the performance of multiple sub-networks, from multiple sub-networks Identify the target neural network in the network as the search result of the neural network.
  • the initially constructed candidate neural network may be called a second neural network
  • the parent network may be called a first neural network
  • the child network may be called a candidate neural network.
  • multiple second neural networks can be obtained by sampling (specifically, you can refer to the description of candidate neural networks obtained by sampling in the above-mentioned embodiments, which will not be repeated here), and the multiple second neural networks can be Training, to obtain multiple trained second neural networks and the performance of the multiple trained second neural networks, specifically, random parameter initialization can be performed on multiple second neural networks, and multiple second neural networks
  • the neural network performs fast search training (for example, through 4w step training) to obtain multiple trained second neural networks, and uses the GLUE task to evaluate multiple trained second neural networks to obtain multiple second neural networks.
  • the performance of the network select the optimal N networks as the parent network, and save the training parameters of the parent network.
  • the N parent networks may include the first neural network.
  • the first neural network may include a first transformer layer, the first transformer layer includes a first attention head, and the first attention head includes a target operator, and then according to the M in the first search space
  • the candidate operator replaces the target operator in the first attention head
  • the positive impact on the performance of the first neural network is determined from the M candidate operators, and the first attention The target operator in the head is replaced by the replacement operator to obtain the target attention head.
  • the acquisition of the first neural network includes:
  • the second neural network includes the first neural network.
  • the target operator can be located at the target operator position of the second neural network, wherein the target operator position can indicate the position of the input from the head to a certain extent, and the target operator position can be compared with The code indicates that the position of the network operators is related to each other.
  • the calculation method of the position of each operator in the second neural network is the same as the calculation method of the target operator in the second neural network. Consistent, it can express the degree to which the different positions of the operator in the attention head have a positive impact on the model performance.
  • the positive influence it may be based on the operator at the position of the target operator in each of the plurality of trained second neural networks and the performance of the plurality of trained second neural networks, and/or, each The frequency of occurrence of the operator at the position of the target operator in the trained second neural network to determine M candidate operators in the first search space to replace the target operator in the first attention head , has a positive impact on the performance of the first neural network.
  • the positive impact can be represented by UCB (upper confidence bound) of the confidence interval
  • UCB upper confidence bound
  • specific calculation method of UCB score can be as follows:
  • ⁇ i represents the score obtained by operator i in the current position of the network structure
  • N i represents the number of times operator i has been sampled in history (when sampling the second neural network)
  • N represents the number of times all operators have been sampled .
  • the right half of the formula will get a larger value, and the current operator will be selected with a greater probability. It should be understood that after the UCB scores of each operator at each position are calculated, a softmax calculation may be performed on these scores to obtain a probability distribution. And set this probability as the probability that operator i is activated at the current position.
  • the embodiment of the present application uses positive influence to perform operator replacement, which can balance the search accuracy and search breadth of the algorithm, avoid falling into local optimum, and continuously search for a better network architecture.
  • the method also includes:
  • the first neural network initialize the parameters of the target candidate neural network to obtain the initialized target candidate neural network; wherein, the updateable parameters in the initialized target candidate neural network are the first neural network It is obtained by parameter sharing of updatable parameters at the same position in the network;
  • the target candidate neural network whose parameters are initialized is trained to obtain the performance of the target candidate neural network.
  • the updatable parameter when performing the parameter sharing of the attention head head, is the parameter in the transformation matrix in the attention head head; when performing the parameter sharing of the convolution layer, the updatable parameter is the convolution kernel; it should be understood that it can Select the corresponding parameters at the centermost position of the convolution kernel for parameter sharing.
  • parameter initialization is performed by means of parameter sharing, which can speed up the search speed, avoid repeated training, and greatly accelerate the search efficiency.
  • the target neural network is used to implement at least one of the following task types:
  • the present application provides a method for providing a model, the method comprising:
  • the performance requirement sent by the receiving end side is used to indicate the performance requirement of the neural network, and the performance requirement may include at least one of the following: data processing accuracy, model size and implemented task type;
  • a target neural network satisfying the performance requirement is obtained from a plurality of candidate neural networks, wherein at least one candidate neural network in the plurality of candidate neural networks includes a target transformer layer, and the target transformer layer Including a target attention head head, the target attention head includes a plurality of operators, and the plurality of operators are obtained by sampling a plurality of candidate operators included in the first search space;
  • the first search space includes multiple candidate operators, and the candidate operators are unary operators or binary operators; the target attention head is based on the multiple operators and the multiple The arrangement relationship between operators is constructed, and the arrangement relationship among multiple operators is determined based on sampling.
  • the target attention head also includes a first linear transformation layer, the first linear transformation layer is used to process the input vector of the target attention head through the target transformation matrix, and the multiple operators It is used to perform operations on the data processing results of the first linear transformation layer; wherein, the target transformation matrix only includes X transformation matrices, where X is a positive integer less than or equal to 4, and the number of X is based on sampling definite.
  • the target transformation matrix may only include one of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or, the target transformation matrix may only include two of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or,
  • the target transformation matrix includes a Q transformation matrix, a V transformation matrix and a K transformation matrix.
  • the target transformation matrix can include a Q transformation matrix, a V transformation matrix, and a K transformation matrix. At least one of matrix and P transformation matrix.
  • the at least one candidate neural network includes a plurality of network layers connected in series, the plurality of network layers includes the target transformer layer, and the position of the target transformer layer in the plurality of network layers is based on sampling determined in a manner.
  • the at least one candidate neural network includes multiple network layers connected in series, where the multiple network layers include the target transformer layer and a target network layer, where the target network layer includes a convolutional layer.
  • the position of the target network layer among the multiple network layers is determined based on sampling.
  • the convolution kernels in the convolution layer are obtained by sampling convolution kernels of multiple sizes included in the second search space.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the present application provides a neural network search method, the method comprising:
  • the at least one candidate neural network includes a plurality of network layers connected in series, the plurality of network layers include a target transformer layer and a target network layer, the target network layer includes a convolution layer, and the convolution The convolution kernels in the layer are obtained by sampling convolution kernels of multiple sizes included in the second search space;
  • a target neural network is selected from the plurality of candidate neural networks.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the target network layer also includes a first summation and normalization layer, a feedforward layer FFN, a second summation and normalization layer, and the first summation and normalization layer uses
  • the feedforward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum and normalization layer For processing the output vector of the first summation and normalization layer and the output vector of the feed-forward layer FFN.
  • the target neural network is used to implement at least one of the following task types:
  • the present application provides a data processing method, the method comprising:
  • the target neural network includes a plurality of serial network layers, the multiple network layers include a target transformer layer and a target network layer, and the target network layer includes a convolutional layer;
  • the target transformer layer includes a target attention head, and the target attention head includes multiple operators, and the multiple operators are unary operators or binary operators.
  • the target attention head includes multiple operators, and the multiple operators are obtained by sampling multiple candidate operators included in the first search space.
  • the target attention head also includes a first linear transformation layer, the first linear transformation layer is used to process the input vector of the target attention head through the target transformation matrix, and the multiple operators It is used to perform operations on the data processing results of the first linear transformation layer.
  • the target transformation matrix only includes X transformation matrices, where X is a positive integer less than or equal to 4.
  • the target transformation matrix may only include one of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or, the target transformation matrix may only include two of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or,
  • the target transformation matrix includes a Q transformation matrix, a V transformation matrix and a K transformation matrix.
  • the target transformation matrix can include a Q transformation matrix, a V transformation matrix, and a K transformation matrix. At least one of matrix and P transformation matrix.
  • the number of X is determined based on sampling.
  • the matrix type of the transformation matrix included in the target transformation matrix can be determined based on sampling, and the matrix type is Q transformation matrix, K transformation matrix or V transformation matrix, or the transformation matrix included in the target transformation matrix is preset.
  • the matrix type is not limited here.
  • the target attention head further includes a second linear transformation layer, and the second linear transformation layer is used to linearly transform the data processing results of the multiple operators to obtain the target attention head The output vector of .
  • the size of the input vector of the target attention head and the output vector of the target attention head are the same.
  • the number of operators included in the target attention head is less than a preset value, for example, the preset value may be 10, 11, 12, 14, 15, 20, 21 and so on.
  • the target transformer layer can include multiple attention heads, and the target attention head can be any one of the multiple attention heads.
  • the The structure between each attention head is the same.
  • the position of the target transformer layer in the plurality of network layers is determined based on sampling.
  • the convolution kernels in the convolution layer may be obtained by sampling convolution kernels of multiple sizes included in the second search space.
  • the convolutional layer includes a target network layer among the plurality of network layers, and the target network layer also includes a first summing and normalization layer, a feed-forward layer FFN, a second summing and normalization layer, the first summing and normalization layer is used to process the input vector of the target network layer and the output vector of the convolutional layer, and the feedforward layer FFN is used to process the first summing and normalization layer
  • the output vector of the normalization layer, the second summation and normalization layer is used to process the output vector of the first summation and normalization layer and the output vector of the feedforward layer FFN.
  • the position of the target network layer among the multiple network layers is determined based on sampling.
  • the present application provides a method for providing a model, the method comprising:
  • the performance requirement sent by the receiving end side is used to indicate the performance requirement of the neural network, and the performance requirement may include at least one of the following: data processing accuracy, model size and implemented task type;
  • a target neural network that meets the performance requirements is obtained from a plurality of candidate neural networks, wherein the target neural network includes a target transformer layer and a target network layer, the target network layer includes a convolutional layer, and the volume
  • the convolution kernel in the product layer is obtained by sampling convolution kernels of multiple sizes included in the second search space;
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the target network layer also includes a first summation and normalization layer, a feedforward layer FFN, a second summation and normalization layer, and the first summation and normalization layer uses
  • the feedforward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum and normalization layer For processing the output vector of the first summation and normalization layer and the output vector of the feed-forward layer FFN.
  • the target neural network is used to implement at least one of the following task types:
  • a neural network search device is characterized in that the device includes:
  • An acquisition module configured to acquire a plurality of candidate neural networks; wherein, at least one candidate neural network in the plurality of candidate neural networks includes a target transformer layer, the target transformer layer includes a target attention head, and the target attention head includes multiple operators, and the plurality of operators are obtained by sampling a plurality of candidate operators included in the first search space;
  • a model selection module configured to select a target neural network from the multiple candidate neural networks based on the performance of the multiple candidate neural networks.
  • the first search space includes multiple candidate operators, where the candidate operators are unary operators or binary operators.
  • the unary operator refers to performing operations on only one data, such as negative operation (neg), square root operation (sqrt), transpose operation (transpose), softmax operation, logsigmoid operation, softsign operation, etc.
  • a binary operator refers to a rule that operates on two data to obtain a third data, such as an addition operation (add), a dot product operation (matmul), a cosine similarity operation, and an euclidean distance operation.
  • the multiple candidate operators include a softmax operator and a dot product operator.
  • the candidate operators of the first search space can be sampled to construct the target attention head.
  • multiple operators can be sampled from the first search space, and the connection relationship. That is to say, when constructing the target attention head, the type, quantity, and connection relationship of each operator included in the target attention head can be determined based on sampling, and further, multiple operators can be obtained based on sampling , and sampling the connections between multiple operators to construct the target attention head.
  • the target attention head also includes a first linear transformation layer, the first linear transformation layer is used to process the input vector of the target attention head through the target transformation matrix, and the multiple operators It is used to perform operations on the data processing results of the first linear transformation layer.
  • the target transformation matrix only includes X transformation matrices, where X is a positive integer less than or equal to 4, and the number of X is determined based on sampling.
  • the target transformation matrix may only include one of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or, the target transformation matrix may only include two of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or,
  • the target transformation matrix includes a Q transformation matrix, a V transformation matrix and a K transformation matrix.
  • the target transformation matrix can include a Q transformation matrix, a V transformation matrix, and a K transformation matrix. At least one of matrix and P transformation matrix.
  • the target attention head further includes a second linear transformation layer, and the second linear transformation layer is used to linearly transform the data processing results of the multiple operators to obtain the target attention head The output vector of .
  • the size of the input vector of the target attention head and the output vector of the target attention head are the same.
  • the number of operators included in the target attention head is less than a preset value.
  • the target transformer layer in the transformer model can be constructed by operator sampling.
  • the target attention head in the target transformer layer in the transformer model can be constructed by operator sampling.
  • the target transformer layer can include multiple attention heads, and the target attention head can be any one of the multiple attention heads.
  • each attention head in the multiple attention heads The structure between the heads is the same.
  • the at least one candidate neural network includes a plurality of network layers connected in series, the plurality of network layers includes the target transformer layer, and the position of the target transformer layer in the plurality of network layers is based on sampling determined in a manner.
  • the at least one candidate neural network includes multiple network layers connected in series, where the multiple network layers include the target transformer layer and a target network layer, where the target network layer includes a convolutional layer.
  • the convolution kernels in the convolution layer may be obtained by sampling convolution kernels of multiple sizes included in the second search space.
  • the type of the network layer in the candidate neural network can be determined as the target network layer including the convolutional layer by sampling or fixed setting, and by sampling from the second search space to determine Determine the size of the convolution kernel in the convolution layer in the target network layer.
  • a diversified search space including both local (convolution kernel in the convolution layer) and global operators (operators in the transformer layer).
  • the global operator can combine mathematical basic operators to construct a new attention mechanism
  • the local operator contains a variety of convolution kernels of different sizes. Through the combination of global operators and local operators, it is possible to more effectively capture the relationship between words and sentences, and improve the performance of the searched model.
  • the neural network model in the embodiment of the present application can be used as a pre-training model and adapted to various downstream tasks.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the target network layer also includes a first summation and normalization layer, a feedforward layer FFN, a second summation and normalization layer, and the first summation and normalization layer uses
  • the feedforward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum and normalization layer For processing the output vector of the first summation and normalization layer and the output vector of the feed-forward layer FFN. That is to say, the structure of the summation and normalization layer, FFN and residual connection in the existing transformer layer can be retained, and the attention head can be replaced by the convolution layer, and then the embodiment of the application can be obtained.
  • the target network layer of where the replacement convolution layer type can be obtained by sampling the convolution kernel from the second search space.
  • the multiple candidate neural networks include a target candidate neural network; the acquisition module is specifically configured to: construct a target attention head in the target candidate neural network;
  • the construction of the target attention head in the target candidate neural network includes:
  • the first neural network includes a first transformer layer, the first transformer layer includes a first attention head, and the plurality of operators included in the first attention head include for the first search space It is obtained by sampling multiple candidate operators;
  • the replacement is determined from the M candidate operators operator, and replace the target operator in the first attention head with the replacement operator to obtain the target attention head.
  • the acquisition module is specifically used for:
  • the second neural network includes the first neural network.
  • the target operator is located at the position of the target operator of the second neural network; the device also includes:
  • the determining module is configured to use the operator at the position of the target operator in each of the plurality of trained second neural networks and the performance of the plurality of trained second neural networks, and/or, each of the trained After the occurrence frequency of the operator at the position of the target operator in the second neural network, when M candidate operators in the first search space are determined to replace the target operator in the first attention head, the Positive effect of first neural network performance.
  • the device also includes:
  • a parameter initialization module configured to initialize parameters of the target candidate neural network according to the first neural network, so as to obtain the initialized target candidate neural network; wherein, the updateable parameters in the initialized target candidate neural network obtained by performing parameter sharing on the updateable parameters of the same position in the first neural network;
  • the model training module is used to train the target candidate neural network whose parameters are initialized to obtain the performance of the target candidate neural network.
  • the target neural network is used to implement at least one of the following task types:
  • the present application provides a model providing device, which includes:
  • the receiving module is used to receive the performance requirements sent by the terminal side, the performance requirements are used to indicate the performance requirements of the neural network, and the performance requirements may include at least one of the following: data processing accuracy, model size and implemented task type;
  • An acquisition module configured to acquire a target neural network that meets the performance requirements from a plurality of candidate neural networks according to the performance requirements, wherein the target neural network includes a target transformer layer, and the target transformer layer includes a target attention head head , the target attention head includes a plurality of operators, and the plurality of operators are obtained by sampling a plurality of candidate operators included in the first search space;
  • a sending module configured to send the target neural network to the end side.
  • the candidate operator is a unary operator or a binary operator;
  • the target attention head is constructed based on the multiple operators and the arrangement relationship between the multiple operators, the multiple The arrangement relationship between operators is determined based on sampling.
  • the target attention head also includes a first linear transformation layer, the first linear transformation layer is used to process the input vector of the target attention head through the target transformation matrix, and the multiple operators It is used to perform operations on the data processing results of the first linear transformation layer; wherein, the target transformation matrix only includes X transformation matrices, where X is a positive integer less than or equal to 4, and the number of X is based on sampling definite.
  • the target transformation matrix may only include one of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or, the target transformation matrix may only include two of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or,
  • the target transformation matrix includes a Q transformation matrix, a V transformation matrix and a K transformation matrix.
  • the target transformation matrix can include a Q transformation matrix, a V transformation matrix, and a K transformation matrix. At least one of matrix and P transformation matrix.
  • the at least one candidate neural network includes a plurality of network layers connected in series, the plurality of network layers includes the target transformer layer, and the position of the target transformer layer in the plurality of network layers is based on sampling determined in a manner.
  • the at least one candidate neural network includes multiple network layers connected in series, where the multiple network layers include the target transformer layer and a target network layer, where the target network layer includes a convolutional layer.
  • the position of the target network layer among the multiple network layers is determined based on sampling.
  • the convolution kernels in the convolution layer are obtained by sampling convolution kernels of multiple sizes included in the second search space.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the present application provides a neural network search device, which includes:
  • An acquisition module configured to acquire a plurality of candidate neural networks; wherein, the at least one candidate neural network includes a plurality of network layers connected in series, the plurality of network layers includes a target transformer layer and a target network layer, and the target network layer includes convolution layer, the convolution kernel in the convolution layer is obtained by sampling convolution kernels of multiple sizes included in the second search space;
  • a model selection module configured to select a target neural network from the multiple candidate neural networks based on the performance of the multiple candidate neural networks.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the target network layer also includes a first summation and normalization layer, a feedforward layer FFN, a second summation and normalization layer, and the first summation and normalization layer uses
  • the feedforward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum and normalization layer For processing the output vector of the first summation and normalization layer and the output vector of the feed-forward layer FFN.
  • the target neural network is used to implement at least one of the following task types:
  • the present application provides a data processing device, which includes:
  • the obtaining module is used to obtain a target neural network, the target neural network includes a plurality of serial network layers, the multiple network layers include a target transformer layer and a target network layer, and the target network layer includes a convolutional layer; the obtaining module also Used to obtain pending data;
  • the data processing module is used to process the data to be processed through the target neural network to obtain a data processing result.
  • the target transformer layer includes a target attention head, and the target attention head includes multiple operators, and the multiple operators are unary operators or binary operators.
  • the target attention head includes multiple operators, and the multiple operators are obtained by sampling multiple candidate operators included in the first search space.
  • the target attention head also includes a first linear transformation layer, the first linear transformation layer is used to process the input vector of the target attention head through the target transformation matrix, and the multiple operators It is used to perform operations on the data processing results of the first linear transformation layer.
  • the target transformation matrix only includes X transformation matrices, where X is a positive integer less than or equal to 4.
  • the target transformation matrix may only include one of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or, the target transformation matrix may only include two of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or,
  • the target transformation matrix includes a Q transformation matrix, a V transformation matrix and a K transformation matrix.
  • the target transformation matrix can include a Q transformation matrix, a V transformation matrix, and a K transformation matrix. At least one of matrix and P transformation matrix.
  • the number of X is determined based on sampling.
  • the matrix type of the transformation matrix included in the target transformation matrix can be determined based on sampling, and the matrix type is Q transformation matrix, K transformation matrix or V transformation matrix, or the transformation matrix included in the target transformation matrix is preset.
  • the matrix type is not limited here.
  • the target attention head further includes a second linear transformation layer, and the second linear transformation layer is used to linearly transform the data processing results of the multiple operators to obtain the target attention head The output vector of .
  • the size of the input vector of the target attention head and the output vector of the target attention head are the same.
  • the number of operators included in the target attention head is less than a preset value, for example, the preset value may be 10, 11, 12, 14, 15, 20, 21 and so on.
  • the target transformer layer can include multiple attention heads, and the target attention head can be any one of the multiple attention heads.
  • the The structure between each attention head is the same.
  • the position of the target transformer layer in the plurality of network layers is determined based on sampling.
  • the convolution kernels in the convolution layer may be obtained by sampling convolution kernels of multiple sizes included in the second search space.
  • the convolutional layer includes a target network layer among the plurality of network layers, and the target network layer also includes a first summing and normalization layer, a feed-forward layer FFN, a second summing and normalization layer, the first summing and normalization layer is used to process the input vector of the target network layer and the output vector of the convolutional layer, and the feedforward layer FFN is used to process the first summing and normalization layer
  • the output vector of the normalization layer, the second summation and normalization layer is used to process the output vector of the first summation and normalization layer and the output vector of the feedforward layer FFN.
  • the position of the target network layer among the multiple network layers is determined based on sampling.
  • the present application provides a model providing device, which includes:
  • the receiving module is used to receive the performance requirements sent by the terminal side, the performance requirements are used to indicate the performance requirements of the neural network, and the performance requirements may include at least one of the following: data processing accuracy, model size and implemented task type;
  • An acquisition module configured to acquire a target neural network that satisfies the performance requirement from multiple candidate neural networks according to the performance requirement, wherein the target neural network includes a target transformer layer and a target network layer, and the target network layer includes volume Convolution layer, the convolution kernel in the convolution layer is obtained by sampling convolution kernels of multiple sizes included in the second search space;
  • a sending module configured to send the target neural network to the end side.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the target network layer also includes a first summation and normalization layer, a feedforward layer FFN, a second summation and normalization layer, and the first summation and normalization layer uses
  • the feedforward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum and normalization layer For processing the output vector of the first summation and normalization layer and the output vector of the feed-forward layer FFN.
  • the target neural network is used to implement at least one of the following task types:
  • the embodiment of the present application provides a neural network search device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to perform the above-mentioned One aspect and any optional method thereof, and the above third aspect and any optional method thereof.
  • the embodiment of the present application provides a model providing device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to perform the above-mentioned second aspect and any optional method thereof, and the above fifth aspect and any optional method thereof.
  • the embodiment of the present application provides a data processing device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to perform the above-mentioned fourth Aspects and any optional methods.
  • an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and when it is run on a computer, the computer executes the above-mentioned first aspect and any one thereof.
  • Optional methods, the above second aspect and any optional method thereof, the above third aspect and any optional method thereof, the above fourth aspect and any optional method thereof, and the above fifth aspect and any optional method thereof Either method is optional.
  • the embodiment of the present application provides a computer program, which, when run on a computer, enables the computer to execute the above-mentioned first aspect and any optional method thereof, the above-mentioned second aspect and any optional method thereof.
  • the present application provides a chip system
  • the chip system includes a processor, used to support the execution device or training device to realize the functions involved in the above aspect, for example, send or process the data involved in the above method ; or, information.
  • the system-on-a-chip further includes a memory, and the memory is used for storing necessary program instructions and data of the execution device or the training device.
  • the system-on-a-chip may consist of chips, or may include chips and other discrete devices.
  • An embodiment of the present application provides a neural network search method, the method comprising: obtaining a plurality of candidate neural networks; wherein at least one candidate neural network in the plurality of candidate neural networks includes a target transformer layer, and the target transformer layer includes a target Attention head head, the target attention head includes a plurality of operators, and the plurality of operators are obtained by sampling a plurality of candidate operators included in the first search space; based on the performance of the plurality of candidate neural networks, A target neural network is selected from the plurality of candidate neural networks.
  • Fig. 1 is a kind of structural schematic diagram of main frame of artificial intelligence
  • Fig. 2 is a kind of neural network search system
  • Fig. 3 is a kind of neural network search system
  • Fig. 4 is a kind of neural network search system
  • Fig. 5 is a kind of neural network search system
  • Fig. 6 is a kind of natural language processing system
  • Fig. 7 is a kind of natural language processing system
  • FIG. 8 is a schematic diagram of related equipment for natural language processing provided by the embodiment of the present application.
  • Fig. 9 is a schematic diagram of a convolutional neural network
  • Figure 10 is a schematic diagram of a convolutional neural network
  • FIG. 11 is a schematic structural diagram of a system architecture provided by an embodiment of the present application.
  • FIG. 12 is a schematic diagram of an embodiment of a neural network search method provided in the embodiment of the present application.
  • Fig. 13 is a structural representation of a transformer model
  • Fig. 14 is a structural representation of a transformer layer
  • Fig. 15 is a schematic structural diagram of a target attention head provided by the embodiment of the present application.
  • 16 to 21 are schematic diagrams of the structure of the target attention head obtained by sampling
  • Fig. 22 is a structural representation of a candidate neural network
  • FIG. 23 is a schematic diagram of a target network layer provided by an embodiment of the present application.
  • FIG. 24 is a schematic diagram of parameter sharing provided by the embodiment of the present application.
  • FIG. 25 is a schematic diagram of parameter sharing provided by the embodiment of the present application.
  • FIG. 26 is a network architecture search result obtained by providing a neural network search algorithm based on an embodiment of the present application.
  • Fig. 27 is a schematic diagram of an embodiment of a method for providing a model provided by the embodiment of the present application.
  • Fig. 28 is a schematic diagram of an embodiment of a neural network search method provided by the embodiment of the present application.
  • Fig. 29 is a schematic diagram of an embodiment of a method for providing a model provided by the embodiment of the present application.
  • FIG. 30 is a schematic diagram of an embodiment of a neural network search device provided in an embodiment of the present application.
  • Figure 31 is a schematic diagram of an embodiment of a model providing device provided in the embodiment of the present application.
  • Fig. 32 is a schematic diagram of an embodiment of a neural network search device provided in the embodiment of the present application.
  • Figure 33 is a schematic diagram of an embodiment of a model providing device provided in the embodiment of the present application.
  • Fig. 34 is a schematic structural diagram of the execution device provided by the embodiment of the present application.
  • Fig. 35 is a schematic structural diagram of a training device provided by an embodiment of the present application.
  • FIG. 36 is a schematic structural diagram of a chip provided by an embodiment of the present application.
  • Figure 1 shows a schematic structural diagram of the main framework of artificial intelligence.
  • the following is from the “intelligent information chain” (horizontal axis) and “IT value chain” ( Vertical axis) to illustrate the above artificial intelligence theme framework in two dimensions.
  • the "intelligent information chain” reflects a series of processes from data acquisition to processing. For example, it can be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has undergone a condensed process of "data-information-knowledge-wisdom".
  • IT value chain reflects the value brought by artificial intelligence to the information technology industry from the underlying infrastructure of artificial intelligence, information (provided and processed by technology) to the systematic industrial ecological process.
  • the infrastructure provides computing power support for the artificial intelligence system, realizes communication with the outside world, and realizes support through the basic platform.
  • the basic platform includes distributed computing framework and network and other related platform guarantees and supports, which can include cloud storage and Computing, interconnection network, etc.
  • sensors communicate with the outside to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
  • Data from the upper layer of the infrastructure is used to represent data sources in the field of artificial intelligence.
  • the data involves graphics, images, voice, text, and IoT data of traditional equipment, including business data of existing systems and sensory data such as force, displacement, liquid level, temperature, and humidity.
  • Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making, etc.
  • machine learning and deep learning can symbolize and formalize intelligent information modeling, extraction, preprocessing, training, etc. of data.
  • Reasoning refers to the process of simulating human intelligent reasoning in a computer or intelligent system, and using formalized information to carry out machine thinking and solve problems according to reasoning control strategies.
  • the typical functions are search and matching.
  • Decision-making refers to the process of decision-making after intelligent information is reasoned, and usually provides functions such as classification, sorting, and prediction.
  • some general capabilities can be formed based on the results of data processing, such as algorithms or a general system, such as translation, text analysis, computer vision processing, speech recognition, image processing identification, etc.
  • Intelligent products and industry applications refer to the products and applications of artificial intelligence systems in various fields. It is the packaging of the overall solution of artificial intelligence, which commercializes intelligent information decision-making and realizes landing applications. Its application fields mainly include: intelligent terminals, intelligent transportation, Smart healthcare, autonomous driving, smart cities, etc.
  • This application can, but is not limited to, be applied in the field of natural language processing in the field of artificial intelligence. Specifically, it can be applied in the fields of neural network search in the field of natural language processing and neural network reasoning in the field of natural language processing. The following will describe multiple landing products Multiple application scenarios are introduced.
  • this application can be applied to services related to neural network search, specifically, it can be a neural network architecture search service provided by a server on the cloud side, wherein the user can transmit information related to model search to the server on the cloud side through the user device
  • a neural network search system (such as a cloud server), in which the information related to model search can be the performance requirements of the user for the searched model, etc., and then the server on the cloud side can use a certain neural network search algorithm based on the performance requirements uploaded by the user.
  • search results (such as the target neural network in the embodiment of the present application), and deliver the search results to the user equipment.
  • FIG. 3 shows a neural network search system 100 .
  • the system may take training data 102 for training the neural network, validation data 104 for evaluating the performance of the neural network, and performance requirements 103, and use the training data 102 and validation data 104 and performance requirements 103 to determine search results 160 (e.g. In the embodiment of the present application, the target neural network), the search result 160 is configured to meet the performance requirement 103 , that is, to receive an input and generate an output that meets the performance requirement 103 .
  • the search result 160 can be the architecture information of the neural network, which can define the number of layers of the neural network, the operations performed by each layer, and the connections between the layers in the neural network, that is, which layers learn from other layers in the neural network. A layer receives input.
  • System 100 may receive training data 102, validation set 104, and performance requirements 103 in any of a variety of ways.
  • system 100 may receive training data and performance requirements 103 as uploads from remote users of the system over a data communications network, such as using an application programming interface (API) available to system 100, and divide the uploaded data randomly is the training data 102 and the validation set 104.
  • system 100 may receive input from a user specifying which data already maintained by system 100 should be used to train a neural network, and then partition the specified data into training data 102 and validation set 104 .
  • API application programming interface
  • system 100 may determine search results 160 by searching the space of candidate architectures to identify one or more best performing architectures. For example, as shown in FIG. 3 , the system 100 can construct a plurality of candidate neural network architectures (such as the candidate neural network in the embodiment of the present application) by searching the space of candidate architectures, and through the candidate selection engine 130, and through The training engine 140 performs model training and other processing on the candidate neural network architecture, and the quality evaluation engine 150 can evaluate the training results to determine the search results 160 .
  • candidate neural network architectures such as the candidate neural network in the embodiment of the present application
  • Fig. 4 shows a neural network search system, which includes a user equipment and a neural network search device.
  • the user equipment includes smart terminals such as a mobile phone, a personal computer, or an information processing center.
  • the user equipment is the initiator of the neural network search, and usually the user initiates a neural network search request through the user equipment.
  • the aforementioned neural network search device may be a device or server with a neural network search function, such as a cloud server, a network server, an application server, and a management server.
  • the neural network search device receives the neural network search from the intelligent terminal through the interactive interface, and then performs machine learning, deep learning, search, reasoning, decision-making and other methods of neural network search through the memory for storing data and the processor link, and sends the search results ( For example, the target neural network in the embodiment of the present application) is fed back to the user equipment.
  • the memory in the neural network search device can be a general term, including local storage and a database for storing historical data.
  • the database can be on the data processing device or on other network servers.
  • the user equipment may receive user instructions, for example, the user equipment may receive a model performance requirement for neural network search input by the user, and then initiate a request to the neural network search device.
  • the neural network search device may execute the neural network search method of the embodiment of the present application.
  • Fig. 5 shows another neural network search system.
  • the user equipment is directly used as a neural network search device.
  • the hardware of the device itself performs the neural network search, and the specific process is similar to that in Figure 4, which can be referred to the above description, and will not be repeated here.
  • the user equipment itself can execute the neural network search method of the embodiment of the present application.
  • Fig. 6 shows a natural language processing system, which includes a user device and a data processing device.
  • the user equipment includes smart terminals such as a mobile phone, a personal computer, or an information processing center.
  • the user device is the initiator of natural language data processing, and as the initiator of requests such as language question and answer or query, usually the user initiates the request through the user device.
  • the above-mentioned data processing device may be a device or server having a data processing function such as a cloud server, a network server, an application server, and a management server.
  • the data processing device receives query sentences/speech/text and other questions (such as the data to be processed in the embodiment of the application) from the intelligent terminal through the interactive interface, and then performs machine learning through the memory for storing data and the processor link for data processing, Language data processing in the form of deep learning, search, reasoning, decision-making, etc. (such as data processing through the target neural network in the embodiment of this application), and feedback the processing results (such as the data processing results in the embodiment of this application) to the user equipment.
  • the storage in the data processing device may be a general term, including local storage and a database storing historical data, and the database may be on the data processing device or on other network servers.
  • the user equipment can receive user instructions, for example, the user equipment can receive a section of text input by the user, and then initiate a request to the data processing equipment, so that the data processing equipment can obtain the text of the user equipment.
  • the text executes natural language processing applications (such as text classification, text reasoning, named entity recognition, translation, etc.), so as to obtain the processing results of the corresponding natural language processing applications for this piece of text (such as classification results, inference results, named entity recognition results , translation results, etc.).
  • the user equipment may receive a piece of Chinese input by the user, and then initiate a request to the data processing device, so that the data processing device performs entity classification on the piece of Chinese, so as to obtain an entity classification result for the piece of Chinese;
  • the user The device may receive a piece of Chinese input by the user, and then initiate a request to the data processing device, so that the data processing device translates the piece of Chinese into English, thereby obtaining an English translation for the piece of Chinese.
  • Fig. 7 shows another natural language processing system.
  • the user equipment is directly used as a data processing equipment, and the user equipment can directly receive input from the user (such as the data to be processed in the embodiment of the present application) and directly
  • the processing is performed by the hardware of the user equipment itself, and the specific process is similar to that shown in FIG. 6 . Reference may be made to the above description, and details will not be repeated here.
  • the user equipment can receive user instructions, for example, the user equipment can receive a section of text input by the user, and then the user equipment itself can execute a natural language processing application (such as text classification) for this section of text. , text reasoning, named entity recognition, translation, etc.), so as to obtain the processing results (such as classification results, reasoning results, named entity recognition results, translation results, etc.) of the corresponding natural language processing application for this piece of text.
  • a natural language processing application such as text classification
  • processing results such as classification results, reasoning results, named entity recognition results, translation results, etc.
  • the user equipment can receive a section of Chinese input by the user, and perform entity classification on the section of Chinese, so as to obtain an entity classification result for the section of Chinese;
  • the user equipment can receive a section of Chinese input by the user, and The Chinese paragraph is translated into English, so as to obtain the English translation for the Chinese paragraph.
  • the user equipment may store the target neural network, and perform inference tasks according to the target neural network after each operating system (operating system, OS) or application program (application, APP) invokes the model.
  • OS operating system
  • APP application program
  • FIG. 8 is a schematic diagram of a device 300 related to natural language processing provided by an embodiment of the present application.
  • the above-mentioned user equipment in FIG. 6 and FIG. 7 may specifically be the local device 301 or the local device 302 in FIG. 8, and the data processing device in FIG. 6 may specifically be the execution device 310 in FIG.
  • the data storage system 350 may be integrated on the execution device 310, or set on the cloud or other network servers.
  • the processors in Figures 6 and 7 can perform data training/machine learning/deep learning through a neural network model or other models, and use the trained model (such as the target neural network in the embodiment of the application) to perform natural Language processing applications (such as text classification, sequence labeling, reading comprehension, text generation, text reasoning, translation, etc.) to obtain corresponding processing results.
  • trained model such as the target neural network in the embodiment of the application
  • natural Language processing applications such as text classification, sequence labeling, reading comprehension, text generation, text reasoning, translation, etc.
  • the neural network can be composed of neural units, and the neural unit can refer to an operation unit that takes xs and intercept 1 as input, and the output of the operation unit can be:
  • Ws is the weight of xs
  • b is the bias of the neural unit.
  • f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal.
  • the output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function.
  • a neural network is a network formed by connecting multiple above-mentioned single neural units, that is, the output of one neural unit can be the input of another neural unit.
  • the input of each neural unit can be connected with the local receptive field of the previous layer to extract the features of the local receptive field.
  • the local receptive field can be an area composed of several neural units.
  • the neural network can include an embedding layer and at least one transformer layer, and at least one transformer layer can be N transformer layers (N is an integer greater than 0), wherein each transformer layer includes successively adjacent attention layers, summation and normalization (add&norm) layer, feedforward (feed forward) layer and summation and normalization layer.
  • the current input is embedded and processed to obtain multiple feature vectors; in the attention layer, P input vectors are obtained from the upper layer of the first transformer layer, and any of the P input vectors is first The input vector is the center, and based on the correlation between each input vector within the preset attention window range and the first input vector, the intermediate vector corresponding to the first input vector is obtained, and the P input vectors are determined in this way.
  • P intermediate vectors in the pooling layer, the P intermediate vectors are combined into Q output vectors, and multiple output vectors obtained by the last transformer layer in the transformer layer are used as the feature representation of the current input.
  • the current input is embedded to obtain multiple feature vectors.
  • the embedding layer may be referred to as an input embedding layer.
  • the current input can be a text input, such as a piece of text or a sentence.
  • the text can be Chinese text, English text, or other language text.
  • the embedding layer After the embedding layer obtains the current input, it can embed each word in the current input to obtain the feature vector of each word.
  • the embedding layer includes an input embedding layer and a positional encoding (positional encoding) layer.
  • word embedding processing can be performed on each word in the current input, so as to obtain the word embedding vector of each word.
  • the position of each word in the current input can be obtained, and then a position vector is generated for the position of each word.
  • the position of each word may be the absolute position of each word in the current input. Take the current input as "what number should be returned to Huabei" as an example, where the position of "several” can be represented as the first digit, and the position of "number” can be represented as the second digit, ... .
  • the position of each word may be a relative position between each word.
  • the position of "several” can be expressed as before “number”, and the position of "number” can be expressed as after “several” and before “should",... ...
  • the word embedding vector and position vector of each word in the current input are obtained, the position vector of each word and the corresponding word embedding vector can be combined to obtain each word feature vector, that is, multiple feature vectors corresponding to the current input can be obtained.
  • Multiple feature vectors can be represented as embedding matrices with preset dimensions.
  • the number of eigenvectors in the plurality of eigenvectors can be set as M, and the preset dimension is H dimension, then the plurality of eigenvectors can be expressed as an M ⁇ H embedding matrix.
  • P input vectors can be obtained from the upper layer of the transformer layer, centering on any input vector in the P input vectors, based on the relationship between each input vector and the input vector within the preset attention window range
  • the degree of relevance is used to obtain the intermediate vector corresponding to the input vector, so that the P intermediate vectors corresponding to the P input vectors are determined.
  • Attention layers can also be called multi-head attention layers.
  • the attention layer can be a fixed window multi-head attention layer.
  • the structure of the transformer layer is redesigned based on the neural network search.
  • the attention mechanism imitates the internal process of biological observation behavior, that is, a mechanism that aligns internal experience and external sensation to increase the observation precision of some areas, and can quickly filter out high-value information from a large amount of information with limited attention resources .
  • the attention mechanism can quickly extract important features of sparse data, so it is widely used in natural language processing tasks, especially machine translation.
  • the self-attention mechanism is an improvement of the attention mechanism, which reduces the dependence on external information and is better at capturing the internal correlation of data or features.
  • the essential idea of the attention mechanism can be rewritten as the following formula:
  • Lx
  • the meaning of the formula is to imagine the constituent elements in Source as being composed of a series of data pairs. At this time, given a certain element Query in the target Target, by calculating Query and The similarity or correlation of each Key, the weight coefficient corresponding to the Value of each Key is obtained, and then the Value is weighted and summed to obtain the final Attention value. So in essence, the Attention mechanism is to weight and sum the Value values of the elements in the Source, and Query and Key are used to calculate the weight coefficient corresponding to the Value.
  • Attention can be understood as selectively screening out a small amount of important information from a large amount of information and focusing on these important information, ignoring most of the unimportant information.
  • the process of focusing is reflected in the calculation of the weight coefficient.
  • the self-attention mechanism can be understood as internal Attention (intra attention).
  • the Attention mechanism occurs between the elements Query of the Target and all elements in the Source.
  • the self-attention mechanism refers to between the internal elements of the Source or between the internal elements of the Target.
  • the specific calculation process is the same, but the calculation object has changed.
  • NLP Natural language processing
  • Natural language is human language, and natural language processing (NLP) is the processing of human language. Natural language processing is the process of systematically analyzing, understanding and extracting information from text data in an intelligent and efficient manner.
  • NLP natural language processing
  • Automatic summarization automated summarization
  • machine translation machine translation
  • NER Named entity recognition
  • relation extraction relation extraction
  • RE information extraction
  • sentiment analysis speech recognition
  • question answering system question answering
  • topic segmentation etc.
  • the natural language processing tasks may fall into the following categories.
  • Sequence annotation Each word in the sentence requires the model to give a classification category according to the context. Such as Chinese word segmentation, part-of-speech tagging, named entity recognition, and semantic role tagging.
  • Classification tasks the entire sentence outputs a classification value, such as text classification.
  • Sentence relationship inference Given two sentences, determine whether the two sentences have a nominal relationship. Such as entilment, QA, semantic rewriting, natural language inference.
  • Generative task output a piece of text and generate another piece of text.
  • Word segmentation (word segmentation or word breaker, WB): Segmenting continuous natural language texts into lexical sequences with semantic rationality and integrity can solve cross-ambiguity problems.
  • NER Named entity recognition
  • Part-speech tagging assign a part of speech (noun, verb, adjective, etc.) to each vocabulary in the natural language text; dependency parsing (dependency parsing): automatically analyze the syntactic components in the sentence (subject, predicate, object, attributive, adverbial and complement), which can solve the problem of structural ambiguity.
  • Word embedding&semantic similarity Vectorized representation of vocabulary, and based on this, the semantic similarity calculation of vocabulary can be realized, which can solve the similarity of vocabulary and language.
  • Text semantic similarity Relying on the massive data of the entire network and deep neural network technology, the ability to realize the semantic similarity calculation between texts can solve the problem of text semantic similarity.
  • Convolutional neural network is a deep neural network with a convolutional structure.
  • the convolutional neural network contains a feature extractor composed of a convolutional layer and a subsampling layer, which can be regarded as a filter.
  • the convolutional layer refers to the neuron layer that performs convolution processing on the input signal in the convolutional neural network.
  • a neuron can only be connected to some adjacent neurons.
  • a convolutional layer usually contains several feature planes, and each feature plane can be composed of some rectangularly arranged neural units. Neural units of the same feature plane share weights, and the shared weights here are convolution kernels. Shared weights can be understood as the way to extract features independent of position.
  • the convolution kernel can be formalized as a matrix of random size, and the convolution kernel can obtain reasonable weights through learning during the training process of the convolutional neural network.
  • the direct benefit of sharing weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.
  • CNN is a very common neural network.
  • the convolutional neural network is a deep neural network with a convolutional structure. It is a deep learning architecture.
  • the deep learning architecture is It refers to multiple levels of learning at different levels of abstraction through machine learning algorithms.
  • CNN is a feed-forward artificial neural network in which individual neurons respond to inputs.
  • a convolutional neural network (CNN) 200 may include an input layer 210 , a convolutional layer/pooling layer 220 (where the pooling layer is optional), and a fully connected layer (fully connected layer) 230 .
  • the convolutional layer/pooling layer 220 may include layers 221-226 as examples, for example: in one implementation, the 221st layer is a convolutional layer, the 222nd layer is a pooling layer, and the 223rd layer is a volume Layers, 224 are pooling layers, 225 are convolutional layers, and 226 are pooling layers; in another implementation, 221 and 222 are convolutional layers, 223 are pooling layers, and 224 and 225 are convolutional layers Layer, 226 is a pooling layer. That is, the output of the convolutional layer can be used as the input of the subsequent pooling layer, or it can be used as the input of another convolutional layer to continue the convolution operation.
  • the convolution layer 221 may include many convolution operators, which are also called kernels, and their role in image processing is equivalent to a filter for extracting specific information from the input image matrix.
  • the convolution operators are essentially It can be a weight matrix. This weight matrix is usually pre-defined. Take an image as an example (other data types are similar). During the convolution operation on the image, the weight matrix is usually followed by one pixel in the horizontal direction on the input image One pixel (or two pixels followed by two pixels...depending on the value of the stride) is processed to complete the work of extracting specific features from the image.
  • the size of the weight matrix should be related to the size of the image. It should be noted that the depth dimension of the weight matrix is the same as the depth dimension of the input image.
  • the weight matrix will be extended to The entire depth of the input image. Therefore, convolution with a single weight matrix will produce a convolutional output with a single depth dimension, but in most cases instead of using a single weight matrix, multiple weight matrices of the same size (row ⁇ column) are applied, That is, multiple matrices of the same shape.
  • the output of each weight matrix is stacked to form the depth dimension of the convolutional image.
  • the dimension here can be understood as determined by the "multiple" above.
  • Different weight matrices can be used to extract different features in the image. For example, one weight matrix is used to extract image edge information, another weight matrix is used to extract specific colors of the image, and another weight matrix is used to filter unwanted noise in the image.
  • the multiple weight matrices have the same size (row ⁇ column), and the feature maps extracted by the multiple weight matrices of the same size are also of the same size, and then the extracted multiple feature maps of the same size are combined to form the convolution operation. output.
  • weight values in these weight matrices need to be obtained through a lot of training in practical applications, and each weight matrix formed by the weight values obtained through training can be used to extract information from the input image, so that the convolutional neural network 200 can make correct predictions .
  • the initial convolutional layer (such as 221) often extracts more general features, which can also be referred to as low-level features;
  • the features extracted by the later convolutional layers (such as 226) become more and more complex, such as features such as high-level semantics, and features with higher semantics are more suitable for the problem to be solved.
  • pooling layer can be a convolutional layer followed by a layer
  • the pooling layer can also be a multi-layer convolutional layer followed by one or more pooling layers.
  • the sole purpose of pooling layers is to reduce the spatial size of the image.
  • the pooling layer may include an average pooling operator and/or a maximum pooling operator for sampling an input image to obtain an image of a smaller size.
  • the average pooling operator can calculate the pixel values in the image within a specific range to generate an average value as the result of average pooling.
  • the maximum pooling operator can take the pixel with the largest value within a specific range as the result of maximum pooling. Also, just like the size of the weight matrix used in the convolutional layer should be related to the size of the image, the operators in the pooling layer should also be related to the size of the image.
  • the size of the image output after being processed by the pooling layer may be smaller than the size of the image input to the pooling layer, and each pixel in the image output by the pooling layer represents the average or maximum value of the corresponding sub-region of the image input to the pooling layer.
  • the convolutional neural network 200 After being processed by the convolutional layer/pooling layer 220, the convolutional neural network 200 is not enough to output the required output information. Because as before, the convolutional layer/pooling layer 220 only extracts features and reduces the parameters brought by the input image. However, in order to generate the final output information (required class information or other relevant information), the convolutional neural network 200 needs to use the fully connected layer 230 to generate one or a group of outputs with the required number of classes. Therefore, the fully connected layer 230 may include multiple hidden layers (231, 232 to 23n as shown in FIG. Pre-trained, for example, the task type can include image recognition, image classification, image super-resolution reconstruction, etc...
  • the output layer 240 has a loss function similar to the classification cross entropy, and is specifically used to calculate the prediction error.
  • the convolutional neural network 200 shown in FIG. 9 is only an example of a convolutional neural network.
  • the convolutional neural network can also exist in the form of other network models.
  • the convolutional neural network used in the embodiment of the present application may only include an input layer 210 , a convolutional layer/pooling layer 220 and an output layer 240 .
  • the convolutional neural network 100 shown in FIG. 9 is only an example of a convolutional neural network.
  • the convolutional neural network can also exist in the form of other network models, for example, as Multiple convolutional layers/pooling layers shown in FIG. 10 are parallelized, and the extracted features are input to the fully connected layer 230 for processing.
  • the convolutional neural network can use the error back propagation (back propagation, BP) algorithm to correct the size of the parameters in the initial super-resolution model during the training process, so that the reconstruction error loss of the super-resolution model becomes smaller and smaller. Specifically, passing the input signal forward until the output will generate an error loss, and updating the parameters in the initial super-resolution model by backpropagating the error loss information, so that the error loss converges.
  • the backpropagation algorithm is a backpropagation movement dominated by error loss, aiming to obtain the parameters of the optimal super-resolution model, such as the weight matrix.
  • FIG. 11 is a schematic diagram of a system architecture provided by an embodiment of the present application.
  • the system architecture 500 includes an execution device 510 , a training device 520 , a database 530 , a client device 540 , a data storage system 550 and a data acquisition system 560 .
  • the execution device 510 includes a calculation module 511 , an I/O interface 512 , a preprocessing module 513 and a preprocessing module 514 .
  • the calculation module 511 may include the target model/rule 501, and the preprocessing module 513 and the preprocessing module 514 are optional.
  • the data collection device 560 is used to collect training samples.
  • the training samples may be image data, text data, audio data, etc.
  • the training samples are the data used for training multiple candidate neural networks. After collecting the training samples, the data collection device 560 stores these training samples in the database 530 .
  • search space may also be maintained in the database 530 .
  • the training device 520 can construct multiple candidate neural networks based on the search space maintained in the database 530 , and train the multiple candidate neural networks based on the training samples to obtain the target model/rule 501 by searching.
  • the target model/rule 501 may be a target neural network.
  • the training samples maintained in the database 530 are not necessarily collected by the data collection device 560, and may also be received from other devices.
  • the training device 520 does not necessarily perform the training of the target model/rule 501 based entirely on the training samples maintained by the database 530, and it is also possible to obtain training samples from the cloud or other places for model training. Limitations of the Examples.
  • the target model/rule 501 trained according to the training device 520 can be applied to different systems or devices, such as the execution device 510 shown in FIG. Computers, augmented reality (augmented reality, AR)/virtual reality (virtual reality, VR) equipment, vehicle terminals, etc., can also be servers or clouds.
  • augmented reality augmented reality, AR
  • virtual reality virtual reality, VR
  • vehicle terminals etc.
  • servers or clouds can also be servers or clouds.
  • the training device 520 may transfer the target neural network to the execution device 510 .
  • the execution device 510 is configured with an input/output (input/output, I/O) interface 512 for data interaction with external devices, and the user can input data to the I/O interface 512 through the client device 540 (such as this The data to be processed in the application examples).
  • I/O input/output
  • the preprocessing module 513 and the preprocessing module 514 are configured to perform preprocessing according to the input data received by the I/O interface 512 . It should be understood that there may be no preprocessing module 513 and preprocessing module 514 or only one preprocessing module. When the preprocessing module 513 and the preprocessing module 514 do not exist, the calculation module 511 may be used directly to process the input data.
  • the execution device 510 When the execution device 510 preprocesses the input data, or in the calculation module 511 of the execution device 510 performs calculation and other related processing, the execution device 510 can call the data, codes, etc. in the data storage system 550 for corresponding processing , the correspondingly processed data and instructions may also be stored in the data storage system 550 .
  • the I/O interface 512 presents the processing result (for example, the data processing result in the embodiment of the present application) to the client device 540, thereby providing it to the user.
  • the processing result for example, the data processing result in the embodiment of the present application
  • the user can manually specify input data, and the “manually specify input data” can be operated through the interface provided by the I/O interface 512 .
  • the client device 540 can automatically send the input data to the I/O interface 512 . If the client device 540 is required to automatically send the input data to obtain the user's authorization, the user can set the corresponding authority in the client device 540 .
  • the user can view the results output by the execution device 510 on the client device 540, and the specific presentation form may be specific ways such as display, sound, and action.
  • the client device 540 can also be used as a data collection terminal, collecting input data from the input I/O interface 512 and output results from the output I/O interface 512 as new sample data, and storing them in the database 530 .
  • the data is stored in database 530 .
  • Fig. 11 is only a schematic diagram of a system architecture provided by the embodiment of the present application, and the positional relationship between devices, devices, modules, etc. shown in the figure does not constitute any limitation.
  • the data The storage system 550 is an external memory relative to the execution device 510 , and in other cases, the data storage system 550 may also be placed in the execution device 510 . It should be understood that the above execution device 510 may be deployed in the client device 540 .
  • the computing module 511 of the execution device 520 can obtain the code stored in the data storage system 550 to implement the data processing method in the embodiment of the present application.
  • the calculation module 511 of the execution device 520 may include a hardware circuit (such as an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a general-purpose processor, digital signal processing (digital signal processing, DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits, for example, the training device 520 can be a hardware system with the function of executing instructions, such as CPU, DSP, etc. , or a hardware system that does not have the function of executing instructions, such as ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems that do not have the function of executing instructions and hardware systems that have the function of executing instructions.
  • ASIC application specific integrated circuit
  • FPGA field-programmable gate array
  • DSP digital signal processing
  • microprocessor or microcontroller etc.
  • the training device 520 can be a hardware system with the function of executing instructions, such as CPU, DSP, etc. , or a hardware system that does not have
  • the computing module 511 of the execution device 520 may be a hardware system capable of executing instructions
  • the data processing method provided in the embodiment of the present application may be software codes stored in the memory
  • the computing module 511 of the execution device 520 may read from the memory The software code is obtained, and the obtained software code is executed to implement the data processing method provided in the embodiment of the present application.
  • calculation module 511 of the execution device 520 can be a combination of a hardware system that does not have the function of executing instructions and a hardware system that has the function of executing instructions.
  • the computing module 511 is implemented by a hardware system that does not have the function of executing instructions, and is not limited here.
  • the above-mentioned training device 520 can obtain the code stored in the memory (not shown in FIG. 11, which can be integrated into the training device 520 or deployed separately from the training device 520) to implement the neural network in the embodiment of the present application. Search method.
  • the training device 520 may include a hardware circuit (such as an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a general-purpose processor, a digital signal processor (digital signal processing, DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits, for example, the training device 520 can be a hardware system with the function of executing instructions, such as CPU, DSP, etc., or for not A hardware system with the function of executing instructions, such as ASIC, FPGA, etc., or a combination of the above-mentioned hardware system without the function of executing instructions and a hardware system with the function of executing instructions.
  • ASIC application specific integrated circuit
  • FPGA field-programmable gate array
  • DSP digital signal processor
  • microprocessor or microcontroller etc.
  • the training device 520 can be a hardware system with the function of executing instructions, such as CPU, DSP, etc., or for not A hardware system with the function of executing instructions, such as ASIC,
  • the training device 520 can be a hardware system capable of executing instructions, and the data processing method provided in the embodiment of the present application can be a software code stored in a memory, and the training device 520 can obtain the software code from the memory, and execute the acquisition The obtained software code is used to implement the neural network search method provided in the embodiment of the present application.
  • the training device 520 can be a combination of a hardware system that does not have the function of executing instructions and a hardware system that has the function of executing instructions.
  • the instruction function is implemented by a hardware system, which is not limited here.
  • FIG. 12 is a schematic diagram of an embodiment of a neural network search method provided by the embodiment of the present application.
  • the neural network search method provided by the embodiment of the present application can be applied to training equipment, and the training equipment can be a mobile phone or a tablet. , notebook computers, smart wearable devices and other terminal devices, the training device can also be a cloud side server, as shown in Figure 12, the neural network search method provided by the embodiment of the present application can include:
  • At least one candidate neural network in the plurality of candidate neural networks includes a target transformer layer, the target transformer layer includes a target attention head, and the target attention head includes a plurality of operators , and the plurality of operators are obtained by sampling the plurality of candidate operators included in the first search space.
  • multiple candidate neural networks can be constructed by searching.
  • the candidate neural network can be a neural network including a transformer layer.
  • it can be determined that the candidate neural network includes The type of each network layer (for example, it may be a transformer layer or a target network layer including a convolutional layer described in subsequent embodiments), and then the network layer may be sampled to complete the construction of a candidate neural network.
  • the types of all network layers included in the candidate neural network may be determined based on sampling (for example, it may be a transformer layer or a target network layer including a convolutional layer described in subsequent embodiments).
  • the type of some network layers included in the candidate neural network can be determined based on sampling (for example, it can be a transformer layer or a target network layer including a convolutional layer described in subsequent embodiments),
  • the structures of the remaining network layers can be preset.
  • the type of the network layer in the candidate neural network can be determined to be a transformer layer (which may be referred to as the target transformer layer in the embodiment of the present application) by sampling or fixed setting, and by starting from the first The way of operator sampling in the search space is to determine the structure of the target attention head in the target transformer layer.
  • Fig. 13 is a structural representation of a transformer model
  • the target transformer layer can be any transformer layer in the candidate neural network, it should be understood that the target transformer layer can be a neural network layer adjacent to the embedding layer or can be The neural network layer closest to the output is not limited here.
  • the position of the target transformer layer in the candidate neural network may also be determined based on sampling.
  • the embedding layer can embedding the input to obtain multiple feature vectors.
  • the core feature of the transformer model lies in its unique attention mechanism. When processing natural language, such as a sentence, the transformer model uses this attention mechanism to assign different attention coefficients to each word vector in the sentence, so as to more fully consider the influence of the context in the sentence on each word.
  • the embedding layer can obtain N embedding vectors X l based on the node features and position codes of each node in the current sequence.
  • the attention layer is connected to the embedding layer, and N embedding vectors are obtained from the embedding layer as input vectors.
  • each input vector is synthesized to obtain N output vectors, which are output to The subsequent transformer layer (or the target network layer in this embodiment of the application).
  • the transformer layer takes the output of the previous layer as an input vector and performs operations similar to those of the previous transformer layer.
  • the target transformer layer in the transformer model can be constructed by operator sampling.
  • the target attention head in the target transformer layer in the transformer model can be constructed by operator sampling.
  • the target transformer layer can include multiple attention heads, and the target attention head can be any one of the multiple attention heads.
  • each attention head in the multiple attention heads The structure between the heads is the same.
  • FIG. 14 is a structural diagram of a transformer layer, wherein the transformer layer may include sequentially adjacent multi-head attention layers (or simply called attention layers), summation and normalization (add&norm) layers, front Feed forward net (FFN), summation and normalization layers.
  • attention layers or simply called attention layers
  • add&norm summation and normalization
  • FNN front Feed forward net
  • the multi-head attention layer obtains N input vectors X l from its upper layer, and the N input vectors X l can be expressed as a matrix X.
  • the multi-head attention layer adopts a self-attention mechanism, based on the correlation between vectors for each The vector is transformed to obtain N output vectors, and the N output vectors can be expressed as a matrix Y.
  • the multi-head attention layer is a layer directly connected to the embedding layer, such as the transformer layer directly connected to the embedding layer in Figure 14, the input vector obtained by it is the embedding vector output by the embedding layer; when the multi-head attention layer is the multi-head attention layer included in the subsequent transformer layer, for example, the multi-head attention layer included in the transformer layer directly connected to the previous transformer layer in Figure 14, and the input vector obtained by it is the output vector of the previous transformer layer .
  • the multi-head attention layer may include multiple attention heads (Head 1, Head 2, . . . , Head N as shown in FIG. 14 ). Wherein, the target attention head can be any one of multiple attention heads.
  • the target attention head may include a first linear transformation layer, multiple operators obtained through sampling, and a second linear transformation layer.
  • the input side of the target attention head can be set as the first linear transformation layer, wherein the first linear transformation layer is used to process the input vector of the target attention head through the target transformation matrix, and the multiple operators use Performing operations on the data processing results of the first linear transformation layer, wherein the target transformation matrix only includes X transformation matrices, where X is a positive integer less than or equal to 4, and the number of X is determined based on sampling .
  • the target transformation matrix may only include one of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or, the target transformation matrix may only include two of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or,
  • the target transformation matrix includes a Q transformation matrix, a V transformation matrix and a K transformation matrix.
  • the target transformation matrix can include a Q transformation matrix, a V transformation matrix, and a K transformation matrix. At least one of matrix and P transformation matrix.
  • the matrix type of the transformation matrix included in the target transformation matrix can be determined based on sampling, and the matrix type is Q transformation matrix, K transformation matrix or V transformation matrix, or the target transformation matrix is preset
  • the matrix type of the transformation matrix included in the transformation matrix is not limited here.
  • the target attention head head can use the Q transformation matrix to transform each input vector Xi in the N input vectors ⁇ X1, X2, ..., XN> to obtain the corresponding
  • the first intermediate vector (q vector) in operation, can use the Q transformation matrix to linearly transform the input matrix X composed of N input vectors to obtain the Q matrix of the input matrix, and then split the Q matrix to obtain The q vector corresponding to each input vector.
  • the target attention head can use the K transformation matrix to transform each input vector Xi in the N input vectors ⁇ X1, X2, ..., XN>, and obtain the corresponding
  • the first intermediate vector (K vector) in operation, can use the K transformation matrix to linearly transform the input matrix X composed of N input vectors to obtain the K matrix of the input matrix, and then split the K matrix to obtain The k-vectors corresponding to each input vector.
  • the target attention head can use the V transformation matrix to transform each input vector Xi in the N input vectors ⁇ X1, X2, ..., XN> to obtain the corresponding
  • the first intermediate vector (V vector) in operation, can use the V transformation matrix to linearly transform the input matrix X composed of N input vectors to obtain the V matrix of the input matrix, and then split the V matrix to obtain The v vector corresponding to each input vector.
  • the target attention head head can use the P transformation matrix to transform each input vector Xi in the N input vectors ⁇ X1, X2, ..., XN>, and obtain the corresponding
  • the first intermediate vector (P vector) in operation, can use the P transformation matrix to linearly transform the input matrix X composed of N input vectors to obtain the P matrix of the input matrix, and then split the P matrix to obtain The p-vector corresponding to each input vector.
  • the target attention head may also include a second linear transformation layer, the second linear transformation layer is used to linearly transform the data processing results of the multiple operators to obtain the target attention The output vector of head.
  • the size of the input vector of the target attention head and the output vector of the target attention head are the same.
  • the source of operator sampling can be the first search space, and the first search space can include multiple candidate operators.
  • the first search space can include multiple candidate operators.
  • multiple candidate operators in the first search space can be sampled.
  • multiple candidate operators may be included in the first search space, and the candidate operators may be unary operators or binary operators, where unary operators refer to operations on only one data Perform operations, such as negative operation (neg), square root operation (sqrt), transpose operation (transpose), softmax operation, logsigmoid operation, softsign operation, etc., binary operator (binary operation) refers to two data A rule for performing operations to obtain the third data, such as sum operation (add), dot multiplication operation (matmul), cosine similarity operation, and euclidean distance operation.
  • unary operators refer to operations on only one data Perform operations, such as negative operation (neg), square root operation (sqrt), transpose operation (transpose), softmax operation, logsigmoid operation, softsign operation, etc.
  • binary operator binary operation refers to two data
  • a rule for performing operations to obtain the third data such as sum operation (add), dot multiplication operation (matmul), cosine similarity operation, and euclidean distance operation.
  • the plurality of candidate operators may include a native softmax operator and a point multiplication operator in the transformer layer.
  • sampling can be random sampling, or adopt some tendentious/referential sampling methods, which are not completely random. For example, when sampling, it can tend to sample and the head in the existing well-known transformer layer little difference in structure.
  • the candidate operators of the first search space can be sampled to construct the target attention head.
  • multiple operators can be sampled from the first search space, and the connection relationship. That is to say, when constructing the target attention head, the type, quantity, and connection relationship of each operator included in the target attention head can be determined based on sampling, and further, multiple operators can be obtained based on sampling , and sampling the connections between multiple operators to construct the target attention head.
  • the number of operators included in the target attention head is less than a preset value, for example, the preset value may be 10, 11, 12, 14, 15, 20, 21 and so on.
  • the target head in the target transformer layer can be constructed in the above manner, and in a possible implementation, each head can adopt the same structure, and at least one transformer layer in the candidate neural network can be Build it in the same way as above for building the target transformer layer.
  • FIG. 16 to FIG. 21 are schematic structural diagrams of the target attention head obtained by sampling.
  • the embodiment of the present application combines model search to generate a new type of attention structure that is stronger than the original self-attention mechanism, and achieve significant improvement in a wide range of downstream tasks.
  • the type of the network layer in the candidate neural network can be determined as the target network layer including the convolutional layer by sampling or fixed setting, and by sampling from the second search space to determine Determine the size of the convolution kernel in the convolution layer in the target network layer.
  • the convolution kernel can use the lightweight convolution architecture to improve the performance of the model.
  • the second search space may include convolution kernels of multiple sizes, and the selection space of convolution kernels may be but not limited to [3, 5, 7, 9, 15, 31, 65].
  • the target network layer may include a convolutional layer, the target network layer also includes a first summation and normalization layer, a feedforward layer FFN, a second summation and normalization layer, the first summation and normalization layer
  • the normalization layer is used to process the input vector of the target network layer and the output vector of the convolutional layer
  • the feed-forward layer FFN is used to process the output vector of the first sum and normalization layer
  • the sum and normalization layer is used to process the output vector of the first summation and normalization layer and the output vector of the feedforward layer FFN.
  • the structure of the summation and normalization layer, FFN and residual connection in the existing transformer layer can be retained, and the attention head can be replaced by the convolution layer, and then the embodiment of the application can be obtained.
  • the target network layer of , where the replacement convolution layer type can be obtained by sampling the convolution kernel from the second search space.
  • FIG. 22 is a structural representation of a candidate neural network, wherein the candidate neural network may include 12 network layers, and among the 12 network layers, the transformer layer and the target network layer are alternated and connected in series.
  • FIG. 23 is a structural representation of a candidate neural network, wherein the candidate neural network may include 12 network layers, and among the 12 network layers, the transformer layer and the target network layer are alternated and connected in series.
  • the target network layer may include a convolutional layer, two summation and normalization layers (that is, the first summation and normalization layer described above layer and the second summation and normalization layer), feed-forward layer FFN, the first summation and normalization layer are used to process the input vector of the target network layer and the output vector of the convolutional layer, the front The feed layer FFN is used to process the output vector of the first sum and normalization layer, and the second sum and normalization layer is used to process the output vector of the first sum and normalization layer and the feedforward The output vector of layer FFN.
  • the target network layer may include a convolutional layer, two summation and normalization layers (that is, the first summation and normalization layer described above layer and the second summation and normalization layer), feed-forward layer FFN, the first summation and normalization layer are used to process the input vector of the target network layer and the output vector of the convolutional layer, the front The feed layer FFN is used to process the output vector of the first sum and normal
  • a diversified search space including both local (convolution kernel in the convolution layer) and global operators (operators in the transformer layer).
  • the global operator can combine mathematical basic operators to construct a new attention mechanism
  • the local operator contains a variety of convolution kernels of different sizes. Through the combination of global operators and local operators, it is possible to more effectively capture the relationship between words and sentences, and improve the performance of the searched model.
  • the neural network model in the embodiment of the present application can be used as a pre-training model and adapted to various downstream tasks.
  • multiple candidate neural networks can be constructed through sampling.
  • the number of sampled candidate neural networks is large, and the performance of multiple candidate neural networks can be determined through training, and Based on the performance of multiple candidate neural networks, a certain number of networks are preliminarily selected from multiple candidate neural networks as the parent network, and then the parent network can be replaced by operators (if it is a transformer layer, it is the attention head.
  • the convolution kernel can be replaced), get multiple sub-networks, and train multiple sub-networks to determine the performance of multiple sub-networks, and based on the performance of multiple sub-networks, from multiple sub-networks Determine the target neural network in the sub-network as the search result of the neural network.
  • the initially constructed candidate neural network may be called a second neural network
  • the parent network may be called a first neural network
  • the child network may be called a candidate neural network.
  • the multiple candidate neural networks include the target candidate neural network, and the following is an example of determining the target candidate neural network:
  • multiple second neural networks can be obtained by sampling (specifically, you can refer to the description of candidate neural networks obtained by sampling in the above-mentioned embodiments, which will not be repeated here), and the multiple second neural networks can be Training, to obtain multiple trained second neural networks and the performance of the multiple trained second neural networks, specifically, random parameter initialization can be performed on multiple second neural networks, and multiple second neural networks
  • the neural network performs fast search training (for example, through 4w step training) to obtain multiple trained second neural networks, and uses the GLUE task to evaluate multiple trained second neural networks to obtain multiple second neural networks.
  • the performance of the network select the optimal N networks as the parent network, and save the training parameters of the parent network.
  • the N parent networks may include the first neural network.
  • the first neural network may include a first transformer layer, the first transformer layer includes a first attention head, and the first attention head includes a target operator, and then according to the M in the first search space
  • the candidate operator replaces the target operator in the first attention head
  • the positive impact on the performance of the first neural network is determined from the M candidate operators, and the first attention The target operator in the head is replaced by the replacement operator to obtain the target attention head.
  • the target operator can be located at the target operator position of the second neural network, wherein the target operator position can indicate the position of the input from the head to a certain extent, and the target operator position can be compared with The code indicates that the position of the network operators is related to each other.
  • the calculation method of the position of each operator in the second neural network is the same as the calculation method of the target operator in the second neural network. Consistent, it can express the degree to which the different positions of the operator in the attention head have a positive impact on the model performance.
  • the positive influence it may be based on the operator at the position of the target operator in each of the plurality of trained second neural networks and the performance of the plurality of trained second neural networks, and/or, each The frequency of occurrence of the operator at the position of the target operator in the trained second neural network to determine M candidate operators in the first search space to replace the target operator in the first attention head , has a positive impact on the performance of the first neural network.
  • the positive impact can be represented by UCB (upper confidence bound) of the confidence interval
  • UCB upper confidence bound
  • specific calculation method of UCB score can be as follows:
  • ⁇ i represents the score obtained by operator i in the current position of the network structure
  • N i represents the number of times operator i has been sampled in history (when sampling the second neural network)
  • N represents the number of times all operators have been sampled .
  • the right half of the formula will get a larger value, and the current operator will be selected with a greater probability. It should be understood that after the UCB scores of each operator at each position are calculated, a softmax calculation may be performed on these scores to obtain a probability distribution. And set this probability as the probability that operator i is activated at the current position.
  • the embodiment of the present application uses positive influence to perform operator replacement, which can balance the search accuracy and search breadth of the algorithm, avoid falling into local optimum, and continuously search for a better network architecture.
  • the target candidate neural network After performing operator replacement on the first neural network, the target candidate neural network can be obtained.
  • the parameters of the target candidate neural network can be initialized according to the first neural network to obtain The initialized target candidate neural network; wherein, the updateable parameters in the initialized target candidate neural network are obtained by parameter sharing of the updateable parameters in the same position in the first neural network, and then can be performed on The target candidate neural network whose parameters are initialized is trained to obtain the performance of the target candidate neural network.
  • the updateable parameters are the parameters in the transformation matrix of the attention head head.
  • the parameters in the transformation matrix of the attention head head on the left can be shared. (or call it parameter inheritance), to initialize the parameters of the attention head head on the right.
  • the updateable parameter is the convolution kernel.
  • the parameters of the left convolution kernel (65*1) can be shared to initialize the parameters of the right convolution kernel (3*1). It should be understood that the corresponding parameters at the centermost position of the convolution kernel may be selected for parameter sharing.
  • parameter initialization is performed by means of parameter sharing, which can speed up the search speed, avoid repeated training, and greatly accelerate the search efficiency.
  • the multiple neural networks after obtaining multiple candidate neural networks, can be trained to obtain the performance of each candidate neural network, and then based on the performance of each candidate neural network, the multiple candidate neural networks can be Select the target neural network in the neural network, wherein the number of the target neural network is at least one, when the number of the target neural network is one, the target neural network can be the model with the best performance among multiple candidate neural networks, when the target neural network When the number of is multiple, the target neural network may be multiple models with the best performance among multiple candidate neural networks.
  • model testing can also be performed after training.
  • the searched model can be fully-trained and tested on the natural language understanding dataset GLUE and the automatic question answering dataset squad dataset.
  • the embodiment of the present application provides a neural network search algorithm that greatly improves the performance of the search algorithm.
  • the results obtained by the neural network search algorithm proposed by the embodiment of the present application are significantly better than Random search (RS) and Evolution Algorithm (EA). Improvement, as shown in Table 2 below:
  • the target neural network is used to implement at least one of the following task types: reading comprehension, text translation, paraphrase recognition, named entity recognition, text sentiment analysis, natural language reasoning, automatic text question answering, text intent recognition, text classification, text simplification, or text story generation.
  • FIG. 26 shows the network architecture search results obtained by providing the neural network search algorithm based on the embodiment of the present application.
  • the network architecture is a transformer structure including 12 sub-modules, and each module selects its own combined structure of convolution and attention mechanisms, of which the 2nd, 4th, 6th, 8th, 10th, and 12th layers are new types of attention
  • the force architecture consists of a series of basic operators, in which layers 1, 3, 5, 7, 9, and 11 are convolution modules (that is, the target network layer described in the embodiment of this application), and the sizes of the convolution kernels are different , is determined by the required receptive field of the layer.
  • the complexity of the attention mechanism gradually increases from the shallow layer to the high layer, and the kernel length of the searched convolution kernel also increases as the number of layers becomes deeper.
  • the pre-trained network architecture achieves better performance than other current models in a series of downstream tasks.
  • the pre-training data can include the General Language Understanding Evaluation (GLUE) task set.
  • MNLI Multi-Genre Natural Language Inference
  • QQP Quora Question Pairs
  • QNLI Question Natural Language Inference
  • SST-2 Sandford Sentiment Treebank
  • CoLA Corpus of Linguistic Acceptability
  • STS-B Semantic Textual Similarity Benchmark
  • MRPC Microsoft Research Paraphrase Corpus
  • RTE Recognizing Textual Entailment
  • the model obtained through the search of the embodiment of the application is significantly better than the existing SOTA hand-designed model in terms of speed and detection accuracy ( BERT-base, T5-base, etc.).
  • AdaBERT and DynaBERT that rely on a huge amount of parameter teacher model, this method does not depend on any teacher model, and the searched model architecture also achieves better results on most tasks, as shown in Table 3 .
  • the performance of the model searched in the embodiment of this application is also significantly improved compared with BERT-base, as shown in Table 4.
  • An embodiment of the present application provides a neural network search method, the method comprising: obtaining a plurality of candidate neural networks; wherein at least one candidate neural network in the plurality of candidate neural networks includes a target transformer layer, and the target transformer layer includes a target Attention head head, the target attention head includes a plurality of operators, and the plurality of operators are obtained by sampling a plurality of candidate operators included in the first search space; based on the performance of the plurality of candidate neural networks, A target neural network is selected from the plurality of candidate neural networks.
  • Fig. 27 shows an embodiment of a method for providing a model provided by the embodiment of the present application.
  • the method for providing a model provided by the embodiment of the present application can be applied to a cloud-side server, as shown in Fig. 27,
  • a method for providing a model provided in an embodiment of the present application includes:
  • the performance requirement includes at least one of the following: data processing accuracy, model size, and implemented task type.
  • the terminal device may send the performance requirements of the terminal device to the cloud-side server.
  • the terminal device can send performance requirements to the cloud-side server, where the performance requirements include but not limited to at least one of accuracy requirements, delay requirements, and implemented task types, and then the cloud-side server can obtain the performance requirements.
  • the performance requirements include but not limited to at least one of accuracy requirements, delay requirements, and implemented task types
  • the target neural network includes a target transformer layer, the target transformer layer includes a target attention head, and the target attention head includes A plurality of operators, and the plurality of operators are obtained by sampling the plurality of candidate operators included in the first search space.
  • the server on the cloud side can perform a neural network search according to the performance requirement, so as to search for a target neural network that meets the performance requirement.
  • the specific description of step 2702 can refer to the corresponding to Figure 12 in the above embodiment. The description in the embodiment will not be repeated here.
  • the cloud-side server After the cloud-side server obtains the target neural network, it can send the target neural network back to the user device, and then the user device can use the model (target neural network) returned by the cloud side to perform inference, and the data to be processed can be obtained during model reasoning. , and use the target neural network to process the data to be processed to obtain the processing result.
  • the model target neural network
  • a plurality of candidate neural networks can be obtained; wherein, at least one candidate neural network in the plurality of candidate neural networks includes a target transformer layer, the target transformer layer includes a target attention head, and the target attention The force head includes a plurality of operators, and the plurality of operators are obtained by sampling from the first search space; according to the performance requirement, a target neural network meeting the performance requirement is obtained from the plurality of candidate neural networks.
  • the first search space includes multiple candidate operators, and the candidate operators are unary operators or binary operators; the target attention head is based on the multiple operators and the multiple The arrangement relationship between operators is constructed, and the arrangement relationship among multiple operators is determined based on sampling.
  • the target attention head also includes a first linear transformation layer, the first linear transformation layer is used to process the input vector of the target attention head through the target transformation matrix, and the multiple operators It is used to perform operations on the data processing results of the first linear transformation layer; wherein, the target transformation matrix only includes one of Q transformation matrix, V transformation matrix and K transformation matrix; or, the target transformation matrix only includes Q transformation matrix, V transformation matrix, and K transformation matrix; or, the target transformation matrix includes a Q transformation matrix, a V transformation matrix, and a K transformation matrix.
  • the at least one candidate neural network includes a plurality of network layers connected in series, the plurality of network layers includes the target transformer layer, and the position of the target transformer layer in the plurality of network layers is based on sampling determined in a manner.
  • the at least one candidate neural network includes a plurality of network layers connected in series, the plurality of network layers include the target transformer layer and a convolution layer, and the convolution kernel in the convolution layer is from the first obtained by sampling in the second search space, and the second search space includes convolution kernels of multiple sizes.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • Fig. 28 is a schematic diagram of an embodiment of a neural network search method provided by the embodiment of the present application.
  • the neural network search method provided by the embodiment of the present application can be applied to training equipment, and the training equipment can be a mobile phone, a tablet, or a notebook. Terminal devices such as computers and smart wearable devices, and training devices can also be cloud-side servers.
  • a neural network search method provided in an embodiment of the present application may include:
  • the at least one candidate neural network includes multiple network layers connected in series, the multiple network layers include a target transformer layer and a target network layer, the target network layer includes a convolutional layer, the The convolution kernels in the convolution layer are obtained by sampling convolution kernels of multiple sizes included in the second search space.
  • step 2801 and step 2802 reference may be made to the description about the target network layer in the foregoing embodiments, and details are not repeated here.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the target network layer also includes a first summation and normalization layer, a feedforward layer FFN, a second summation and normalization layer, and the first summation and normalization layer uses
  • the feedforward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum and normalization layer For processing the output vector of the first summation and normalization layer and the output vector of the feed-forward layer FFN.
  • the target neural network is used to implement at least one of the following task types:
  • Fig. 29 shows an embodiment of a model providing method provided by the embodiment of the present application.
  • the model providing method provided by the embodiment of the present application can be applied on the cloud side server.
  • a method for providing a model provided by an embodiment includes:
  • the terminal device may send the performance requirements of the terminal device to the cloud-side server.
  • the terminal device can send performance requirements to the cloud-side server, where the performance requirements include but not limited to at least one of accuracy requirements, delay requirements, and implemented task types, and then the cloud-side server can obtain the performance requirements.
  • the performance requirements include but not limited to at least one of accuracy requirements, delay requirements, and implemented task types
  • the target neural network includes a target transformer layer and a target network layer, and the target network layer includes a convolutional layer,
  • the convolution kernels in the convolution layer are obtained by sampling convolution kernels of multiple sizes included in the second search space.
  • the server on the cloud side can perform a neural network search according to the performance requirement, so as to search for a target neural network that meets the performance requirement.
  • the specific description of step 2702 can refer to that corresponding to Figure 28 in the above embodiment. The description in the embodiment will not be repeated here.
  • the cloud-side server After the cloud-side server obtains the target neural network, it can send the target neural network back to the user device, and then the user device can use the model (target neural network) returned by the cloud side to perform inference, and the data to be processed can be obtained during model reasoning. , and use the target neural network to process the data to be processed to obtain the processing result.
  • the model target neural network
  • multiple candidate neural networks may be obtained; according to the performance requirement, a target neural network meeting the performance requirement is obtained from the multiple candidate neural networks.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the target network layer also includes a first summation and normalization layer, a feedforward layer FFN, a second summation and normalization layer, and the first summation and normalization layer uses
  • the feedforward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum and normalization layer For processing the output vector of the first summation and normalization layer and the output vector of the feed-forward layer FFN.
  • the target neural network is used to implement at least one of the following task types:
  • FIG. 30 is a schematic diagram of an embodiment of a neural network search device provided in the embodiment of the present application.
  • the neural network search device 3000 provided in the embodiment of the present application may include:
  • An acquisition module 3001 configured to acquire a plurality of candidate neural networks; wherein at least one candidate neural network in the plurality of candidate neural networks includes a target transformer layer, the target transformer layer includes a target attention head, and the target attention head includes A plurality of operators, and the plurality of operators are obtained by sampling the plurality of candidate operators included in the first search space.
  • a model selection module 3002 configured to select a target neural network from the multiple candidate neural networks based on the performance of the multiple candidate neural networks.
  • model selection module 300 For the description of the model selection module 3002, reference may be made to the description of step 1202 in the above embodiment, and details are not repeated here.
  • the first search space includes multiple candidate operators, where the candidate operators are unary operators or binary operators.
  • the unary operator refers to performing operations on only one data, such as negative operation (neg), square root operation (sqrt), transpose operation (transpose), softmax operation, logsigmoid operation, softsign operation, etc.
  • a binary operator refers to a rule that operates on two data to obtain a third data, such as an addition operation (add), a dot product operation (matmul), a cosine similarity operation, and an euclidean distance operation.
  • the multiple candidate operators include a softmax operator and a dot product operator.
  • the candidate operators of the first search space can be sampled to construct the target attention head.
  • multiple operators can be sampled from the first search space, and the connection relationship. That is to say, when constructing the target attention head, the type, quantity, and connection relationship of each operator included in the target attention head can be determined based on sampling, and further, multiple operators can be obtained based on sampling , and sampling the connections between multiple operators to construct the target attention head.
  • the target attention head also includes a first linear transformation layer, the first linear transformation layer is used to process the input vector of the target attention head through the target transformation matrix, and the multiple operators It is used to perform operations on the data processing results of the first linear transformation layer.
  • the target transformation matrix only includes X transformation matrices, where X is a positive integer less than or equal to 4, and the number of X is determined based on sampling.
  • the target transformation matrix may only include one of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or, the target transformation matrix may only include two of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or,
  • the target transformation matrix includes a Q transformation matrix, a V transformation matrix and a K transformation matrix.
  • the target transformation matrix can include a Q transformation matrix, a V transformation matrix, and a K transformation matrix. At least one of matrix and P transformation matrix.
  • the target attention head further includes a second linear transformation layer, and the second linear transformation layer is used to linearly transform the data processing results of the multiple operators to obtain the target attention head The output vector of .
  • the size of the input vector of the target attention head is consistent with the size of the output vector of the target attention head.
  • the number of operators included in the target attention head is less than a preset value.
  • the target transformer layer in the transformer model can be constructed by operator sampling.
  • the target attention head in the target transformer layer in the transformer model can be constructed by operator sampling.
  • the target transformer layer can include multiple attention heads, and the target attention head can be any one of the multiple attention heads.
  • each attention head in the multiple attention heads The structure between the heads is the same.
  • the at least one candidate neural network includes a plurality of network layers connected in series, the plurality of network layers includes the target transformer layer, and the position of the target transformer layer in the plurality of network layers is based on sampling determined in a manner.
  • the at least one candidate neural network includes multiple network layers connected in series, where the multiple network layers include the target transformer layer and a target network layer, where the target network layer includes a convolutional layer.
  • the convolution kernels in the convolution layer may be obtained by sampling convolution kernels of multiple sizes included in the second search space.
  • the type of the network layer in the candidate neural network can be determined as the target network layer including the convolutional layer by sampling or fixed setting, and by sampling from the second search space to determine Determine the size of the convolution kernel in the convolution layer in the target network layer.
  • a diversified search space including both local (convolution kernel in the convolution layer) and global operators (operators in the transformer layer).
  • the global operator can combine mathematical basic operators to construct a new attention mechanism
  • the local operator contains a variety of convolution kernels of different sizes. Through the combination of global operators and local operators, it is possible to more effectively capture the relationship between words and sentences, and improve the performance of the searched model.
  • the neural network model in the embodiment of the present application can be used as a pre-training model and adapted to various downstream tasks.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the target network layer also includes a first summation and normalization layer, a feedforward layer FFN, a second summation and normalization layer, and the first summation and normalization layer uses
  • the feedforward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum and normalization layer For processing the output vector of the first summation and normalization layer and the output vector of the feed-forward layer FFN. That is to say, the structure of the summation and normalization layer, FFN and residual connection in the existing transformer layer can be retained, and the attention head can be replaced by the convolution layer, and then the embodiment of the application can be obtained.
  • the target network layer of where the replacement convolution layer type can be obtained by sampling the convolution kernel from the second search space.
  • the multiple candidate neural networks include a target candidate neural network; the acquiring module 3001 is specifically configured to: construct a target attention head in the target candidate neural network;
  • the construction of the target attention head in the target candidate neural network includes:
  • the first neural network includes a first transformer layer, the first transformer layer includes a first attention head, and the plurality of operators included in the first attention head include for the first search space It is obtained by sampling multiple candidate operators;
  • the obtaining module 3001 is specifically used for:
  • the second neural network includes the first neural network.
  • the target operator is located at the position of the target operator of the second neural network; the device also includes:
  • the determining module is configured to use the operator at the position of the target operator in each of the plurality of trained second neural networks and the performance of the plurality of trained second neural networks, and/or, each of the trained After the occurrence frequency of the operator at the position of the target operator in the second neural network, when M candidate operators in the first search space are determined to replace the target operator in the first attention head, the Positive effect of first neural network performance.
  • the device also includes:
  • a parameter initialization module configured to initialize parameters of the target candidate neural network according to the first neural network, so as to obtain the initialized target candidate neural network; wherein, the updateable parameters in the initialized target candidate neural network obtained by performing parameter sharing on the updateable parameters of the same position in the first neural network;
  • the model training module is used to train the target candidate neural network whose parameters are initialized to obtain the performance of the target candidate neural network.
  • the target neural network is used to implement at least one of the following task types:
  • FIG. 31 is a schematic diagram of an embodiment of a model providing device provided by the embodiment of the present application.
  • the model providing device 3100 provided by the embodiment of the present application may include:
  • the receiving module 3101 is configured to receive the performance requirements sent by the terminal side, and the performance requirements are used to indicate the performance requirements of the neural network;
  • An acquisition module 3102 configured to acquire a target neural network satisfying the performance requirement from a plurality of candidate neural networks according to the performance requirement, wherein the target neural network includes a target transformer layer, and the target transformer layer includes a target attention head head, the target attention head includes a plurality of operators, and the plurality of operators are obtained by sampling a plurality of candidate operators included in the first search space;
  • step 2702 For the description of the acquiring module 3102, reference may be made to the description of step 2702 in the above embodiment, and details are not repeated here.
  • a sending module 3103 configured to send the target neural network to the end-side.
  • the performance requirement may include at least one of the following: data processing accuracy, model size, and implemented task type.
  • the acquiring module 3102 is specifically used for:
  • a target neural network meeting the performance requirement is obtained from the plurality of candidate neural networks.
  • the first search space includes multiple candidate operators, and the candidate operators are unary operators or binary operators; the target attention head is based on the multiple operators and the multiple The arrangement relationship between operators is constructed, and the arrangement relationship among multiple operators is determined based on sampling.
  • the target attention head also includes a first linear transformation layer, the first linear transformation layer is used to process the input vector of the target attention head through the target transformation matrix, and the multiple operators It is used to perform operations on the data processing results of the first linear transformation layer; wherein, the target transformation matrix only includes X transformation matrices, where X is a positive integer less than or equal to 4, and the number of X is based on sampling definite.
  • the target transformation matrix may only include one of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or, the target transformation matrix may only include two of the Q transformation matrix, the V transformation matrix, and the K transformation matrix; or,
  • the target transformation matrix includes a Q transformation matrix, a V transformation matrix and a K transformation matrix.
  • the target transformation matrix can include a Q transformation matrix, a V transformation matrix, and a K transformation matrix. At least one of matrix and P transformation matrix.
  • the at least one candidate neural network includes a plurality of network layers connected in series, the plurality of network layers includes the target transformer layer, and the position of the target transformer layer in the plurality of network layers is based on sampling determined in a manner.
  • the at least one candidate neural network includes multiple network layers connected in series, where the multiple network layers include the target transformer layer and a target network layer, where the target network layer includes a convolutional layer.
  • the position of the target network layer among the multiple network layers is determined based on sampling.
  • the convolution kernels in the convolution layer are obtained by sampling convolution kernels of multiple sizes included in the second search space.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • FIG. 32 is a schematic diagram of an embodiment of a neural network search device provided in the embodiment of the present application.
  • the neural network search device 3200 provided in the embodiment of the present application may include:
  • An acquisition module 3201 configured to acquire multiple candidate neural networks; wherein, the at least one candidate neural network includes multiple network layers connected in series, the multiple network layers include a target transformer layer and a target network layer, and the target network layer includes volume Convolution layer, the convolution kernel in the convolution layer is obtained by sampling convolution kernels of multiple sizes included in the second search space;
  • a model selection module 3202 configured to select a target neural network from the multiple candidate neural networks based on the performance of the multiple candidate neural networks.
  • model selection module 3202 For the description of the model selection module 3202, reference may be made to the description of step 2802 in the above embodiment, and details are not repeated here.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the target network layer further includes a first summing and normalization layer, a feedforward layer FFN, a second summing and normalization layer, and the first summing and normalization layer uses
  • the feedforward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum and normalization layer For processing the output vector of the first summation and normalization layer and the output vector of the feed-forward layer FFN.
  • the target neural network is used to implement at least one of the following task types:
  • Fig. 33 is a schematic diagram of an embodiment of a model providing device provided by the embodiment of the present application.
  • the model providing device 3300 provided by the embodiment of the present application may include:
  • the receiving module 3301 is used to receive the performance requirements sent by the terminal side, the performance requirements are used to indicate the performance requirements of the neural network, and the performance requirements include at least one of the following: data processing accuracy, model size and implemented task type;
  • An acquisition module 3302 configured to acquire a target neural network that meets the performance requirement from a plurality of candidate neural networks according to the performance requirement, wherein the target neural network includes a target transformer layer and a target network layer, and the target network layer includes a convolution layer, the convolution kernel in the convolution layer is obtained by sampling convolution kernels of multiple sizes included in the second search space;
  • step 2902 For a description of the acquiring module 3302, reference may be made to the description of step 2902 in the above embodiment, and details are not repeated here.
  • a sending module 3303 configured to send the target neural network to the end side.
  • the obtaining module 3302 is specifically used to:
  • a target neural network meeting the performance requirement is obtained from the plurality of candidate neural networks.
  • the type of the convolution kernel in the convolution layer is lightweight convolution (highweight convolution).
  • the target network layer also includes a first summation and normalization layer, a feedforward layer FFN, a second summation and normalization layer, and the first summation and normalization layer uses
  • the feedforward layer FFN is used to process the output vector of the first sum and normalization layer
  • the second sum and normalization layer For processing the output vector of the first summation and normalization layer and the output vector of the feed-forward layer FFN.
  • the target neural network is used to implement at least one of the following task types:
  • FIG. 34 is a schematic structural diagram of the execution device provided by the embodiment of the present application. Tablets, laptops, smart wearable devices, monitoring data processing equipment or servers, etc., are not limited here.
  • the execution device 3400 includes: a receiver 3401, a transmitter 3402, a processor 3403, and a memory 3404 (the number of processors 3403 in the execution device 3400 can be one or more, and one processor is taken as an example in FIG. 34 ) , where the processor 3403 may include an application processor 34031 and a communication processor 34032 .
  • the receiver 3401 , the transmitter 3402 , the processor 3403 and the memory 3404 may be connected through a bus or in other ways.
  • the memory 3404 may include read-only memory and random-access memory, and provides instructions and data to the processor 3403 .
  • a part of the memory 3404 may also include a non-volatile random access memory (non-volatile random access memory, NVRAM).
  • NVRAM non-volatile random access memory
  • the memory 3404 stores processors and operating instructions, executable modules or data structures, or their subsets, or their extended sets, wherein the operating instructions may include various operating instructions for implementing various operations.
  • the processor 3403 controls the operations of the execution device.
  • various components of the execution device are coupled together through a bus system, where the bus system may include not only a data bus, but also a power bus, a control bus, and a status signal bus.
  • the various buses are referred to as bus systems in the figures.
  • the methods disclosed in the foregoing embodiments of the present application may be applied to the processor 3403 or implemented by the processor 3403 .
  • the processor 3403 may be an integrated circuit chip, which has a signal processing capability. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 3403 or instructions in the form of software.
  • the above-mentioned processor 3403 can be a general-purpose processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and can further include an application-specific integrated circuit (application specific integrated circuit, ASIC), field programmable Field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • DSP digital signal processing
  • ASIC application specific integrated circuit
  • FPGA field programmable Field-programmable gate array
  • the processor 3403 may implement or execute various methods, steps, and logic block diagrams disclosed in the embodiments of the present application.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory 3404, and the processor 3403 reads the information in the memory 3404, and completes the steps of the above method in combination with its hardware.
  • the receiver 3401 can be used to receive input digital or character information, and generate signal input related to performing device related settings and function control.
  • the transmitter 3402 can be used to output numeric or character information; the transmitter 3402 can also be used to send instructions to the disk group to modify the data in the disk group.
  • the processor 3403 is configured to execute the data processing method performed by the execution device in the above embodiment (for example, the step of performing model reasoning through the target neural network).
  • FIG. 35 is a schematic structural diagram of the training device provided in the embodiment of the present application. 33 corresponds to the device described in the embodiment.
  • the training device 3500 is implemented by one or more servers.
  • the training device 3500 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (central processing units (CPU) 3535 (eg, one or more processors) and memory 3532, one or more storage media 3530 (eg, one or more mass storage devices) for storing application programs 3542 or data 3544.
  • CPU central processing units
  • storage media 3530 eg, one or more mass storage devices
  • the memory 3532 and the storage medium 3530 may be temporary storage or persistent storage.
  • the program stored in the storage medium 3530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the training device. Furthermore, the central processing unit 3535 can be configured to communicate with the storage medium 3530 , and execute a series of instruction operations in the storage medium 3530 on the training device 3500 .
  • the training device 3500 can also include one or more power supplies 3526, one or more wired or wireless network interfaces 3550, one or more input and output interfaces 3558; or, one or more operating systems 3541, such as Windows ServerTM, Mac OS XTM , UnixTM, LinuxTM, FreeBSDTM and so on.
  • operating systems 3541 such as Windows ServerTM, Mac OS XTM , UnixTM, LinuxTM, FreeBSDTM and so on.
  • the central processing unit 3535 is configured to execute the methods in the embodiments corresponding to FIG. 12 , FIG. 27 , FIG. 28 and FIG. 29 .
  • the embodiment of the present application also provides a computer program product, which, when running on a computer, causes the computer to perform the steps performed by the aforementioned execution device, or enables the computer to perform the steps performed by the aforementioned training device.
  • An embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores a program for signal processing, and when it is run on a computer, the computer executes the steps performed by the aforementioned executing device , or, causing the computer to perform the steps performed by the aforementioned training device.
  • the execution device, training device or terminal device provided in the embodiment of the present application may specifically be a chip.
  • the chip includes: a processing unit and a communication unit.
  • the processing unit may be, for example, a processor.
  • the communication unit may be, for example, an input/output interface, a pin or circuits etc.
  • the processing unit can execute the computer-executed instructions stored in the storage unit, so that the chips in the execution device execute the data processing methods described in the above embodiments, or make the chips in the training device execute the data processing methods described in the above embodiments.
  • the storage unit is a storage unit in the chip, such as a register, a cache, etc.
  • the storage unit may also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (read- only memory, ROM) or other types of static storage devices that can store static information and instructions, random access memory (random access memory, RAM), etc.
  • ROM read-only memory
  • RAM random access memory
  • FIG. 36 is a schematic structural diagram of a chip provided by the embodiment of the present application.
  • the chip can be represented as a neural network processor NPU 3600, and the NPU 3600 is mounted to the main CPU (Host CPU) as a coprocessor ), the tasks are assigned by the Host CPU.
  • the core part of the NPU is the operation circuit 3603, and the controller 3604 controls the operation circuit 3603 to extract matrix data in the memory and perform multiplication operations.
  • the operation circuit 3603 includes multiple processing units (Process Engine, PE).
  • arithmetic circuit 3603 is a two-dimensional systolic array.
  • the arithmetic circuit 3603 may also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition.
  • arithmetic circuit 3603 is a general-purpose matrix processor.
  • the operation circuit fetches the data corresponding to the matrix B from the weight memory 3602, and caches it in each PE in the operation circuit.
  • the operation circuit fetches the data of matrix A from the input memory 3601 and performs matrix operation with matrix B, and the obtained partial results or final results of the matrix are stored in the accumulator (accumulator) 3608 .
  • the unified memory 3606 is used to store input data and output data.
  • the weight data directly accesses the controller (Direct Memory Access Controller, DMAC) 3605 through the storage unit, and the DMAC is transferred to the weight storage 3602.
  • the input data is also transferred to the unified memory 3606 through the DMAC.
  • DMAC Direct Memory Access Controller
  • the BIU is the Bus Interface Unit, that is, the bus interface unit 3610, which is used for the interaction between the AXI bus and the DMAC and the instruction fetch buffer (Instruction Fetch Buffer, IFB) 3609.
  • IFB Instruction Fetch Buffer
  • the bus interface unit 3610 (Bus Interface Unit, BIU for short) is used for the instruction fetch memory 3609 to obtain instructions from the external memory, and for the storage unit access controller 3605 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
  • the DMAC is mainly used to move the input data in the external memory DDR to the unified memory 3606 or move the weight data to the weight memory 3602 or move the input data to the input memory 3601 .
  • the vector calculation unit 3607 includes a plurality of calculation processing units, and further processes the output of the calculation circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc., if necessary. It is mainly used for non-convolutional/fully connected layer network calculations in neural networks, such as Batch Normalization (batch normalization), pixel-level summation, and upsampling of feature planes.
  • the vector computation unit 3607 can store the vector of the processed output to unified memory 3606 .
  • the vector calculation unit 3607 can apply a linear function; or, a non-linear function to the output of the operation circuit 3603, such as performing linear interpolation on the feature plane extracted by the convolution layer, and then such as a vector of accumulated values to generate an activation value.
  • the vector computation unit 3607 generates normalized values, pixel-level summed values, or both.
  • the vector of processed outputs can be used as an activation input to operational circuitry 3603, eg, for use in subsequent layers in a neural network.
  • An instruction fetch buffer (instruction fetch buffer) 3609 connected to the controller 3604 is used to store instructions used by the controller 3604;
  • the unified memory 3606, the input memory 3601, the weight memory 3602 and the fetch memory 3609 are all On-Chip memories. External memory is private to the NPU hardware architecture.
  • the processor mentioned above can be a general-purpose central processing unit, microprocessor, ASIC, or one or more integrated circuits for controlling the execution of the above-mentioned programs.
  • the device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, and the components shown as units may or may not be A physical unit can be located in one place, or it can be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • the connection relationship between the modules indicates that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines.
  • the essence of the technical solution of this application or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a readable storage medium, such as a floppy disk of a computer , U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., including several instructions to make a computer device (which can be a personal computer, training device, or network device, etc.) execute the instructions described in various embodiments of the present application method.
  • a computer device which can be a personal computer, training device, or network device, etc.
  • all or part of them may be implemented by software, hardware, firmware or any combination thereof.
  • software When implemented using software, it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transferred from a website, computer, training device, or data
  • the center transmits to another website site, computer, training device or data center via wired (eg, coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.).
  • wired eg, coaxial cable, fiber optic, digital subscriber line (DSL)
  • wireless eg, infrared, wireless, microwave, etc.
  • the computer-readable storage medium may be any available medium that can be stored by a computer, or a data storage device such as a training device or a data center integrated with one or more available media.
  • the available medium may be a magnetic medium (such as a floppy disk, a hard disk, or a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (Solid State Disk, SSD)), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • Molecular Biology (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Human Computer Interaction (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Medical Informatics (AREA)
  • Image Analysis (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请涉及人工智能领域,公开了一种神经网络搜索方法以及相关装置,其中神经网络搜索方法包括:在进行模型搜索时,通过对多个候选算子进行采样的方式来构建transformer层中的注意力头head,以此构建多个候选神经网络,并对多个候选神经网络进行性能比较,来选择性能较高的目标神经网络。本申请结合模型搜索来构建transformer模型,能生成相比原自注意力机制性能更优的新型注意力结构,在广泛的下游任务的效果提升明显。

Description

一种神经网络搜索方法及相关设备
本申请要求于2021年7月15日提交中国专利局、申请号为202110803202.X、发明名称为“一种神经网络搜索方法及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能领域,尤其涉及一种神经网络搜索方法及相关设备。
背景技术
人工智能(artificial intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。换句话说,人工智能是计算机科学的一个分支,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式作出反应的智能机器。人工智能也就是研究各种智能机器的设计原理与实现方法,使机器具有感知、推理与决策的功能。
随着人工智能技术的不断发展,让人机之间能够通过自然语言进行交互的自然语言人机交互系统变的越来越重要。人机之间能够通过自然语言进行交互,就需要系统能够识别出人类自然语言的具体含义。通常,系统通过采用对自然语言的句子进行关键信息提取来识别句子的具体含义。
transformer结构具有强大的语义表达能力,能捕捉文本长依赖关系。自被提出以来在以翻译为代表的一系列自然语言处理的任务上显著超越了之前的模型,基于transformer结构的预训练语言模型在问答系统,语音助手等领域也取得了非常好的效果。
随着人工智能技术的快速发展,一个性能优良的神经网络往往拥有精妙的网络结构,而这需要具有高超技能和丰富经验的人类专家花费大量精力进行构建。为了更好地构建神经网络,人们提出了通过神经网络结构搜索(neuralarchitecture search,NAS)的方法来搭建神经网络,通过自动化地搜索神经网络结构,从而得到性能优异的神经网络结构。
现有针对于transformer模型的神经网络搜索方法,对transformer模型的性能提升有限。
发明内容
第一方面,本申请提供了一种神经网络搜索方法,该方法包括:
获取多个候选神经网络;其中,该多个候选神经网络中的至少一个候选神经网络包括目标transformer层,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
其中,可以通过采样或者固定设置的方式,确定候选神经网络中的网络层的类型为transformer层(本申请实施例中可以称之为目标transformer层),并通过从第一搜索空间中进行算子采样的方式来确定目标transformer层中目标注意力头head的结构;
在一种可能的实现中,算子采样的来源可以为第一搜索空间,第一搜索空间可以包括多个候选算子,在构建注意力头head时,可以采样第一搜索空间中的多个候选算子,并对 采样得到的候选算子进行组合,以得到一个transformer层中的注意力头head,经过多次采样,可以得到多个transformer层中的注意力头head;具体的,在一种可能的实现中,可以采样第一搜索空间的候选算子来构建目标注意力head,具体的,可以从第一搜索空间中采样多个算子,以及采样多个算子之间的连接关系。也就是说,在构建目标注意力head时,目标注意力head中包括的各个算子的类型、数量以及连接关系都可以是基于采样的方式确定的,进而,可以基于采样得到的多个算子,以及采样多个算子之间的连接关系来构建目标注意力头head;
应理解,本申请实施例中的采样可以为随机采样或者是非随机采样,其中,随机采样可以指遵照随机化原则从总体中抽取样本的抽样方法,随机采样例如但不限于包括简单随机抽样、系统抽样、整群抽样和分层抽样等。非随机采样可以是基于一定概率分布或者其他指导采样过程的方式,使得不同被采样的信息在每次采样时被采样到的几率不完全相同。
本申请实施例中的采样可以包括网络层类型的采样(网络层类型具体包括transformer层以及目标网络层)、注意力头head中多个算子的采样(具体包括算子类型、算子数量以及连接关系的采样)、注意力头head中变换矩阵数量的采样、目标网络层中卷积层的卷积核的尺寸大小采样,上述采样过程可以部分基于随机采样实现,部分基于非随机采样实现,也可以全部基于随机采样实现,也可以全部基于非随机采样实现。
其中,网络层类型的采样是用于确定候选神经网络中串行连接的各个网络层的网络类型(网络类型可以为transformer层或者目标网络层,或者是其他网络类型)。
其中,注意力头head中多个算子的采样是用于确定注意力头head中包括的算子的算子类型、算子数量以及算子之间的连接关系,其中,算子类型是对第一搜索空间中的多个候选算子进行采样得到的,算子数量是从预设范围内采样得到的,例如针对于目标head采样确定5-20之间的算子数量,算子之间的连接关系是基于采样得到的多个算子之间的数量流向进行采样得到的,例如采样得到的多个算子包括算子A和算子B,那么算子A是否和算子B连接可以是基于采样的方式确定的,以及在具备连接关系的情况下,是算子A的输出作为算子B的输入还是算子B的输出作为算子A的输入也可以是基于采样的方式确定的。
其中,注意力头head中变换矩阵数量的采样是用于确定注意力头head中包括多少个变换矩阵数量,采样的数量可以具有上限和/或下限,例如是在1-4的数量区间内采样确定,或者是在2-4的数量区间内采样确定,或者是在2-3的数量区间内采样确定,这里并不限定。基于该多个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络。
在得到多个候选神经网络之后,可以对多个神经网络进行训练,以得每个候选神经网络的性能,进而可以基于每个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络,其中目标神经网络的数量为至少一个,当目标神经网络的数量为一个时,该目标神经网络可以为多个候选神经网络中性能最好的模型,当目标神经网络的数量为多个时,该目标神经网络可以为多个候选神经网络中性能最好的多个模型。
通过上述方式,结合模型搜索,能生成相比原自注意力机制更强的新型注意力结构,在广泛的下游任务中取得明显效果提升。
在一种可能的实现中,该第一搜索空间包括多个候选算子,该候选算子为一元运算符或二元运算符。其中一元运算符(unary operation)是指只对一个数据执行操作,例如负数操作(neg)、开根号操作(sqrt)、转置操作(transpose)、softmax操作、logsigmoid操作、softsign操作等等,二元运算符(binary operation)是指对两个数据进行操作得到第三个数据的一种规则,例如加和操作(add)、点乘操作(matmul)、cosine similarity操作以及euclidean distance操作。
其中,上述候选算子的类型相比现有的注意力头的算子类型更为丰富,大大增加了候选transformer层的结构类型,进而增加了搜索得到具有更优性能的transformer模型的可能。
在一种可能的实现中,该多个候选算子包括softmax算子以及点乘算子。
其中,在丰富了算子类型的前提下,保留了现有的注意力头head中的softmax算子以及点乘算子,由于softmax算子以及点乘算子作为注意力机制中很重要的算子类型,当进行针对于注意力头head的算子采样时,缺失这两种算子类型可能会导致搜索后的注意力头的head与现有的注意力头head的结构差异过大,一方面,很难采样到性能很优的注意力头head结构,另一方面,也增加了搜索过程的时间以及算力开销。
在一种可能的实现中,可以采样第一搜索空间的候选算子来构建目标注意力head,具体的,可以从第一搜索空间中采样多个算子,以及采样多个算子之间的连接关系。也就是说,在构建目标注意力head时,目标注意力head中包括的各个算子的类型、数量以及连接关系都可以是基于采样的方式确定的,进而,可以基于采样得到的多个算子,以及采样多个算子之间的连接关系来构建目标注意力头head。
其中,算子之间的连接关系,也是,上述候选算子的类型相比现有的注意力头的算子类型更为丰富,大大增加了候选transformer层的结构类型,进而增加了搜索得到具有更优性能的transformer模型的可能。
在一种可能的实现中,该目标注意力head还包括第一线性变换层,该第一线性变换层用于通过目标变换矩阵对该目标注意力head的输入向量进行处理,该多个算子用于对该第一线性变换层的数据处理结果进行运算。
在一种可能的实现中,该目标变换矩阵仅包括X个变换矩阵,该X为小于或等于4的正整数,且该X的数量为基于采样的方式确定的。
例如,目标变换矩阵可以仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的一种;或者,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的两种;或者,该目标变换矩阵包括Q变换矩阵、V变换矩阵以及K变换矩阵。
例如,还可以再构建一个变换矩阵(例如称之为P变换矩阵),P变换矩阵和其他变换矩阵的结构相似或完全一致,进而,目标变换矩阵可以包括Q变换矩阵、V变换矩阵、K变换矩阵以及P变换矩阵中的至少一种。
在一种可能的实现中,可以基于采样的方式,来确定该目标变换矩阵包括的变换矩阵的矩阵类型,该矩阵类型为Q变换矩阵、K变换矩阵或者V变换矩阵,或者是预先设置该目标变换矩阵包括的变换矩阵的矩阵类型,这里并不限定。当通过采样的方式来确定目标变换矩阵包括的变换矩阵的矩阵类型时,可以增加目标注意力头head的结构的可能性,进而可以搜索得到性能更好的模型。
在一种可能的实现中,该目标注意力head还包括第二线性变换层,该第二线性变换层用于对该多个算子的数据处理结果进行线性变换,以得到该目标注意力head的输出向量。
在一种可能的实现中,该目标注意力head的输入向量和该目标注意力head的输出向量的尺寸大小一致。
其中,在仅针对transformer层中的注意力头head进行搜索重新确定结构的情况下,为了保证transformer层的其他网络层的工作不受影响,可以保留现有技术中注意力头head的输入和输出之间的关系特性,也就是保证目标注意力head的输入向量和该目标注意力head的输出向量的尺寸大小一致,通过上述方式,降低了transformer层其他网络层需要适配性修改的成本,进而提高了网络的搜索效率。
在一种可能的实现中,该目标注意力head包括的算子的数量小于预设值,例如预设值可以为10、11、12、14、15、20、21等等。
其中,在对注意力头head进行搜索的过程中,设定了算子采样的数量上限,可以保证搜索出来的网络大小不会太大,进而可以搜索出在满足一定的模型大小约束的前提下性能较优的模型。
在一种可能的实现中,可以通过算子采样的方式来构建transformer模型中的目标transformer层,具体的,可以通过算子采样的方式来构建transformer模型中目标transformer层中的目标注意力头head,其中,目标transformer层可以包括多个注意力头head,目标注意力头head可以为多个注意力头head中的任意一个,可选的,多个注意力头head中的每个注意力头head的之间的结构相同。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层,该目标transformer层在该多个网络层中的位置为基于采样的方式确定的。
其中,和现有的transformer模型中各个串行的网络层的网络层类型都是transformer层相比,基于采样的方式确定网络层的网络类型(例如为目标transformer层或者是后续的目标网络层),可以大大增加了候选transformer层的结构类型,进而增加了搜索得到具有更优性能的transformer模型的可能。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层以及目标网络层,该目标网络层包括卷积层。其中,该卷积层中的卷积核可以为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
在一种可能的实现中,可以通过采样或者固定设置的方式,确定候选神经网络中的网络层的类型为包括卷积层的目标网络层,并通过从第二搜索空间中进行采样的方式来确定目标网络层中卷积层中卷积核的大小。
本申请实施例中,设计了多样化的搜索空间,同时包含局部(卷积层中的卷积核)和全局算子(transformer层中的算子)。其中,全局算子能够结合数学基础运算符构造新型注意力机制,局部算子包含多种不同大小的卷积核。通过全局算子与局部算子的结合,能够更有效的捕捉到词与词,句子与句子之间的关联关系,提高搜索得到的模型的性能。此外,本申请实施例中的神经网络模型可以作为预训练模型,且适配于多种下游任务。
在一种可能的实现中,由于轻量化卷积lightweight convolution在一系列自然语言理解任务上(如机器翻译)取得较好表现,卷积核可以使用lightweight convolution架构,来提升模型的性能。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层(feed forward net,FFN)、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。也就是说,可以将现有的transformer层中的加和与归一化层、FFN以及残差连接的架构保留,而将注意力头head替换为卷积层,进而可以得到本申请实施例中的目标网络层,其中替换的卷积层类型可以通过从第二搜索空间中进行卷积核采样的方式得到。
在一种可能的实现中,该多个候选神经网络包括目标候选神经网络;该获取多个候选神经网络,具体包括:构建该目标候选神经网络中的目标注意力head;
该构建该目标候选神经网络中的目标注意力head,包括:
获取第一神经网络,其中,该第一神经网络包括第一transformer层,该第一transformer层包括第一注意力head,该第一注意力head包括的多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
根据该第一搜索空间中的M个候选算子替换该第一注意力head中的该目标算子时,对该第一神经网络性能的正向影响,从该M个候选算子中确定替换算子,并将该第一注意力head中的该目标算子替换为该替换算子,以得到该目标注意力head。
在一种可能的实现中,通过采样可以构建多个候选神经网络,为了能够选取性能较好的模型,候选神经网络的采样数量很多,可以通过训练来确定多个候选神经网络的性能,并基于多个候选神经网络的性能,从多个候选神经网络中初步选取一定数量的网络作为父网络,之后可以对父网络进行算子的替换(若是transformer层,则是进行注意力头head中 的算子的替换,若是目标网络层,则可以进行卷积核的替换),得到多个子网络,并对多个子网络进行训练来确定多个子网络的性能,并基于多个子网络的性能,从多个子网络中确定目标神经网络,作为神经网络的搜索结果。
其中,上述初始构建的候选神经网络可以称之为第二神经网络,父网络可以称之为第一神经网络,子网络可以称之为候选神经网络。
本申请实施例中,可以通过采样的方式获取多个第二神经网络(具体可以参照上述实施例中采样得到候选神经网络的描述,这里不再赘述),并对该多个第二神经网络进行训练,以得到多个训练后的第二神经网络以及该多个训练后的第二神经网络的性能,具体的,可以对多个第二神经网络的进行随机参数初始化,并对多个第二神经网络进行快速搜索训练(例如通过4w步训练),以得到多个训练后的第二神经网络,并利用GLUE任务对多个训练后的第二神经网络进行测评,以得到多个第二神经网络的性能,选择最优的N个网络作为父网络,并将父网络的训练参数进行保存。其中,N个父网络可以包括第一神经网络。其中,该第一神经网络可以包括第一transformer层,该第一transformer层包括第一注意力head,且该第一注意力head包括目标算子,之后可以根据该第一搜索空间中的M个候选算子替换该第一注意力head中的该目标算子时,对该第一神经网络性能的正向影响,从该M个候选算子中确定替换算子,并将该第一注意力head中的该目标算子替换为该替换算子,以得到该目标注意力head。
在一种可能的实现中,该获取第一神经网络,包括:
获取多个第二神经网络,并对该多个第二神经网络进行训练,以得到多个训练后的第二神经网络以及该多个训练后的第二神经网络的性能;
根据该多个训练后的第二神经网络的性能,从该多个训练后的第二神经网络中选择性能满足预设要求的N个训练后的第二神经网络,该N个训练后的第二神经网络包括该第一神经网络。
以该目标算子为例,目标算子可以位于该第二神经网络的目标算子位置,其中,目标算子位置可以在一定程度上表示出距离head的输入的位置,目标算子位置可以与代码上表示网络算子之间的位置方式有关,在计算正向影响时,各个算子在第二神经网络的位置的计算方式与目标算子在第二神经网络的目标算子位置的计算方式一致,都可以表达出算子位于注意力头head的不同位置对于模型性能正向影响的程度。在计算正向影响时,可以根据每个该多个训练后的第二神经网络中位于该目标算子位置的算子以及该多个训练后的第二神经网络的性能,和/或,每个该训练后的第二神经网络中位于该目标算子位置的算子的出现频次,来确定该第一搜索空间中的M个候选算子替换该第一注意力head中的该目标算子时,对该第一神经网络性能的正向影响。
示例性的,正向影响可以通过置信区间上界UCB(upper confidence bound)来表示,具体的UCB分数计算方式可以为:
Figure PCTCN2022105115-appb-000001
其中,μ i表示算子i在这个网络结构当前位置中获得的分数,N i表示算子i在历史上(采样第二神经网络时)被采样的次数,N表示所有算子被采样的次数。当某个算子很少被采样时,公式右半部分的会获得较大数值,以更大概率选择当前算子。应理解,在每个位置的每个算子的UCB分数计算完后,可以会对这些分数做softmax计算,获得一个概率分布。并将该概率设为在当前位置算子i被激活的概率。
本申请实施例利用正向影响来进行算子替换,能够均衡算法的搜索精度和搜索广度,能够避免陷入局部最优,持续搜索到更优的网络架构。
在一种可能的实现中,该方法还包括:
根据该第一神经网络,对该目标候选神经网络进行参数初始化,以得到初始化后的该目标候选神经网络;其中,该初始化后的该目标候选神经网络中的可更新参数为对该第一神经网络中相同的位置的可更新参数进行参数共享得到的;
对进行参数初始化的该目标候选神经网络进行训练,以得到该目标候选神经网络的性能。
其中,在进行注意力头head的参数共享时,可更新参数为注意力头head中变换矩阵中的参数;在进行卷积层的参数共享时,可更新参数为卷积核;应理解,可以选择卷积核最中心位置的相应参数进行参数共享。
本申请实施例中,通过参数共享的方式进行参数初始化,可以加快搜索速度,避免重复训练,极大加速搜索效率。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
第二方面,本申请提供了一种模型提供方法,该方法包括:
接收端侧发送的性能要求,该性能要求用于指示神经网络的性能要求,该性能要求可以包括如下的至少一种:数据处理精度、模型大小以及实现的任务类型;
根据所述性能要求,从多个候选神经网络中获取满足所述性能要求的目标神经网络,其中,所述多个候选神经网络中的至少一个候选神经网络包括目标transformer层,所述目标transformer层包括目标注意力头head,所述目标注意力head包括多个算子,且所述多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
向该端侧发送该目标神经网络。
在一种可能的实现中,该第一搜索空间包括多个候选算子,该候选算子为一元运算符或二元运算符;该目标注意力head为基于该多个算子以及该多个算子之间的排列关系构建的,该多个算子之间的排列关系为基于采样的方式确定的。
在一种可能的实现中,该目标注意力head还包括第一线性变换层,该第一线性变换层用于通过目标变换矩阵对该目标注意力head的输入向量进行处理,该多个算子用于对该第一线性变换层的数据处理结果进行运算;其中,该目标变换矩阵仅包括X个变换矩阵,该X为小于或等于4的正整数,且该X的数量为基于采样的方式确定的。
例如,目标变换矩阵可以仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的一种;或者,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的两种;或者,该目标变换矩阵包括Q变换矩阵、V变换矩阵以及K变换矩阵。
例如,还可以再构建一个变换矩阵(例如称之为P变换矩阵),P变换矩阵和其他变换矩阵的结构相似或完全一致,进而,目标变换矩阵可以包括Q变换矩阵、V变换矩阵、K变换矩阵以及P变换矩阵中的至少一种。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层,该目标transformer层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层以及目标网络层,该目标网络层包括卷积层。
在一种可能的实现中,该目标网络层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
第三方面,本申请提供了一种神经网络搜索方法,该方法包括:
获取多个候选神经网络;其中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括目标transformer层以及目标网络层,该目标网络层包括卷积层,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的;
基于该多个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二 加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
第四方面,本申请提供了一种数据处理方法,该方法包括:
获取目标神经网络,该目标神经网络包括串行的多个网络层,该多个网络层包括目标transformer层以及目标网络层,该目标网络层包括卷积层;
获取待处理数据,通过该目标神经网络对该待处理数据进行处理,以得到数据处理结果。
在一种可能的实现中,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,该多个算子为一元运算符或二元运算符。
在一种可能的实现中,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的。
在一种可能的实现中,该目标注意力head还包括第一线性变换层,该第一线性变换层用于通过目标变换矩阵对该目标注意力head的输入向量进行处理,该多个算子用于对该第一线性变换层的数据处理结果进行运算。
在一种可能的实现中,该目标变换矩阵仅包括X个变换矩阵,该X为小于或等于4的正整数。
例如,目标变换矩阵可以仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的一种;或者,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的两种;或者,该目标变换矩阵包括Q变换矩阵、V变换矩阵以及K变换矩阵。
例如,还可以再构建一个变换矩阵(例如称之为P变换矩阵),P变换矩阵和其他变换矩阵的结构相似或完全一致,进而,目标变换矩阵可以包括Q变换矩阵、V变换矩阵、K变换矩阵以及P变换矩阵中的至少一种。
在一种可能的实现中,该X的数量为基于采样的方式确定的。具体可以基于采样的方式,来确定该目标变换矩阵包括的变换矩阵的矩阵类型,该矩阵类型为Q变换矩阵、K变换矩阵或者V变换矩阵,或者是预先设置该目标变换矩阵包括的变换矩阵的矩阵类型,这里并不限定。当通过采样的方式来确定目标变换矩阵包括的变换矩阵的矩阵类型时,可以 增加目标注意力头head的结构的可能性,进而可以搜索得到性能更好的模型。
在一种可能的实现中,该目标注意力head还包括第二线性变换层,该第二线性变换层用于对该多个算子的数据处理结果进行线性变换,以得到该目标注意力head的输出向量。
在一种可能的实现中,该目标注意力head的输入向量和该目标注意力head的输出向量的尺寸大小一致。
在一种可能的实现中,该目标注意力head包括的算子的数量小于预设值,例如预设值可以为10、11、12、14、15、20、21等等。
在一种可能的实现中,目标transformer层可以包括多个注意力头head,目标注意力头head可以为多个注意力头head中的任意一个,可选的,多个注意力头head中的每个注意力头head的之间的结构相同。
在一种可能的实现中,该目标transformer层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该卷积层中的卷积核可以为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
在一种可能的实现中,该卷积层包括于该多个网络层中的目标网络层,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
在一种可能的实现中,该目标网络层在该多个网络层中的位置为基于采样的方式确定的。
第五方面,本申请提供了一种模型提供方法,该方法包括:
接收端侧发送的性能要求,该性能要求用于指示神经网络的性能要求,该性能要求可以包括如下的至少一种:数据处理精度、模型大小以及实现的任务类型;
根据所述性能要求,从多个候选神经网络中获取满足所述性能要求的目标神经网络,其中,该目标神经网络包括目标transformer层以及目标网络层,该目标网络层包括卷积层,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的;
向该端侧发送该目标神经网络。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
第六方面,一种神经网络搜索装置,其特征在于,该装置包括:
获取模块,用于获取多个候选神经网络;其中,该多个候选神经网络中的至少一个候选神经网络包括目标transformer层,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
模型选择模块,用于基于该多个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络。
在一种可能的实现中,该第一搜索空间包括多个候选算子,该候选算子为一元运算符或二元运算符。其中一元运算符(unary operation)是指只对一个数据执行操作,例如负数操作(neg)、开根号操作(sqrt)、转置操作(transpose)、softmax操作、logsigmoid操作、softsign操作等等,二元运算符(binary operation)是指对两个数据进行操作得到第三个数据的一种规则,例如加和操作(add)、点乘操作(matmul)、cosine similarity操作以及euclidean distance操作。
在一种可能的实现中,该多个候选算子包括softmax算子以及点乘算子。
在一种可能的实现中,可以采样第一搜索空间的候选算子来构建目标注意力head,具体的,可以从第一搜索空间中采样多个算子,以及采样多个算子之间的连接关系。也就是说,在构建目标注意力head时,目标注意力head中包括的各个算子的类型、数量以及连接关系都可以是基于采样的方式确定的,进而,可以基于采样得到的多个算子,以及采样多个算子之间的连接关系来构建目标注意力头head。
在一种可能的实现中,该目标注意力head还包括第一线性变换层,该第一线性变换层 用于通过目标变换矩阵对该目标注意力head的输入向量进行处理,该多个算子用于对该第一线性变换层的数据处理结果进行运算。
在一种可能的实现中,该目标变换矩阵仅包括X个变换矩阵,该X为小于或等于4的正整数,且该X的数量为基于采样的方式确定的。
例如,目标变换矩阵可以仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的一种;或者,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的两种;或者,该目标变换矩阵包括Q变换矩阵、V变换矩阵以及K变换矩阵。
例如,还可以再构建一个变换矩阵(例如称之为P变换矩阵),P变换矩阵和其他变换矩阵的结构相似或完全一致,进而,目标变换矩阵可以包括Q变换矩阵、V变换矩阵、K变换矩阵以及P变换矩阵中的至少一种。
在一种可能的实现中,该目标注意力head还包括第二线性变换层,该第二线性变换层用于对该多个算子的数据处理结果进行线性变换,以得到该目标注意力head的输出向量。
在一种可能的实现中,该目标注意力head的输入向量和该目标注意力head的输出向量的尺寸大小一致。
在一种可能的实现中,该目标注意力head包括的算子的数量小于预设值。
在一种可能的实现中,可以通过算子采样的方式来构建transformer模型中的目标transformer层,具体的,可以通过算子采样的方式来构建transformer模型中目标transformer层中的目标注意力头head,其中,目标transformer层可以包括多个注意力头head,目标注意力头head可以为多个注意力头head中的任意一个,可选的,多个注意力头head中的每个注意力头head的之间的结构相同。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层,该目标transformer层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层以及目标网络层,该目标网络层包括卷积层。其中,该卷积层中的卷积核可以为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
在一种可能的实现中,可以通过采样或者固定设置的方式,确定候选神经网络中的网络层的类型为包括卷积层的目标网络层,并通过从第二搜索空间中进行采样的方式来确定目标网络层中卷积层中卷积核的大小。
本申请实施例中,设计了多样化的搜索空间,同时包含局部(卷积层中的卷积核)和 全局算子(transformer层中的算子)。其中,全局算子能够结合数学基础运算符构造新型注意力机制,局部算子包含多种不同大小的卷积核。通过全局算子与局部算子的结合,能够更有效的捕捉到词与词,句子与句子之间的关联关系,提高搜索得到的模型的性能。此外,本申请实施例中的神经网络模型可以作为预训练模型,且适配于多种下游任务。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。也就是说,可以将现有的transformer层中的加和与归一化层、FFN以及残差连接的架构保留,而将注意力头head替换为卷积层,进而可以得到本申请实施例中的目标网络层,其中替换的卷积层类型可以通过从第二搜索空间中进行卷积核采样的方式得到。
在一种可能的实现中,该多个候选神经网络包括目标候选神经网络;该获取模块,具体用于:构建该目标候选神经网络中的目标注意力head;
该构建该目标候选神经网络中的目标注意力head,包括:
获取第一神经网络,其中,该第一神经网络包括第一transformer层,该第一transformer层包括第一注意力head,该第一注意力head包括的多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
根据该第一搜索空间中的M个候选算子替换该第一注意力head中的该目标算子时,对该第一神经网络性能的正向影响,从该M个候选算子中确定替换算子,并将该第一注意力head中的该目标算子替换为该替换算子,以得到该目标注意力head。
在一种可能的实现中,该获取模块,具体用于:
获取多个第二神经网络,并对该多个第二神经网络进行训练,以得到多个训练后的第二神经网络以及该多个训练后的第二神经网络的性能;
根据该多个训练后的第二神经网络的性能,从该多个训练后的第二神经网络中选择性能满足预设要求的N个训练后的第二神经网络,该N个训练后的第二神经网络包括该第一神经网络。
在一种可能的实现中,该目标算子位于该第二神经网络的目标算子位置;该装置还包括:
确定模块,用于根据每个该多个训练后的第二神经网络中位于该目标算子位置的算子以及该多个训练后的第二神经网络的性能,和/或,每个该训练后的第二神经网络中位于该 目标算子位置的算子的出现频次,确定该第一搜索空间中的M个候选算子替换该第一注意力head中的该目标算子时,对该第一神经网络性能的正向影响。
在一种可能的实现中,该装置还包括:
参数初始化模块,用于根据该第一神经网络,对该目标候选神经网络进行参数初始化,以得到初始化后的该目标候选神经网络;其中,该初始化后的该目标候选神经网络中的可更新参数为对该第一神经网络中相同的位置的可更新参数进行参数共享得到的;
模型训练模块,用于对进行参数初始化的该目标候选神经网络进行训练,以得到该目标候选神经网络的性能。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
第七方面,本申请提供了一种模型提供装置,该装置包括:
接收模块,用于接收端侧发送的性能要求,该性能要求用于指示神经网络的性能要求,该性能要求可以包括如下的至少一种:数据处理精度、模型大小以及实现的任务类型;
获取模块,用于根据所述性能要求,从多个候选神经网络中获取满足所述性能要求的目标神经网络,其中,该目标神经网络包括目标transformer层,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
发送模块,用于向该端侧发送该目标神经网络。
在一种可能的实现中,该候选算子为一元运算符或二元运算符;该目标注意力head为基于该多个算子以及该多个算子之间的排列关系构建的,该多个算子之间的排列关系为基于采样的方式确定的。
在一种可能的实现中,该目标注意力head还包括第一线性变换层,该第一线性变换层用于通过目标变换矩阵对该目标注意力head的输入向量进行处理,该多个算子用于对该第一线性变换层的数据处理结果进行运算;其中,该目标变换矩阵仅包括X个变换矩阵,该X为小于或等于4的正整数,且该X的数量为基于采样的方式确定的。
例如,目标变换矩阵可以仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的一种;或者,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的两种;或者,该目标变换矩阵包括Q变换矩阵、V变换矩阵以及K变换矩阵。
例如,还可以再构建一个变换矩阵(例如称之为P变换矩阵),P变换矩阵和其他变换矩阵的结构相似或完全一致,进而,目标变换矩阵可以包括Q变换矩阵、V变换矩阵、K变换矩阵以及P变换矩阵中的至少一种。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层,该目标transformer层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层以及目标网络层,该目标网络层包括卷积层。
在一种可能的实现中,该目标网络层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
第八方面,本申请提供了一种神经网络搜索装置,该装置包括:
获取模块,用于获取多个候选神经网络;其中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括目标transformer层以及目标网络层,该目标网络层包括卷积层,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的;
模型选择模块,用于基于该多个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
第九方面,本申请提供了一种数据处理装置,该装置包括:
获取模块,用于获取目标神经网络,该目标神经网络包括串行的多个网络层,该多个网络层包括目标transformer层以及目标网络层,该目标网络层包括卷积层;该获取模块还用于获取待处理数据;
数据处理模块,用于通过该目标神经网络对该待处理数据进行处理,以得到数据处理结果。
在一种可能的实现中,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,该多个算子为一元运算符或二元运算符。
在一种可能的实现中,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的。
在一种可能的实现中,该目标注意力head还包括第一线性变换层,该第一线性变换层用于通过目标变换矩阵对该目标注意力head的输入向量进行处理,该多个算子用于对该第一线性变换层的数据处理结果进行运算。
在一种可能的实现中,该目标变换矩阵仅包括X个变换矩阵,该X为小于或等于4的正整数。
例如,目标变换矩阵可以仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的一种;或者,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的两种;或者,该目标变换矩阵包括Q变换矩阵、V变换矩阵以及K变换矩阵。
例如,还可以再构建一个变换矩阵(例如称之为P变换矩阵),P变换矩阵和其他变换矩阵的结构相似或完全一致,进而,目标变换矩阵可以包括Q变换矩阵、V变换矩阵、K变换矩阵以及P变换矩阵中的至少一种。
在一种可能的实现中,该X的数量为基于采样的方式确定的。具体可以基于采样的方式,来确定该目标变换矩阵包括的变换矩阵的矩阵类型,该矩阵类型为Q变换矩阵、K变换矩阵或者V变换矩阵,或者是预先设置该目标变换矩阵包括的变换矩阵的矩阵类型,这里并不限定。当通过采样的方式来确定目标变换矩阵包括的变换矩阵的矩阵类型时,可以增加目标注意力头head的结构的可能性,进而可以搜索得到性能更好的模型。
在一种可能的实现中,该目标注意力head还包括第二线性变换层,该第二线性变换层用于对该多个算子的数据处理结果进行线性变换,以得到该目标注意力head的输出向量。
在一种可能的实现中,该目标注意力head的输入向量和该目标注意力head的输出向量的尺寸大小一致。
在一种可能的实现中,该目标注意力head包括的算子的数量小于预设值,例如预设值可以为10、11、12、14、15、20、21等等。
在一种可能的实现中,目标transformer层可以包括多个注意力头head,目标注意力头head可以为多个注意力头head中的任意一个,可选的,多个注意力头head中的每个注意力头head的之间的结构相同。
在一种可能的实现中,该目标transformer层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该卷积层中的卷积核可以为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
在一种可能的实现中,该卷积层包括于该多个网络层中的目标网络层,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
在一种可能的实现中,该目标网络层在该多个网络层中的位置为基于采样的方式确定的。
第十方面,本申请提供了一种模型提供装置,该装置包括:
接收模块,用于接收端侧发送的性能要求,该性能要求用于指示神经网络的性能要求,该性能要求可以包括如下的至少一种:数据处理精度、模型大小以及实现的任务类型;
获取模块,用于根据所述性能要求,从多个候选神经网络中获取满足所述性能要求的目标神经网络,其中,该目标神经网络包括目标transformer层以及目标网络层,该目标网络层包括卷积层,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的;
发送模块,用于向该端侧发送该目标神经网络。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层 的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
第十一方面,本申请实施例提供了一种神经网络搜索装置,可以包括存储器、处理器以及总线系统,其中,存储器用于存储程序,处理器用于执行存储器中的程序,以执行如上述第一方面及其任一可选的方法,以及上述第三方面及其任一可选的方法。
第十二方面,本申请实施例提供了一种模型提供装置,可以包括存储器、处理器以及总线系统,其中,存储器用于存储程序,处理器用于执行存储器中的程序,以执行如上述第二方面及其任一可选的方法,以及上述第五方面及其任一可选的方法。
第十三方面,本申请实施例提供了一种数据处理装置,可以包括存储器、处理器以及总线系统,其中,存储器用于存储程序,处理器用于执行存储器中的程序,以执行如上述第四方面及其任一可选的方法。
第十四方面,本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行上述第一方面及其任一可选的方法、上述第二方面及其任一可选的方法、上述第三方面及其任一可选的方法、上述第四方面及其任一可选的方法以及上述第五方面及其任一可选的方法。
第十五方面,本申请实施例提供了一种计算机程序,当其在计算机上运行时,使得计算机执行上述第一方面及其任一可选的方法、上述第二方面及其任一可选的方法、上述第三方面及其任一可选的方法、上述第四方面及其任一可选的方法以及上述第五方面及其任一可选的方法。
第十六方面,本申请提供了一种芯片系统,该芯片系统包括处理器,用于支持执行设备或训练设备实现上述方面中所涉及的功能,例如,发送或处理上述方法中所涉及的数据;或,信息。在一种可能的设计中,该芯片系统还包括存储器,该存储器,用于保存执行设备或训练设备必要的程序指令和数据。该芯片系统,可以由芯片构成,也可以包括芯片和其他分立器件。
本申请实施例提供了一种神经网络搜索方法,该方法包括:获取多个候选神经网络;其中,该多个候选神经网络中的至少一个候选神经网络包括目标transformer层,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;基于该多个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络。通过上述方式,结合模型搜索,能生成相比原自注意力机制更强的新型注意力结构,在广泛的下游任务中取得明显效果提升。
应理解,上述各方面描述的方法以及装置之间在不存在技术矛盾的情况下,可以相互引用、组合、解释。
附图说明
图1为人工智能主体框架的一种结构示意图;
图2为一种神经网络搜索系统;
图3为一种神经网络搜索系统;
图4为一种神经网络搜索系统;
图5为一种神经网络搜索系统;
图6为一种自然语言处理系统;
图7为一种自然语言处理系统;
图8为本申请实施例提供的自然语言处理的相关设备的示意图;
图9为卷积神经网络的示意图;
图10为卷积神经网络的示意图;
图11为本申请实施例提供的一种系统架构的结构示意;
图12为本申请实施例提供的一种神经网络搜索方法的实施例示意;
图13为一种transformer模型的结构示意;
图14为一种transformer层的结构示意;
图15为本申请实施例提供的一种目标注意力head的结构示意;
图16至21为通过采样的方式得到的目标注意力头head的结构示意;
图22为一个候选神经网络的结构示意;
图23为本申请实施例提供的一种目标网络层的示意;
图24为本申请实施例提供的一种参数共享示意;
图25为本申请实施例提供的一种参数共享示意;
图26为基于本申请实施例提供神经网络搜索算法得到的网络架构搜索结果;
图27为本申请实施例提供的一种模型提供方法的实施例示意;
图28为本申请实施例提供的一种神经网络搜索方法的实施例示意;
图29为本申请实施例提供的一种模型提供方法的实施例示意;
图30为本申请实施例提供的一种神经网络搜索装置的实施例示意;
图31为本申请实施例提供的一种模型提供装置的实施例示意;
图32为本申请实施例提供的一种神经网络搜索装置的实施例示意;
图33为本申请实施例提供的一种模型提供装置的实施例示意;
图34为本申请实施例提供的执行设备的一种结构示意图;
图35是本申请实施例提供的训练设备一种结构示意图;
图36为本申请实施例提供的芯片的一种结构示意图。
具体实施方式
下面结合本发明实施例中的附图对本发明实施例进行描述。本发明的实施方式部分使用的术语仅用于对本发明的具体实施例进行解释,而非旨在限定本发明。
下面结合附图,对本申请的实施例进行描述。本领域普通技术人员可知,随着技术的发展和新场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的术语在适当情况下可以互换,这仅仅是描述本申请的实施例中对相同属性的对象在描述时所采用的区分方式。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,以便包含一系列单元的过程、方法、系统、产品或设备不必限于那些单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它单元。
首先对人工智能系统总体工作流程进行描述,请参见图1,图1示出的为人工智能主体框架的一种结构示意图,下面从“智能信息链”(水平轴)和“IT价值链”(垂直轴)两个维度对上述人工智能主题框架进行阐述。其中,“智能信息链”反映从数据的获取到处理的一列过程。举例来说,可以是智能信息感知、智能信息表示与形成、智能推理、智能决策、智能执行与输出的一般过程。在这个过程中,数据经历了“数据—信息—知识—智慧”的凝练过程。“IT价值链”从人智能的底层基础设施、信息(提供和处理技术实现)到系统的产业生态过程,反映人工智能为信息技术产业带来的价值。
(1)基础设施
基础设施为人工智能系统提供计算能力支持,实现与外部世界的沟通,并通过基础平台实现支撑。通过传感器与外部沟通;计算能力由智能芯片(CPU、NPU、GPU、ASIC、FPGA等硬件加速芯片)提供;基础平台包括分布式计算框架及网络等相关的平台保障和支持,可以包括云存储和计算、互联互通网络等。举例来说,传感器和外部沟通获取数据,这些数据提供给基础平台提供的分布式计算系统中的智能芯片进行计算。
(2)数据
基础设施的上一层的数据用于表示人工智能领域的数据来源。数据涉及到图形、图像、语音、文本,还涉及到传统设备的物联网数据,包括已有系统的业务数据以及力、位移、液位、温度、湿度等感知数据。
(3)数据处理
数据处理通常包括数据训练,机器学习,深度学习,搜索,推理,决策等方式。
其中,机器学习和深度学习可以对数据进行符号化和形式化的智能信息建模、抽取、预处理、训练等。
推理是指在计算机或智能系统中,模拟人类的智能推理方式,依据推理控制策略,利用形式化的信息进行机器思维和求解问题的过程,典型的功能是搜索与匹配。
决策是指智能信息经过推理后进行决策的过程,通常提供分类、排序、预测等功能。
(4)通用能力
对数据经过上面提到的数据处理后,进一步基于数据处理的结果可以形成一些通用的能力,比如可以是算法或者一个通用系统,例如,翻译,文本的分析,计算机视觉的处理,语音识别,图像的识别等等。
(5)智能产品及行业应用
智能产品及行业应用指人工智能系统在各领域的产品和应用,是对人工智能整体解决方案的封装,将智能信息决策产品化、实现落地应用,其应用领域主要包括:智能终端、智能交通、智能医疗、自动驾驶、智慧城市等。
本申请可以但不限于应用于人工智能领域的自然语言处理领域中,具体可以应用于自然语言处理领域的神经网络搜索以及自然语言处理领域的神经网络推理等领域,下面将对多个落地到产品的多个应用场景进行介绍。
为了更好地理解本申请实施例的方案,下面先结合图2至图8对本申请实施例可能的应用场景进行简单的介绍。
场景1:神经网络搜索
参照图2,本申请可以应用于神经网络搜索相关的服务中,具体可以为云侧服务器提供的神经网络架构搜索服务,其中,用户可以通过用户设备将与模型搜索相关的信息传递至云侧的神经网络搜索系统(例如云服务器),其中与模型搜索相关的信息可以为用户对于搜索的模型的性能要求等,进而云侧的服务器可以基于用户上传的性能要求,通过一定的神经网络搜索算法,得到搜索结果(例如本申请实施例中的目标神经网络),并将搜索结果下发至用户设备。
图3示出了一种神经网络搜索系统100。该系统可以获取用于训练神经网络的训练数据102、用于评估神经网络的性能的验证数据104、以及性能要求103,并使用训练数据102和验证数据104以及性能要求103确定搜索结果160(例如本申请实施例中的目标神经网络),该搜索结果160配置为满足性能要求103,即,接收输入并生成符合性能要求103的输出。该搜索结果160可以为神经网络的架构信息,该架构信息可以定义神经网络的层数、每个层执行的操作以及神经网络中各层之间的连接,即,哪些层从神经网络中的其他层接收输入。
系统100可以以各种方式中的任何一种来接收训练数据102、验证集104以及性能要求103。例如,系统100可以例如使用可用于系统100的应用编程接口(application programming interface,API),通过数据通信网络从系统的远程用户作为上传接收训练数据以及性能要求103,并且将上传的数据随机地划分为训练数据102和验证集104。作为另一个示例,系统100可以从用户接收输入,该输入指定系统100已经维护的哪些数据应当用于训练神经网络,并且然后将指定的数据划分为训练数据102和验证集104。
通常,系统100可以通过搜索候选架构的空间以识别一个或多个性能最佳的架构来确定搜索结果160。例如,如图3所示的那样,系统100可以通过搜索候选架构的空间,并通过候选选择引擎130来构建多个候选的神经网络架构(例如本申请实施例中的候选神经网络),并通过训练引擎140对候选的神经网络架构进行模型训练等处理,质量评估引擎150可以对训练结果进行评估,以确定搜索结果160。
图4示出了一种神经网络搜索系统,该神经网络搜索系统包括用户设备以及神经网络搜索设备。其中,用户设备包括手机、个人电脑或者信息处理中心等智能终端。用户设备为神经网络搜索的发起端,通常用户通过用户设备发起神经网络搜索请求。
上述神经网络搜索设备可以是云服务器、网络服务器、应用服务器以及管理服务器等具有神经网络搜索功能的设备或服务器。神经网络搜索设备通过交互接口接收来自智能终端的神经网络搜索,再通过存储数据的存储器以及处理器环节进行机器学习,深度学习,搜索,推理,决策等方式的神经网络搜索,并将搜索结果(例如本申请实施例中的目标神经网络)反馈至用户设备。神经网络搜索设备中的存储器可以是一个统称,包括本地存储以及存储历史数据的数据库,数据库可以在数据处理设备上,也可以在其它网络服务器上。
在图4所示的神经网络搜索系统中,用户设备可以接收用户的指令,例如用户设备可以接收用户输入的针对于神经网络搜索的模型性能要求,然后向神经网络搜索设备发起请求。
在图4中,神经网络搜索设备可以执行本申请实施例的神经网络搜索方法。
图5示出了另一种神经网络搜索系统,在图5中,用户设备直接作为神经网络搜索设备,该用户设备能够直接接收来自用户输入的针对于神经网络搜索的模型性能要求并直接由用户设备本身的硬件进行神经网络搜索,具体过程与图4相似,可参考上面的描述,在此不再赘述。
在图5中,用户设备自身就可以执行本申请实施例的神经网络搜索方法。
场景2:自然语言处理
图6示出了一种自然语言处理系统,该自然语言处理系统包括用户设备以及数据处理设备。其中,用户设备包括手机、个人电脑或者信息处理中心等智能终端。用户设备为自然语言数据处理的发起端,作为语言问答或者查询等请求的发起方,通常用户通过用户设备发起请求。
上述数据处理设备可以是云服务器、网络服务器、应用服务器以及管理服务器等具有数据处理功能的设备或服务器。数据处理设备通过交互接口接收来自智能终端的查询语句/语音/文本等问句(例如本申请实施例中的待处理数据),再通过存储数据的存储器以及数据处理的处理器环节进行机器学习,深度学习,搜索,推理,决策等方式的语言数据处理(例如通过本申请实施例中的目标神经网络进行数据处理),并将处理结果(例如本申请实施例中的数据处理结果)反馈至用户设备。数据处理设备中的存储器可以是一个统称,包括本地存储以及存储历史数据的数据库,数据库可以在数据处理设备上,也可以在其它网络服务器上。
在图6所示的自然语言处理系统中,用户设备可以接收用户的指令,例如用户设备可以接收用户输入的一段文本,然后向数据处理设备发起请求,使得数据处理设备针对用户设备得到的该一段文本执行自然语言处理应用(例如文本分类、文本推理、命名实体识别、翻译等),从而得到针对该一段文本的对应的自然语言处理应用的处理结果(例如分类结果、推理结果、命名实体识别结果、翻译结果等)。示例性的,用户设备可以接收用户输入的一段中文,然后向数据处理设备发起请求,使得数据处理设备对该一段中文进行实体分类,从而得到针对该一段中文的实体分类结果;示例性的,用户设备可以接收用户输入的一段 中文,然后向数据处理设备发起请求,使得数据处理设备将该一段中文翻译成英文,从而得到针对该一段中文的英文译文。
图7示出了另一种自然语言处理系统,在图7中,用户设备直接作为数据处理设备,该用户设备能够直接接收来自用户的输入(例如本申请实施例中的待处理数据)并直接由用户设备本身的硬件进行处理,具体过程与图6相似,可参考上面的描述,在此不再赘述。
在图7所示的自然语言处理系统中,用户设备可以接收用户的指令,例如用户设备可以接收用户输入的一段文本,然后再由用户设备自身针对该一段文本执行自然语言处理应用(例如文本分类、文本推理、命名实体识别、翻译等),从而得到针对该一段文本的对应的自然语言处理应用的处理结果(例如分类结果、推理结果、命名实体识别结果、翻译结果等)。示例性的,用户设备可以接收用户输入的一段中文,并针对该一段中文进行实体分类,从而得到针对该一段中文的实体分类结果;示例性的,用户设备可以接收用户输入的一段中文,并将该一段中文翻译成英文,从而得到针对该一段中文的英文译文。
在本申请实施例中,用户设备可以存储有目标神经网络,并在每次操作系统(operating system,OS)或应用程序(application,APP)调用该模型后,根据目标神经网络执行推理任务。
图8是本申请实施例提供的自然语言处理的相关设备300的示意图。
上述图6和图7中的用户设备具体可以是图8中的本地设备301或者本地设备302,图6中的数据处理设备具体可以是图8中的执行设备310,其中,数据存储系统350可以存储执行设备310的待处理数据,数据存储系统350可以集成在执行设备310上,也可以设置在云上或其它网络服务器上。
图6和图7中的处理器可以通过神经网络模型或者其它模型进行数据训练/机器学习/深度学习,并利用训练得到的模型(例如本申请实施例中的目标神经网络)针对文本序列执行自然语言处理应用(例如文本分类、序列标注、阅读理解、文本生成、文本推理、翻译等),从而得到相应的处理结果。
由于本申请实施例涉及大量神经网络的应用,为了便于理解,下面先对本申请实施例涉及的相关术语及神经网络等相关概念进行介绍。
(1)神经网络
神经网络可以是由神经单元组成的,神经单元可以是指以xs和截距1为输入的运算单元,该运算单元的输出可以为:
其中,s=1、2、……n,n为大于1的自然数,Ws为xs的权重,b为神经单元的偏置。f为神经单元的激活函数(activation functions),用于将非线性特性引入神经网络中,来将神经单元中的输入信号转换为输出信号。该激活函数的输出信号可以作为下一层卷积层的输入,激活函数可以是sigmoid函数。神经网络是将多个上述单一的神经单元联结在一起形成的网络,即一个神经单元的输出可以是另一个神经单元的输入。每个神经单元的输入可以与前一层的局部接受域相连,来提取局部接受域的特征,局部接受域可以是由若干个神经单元组成的区域。
(2)transformer层
神经网络可以包括嵌入层和至少一个transformer层,至少一个transformer层可以为N个transformer层(N大于0的整数),其中,每个transformer层包括依次相邻的注意力层、加和与归一化(add&norm)层、前馈(feed forward)层和加和与归一化层。在嵌入层,对当前输入进行嵌入处理,得到多个特征向量;在该注意力层,从该第一transformer层的上一层获取P个输入向量,以P个输入向量中的任意的第一输入向量为中心,基于预设的注意力窗口范围内的各个输入向量与该第一输入向量之间的关联度,得到该第一输入向量对应的中间向量,如此确定出P个输入向量对应的P个中间向量;在该池化层,将该P个中间向量合并为Q个输出向量,其中transformer层中最后一个transformer层得到的多个输出向量用作该当前输入的特征表示。
接下来,结合具体例子对上述各步骤进行具体介绍。
首先,在该嵌入层,对当前输入进行嵌入处理,得到多个特征向量。
嵌入层可以称为输入嵌入(input embedding)层。当前输入可以为文本输入,例如可以为一段文本,也可以为一个句子。文本可以为中文文本,也可以为英文文本,还可以为其他语言文本。嵌入层在获取当前输入后,可以对该当前输入中各个词进行嵌入处理,可得到各个词的特征向量。在一些实施例中,如图1所示,该嵌入层包括输入嵌入层和位置编码(positional encoding)层。在输入嵌入层,可以对当前输入中的各个词进行词嵌入处理,从而得到各个词的词嵌入向量。在位置编码层,可以获取各个词在该当前输入中的位置,进而对各个词的位置生成位置向量。在一些示例中,各个词的位置可以为各个词在该当前输入中的绝对位置。以当前输入为“几号应还花呗”为例,其中的“几”的位置可以表示为第一位,“号”的位置可以表示为第二位,……。在一些示例中,各个词的位置可以为各个词之间的相对位置。仍以当前输入为“几号应还花呗”为例,其中的“几”的位置可以表示为“号”之前,“号”的位置可以表示为“几”之后、“应”之前,……。当得到当前输入中各个词的词嵌入向量和位置向量时,可以将各个词的位置向量和对应的词嵌入向量进行组合,得到各个词特征向量,即得到该当前输入对应的多个特征向量。多个特征向量可以表示为具有预设维度的嵌入矩阵。可以设定该多个特征向量中的特征向量个数为M,预设维度为H维,则该多个特征向量可以表示为M×H的嵌入矩阵。
其次,可以从transformer层的上一层获取P个输入向量,以P个输入向量中的任意的输入向量为中心,基于预设的注意力窗口范围内的各个输入向量与该输入向量之间的关联度,得到该输入向量对应的中间向量,如此确定出P个输入向量对应的P个中间向量。注意力层也可以称为多头注意力(multi-head attention)层。在一个例子中,注意力层可以为固定窗口多头注意力(fixed window multi-head attention)层。
本申请实施例中,基于神经网络搜索对transformer层进行了架构的重新设计。
(3)注意力机制(attention mechanism)
注意力机制模仿了生物观察行为的内部过程,即一种将内部经验和外部感觉对齐从而增加部分区域的观察精细度的机制,能够利用有限的注意力资源从大量信息中快速筛选出高价值信息。注意力机制可以快速提取稀疏数据的重要特征,因而被广泛用于自然语言处 理任务,特别是机器翻译。而自注意力机制(self-attention mechanism)是注意力机制的改进,其减少了对外部信息的依赖,更擅长捕捉数据或特征的内部相关性。注意力机制的本质思想可以改写为如下公式:
其中,Lx=||Source||代表Source的长度,公式含义即将Source中的构成元素想象成是由一系列的数据对构成,此时给定目标Target中的某个元素Query,通过计算Query和各个Key的相似性或者相关性,得到每个Key对应Value的权重系数,然后对Value进行加权求和,即得到了最终的Attention数值。所以本质上Attention机制是对Source中元素的Value值进行加权求和,而Query和Key用来计算对应Value的权重系数。从概念上理解,把Attention可以理解为从大量信息中有选择地筛选出少量重要信息并聚焦到这些重要信息上,忽略大多不重要的信息。聚焦的过程体现在权重系数的计算上,权重越大越聚焦于其对应的Value值上,即权重代表了信息的重要性,而Value是其对应的信息。自注意力机制可以理解为内部Attention(intra attention),Attention机制发生在Target的元素Query和Source中的所有元素之间,自注意力机制指的是在Source内部元素之间或者Target内部元素之间发生的Attention机制,也可以理解为Target=Source这种特殊情况下的注意力计算机制,其具体计算过程是一样的,只是计算对象发生了变化而已。
(4)自然语言处理(natural language processing,NLP)
自然语言(natural language)即人类语言,自然语言处理(NLP)就是对人类语言的处理。自然语言处理是以一种智能与高效的方式,对文本数据进行系统化分析、理解与信息提取的过程。通过使用NLP及其组件,我们可以管理非常大块的文本数据,或者执行大量的自动化任务,并且解决各式各样的问题,如自动摘要(automatic summarization),机器翻译(machine translation,MT),命名实体识别(named entity recognition,NER),关系提取(relation extraction,RE),信息抽取(information extraction,IE),情感分析,语音识别(speech recognition),问答系统(question answering)以及主题分割等等。
示例性的,自然语言处理任务可以有以下几类。
序列标注:句子中每一个单词要求模型根据上下文给出一个分类类别。如中文分词、词性标注、命名实体识别、语义角色标注。
分类任务:整个句子输出一个分类值,如文本分类。
句子关系推断:给定两个句子,判断这两个句子是否具备某种名义关系。例如entilment、QA、语义改写、自然语言推断。
生成式任务:输出一段文本,生成另一段文本。如机器翻译、文本摘要、写诗造句、看图说话。
下面示例性的列举一些自然语言处理案例。
分词(word segmentation或word breaker,WB):将连续的自然语言文本,切分成具有语义合理性和完整性的词汇序列,可以解决交叉歧义问题。
命名实体识别(named entity recognition,NER):识别自然语言文本中具有特定意义的实体(人、地、机构、时间、作品等)。
词性标注(part-speech tagging):为自然语言文本中的每个词汇赋予一个词性(名词、动词、形容词等);依存句法分析(dependency parsing):自动分析句子中的句法成分(主语、谓语、宾语、定语、状语和补语等成分),可以解决结构歧义问题。
词向量与语义相似度(word embedding&semantic similarity):对词汇进行向量化表示,并据此实现词汇的语义相似度计算,可以解决词汇语言相似度。
文本语义相似度(text semantic similarity):依托全网海量数据和深度神经网络技术,实现文本间的语义相似度计算的能力,可以解决文本语义相似度问题。
(5)卷积神经网络(convolutional neuron network,CNN)是一种带有卷积结构的深度神经网络。卷积神经网络包含了一个由卷积层和子采样层构成的特征抽取器,该特征抽取器可以看作是滤波器。卷积层是指卷积神经网络中对输入信号进行卷积处理的神经元层。在卷积神经网络的卷积层中,一个神经元可以只与部分邻层神经元连接。一个卷积层中,通常包含若干个特征平面,每个特征平面可以由一些矩形排列的神经单元组成。同一特征平面的神经单元共享权重,这里共享的权重就是卷积核。共享权重可以理解为提取特征的方式与位置无关。卷积核可以以随机大小的矩阵的形式化,在卷积神经网络的训练过程中卷积核可以通过学习得到合理的权重。另外,共享权重带来的直接好处是减少卷积神经网络各层之间的连接,同时又降低了过拟合的风险。
CNN是一种非常常见的神经网络,如前文的基础概念介绍该,卷积神经网络是一种带有卷积结构的深度神经网络,是一种深度学习(deep learning)架构,深度学习架构是指通过机器学习的算法,在不同的抽象层级上进行多个层次的学习。作为一种深度学习架构,CNN是一种前馈(feed-forward)人工神经网络,该前馈人工神经网络中的各个神经元可以对输入作出响应。
卷积神经网络(CNN)200可以包括输入层210,卷积层/池化层220(其中池化层为可选的),以及全连接层(fully connected layer)230。
卷积层/池化层220:
卷积层:
如图9所示卷积层/池化层220可以包括如示例221-226层,举例来说:在一种实现中,221层为卷积层,222层为池化层,223层为卷积层,224层为池化层,225为卷积层,226为池化层;在另一种实现方式中,221、222为卷积层,223为池化层,224、225为卷积层,226为池化层。即卷积层的输出可以作为随后的池化层的输入,也可以作为另一个卷积层的输入以继续进行卷积操作。
下面将以卷积层221为例,介绍一层卷积层的内部工作原理。
卷积层221可以包括很多个卷积算子,卷积算子也称为核,其在图像处理中的作用相当于一个从输入图像矩阵中提取特定信息的过滤器,卷积算子本质上可以是一个权重矩阵,这个权重矩阵通常被预先定义,以图像为例(其他数据类型类似),在对图像进行卷积操作的过程中,权重矩阵通常在输入图像上沿着水平方向一个像素接着一个像素(或两个像素接着两个像素……这取决于步长stride的取值)的进行处理,从而完成从图像中提取特定特征的工作。该权重矩阵的大小应该与图像的大小相关,需要注意的是,权重矩阵的纵深 维度(depth dimension)和输入图像的纵深维度是相同的,在进行卷积运算的过程中,权重矩阵会延伸到输入图像的整个深度。因此,和一个单一的权重矩阵进行卷积会产生一个单一纵深维度的卷积化输出,但是大多数情况下不使用单一权重矩阵,而是应用多个尺寸(行×列)相同的权重矩阵,即多个同型矩阵。每个权重矩阵的输出被堆叠起来形成卷积图像的纵深维度,这里的维度可以理解为由上面该的“多个”来决定。不同的权重矩阵可以用来提取图像中不同的特征,例如一个权重矩阵用来提取图像边缘信息,另一个权重矩阵用来提取图像的特定颜色,又一个权重矩阵用来对图像中不需要的噪点进行模糊化等。该多个权重矩阵尺寸(行×列)相同,经过该多个尺寸相同的权重矩阵提取后的特征图的尺寸也相同,再将提取到的多个尺寸相同的特征图合并形成卷积运算的输出。
这些权重矩阵中的权重值在实际应用中需要经过大量的训练得到,通过训练得到的权重值形成的各个权重矩阵可以用来从输入图像中提取信息,从而使得卷积神经网络200进行正确的预测。
当卷积神经网络200有多个卷积层的时候,初始的卷积层(例如221)往往提取较多的一般特征,该一般特征也可以称之为低级别的特征;随着卷积神经网络200深度的加深,越往后的卷积层(例如226)提取到的特征越来越复杂,比如高级别的语义之类的特征,语义越高的特征越适用于待解决的问题。
池化层:
由于常常需要减少训练参数的数量,因此卷积层之后常常需要周期性的引入池化层,在如图9中220所示例的221-226各层,可以是一层卷积层后面跟一层池化层,也可以是多层卷积层后面接一层或多层池化层。在图像处理过程中,池化层的唯一目的就是减少图像的空间大小。池化层可以包括平均池化算子和/或最大池化算子,以用于对输入图像进行采样得到较小尺寸的图像。平均池化算子可以在特定范围内对图像中的像素值进行计算产生平均值作为平均池化的结果。最大池化算子可以在特定范围内取该范围内值最大的像素作为最大池化的结果。另外,就像卷积层中用权重矩阵的大小应该与图像尺寸相关一样,池化层中的运算符也应该与图像的大小相关。通过池化层处理后输出的图像尺寸可以小于输入池化层的图像的尺寸,池化层输出的图像中每个像素点表示输入池化层的图像的对应子区域的平均值或最大值。
全连接层230:
在经过卷积层/池化层220的处理后,卷积神经网络200还不足以输出所需要的输出信息。因为如前该,卷积层/池化层220只会提取特征,并减少输入图像带来的参数。然而为了生成最终的输出信息(所需要的类信息或其他相关信息),卷积神经网络200需要利用全连接层230来生成一个或者一组所需要的类的数量的输出。因此,在全连接层230中可以包括多层隐含层(如图9所示的231、232至23n),该多层隐含层中所包含的参数可以根据具体的任务类型的相关训练数据进行预先训练得到,例如该任务类型可以包括图像识别,图像分类,图像超分辨率重建等等……
在全连接层230中的多层隐含层之后,也就是整个卷积神经网络200的最后层为输出层240,该输出层240具有类似分类交叉熵的损失函数,具体用于计算预测误差,一旦整 个卷积神经网络200的前向传播(如图9由210至240方向的传播为前向传播)完成,反向传播(如图9由240至210方向的传播为反向传播)就会开始更新前面提到的各层的权重值以及偏差,以减少卷积神经网络200的损失,及卷积神经网络200通过输出层输出的结果和理想结果之间的误差。
需要说明的是,如图9所示的卷积神经网络200仅作为一种卷积神经网络的示例,在具体的应用中,卷积神经网络还可以以其他网络模型的形式存在,例如,仅包括图9中所示的网络结构的一部分,比如,本申请实施例中所采用的卷积神经网络可以仅包括输入层210、卷积层/池化层220和输出层240。
需要说明的是,如图9所示的卷积神经网络100仅作为一种卷积神经网络的示例,在具体的应用中,卷积神经网络还可以以其他网络模型的形式存在,例如,如图10所示的多个卷积层/池化层并行,将分别提取的特征均输入给全连接层230进行处理。
(6)损失函数
在训练深度神经网络的过程中,因为希望深度神经网络的输出尽可能的接近真正想要预测的值,所以可以通过比较当前网络的预测值和真正想要的目标值,再根据两者之间的差异情况来更新每一层神经网络的权重向量(当然,在第一次更新之前通常会有初始化的过程,即为深度神经网络中的各层预先配置参数),比如,如果网络的预测值高了,就调整权重向量让它预测低一些,不断的调整,直到深度神经网络能够预测出真正想要的目标值或与真正想要的目标值非常接近的值。因此,就需要预先定义“如何比较预测值和目标值之间的差异”,这便是损失函数(loss function)或目标函数(objective function),它们是用于衡量预测值和目标值的差异的重要方程。其中,以损失函数举例,损失函数的输出值(loss)越高表示差异越大,那么深度神经网络的训练就变成了尽可能缩小这个loss的过程。
(7)反向传播算法
卷积神经网络可以采用误差反向传播(back propagation,BP)算法在训练过程中修正初始的超分辨率模型中参数的大小,使得超分辨率模型的重建误差损失越来越小。具体地,前向传递输入信号直至输出会产生误差损失,通过反向传播误差损失信息来更新初始的超分辨率模型中参数,从而使误差损失收敛。反向传播算法是以误差损失为主导的反向传播运动,旨在得到最优的超分辨率模型的参数,例如权重矩阵。
接下来介绍本申请实施例中执行神经网络搜索方法的执行主体的更细节的架构。
下面结合图11对本申请实施例提供的系统架构进行详细的介绍。图11为本申请实施例提供的系统架构示意图。如图11所示,系统架构500包括执行设备510、训练设备520、数据库530、客户设备540、数据存储系统550以及数据采集系统560。
执行设备510包括计算模块511、I/O接口512、预处理模块513和预处理模块514。计算模块511中可以包括目标模型/规则501,预处理模块513和预处理模块514是可选的。
数据采集设备560用于采集训练样本。训练样本可以为图像数据、文本数据、音频数据等等,在本申请实施例中,训练样本为对多个候选神经网络进行训练时所采用的数据。在采集到训练样本之后,数据采集设备560将这些训练样本存入数据库530。
应理解,数据库530中还可以维护有搜索空间。
训练设备520可以基于数据库530中维护的搜索空间构建多个候选神经网络,并基于训练样本对多个候选神经网络进行训练,以搜索得到目标模型/规则501。本申请实施例中,目标模型/规则501可以为目标神经网络。
需要说明的是,在实际应用中,数据库530中维护的训练样本不一定都来自于数据采集设备560的采集,也有可能是从其他设备接收得到的。另外需要说明的是,训练设备520也不一定完全基于数据库530维护的训练样本进行目标模型/规则501的训练,也有可能从云端或其他地方获取训练样本进行模型训练,上述描述不应该作为对本申请实施例的限定。
根据训练设备520训练得到的目标模型/规则501可以应用于不同的系统或设备中,如应用于图11所示的执行设备510,该执行设备510可以是终端,如手机终端,平板电脑,笔记本电脑,增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备,车载终端等,还可以是服务器或者云端等。
具体的,训练设备520可以将目标神经网络传递至执行设备510。
在图11中,执行设备510配置输入/输出(input/output,I/O)接口512,用于与外部设备进行数据交互,用户可以通过客户设备540向I/O接口512输入数据(例如本申请实施例中的待处理数据)。
预处理模块513和预处理模块514用于根据I/O接口512接收到的输入数据进行预处理。应理解,可以没有预处理模块513和预处理模块514或者只有的一个预处理模块。当不存在预处理模块513和预处理模块514时,可以直接采用计算模块511对输入数据进行处理。
在执行设备510对输入数据进行预处理,或者在执行设备510的计算模块511执行计算等相关的处理过程中,执行设备510可以调用数据存储系统550中的数据、代码等以用于相应的处理,也可以将相应处理得到的数据、指令等存入数据存储系统550中。
最后,I/O接口512将处理结果(例如本申请实施例中的数据处理结果)呈现给客户设备540,从而提供给用户。
在图11所示情况下,用户可以手动给定输入数据,该“手动给定输入数据”可以通过I/O接口512提供的界面进行操作。另一种情况下,客户设备540可以自动地向I/O接口512发送输入数据,如果要求客户设备540自动发送输入数据需要获得用户的授权,则用户可以在客户设备540中设置相应权限。用户可以在客户设备540查看执行设备510输出的结果,具体的呈现形式可以是显示、声音、动作等具体方式。客户设备540也可以作为数据采集端,采集如图所示输入I/O接口512的输入数据及输出I/O接口512的输出结果作为新的样本数据,并存入数据库530。当然,也可以不经过客户设备540进行采集,而是由I/O接口512直接将如图所示输入I/O接口512的输入数据及输出I/O接口512的输出结果,作为新的样本数据存入数据库530。
值得注意的是,图11仅是本申请实施例提供的一种系统架构的示意图,图中所示设备、器件、模块等之间的位置关系不构成任何限制,例如,在图11中,数据存储系统550相对 执行设备510是外部存储器,在其它情况下,也可以将数据存储系统550置于执行设备510中。应理解,上述执行设备510可以部署于客户设备540中。
从模型的推理侧来说:
本申请实施例中,上述执行设备520的计算模块511可以获取到数据存储系统550中存储的代码来实现本申请实施例中的数据处理方法。
本申请实施例中,执行设备520的计算模块511可以包括硬件电路(如专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)、通用处理器、数字信号处理器(digital signal processing,DSP)、微处理器或微控制器等等)、或这些硬件电路的组合,例如,训练设备520可以为具有执行指令功能的硬件系统,如CPU、DSP等,或者为不具有执行指令功能的硬件系统,如ASIC、FPGA等,或者为上述不具有执行指令功能的硬件系统以及具有执行指令功能的硬件系统的组合。
具体的,执行设备520的计算模块511可以为具有执行指令功能的硬件系统,本申请实施例提供的数据处理方法可以为存储在存储器中的软件代码,执行设备520的计算模块511可以从存储器中获取到软件代码,并执行获取到的软件代码来实现本申请实施例提供的数据处理方法。
应理解,执行设备520的计算模块511可以为不具有执行指令功能的硬件系统以及具有执行指令功能的硬件系统的组合,本申请实施例提供的数据处理方法的部分步骤还可以通过执行设备520的计算模块511中不具有执行指令功能的硬件系统来实现,这里并不限定。
从模型的训练侧来说:
本申请实施例中,上述训练设备520可以获取到存储器(图11中未示出,可以集成于训练设备520或者与训练设备520分离部署)中存储的代码来实现本申请实施例中的神经网络搜索方法。
本申请实施例中,训练设备520可以包括硬件电路(如专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)、通用处理器、数字信号处理器(digital signal processing,DSP)、微处理器或微控制器等等)、或这些硬件电路的组合,例如,训练设备520可以为具有执行指令功能的硬件系统,如CPU、DSP等,或者为不具有执行指令功能的硬件系统,如ASIC、FPGA等,或者为上述不具有执行指令功能的硬件系统以及具有执行指令功能的硬件系统的组合。
具体的,训练设备520可以为具有执行指令功能的硬件系统,本申请实施例提供的数据处理方法可以为存储在存储器中的软件代码,训练设备520可以从存储器中获取到软件代码,并执行获取到的软件代码来实现本申请实施例提供的神经网络搜索方法。
应理解,训练设备520可以为不具有执行指令功能的硬件系统以及具有执行指令功能的硬件系统的组合,本申请实施例提供的神经网络搜索方法的部分步骤还可以通过训练设备520中不具有执行指令功能的硬件系统来实现,这里并不限定。
参照图12,图12为本申请实施例提供的一种神经网络搜索方法的实施例示意,本申 请实施例提供的一种神经网络搜索方法可以应用在训练设备中,训练设备可以为手机、平板、笔记本电脑、智能穿戴设备等终端设备,训练设备也可以为云侧服务器,如图12示出的那样,本申请实施例提供的神经网络搜索方法可以包括:
1201、获取多个候选神经网络;其中,该多个候选神经网络中的至少一个候选神经网络包括目标transformer层,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的。
本申请实施例中,可以通过搜索来构建多个候选神经网络,候选神经网络可以为包括transformer层的神经网络,在进行候选神经网络的构建时,可以基于采样的方式,确定候选神经网络中包括的各个网络层的类型(例如可以是transformer层或者是后续实施例中描述的包括卷积层的目标网络层),之后可以对网络层进行采样,以完成候选神经网络的构建。
在一种可能的实现中,可以基于采样的方式,确定候选神经网络中包括的全部网络层的类型(例如可以是transformer层或者是后续实施例中描述的包括卷积层的目标网络层)。
在一种可能的实现中,可以基于采样的方式,确定候选神经网络中包括的部分网络层的类型(例如可以是transformer层或者是后续实施例中描述的包括卷积层的目标网络层),而其余网络层的结构可以预设设置好。
在一种可能的实现中,可以通过采样或者固定设置的方式,确定候选神经网络中的网络层的类型为transformer层(本申请实施例中可以称之为目标transformer层),并通过从第一搜索空间中进行算子采样的方式来确定目标transformer层中目标注意力头head的结构。
参照图13,图13为一种transformer模型的结构示意,目标transformer层可以为候选神经网络中的任意一个transformer层,应理解,目标transformer层可以为和嵌入层相邻的神经网络层也可以为最靠近输出的神经网络层,这里并不限定。
应理解,目标transformer层在候选神经网络中的位置也可以为基于采样的方式确定的。
需要理解,图13的结构仅仅是一个示例,神经网络层的数目可以根据需要而设置。嵌入层可以对输入进行嵌入处理,得到多个特征向量。transformer模型的核心特点在于其采用的独特的注意力机制。在处理自然语言,例如一个句子时,transformer模型利用该注意力机制,为句子中各个词向量赋予不同的注意力系数,从而更全面地考虑句子中上下文对各个词的影响。嵌入层可以基于当前序列中各个节点的节点特征及其位置编码,得到N个嵌入向量X l。注意力层与嵌入层相连,从嵌入层获取N个嵌入向量作为输入向量,基于N个输入向量中各个输入向量之间的关联度,对各个输入向量进行综合,得到N个输出向量,输出给后续的transformer层(或者为本申请实施例中的目标网络层)。transformer层获取前一层的输出作为输入向量,执行与前一级transformer层类似的操作。
在一种可能的实现中,可以通过算子采样的方式来构建transformer模型中的目标transformer层,具体的,可以通过算子采样的方式来构建transformer模型中目标transformer层中的目标注意力头head,其中,目标transformer层可以包括多个注意力头head,目标注意力头head可以为多个注意力头head中的任意一个,可选的,多个注意力头head中的每个注意力头head的之间的结构相同。
参照图14,图14为一种transformer层的结构示意,其中,transformer层可以包括依 次相邻的多头注意力层(或者简称为注意力层)、加和与归一化(add&norm)层、前馈层(feed forward net,FFN)、加和与归一化层。
其中,多头注意力层从其上一层获取N个输入向量X l,N个输入向量X l又可以表示为矩阵X,多头注意力层采用自注意力机制,基于向量间的关联度对各个向量进行变换,得到N个输出向量,N个输出向量又可以表示为矩阵Y。可以理解,当该多头注意力层是与嵌入层直接相连的层,例如图14中与嵌入层直连的transformer层,其获取的输入向量即为嵌入层输出的嵌入向量;当该多头注意力层是后续的transformer层包括的多头注意力层,例如图14中与上一级transformer层直连的transformer层包括的多头注意力层,其获取的输入向量即为前一级transformer层的输出向量。多头注意力层可以包括多个注意力头head(如图14中示出的Head 1、Head 2、…、Head N)。其中,目标注意力head可以为多个注意力头head中的任意一个。
接下来描述,如何通过采样的方式构建目标head:
在一种可能的实现中,参照图15,目标注意力head可以包括第一线性变换层、通过采样得到的多个算子、以及第二线性变换层。
其中,目标注意力head的输入侧可以设置为第一线性变换层,其中,该第一线性变换层用于通过目标变换矩阵对该目标注意力head的输入向量进行处理,该多个算子用于对该第一线性变换层的数据处理结果进行运算,其中该目标变换矩阵仅包括X个变换矩阵,该X为小于或等于4的正整数,且该X的数量为基于采样的方式确定的。
例如,目标变换矩阵可以仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的一种;或者,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的两种;或者,该目标变换矩阵包括Q变换矩阵、V变换矩阵以及K变换矩阵。
例如,还可以再构建一个变换矩阵(例如称之为P变换矩阵),P变换矩阵和其他变换矩阵的结构相似或完全一致,进而,目标变换矩阵可以包括Q变换矩阵、V变换矩阵、K变换矩阵以及P变换矩阵中的至少一种。
在一种可能的实现中,可以基于采样的方式,来确定该目标变换矩阵包括的变换矩阵的矩阵类型,该矩阵类型为Q变换矩阵、K变换矩阵或者V变换矩阵,或者是预先设置该目标变换矩阵包括的变换矩阵的矩阵类型,这里并不限定。当通过采样的方式来确定目标变换矩阵包括的变换矩阵的矩阵类型时,可以增加目标注意力头head的结构的可能性,进而可以搜索得到性能更好的模型。
其中,当目标变换矩阵包括Q变换矩阵时,目标注意力头head可以采用Q变换矩阵对N个输入向量<X1,X2,…,XN>中各个输入向量Xi进行变换,得到各个输入向量对应的第一中间向量(q向量),在操作上,可以用Q变换矩阵对N个输入向量构成的输入矩阵X进行线性变换,得到输入矩阵的Q矩阵,再对Q矩阵进行拆分,即可得到各个输入向量对应的q向量。
其中,当目标变换矩阵包括K变换矩阵时,目标注意力头head可以采用K变换矩阵对N个输入向量<X1,X2,…,XN>中各个输入向量Xi进行变换,得到各个输入向量对应的第一中间向量(K向量),在操作上,可以用K变换矩阵对N个输入向量构成的输入矩阵X进行线 性变换,得到输入矩阵的K矩阵,再对K矩阵进行拆分,即可得到各个输入向量对应的k向量。
其中,当目标变换矩阵包括V变换矩阵时,目标注意力头head可以采用V变换矩阵对N个输入向量<X1,X2,…,XN>中各个输入向量Xi进行变换,得到各个输入向量对应的第一中间向量(V向量),在操作上,可以用V变换矩阵对N个输入向量构成的输入矩阵X进行线性变换,得到输入矩阵的V矩阵,再对V矩阵进行拆分,即可得到各个输入向量对应的v向量。
其中,当目标变换矩阵包括P变换矩阵时,目标注意力头head可以采用P变换矩阵对N个输入向量<X1,X2,…,XN>中各个输入向量Xi进行变换,得到各个输入向量对应的第一中间向量(P向量),在操作上,可以用P变换矩阵对N个输入向量构成的输入矩阵X进行线性变换,得到输入矩阵的P矩阵,再对P矩阵进行拆分,即可得到各个输入向量对应的p向量。
在一种可能的实现中,该目标注意力head还可以包括第二线性变换层,该第二线性变换层用于对该多个算子的数据处理结果进行线性变换,以得到该目标注意力head的输出向量。
在一种可能的实现中,该目标注意力head的输入向量和该目标注意力head的输出向量的尺寸大小一致。
在一种可能的实现中,算子采样的来源可以为第一搜索空间,第一搜索空间可以包括多个候选算子,在构建注意力头head时,可以采样第一搜索空间中的多个候选算子,并对采样得到的候选算子进行组合(组合的方式也可以为采样),以得到一个候选神经网络,经过多次采样,可以得到多个候选神经网络。
接下来介绍本申请实施例中的第一搜索空间:
在一种可能的实现中,第一搜索空间中可以包括多个候选算子,该候选算子可以为一元运算符或二元运算符,其中一元运算符(unary operation)是指只对一个数据执行操作,例如负数操作(neg)、开根号操作(sqrt)、转置操作(transpose)、softmax操作、logsigmoid操作、softsign操作等等,二元运算符(binary operation)是指对两个数据进行操作得到第三个数据的一种规则,例如加和操作(add)、点乘操作(matmul)、cosine similarity操作以及euclidean distance操作。
在一种可能的实现中,该多个候选算子可以包括transformer层中原生的softmax算子以及点乘算子。
应理解,上述采样可以为随机采样,或者是采用了一些有倾向性/参考性的采样方式,并不是完全的随机,例如在采样时,可以倾向于采样和现有公知的transformer层中的head差异不大的结构。
示例性的,第一搜索空间中包含的算子类型的示例可以见表1。
表1
Figure PCTCN2022105115-appb-000002
在一种可能的实现中,可以采样第一搜索空间的候选算子来构建目标注意力head,具体的,可以从第一搜索空间中采样多个算子,以及采样多个算子之间的连接关系。也就是说,在构建目标注意力head时,目标注意力head中包括的各个算子的类型、数量以及连接关系都可以是基于采样的方式确定的,进而,可以基于采样得到的多个算子,以及采样多个算子之间的连接关系来构建目标注意力头head。
在一种可能的实现中,在一种可能的实现中,该目标注意力head包括的算子的数量小于预设值,例如预设值可以为10、11、12、14、15、20、21等等。
在一种可能的实现中,可以通过上述方式构建目标transformer层中的目标head,且在一种可能的实现中的每个head都可以采用相同的结构,候选神经网络中的至少一个transformer层可以采用和上述构建目标transformer层相同的方式来构建。
参照图16至图21,图16至21为通过采样的方式得到的目标注意力头head的结构示意。
本申请实施例结合模型搜索,可以生成相比原自注意力机制更强的新型注意力结构,在广泛的下游任务中取得明显效果提升。
在一种可能的实现中,可以通过采样或者固定设置的方式,确定候选神经网络中的网络层的类型为包括卷积层的目标网络层,并通过从第二搜索空间中进行采样的方式来确定目标网络层中卷积层中卷积核的大小。
在一种可能的实现中,由于轻量化卷积lightweight convolution在一系列自然语言理解任务上(如机器翻译)取得较好表现,卷积核可以使用lightweight convolution架构,来提升模型的性能。
其中,第二搜索空间可以包括多个尺寸的卷积核,卷积核的选择空间可以但不限于为[3,5,7,9,15,31,65]。
参照图23,目标网络层可以包括卷积层,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。也就是说,可以将现有的transformer层中的加和与归一化层、FFN以及残差连接的架构保留,而将注意力头head替换为卷积层,进而可以得到本申请实施例中的目标网络 层,其中替换的卷积层类型可以通过从第二搜索空间中进行卷积核采样的方式得到。
示例性的,可以参照图22,图22为一个候选神经网络的结构示意,其中,候选神经网络可以包括12个网络层,12个网络层中transformer层和目标网络层依次交替并串联,参照图23,图23为本申请实施例中的一种目标网络层的结构示意,其中,目标网络层可以包括卷积层、两个加和与归一化层(即上述第一加和与归一化层和第二加和与归一化层)、前馈层FFN,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
本申请实施例中,设计了多样化的搜索空间,同时包含局部(卷积层中的卷积核)和全局算子(transformer层中的算子)。其中,全局算子能够结合数学基础运算符构造新型注意力机制,局部算子包含多种不同大小的卷积核。通过全局算子与局部算子的结合,能够更有效的捕捉到词与词,句子与句子之间的关联关系,提高搜索得到的模型的性能。此外,本申请实施例中的神经网络模型可以作为预训练模型,且适配于多种下游任务。
在一种可能的实现中,可以通过采样可以构建多个候选神经网络,为了能够选取性能较好的模型,候选神经网络的采样数量很多,可以通过训练来确定多个候选神经网络的性能,并基于多个候选神经网络的性能,从多个候选神经网络中初步选取一定数量的网络作为父网络,之后可以对父网络进行算子的替换(若是transformer层,则是进行注意力头head中的算子的替换,若是目标网络层,则可以进行卷积核的替换),得到多个子网络,并对多个子网络进行训练来确定多个子网络的性能,并基于多个子网络的性能,从多个子网络中确定目标神经网络,作为神经网络的搜索结果。
其中,上述初始构建的候选神经网络可以称之为第二神经网络,父网络可以称之为第一神经网络,子网络可以称之为候选神经网络。
本申请实施例中,该多个候选神经网络包括目标候选神经网络,接下来以确定目标候选神经网络为例进行说明:
本申请实施例中,可以通过采样的方式获取多个第二神经网络(具体可以参照上述实施例中采样得到候选神经网络的描述,这里不再赘述),并对该多个第二神经网络进行训练,以得到多个训练后的第二神经网络以及该多个训练后的第二神经网络的性能,具体的,可以对多个第二神经网络的进行随机参数初始化,并对多个第二神经网络进行快速搜索训练(例如通过4w步训练),以得到多个训练后的第二神经网络,并利用GLUE任务对多个训练后的第二神经网络进行测评,以得到多个第二神经网络的性能,选择最优的N个网络作为父网络,并将父网络的训练参数进行保存。其中,N个父网络可以包括第一神经网络。其中,该第一神经网络可以包括第一transformer层,该第一transformer层包括第一注意力head,且该第一注意力head包括目标算子,之后可以根据该第一搜索空间中的M个候选算子替换该第一注意力head中的该目标算子时,对该第一神经网络性能的正向影响,从该M个候选算子中确定替换算子,并将该第一注意力head中的该目标算子替换为该替换算子,以得到该目标注意力head。
以该目标算子为例,目标算子可以位于该第二神经网络的目标算子位置,其中,目标 算子位置可以在一定程度上表示出距离head的输入的位置,目标算子位置可以与代码上表示网络算子之间的位置方式有关,在计算正向影响时,各个算子在第二神经网络的位置的计算方式与目标算子在第二神经网络的目标算子位置的计算方式一致,都可以表达出算子位于注意力头head的不同位置对于模型性能正向影响的程度。在计算正向影响时,可以根据每个该多个训练后的第二神经网络中位于该目标算子位置的算子以及该多个训练后的第二神经网络的性能,和/或,每个该训练后的第二神经网络中位于该目标算子位置的算子的出现频次,来确定该第一搜索空间中的M个候选算子替换该第一注意力head中的该目标算子时,对该第一神经网络性能的正向影响。
示例性的,正向影响可以通过置信区间上界UCB(upper confidence bound)来表示,具体的UCB分数计算方式可以为:
Figure PCTCN2022105115-appb-000003
其中,μ i表示算子i在这个网络结构当前位置中获得的分数,N i表示算子i在历史上(采样第二神经网络时)被采样的次数,N表示所有算子被采样的次数。当某个算子很少被采样时,公式右半部分的会获得较大数值,以更大概率选择当前算子。应理解,在每个位置的每个算子的UCB分数计算完后,可以会对这些分数做softmax计算,获得一个概率分布。并将该概率设为在当前位置算子i被激活的概率。
本申请实施例利用正向影响来进行算子替换,能够均衡算法的搜索精度和搜索广度,能够避免陷入局部最优,持续搜索到更优的网络架构。
在对第一神经网路进行算子替换之后,可以得到目标候选神经网络,在对目标候选神经网络进行训练时,可以根据该第一神经网络,对该目标候选神经网络进行参数初始化,以得到初始化后的该目标候选神经网络;其中,该初始化后的该目标候选神经网络中的可更新参数为对该第一神经网络中相同的位置的可更新参数进行参数共享得到的,进而可以对进行参数初始化的该目标候选神经网络进行训练,以得到该目标候选神经网络的性能。
其中,在进行注意力头head的参数共享时,可更新参数为注意力头head中变换矩阵中的参数,参照图24,可以对左侧的注意力头head的变换矩阵中的参数进行参数共享(或者称之为参数继承),来进行右侧的注意力头head的参数初始化。
其中,在进行卷积层的参数共享时,可更新参数为卷积核,参照图25,可以对左侧的卷积核(65*1)进行参数共享,来进行右侧的卷积核(5*1)的参数初始化,类似的,可以对左侧的卷积核(65*1)进行参数共享,来进行右侧的卷积核(3*1)的参数初始化。应理解,可以选择卷积核最中心位置的相应参数进行参数共享。
本申请实施例中,通过参数共享的方式进行参数初始化,可以加快搜索速度,避免重复训练,极大加速搜索效率。
1202、基于该多个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络。
本申请实施例中,在得到多个候选神经网络之后,可以对多个神经网络进行训练,以得每个候选神经网络的性能,进而可以基于每个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络,其中目标神经网络的数量为至少一个,当目标神经网络的数量 为一个时,该目标神经网络可以为多个候选神经网络中性能最好的模型,当目标神经网络的数量为多个时,该目标神经网络可以为多个候选神经网络中性能最好的多个模型。
应理解,在训练之后还可以进行模型的测试,示例性的,可以对搜索出来的模型进行全量训练fully-train,并在自然语言理解数据集GLUE和自动问答数据集squad数据集上进行测试。
本申请实施例提供神经网络搜索算法在极大程度上提升了搜索算法的表现,通过本申请实施例提出神经网络搜索算法搜索得到的结果相较Random search(RS)和Evolution Algorithm(EA)有明显提升,具体可以如下表2所示:
表2
Figure PCTCN2022105115-appb-000004
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
图26示出了基于本申请实施例提供神经网络搜索算法得到的网络架构搜索结果。该网络架构为包括12个的子模块的transformer的结构,每个模块选取了各自适合的卷积和注意力机制的组合结构,其中第2、4、6、8、10、12层为新型注意力架构,由一系列基本算子构成,其中第1,3,5,7,9,11层为卷积模块(也就是本申请实施例中描述的目标网络层),卷积核的大小不同,由所在层数的需要的感受野决定。该注意力机制的复杂度从浅层到高层逐渐递增,而搜索出来的卷积核的核长也随着层数的变深呈增长趋势。该预训练网络架构在一系列下游任务中相较当前其余模型取得更优表现。
接下来以在自然语言理解任务GLUE和自动问答任务SquAD上为例描述本申请实施例中的神经网络搜索方法的效果。
其中,预训练数据可以包含通用语言理解评估(General Language Understanding Evaluation,GLUE)任务集。MNLI(Multi-Genre Natural Language Inference)任务集。QQP(Quora Question Pairs)任务集。QNLI(Question Natural Language Inference)。SST-2(Standford Sentiment Treebank)任务集。CoLA(Corpus of Linguistic Acceptability)任务集。STS-B(Semantic Textual Similarity Benchmark)任务集。MRPC(Microsoft Research Paraphrase Corpus)任务集。RTE(Recognizing Textual Entailment)任务集。
在这个8个数据集上的结果可以看出,在公开数据集GLUE上,通过本申请实施例搜索得到的模型,在速度与检测精度上均大幅度优于目前已有的SOTA手工设计模型(BERT-base、T5-base等)。相较依赖于巨大参数量teacher model的自动搜索算法AdaBERT和DynaBERT,本方法不依赖于任何teacher model,且搜索到的模型架构在大部分任务上也取得更优结果,具体可以如表3所示。在自动问答数据集SQuAD上,本本申请实施例搜索得到的模型表现也相较BERT-base有明显提升,具体可以如表4所示。
表3
Figure PCTCN2022105115-appb-000005
表4
Figure PCTCN2022105115-appb-000006
本申请实施例提供了一种神经网络搜索方法,该方法包括:获取多个候选神经网络;其中,该多个候选神经网络中的至少一个候选神经网络包括目标transformer层,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;基于该多个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络。通过上述方式,结合模型搜索,能生成相比原自注意力机制更强的新型注意力结构,在广泛的下游任务中取得明显效果提升。
参照图27,图27为本申请实施例提供的一种模型提供方法的实施例示意,本申请实施例提供的一种模型提供方法可以应用在云侧服务器上,如图27示出的那样,本申请实施例提供的一种模型提供方法包括:
2701、接收端侧发送的性能要求,该性能要求用于指示神经网络的性能要求。
在一种可能的实现中,该性能要求包括如下的至少一种:数据处理精度、模型大小以及实现的任务类型。
本申请实施例中,终端设备可以向云侧服务器发送该终端设备的性能要求。
具体的,终端设备可以向云侧服务器发送性能要求,其中,性能要求包括且不限于精度要求、时延要求以及实现的任务类型中的至少一种,进而云侧服务器可以获取到性能要求。
2702、根据所述性能要求,从多个候选神经网络中获取满足所述性能要求的目标神经网络,目标神经网络包括目标transformer层,目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的。
在一种可能的实现中,云侧服务器可以根据该性能要求,进行神经网络搜索,以搜索得到满足该性能要求的目标神经网络,关于步骤2702的具体描述可以参数上述实施例中图12对应的实施例中的描述,这里不再赘述。
2703、向该端侧发送该目标神经网络。
云侧服务器在得到目标神经网络之后,可以将目标神经网络传回用户设备,进而用户设备可以使用云侧返回的模型(目标神经网络)进行推理,在进行模型推理时,可以获取 到待处理数据,并利用目标神经网络对待处理数据进行处理,以得到处理结果。
在一种可能的实现中,可以获取多个候选神经网络;其中,该多个候选神经网络中的至少一个候选神经网络包括目标transformer层,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,且该多个算子为从第一搜索空间中采样得到的;根据该性能要求,从该多个候选神经网络中获取满足该性能要求的目标神经网络。
在一种可能的实现中,该第一搜索空间包括多个候选算子,该候选算子为一元运算符或二元运算符;该目标注意力head为基于该多个算子以及该多个算子之间的排列关系构建的,该多个算子之间的排列关系为基于采样的方式确定的。
在一种可能的实现中,该目标注意力head还包括第一线性变换层,该第一线性变换层用于通过目标变换矩阵对该目标注意力head的输入向量进行处理,该多个算子用于对该第一线性变换层的数据处理结果进行运算;其中,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的一种;或者,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的两种;或者,该目标变换矩阵包括Q变换矩阵、V变换矩阵以及K变换矩阵。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层,该目标transformer层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层以及卷积层,该卷积层中的卷积核为从第二搜索空间中采样得到的,该第二搜索空间包括多个尺寸的卷积核。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
参照图28,图28为本申请实施例提供的一种神经网络搜索方法的实施例示意,本申请实施例提供的神经网络搜索方法可以应用在训练设备中,训练设备可以为手机、平板、笔记本电脑、智能穿戴设备等终端设备,训练设备也可以为云侧服务器,如图28示出的那样,本申请实施例提供的一种神经网络搜索方法可以包括:
2801、获取多个候选神经网络;其中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括目标transformer层以及目标网络层,该目标网络层包括卷积层,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
2802、基于该多个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络。
步骤2801以及步骤2802的描述可以参照上述实施例中关于目标网络层的描述,这里不再赘述。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层 的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
参照图29,图29为本申请实施例提供的一种模型提供方法的实施例示意,本申请实施例提供的模型提供方法可以应用在云侧服务器上,如图29示出的那样,本申请实施例提供的一种模型提供方法包括:
2901、接收端侧发送的性能要求,该性能要求用于指示神经网络的性能要求。
本申请实施例中,终端设备可以向云侧服务器发送该终端设备的性能要求。
具体的,终端设备可以向云侧服务器发送性能要求,其中,性能要求包括且不限于精度要求、时延要求以及实现的任务类型中的至少一种,进而云侧服务器可以获取到性能要求。
2902、根据所述性能要求,从多个候选神经网络中获取满足所述性能要求的目标神经网络,其中,该目标神经网络包括目标transformer层以及目标网络层,该目标网络层包括卷积层,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
在一种可能的实现中,云侧服务器可以根据该性能要求,进行神经网络搜索,以搜索得到满足该性能要求的目标神经网络,关于步骤2702的具体描述可以参数上述实施例中图28对应的实施例中的描述,这里不再赘述。
2903、向该端侧发送该目标神经网络。
云侧服务器在得到目标神经网络之后,可以将目标神经网络传回用户设备,进而用户设备可以使用云侧返回的模型(目标神经网络)进行推理,在进行模型推理时,可以获取到待处理数据,并利用目标神经网络对待处理数据进行处理,以得到处理结果。
在一种可能的实现中,可以获取多个候选神经网络;根据该性能要求,从该多个候选神经网络中获取满足该性能要求的目标神经网络。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
参照图30,图30为本申请实施例提供的一种神经网络搜索装置的实施例示意,如图30示出的那样,本申请实施例提供的神经网络搜索装置3000可以包括:
获取模块3001,用于获取多个候选神经网络;其中,该多个候选神经网络中的至少一个候选神经网络包括目标transformer层,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的。
关于获取模块3001的描述可以参照上述实施例中步骤1201的描述,这里不再赘述。
模型选择模块3002,用于基于该多个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络。
关于模型选择模块3002的描述可以参照上述实施例中步骤1202的描述,这里不再赘述。
在一种可能的实现中,该第一搜索空间包括多个候选算子,该候选算子为一元运算符或二元运算符。其中一元运算符(unary operation)是指只对一个数据执行操作,例如负数操作(neg)、开根号操作(sqrt)、转置操作(transpose)、softmax操作、logsigmoid操作、softsign操作等等,二元运算符(binary operation)是指对两个数据进行操作得到第三个数据的一种规则,例如加和操作(add)、点乘操作(matmul)、cosine similarity操作以及euclidean distance操作。
在一种可能的实现中,该多个候选算子包括softmax算子以及点乘算子。
在一种可能的实现中,可以采样第一搜索空间的候选算子来构建目标注意力head,具体的,可以从第一搜索空间中采样多个算子,以及采样多个算子之间的连接关系。也就是说,在构建目标注意力head时,目标注意力head中包括的各个算子的类型、数量以及连接关系都可以是基于采样的方式确定的,进而,可以基于采样得到的多个算子,以及采样多个算子之间的连接关系来构建目标注意力头head。
在一种可能的实现中,该目标注意力head还包括第一线性变换层,该第一线性变换层用于通过目标变换矩阵对该目标注意力head的输入向量进行处理,该多个算子用于对该第一线性变换层的数据处理结果进行运算。
在一种可能的实现中,该目标变换矩阵仅包括X个变换矩阵,该X为小于或等于4的正整数,且该X的数量为基于采样的方式确定的。
例如,目标变换矩阵可以仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的一种;或者,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的两种;或者,该目标变换矩阵包括Q变换矩阵、V变换矩阵以及K变换矩阵。
例如,还可以再构建一个变换矩阵(例如称之为P变换矩阵),P变换矩阵和其他变换矩阵的结构相似或完全一致,进而,目标变换矩阵可以包括Q变换矩阵、V变换矩阵、K变换矩阵以及P变换矩阵中的至少一种。
在一种可能的实现中,该目标注意力head还包括第二线性变换层,该第二线性变换层用于对该多个算子的数据处理结果进行线性变换,以得到该目标注意力head的输出向量。
在一种可能的实现中,该目标注意力head的输入向量和该目标注意力head的输出向 量的尺寸大小一致。
在一种可能的实现中,该目标注意力head包括的算子的数量小于预设值。
在一种可能的实现中,可以通过算子采样的方式来构建transformer模型中的目标transformer层,具体的,可以通过算子采样的方式来构建transformer模型中目标transformer层中的目标注意力头head,其中,目标transformer层可以包括多个注意力头head,目标注意力头head可以为多个注意力头head中的任意一个,可选的,多个注意力头head中的每个注意力头head的之间的结构相同。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层,该目标transformer层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层以及目标网络层,该目标网络层包括卷积层。其中,该卷积层中的卷积核可以为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
在一种可能的实现中,可以通过采样或者固定设置的方式,确定候选神经网络中的网络层的类型为包括卷积层的目标网络层,并通过从第二搜索空间中进行采样的方式来确定目标网络层中卷积层中卷积核的大小。
本申请实施例中,设计了多样化的搜索空间,同时包含局部(卷积层中的卷积核)和全局算子(transformer层中的算子)。其中,全局算子能够结合数学基础运算符构造新型注意力机制,局部算子包含多种不同大小的卷积核。通过全局算子与局部算子的结合,能够更有效的捕捉到词与词,句子与句子之间的关联关系,提高搜索得到的模型的性能。此外,本申请实施例中的神经网络模型可以作为预训练模型,且适配于多种下游任务。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。也就是说,可以将现有的transformer层中的加和与归一化层、FFN以及残差连接的架构保留,而将注意力头head替换为卷积层,进而可以得到本申请实施例中的目标网络层,其中替换的卷积层类型可以通过从第二搜索空间中进行卷积核采样的方式得到。
在一种可能的实现中,该多个候选神经网络包括目标候选神经网络;该获取模块3001,具体用于:构建该目标候选神经网络中的目标注意力head;
该构建该目标候选神经网络中的目标注意力head,包括:
获取第一神经网络,其中,该第一神经网络包括第一transformer层,该第一transformer层包括第一注意力head,该第一注意力head包括的多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
根据该第一搜索空间中的M个候选算子替换该第一注意力head中的该目标算子时, 对该第一神经网络性能的正向影响,从该M个候选算子中确定替换算子,并将该第一注意力head中的该目标算子替换为该替换算子,以得到该目标注意力head。
在一种可能的实现中,该获取模块3001,具体用于:
获取多个第二神经网络,并对该多个第二神经网络进行训练,以得到多个训练后的第二神经网络以及该多个训练后的第二神经网络的性能;
根据该多个训练后的第二神经网络的性能,从该多个训练后的第二神经网络中选择性能满足预设要求的N个训练后的第二神经网络,该N个训练后的第二神经网络包括该第一神经网络。
在一种可能的实现中,该目标算子位于该第二神经网络的目标算子位置;该装置还包括:
确定模块,用于根据每个该多个训练后的第二神经网络中位于该目标算子位置的算子以及该多个训练后的第二神经网络的性能,和/或,每个该训练后的第二神经网络中位于该目标算子位置的算子的出现频次,确定该第一搜索空间中的M个候选算子替换该第一注意力head中的该目标算子时,对该第一神经网络性能的正向影响。
在一种可能的实现中,该装置还包括:
参数初始化模块,用于根据该第一神经网络,对该目标候选神经网络进行参数初始化,以得到初始化后的该目标候选神经网络;其中,该初始化后的该目标候选神经网络中的可更新参数为对该第一神经网络中相同的位置的可更新参数进行参数共享得到的;
模型训练模块,用于对进行参数初始化的该目标候选神经网络进行训练,以得到该目标候选神经网络的性能。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
参照图31,图31为本申请实施例提供的一种模型提供装置的实施例示意,如图31示出的那样,本申请实施例提供的模型提供装置3100可以包括:
接收模块3101,用于接收端侧发送的性能要求,该性能要求用于指示神经网络的性能要求;
关于接收模块3101的描述可以参照上述实施例中步骤2701的描述,这里不再赘述。
获取模块3102,用于根据所述性能要求,从多个候选神经网络中获取满足所述性能要求的目标神经网络,其中,该目标神经网络包括目标transformer层,该目标transformer层包括目标注意力头head,该目标注意力head包括多个算子,且该多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
关于获取模块3102的描述可以参照上述实施例中步骤2702的描述,这里不再赘述。
发送模块3103,用于向该端侧发送该目标神经网络。
关于发送模块3103的描述可以参照上述实施例中步骤2703的描述,这里不再赘述。
在一种可能的实现中,该性能要求可以包括如下的至少一种:数据处理精度、模型大 小以及实现的任务类型。
在一种可能的实现中,该获取模块3102,具体用于:
获取多个候选神经网络;
根据该性能要求,从该多个候选神经网络中获取满足该性能要求的目标神经网络。
在一种可能的实现中,该第一搜索空间包括多个候选算子,该候选算子为一元运算符或二元运算符;该目标注意力head为基于该多个算子以及该多个算子之间的排列关系构建的,该多个算子之间的排列关系为基于采样的方式确定的。
在一种可能的实现中,该目标注意力head还包括第一线性变换层,该第一线性变换层用于通过目标变换矩阵对该目标注意力head的输入向量进行处理,该多个算子用于对该第一线性变换层的数据处理结果进行运算;其中,该目标变换矩阵仅包括X个变换矩阵,该X为小于或等于4的正整数,且该X的数量为基于采样的方式确定的。
例如,目标变换矩阵可以仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的一种;或者,该目标变换矩阵仅包括Q变换矩阵、V变换矩阵以及K变换矩阵中的两种;或者,该目标变换矩阵包括Q变换矩阵、V变换矩阵以及K变换矩阵。
例如,还可以再构建一个变换矩阵(例如称之为P变换矩阵),P变换矩阵和其他变换矩阵的结构相似或完全一致,进而,目标变换矩阵可以包括Q变换矩阵、V变换矩阵、K变换矩阵以及P变换矩阵中的至少一种。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层,该目标transformer层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括该目标transformer层以及目标网络层,该目标网络层包括卷积层。
在一种可能的实现中,该目标网络层在该多个网络层中的位置为基于采样的方式确定的。
在一种可能的实现中,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
参照图32,图32为本申请实施例提供的一种神经网络搜索装置的实施例示意,如图32示出的那样,本申请实施例提供的神经网络搜索装置3200可以包括:
获取模块3201,用于获取多个候选神经网络;其中,该至少一个候选神经网络包括串联连接的多个网络层,该多个网络层包括目标transformer层以及目标网络层,该目标网络层包括卷积层,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的;
关于获取模块3201的描述可以参照上述实施例中步骤2801的描述,这里不再赘述。
模型选择模块3202,用于基于该多个候选神经网络的性能,从该多个候选神经网络中选择目标神经网络。
关于模型选择模块3202的描述可以参照上述实施例中步骤2802的描述,这里不再赘述。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
参照图33,图33为本申请实施例提供的一种模型提供装置的实施例示意,如图33示出的那样,本申请实施例提供的模型提供装置3300可以包括:
接收模块3301,用于接收端侧发送的性能要求,该性能要求用于指示神经网络的性能要求,该性能要求包括如下的至少一种:数据处理精度、模型大小以及实现的任务类型;
关于接收模块3301的描述可以参照上述实施例中步骤2901的描述,这里不再赘述。
获取模块3302,用于根据所述性能要求,从多个候选神经网络中获取满足所述性能要求的目标神经网络,其中,该目标神经网络包括目标transformer层以及目标网络层,该目标网络层包括卷积层,该卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的;
关于获取模块3302的描述可以参照上述实施例中步骤2902的描述,这里不再赘述。
发送模块3303,用于向该端侧发送该目标神经网络。
关于发送模块3303的描述可以参照上述实施例中步骤2903的描述,这里不再赘述。
在一种可能的实现中,该获取模块3302,具体用于:
获取多个候选神经网络;
根据该性能要求,从该多个候选神经网络中获取满足该性能要求的目标神经网络。
在一种可能的实现中,该卷积层中的卷积核的类型为轻量卷积(hightweight convolution)。
在一种可能的实现中,该目标网络层还包括第一加和与归一化层、前馈层FFN、第二加和与归一化层,该第一加和与归一化层用于处理该目标网络层的输入向量以及该卷积层的输出向量,该前馈层FFN用于处理该第一加和与归一化层的输出向量,该第二加和与归一化层用于处理该第一加和与归一化层的输出向量以及该前馈层FFN的输出向量。
在一种可能的实现中,该目标神经网络用于实现如下任务类型的至少一种:
阅读理解、文本翻译、复述识别、命名实体识别、文本情感分析、自然语言推理、文本自动问答、文本意图识别、文本分类、文本简化或者文本故事生成。
接下来介绍本申请实施例提供的一种执行设备,请参阅图34,图34为本申请实施例提供的执行设备的一种结构示意图,执行设备3400具体可以表现为虚拟现实VR设备、手机、平板、笔记本电脑、智能穿戴设备、监控数据处理设备或服务器等,此处不做限定。具体的,执行设备3400包括:接收器3401、发射器3402、处理器3403和存储器3404(其中执行设备3400中的处理器3403的数量可以一个或多个,图34中以一个处理器为例),其中,处理器3403可以包括应用处理器34031和通信处理器34032。在本申请的一些实施例中,接收器3401、发射器3402、处理器3403和存储器3404可通过总线或其它方式连接。
存储器3404可以包括只读存储器和随机存取存储器,并向处理器3403提供指令和数据。存储器3404的一部分还可以包括非易失性随机存取存储器(non-volatile random access memory,NVRAM)。存储器3404存储有处理器和操作指令、可执行模块或者数据结构,或者它们的子集,或者它们的扩展集,其中,操作指令可包括各种操作指令,用于实现各种操作。
处理器3403控制执行设备的操作。具体的应用中,执行设备的各个组件通过总线系统耦合在一起,其中总线系统除包括数据总线之外,还可以包括电源总线、控制总线和状态信号总线等。但是为了清楚说明起见,在图中将各种总线都称为总线系统。
上述本申请实施例揭示的方法可以应用于处理器3403中,或者由处理器3403实现。处理器3403可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器3403中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器3403可以是通用处理器、数字信号处理器(digital signal processing,DSP)、微处理器或微控制器,还可进一步包括专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。该处理器3403可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器3404,处理器3403读取存储器3404中的信息,结合其硬件完成上述方法的步骤。
接收器3401可用于接收输入的数字或字符信息,以及产生与执行设备的相关设置以及功能控制有关的信号输入。发射器3402可用于输出数字或字符信息;发射器3402还可用于向磁盘组发送指令,以修改磁盘组中的数据。
本申请实施例中,在一种情况下,处理器3403,用于执行上述实施例中执行设备执行的数据处理方法(例如通过目标神经网络的进行模型推理的步骤)。
本申请实施例还提供了一种训练设备,请参阅图35,图35是本申请实施例提供的训练设备一种结构示意图,训练设备3500上可以部署有图30、图31、图32以及图33对应实施例中所描述的装置,具体的,训练设备3500由一个或多个服务器实现,训练设备3500 可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上中央处理器(central processing units,CPU)3535(例如,一个或一个以上处理器)和存储器3532,一个或一个以上存储应用程序3542或数据3544的存储介质3530(例如一个或一个以上海量存储设备)。其中,存储器3532和存储介质3530可以是短暂存储或持久存储。存储在存储介质3530的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对训练设备中的一系列指令操作。更进一步地,中央处理器3535可以设置为与存储介质3530通信,在训练设备3500上执行存储介质3530中的一系列指令操作。
训练设备3500还可以包括一个或一个以上电源3526,一个或一个以上有线或无线网络接口3550,一个或一个以上输入输出接口3558;或,一个或一个以上操作系统3541,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM等等。
本申请实施例中,中央处理器3535,用于执行图12、图27、图28以及图29对应实施例中的方法。
本申请实施例中还提供一种包括计算机程序产品,当其在计算机上运行时,使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。
本申请实施例中还提供一种计算机可读存储介质,该计算机可读存储介质中存储有用于进行信号处理的程序,当其在计算机上运行时,使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。
本申请实施例提供的执行设备、训练设备或终端设备具体可以为芯片,芯片包括:处理单元和通信单元,该处理单元例如可以是处理器,该通信单元例如可以是输入/输出接口、管脚或电路等。该处理单元可执行存储单元存储的计算机执行指令,以使执行设备内的芯片执行上述实施例描述的数据处理方法,或者,以使训练设备内的芯片执行上述实施例描述的数据处理方法。可选地,该存储单元为该芯片内的存储单元,如寄存器、缓存等,该存储单元还可以是该无线接入设备端内的位于该芯片外部的存储单元,如只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)等。
具体的,请参阅图36,图36为本申请实施例提供的芯片的一种结构示意图,该芯片可以表现为神经网络处理器NPU 3600,NPU 3600作为协处理器挂载到主CPU(Host CPU)上,由Host CPU分配任务。NPU的核心部分为运算电路3603,通过控制器3604控制运算电路3603提取存储器中的矩阵数据并进行乘法运算。
在一些实现中,运算电路3603内部包括多个处理单元(Process Engine,PE)。在一些实现中,运算电路3603是二维脉动阵列。运算电路3603还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路3603是通用的矩阵处理器。
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器3602 中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器3601中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)3608中。
统一存储器3606用于存放输入数据以及输出数据。权重数据直接通过存储单元访问控制器(Direct Memory Access Controller,DMAC)3605,DMAC被搬运到权重存储器3602中。输入数据也通过DMAC被搬运到统一存储器3606中。
BIU为Bus Interface Unit即,总线接口单元3610,用于AXI总线与DMAC和取指存储器(Instruction Fetch Buffer,IFB)3609的交互。
总线接口单元3610(Bus Interface Unit,简称BIU),用于取指存储器3609从外部存储器获取指令,还用于存储单元访问控制器3605从外部存储器获取输入矩阵A或者权重矩阵B的原数据。
DMAC主要用于将外部存储器DDR中的输入数据搬运到统一存储器3606或将权重数据搬运到权重存储器3602中或将输入数据数据搬运到输入存储器3601中。
向量计算单元3607包括多个运算处理单元,在需要的情况下,对运算电路的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。主要用于神经网络中非卷积/全连接层网络计算,如Batch Normalization(批归一化),像素级求和,对特征平面进行上采样等。
在一些实现中,向量计算单元3607能将经处理的输出的向量存储到统一存储器3606。例如,向量计算单元3607可以将线性函数;或,非线性函数应用到运算电路3603的输出,例如对卷积层提取的特征平面进行线性插值,再例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元3607生成归一化的值、像素级求和的值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路3603的激活输入,例如用于在神经网络中的后续层中的使用。
控制器3604连接的取指存储器(instruction fetch buffer)3609,用于存储控制器3604使用的指令;
统一存储器3606,输入存储器3601,权重存储器3602以及取指存储器3609均为On-Chip存储器。外部存储器私有于该NPU硬件架构。
其中,上述任一处提到的处理器,可以是一个通用中央处理器,微处理器,ASIC,或一个或多个用于控制上述程序执行的集成电路。
另外需说明的是,以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本申请提供的装置实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、 专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。但是,对本申请而言更多情况下软件程序实现是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘、U盘、移动硬盘、ROM、RAM、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,训练设备,或者网络设备等)执行本申请各个实施例所述的方法。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、训练设备或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、训练设备或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的训练设备、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。

Claims (33)

  1. 一种神经网络搜索方法,其特征在于,所述方法包括:
    获取多个候选神经网络;其中,所述多个候选神经网络中的至少一个候选神经网络包括目标transformer层,所述目标transformer层包括目标注意力头head,所述目标注意力head包括多个算子,且所述多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
    基于所述多个候选神经网络的性能,从所述多个候选神经网络中选择目标神经网络。
  2. 根据权利要求1所述的方法,其特征在于,所述目标注意力head为基于所述多个算子以及所述多个算子之间的排列关系构建的,所述多个算子之间的排列关系为基于采样的方式确定的。
  3. 根据权利要求1或2所述的方法,其特征在于,所述目标注意力head还包括第一线性变换层,所述第一线性变换层用于通过目标变换矩阵对所述目标注意力head的输入向量进行处理,所述多个算子用于对所述第一线性变换层的数据处理结果进行运算。
  4. 根据权利要求3所述的方法,其特征在于,所述目标变换矩阵仅包括X个变换矩阵,所述X为小于或等于4的正整数,且所述X的数量为基于采样的方式确定的。
  5. 根据权利要求1至4任一所述的方法,其特征在于,所述目标注意力head的输入向量和所述目标注意力head的输出向量的尺寸大小一致。
  6. 根据权利要求1至5任一所述的方法,其特征在于,所述目标注意力head包括的算子的数量小于预设值。
  7. 根据权利要求1至6任一所述的方法,其特征在于,所述至少一个候选神经网络包括串联连接的多个网络层,所述多个网络层包括所述目标transformer层,所述目标transformer层在所述多个网络层中的位置为基于采样的方式确定的。
  8. 根据权利要求1至7任一所述的方法,其特征在于,所述至少一个候选神经网络包括串联连接的多个网络层,所述多个网络层包括所述目标transformer层以及目标网络层,所述目标网络层包括卷积层。
  9. 根据权利要求8所述的方法,其特征在于,所述目标网络层在所述多个网络层中的位置为基于采样的方式确定的。
  10. 根据权利要求8或9所述的方法,其特征在于,所述卷积层中的卷积核为对第二搜 索空间中包括的多个尺寸的卷积核进行采样得到的。
  11. 根据权利要求1至10任一所述的方法,其特征在于,所述多个候选神经网络包括目标候选神经网络;所述获取多个候选神经网络,具体包括:构建所述目标候选神经网络中的目标注意力head;
    所述构建所述目标候选神经网络中的目标注意力head,包括:
    获取第一神经网络,其中,所述第一神经网络包括第一transformer层,所述第一transformer层包括第一注意力head,所述第一注意力head包括的多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
    根据所述第一搜索空间中的M个候选算子替换所述第一注意力head中的目标算子时,对所述第一神经网络性能的正向影响,从所述M个候选算子中确定替换算子,并将所述第一注意力head中的所述目标算子替换为所述替换算子,以得到所述目标注意力head,所述M为正整数。
  12. 根据权利要求11所述的方法,其特征在于,所述目标算子位于所述第二神经网络的目标算子位置;所述方法还包括:
    根据每个所述多个训练后的第二神经网络中位于所述目标算子位置的算子以及所述多个训练后的第二神经网络的性能,和/或,每个所述训练后的第二神经网络中位于所述目标算子位置的算子的出现频次,确定所述第一搜索空间中的M个候选算子替换所述第一注意力head中的所述目标算子时,对所述第一神经网络性能的正向影响。
  13. 根据权利要求11或12所述的方法,其特征在于,所述方法还包括:
    根据所述第一神经网络,对所述目标候选神经网络进行参数初始化,以得到初始化后的所述目标候选神经网络;其中,所述初始化后的所述目标候选神经网络中的可更新参数为对所述第一神经网络中相同的位置的可更新参数进行参数共享得到的;
    对进行参数初始化的所述目标候选神经网络进行训练,以得到所述目标候选神经网络的性能。
  14. 一种模型提供方法,其特征在于,所述方法包括:
    接收端侧发送的性能要求,所述性能要求用于指示神经网络的性能要求;
    根据所述性能要求,从多个候选神经网络中获取满足所述性能要求的目标神经网络,其中,所述多个候选神经网络中的至少一个候选神经网络包括目标transformer层,所述目标transformer层包括目标注意力头head,所述目标注意力head包括多个算子,且所述多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
    向所述端侧发送所述目标神经网络。
  15. 根据权利要求14所述的方法,在一种可能的实现中,所述性能要求包括如下的至少 一种:数据处理精度、模型大小以及实现的任务类型。
  16. 根据权利要求14或15所述的方法,其特征在于,所述目标注意力head为基于所述多个算子以及所述多个算子之间的排列关系构建的,所述多个算子之间的排列关系为基于采样的方式确定的。
  17. 根据权利要求14至16任一所述的方法,其特征在于,所述目标注意力head还包括第一线性变换层,所述第一线性变换层用于通过目标变换矩阵对所述目标注意力head的输入向量进行处理,所述多个算子用于对所述第一线性变换层的数据处理结果进行运算;其中,所述目标变换矩阵仅包括X个变换矩阵,所述X为小于或等于4的正整数,且所述X的数量为基于采样的方式确定的。
  18. 根据权利要求14至17任一所述的方法,其特征在于,所述至少一个候选神经网络包括串联连接的多个网络层,所述多个网络层包括所述目标transformer层,所述目标transformer层在所述多个网络层中的位置为基于采样的方式确定的。
  19. 根据权利要求14至18任一所述的方法,其特征在于,所述至少一个候选神经网络包括串联连接的多个网络层,所述多个网络层包括所述目标transformer层以及目标网络层,所述目标网络层包括卷积层。
  20. 根据权利要求19所述的方法,其特征在于,所述目标网络层在所述多个网络层中的位置为基于采样的方式确定的。
  21. 根据权利要求19或20所述的方法,其特征在于,所述卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
  22. 一种神经网络搜索装置,其特征在于,所述装置包括:
    获取模块,用于获取多个候选神经网络;其中,所述多个候选神经网络中的至少一个候选神经网络包括目标transformer层,所述目标transformer层包括目标注意力头head,所述目标注意力head包括多个算子,且所述多个算子为对第一搜索空间包括的多个候选算子进行采样得到的;
    模型选择模块,用于基于所述多个候选神经网络的性能,从所述多个候选神经网络中选择目标神经网络。
  23. 根据权利要求22所述的装置,其特征在于,所述目标注意力head为基于所述多个算子以及所述多个算子之间的排列关系构建的,所述多个算子之间的排列关系为基于采样的方式确定的。
  24. 根据权利要求22或23所述的装置,其特征在于,所述目标注意力head还包括第一线性变换层,所述第一线性变换层用于通过目标变换矩阵对所述目标注意力head的输入向量进行处理,所述多个算子用于对所述第一线性变换层的数据处理结果进行运算。
  25. 根据权利要求24所述的装置,其特征在于,所述目标变换矩阵仅包括X个变换矩阵,所述X为小于或等于4的正整数,且所述X的数量为基于采样的方式确定的。
  26. 根据权利要求22至25任一所述的装置,其特征在于,所述目标注意力head的输入向量和所述目标注意力head的输出向量的尺寸大小一致。
  27. 根据权利要求22至26任一所述的装置,其特征在于,所述至少一个候选神经网络包括串联连接的多个网络层,所述多个网络层包括所述目标transformer层,所述目标transformer层在所述多个网络层中的位置为基于采样的方式确定的。
  28. 根据权利要求22至27任一所述的装置,其特征在于,所述至少一个候选神经网络包括串联连接的多个网络层,所述多个网络层包括所述目标transformer层以及目标网络层,所述目标网络层包括卷积层。
  29. 根据权利要求28所述的装置,其特征在于,所述目标网络层在所述多个网络层中的位置为基于采样的方式确定的。
  30. 根据权利要求28或29所述的装置,其特征在于,所述卷积层中的卷积核为对第二搜索空间中包括的多个尺寸的卷积核进行采样得到的。
  31. 一种神经网络搜索装置,其特征在于,所述装置包括存储器和处理器;所述存储器存储有代码,所述处理器被配置为获取所述代码,并执行如权利要求1至21任一所述的方法。
  32. 一种计算机可读存储介质,其特征在于,包括计算机可读指令,当所述计算机可读指令在计算机设备上运行时,使得所述计算机设备执行权利要求1至21任一项所述的方法。
  33. 一种计算机程序产品,其特征在于,包括计算机可读指令,当所述计算机可读指令在计算机设备上运行时,使得所述计算机设备执行如权利要求1至21任一所述的方法。
PCT/CN2022/105115 2021-07-15 2022-07-12 一种神经网络搜索方法及相关设备 WO2023284716A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP22841352.2A EP4361843A1 (en) 2021-07-15 2022-07-12 Neural network searching method and related device
US18/411,616 US20240152770A1 (en) 2021-07-15 2024-01-12 Neural network search method and related device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110803202.X 2021-07-15
CN202110803202.XA CN113656563A (zh) 2021-07-15 2021-07-15 一种神经网络搜索方法及相关设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/411,616 Continuation US20240152770A1 (en) 2021-07-15 2024-01-12 Neural network search method and related device

Publications (1)

Publication Number Publication Date
WO2023284716A1 true WO2023284716A1 (zh) 2023-01-19

Family

ID=78489439

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/105115 WO2023284716A1 (zh) 2021-07-15 2022-07-12 一种神经网络搜索方法及相关设备

Country Status (4)

Country Link
US (1) US20240152770A1 (zh)
EP (1) EP4361843A1 (zh)
CN (1) CN113656563A (zh)
WO (1) WO2023284716A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117239743A (zh) * 2023-11-15 2023-12-15 青岛鼎信通讯股份有限公司 一种电能表用电负荷获取方法、装置、设备及介质
CN117708568A (zh) * 2024-02-02 2024-03-15 智慧眼科技股份有限公司 大语言模型的特征提取方法、装置、计算机设备及介质

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113656563A (zh) * 2021-07-15 2021-11-16 华为技术有限公司 一种神经网络搜索方法及相关设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020160252A1 (en) * 2019-01-30 2020-08-06 Google Llc Task-aware neural network architecture search
CN112445823A (zh) * 2019-09-04 2021-03-05 华为技术有限公司 神经网络结构的搜索方法、图像处理方法和装置
CN112561027A (zh) * 2019-09-25 2021-03-26 华为技术有限公司 神经网络架构搜索方法、图像处理方法、装置和存储介质
CN112949832A (zh) * 2021-03-25 2021-06-11 鼎富智能科技有限公司 一种网络结构搜索方法、装置、电子设备及存储介质
CN113065645A (zh) * 2021-04-30 2021-07-02 华为技术有限公司 孪生注意力网络、图像处理方法和装置
CN113656563A (zh) * 2021-07-15 2021-11-16 华为技术有限公司 一种神经网络搜索方法及相关设备

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111242176B (zh) * 2019-12-31 2023-10-13 北京迈格威科技有限公司 计算机视觉任务的处理方法、装置及电子系统
CN112541159A (zh) * 2020-09-30 2021-03-23 华为技术有限公司 一种模型训练方法及相关设备
CN112579063B (zh) * 2021-03-01 2021-06-08 之江实验室 一种用于深度学习编译器中探索优化空间的加速方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020160252A1 (en) * 2019-01-30 2020-08-06 Google Llc Task-aware neural network architecture search
CN112445823A (zh) * 2019-09-04 2021-03-05 华为技术有限公司 神经网络结构的搜索方法、图像处理方法和装置
CN112561027A (zh) * 2019-09-25 2021-03-26 华为技术有限公司 神经网络架构搜索方法、图像处理方法、装置和存储介质
CN112949832A (zh) * 2021-03-25 2021-06-11 鼎富智能科技有限公司 一种网络结构搜索方法、装置、电子设备及存储介质
CN113065645A (zh) * 2021-04-30 2021-07-02 华为技术有限公司 孪生注意力网络、图像处理方法和装置
CN113656563A (zh) * 2021-07-15 2021-11-16 华为技术有限公司 一种神经网络搜索方法及相关设备

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117239743A (zh) * 2023-11-15 2023-12-15 青岛鼎信通讯股份有限公司 一种电能表用电负荷获取方法、装置、设备及介质
CN117239743B (zh) * 2023-11-15 2024-02-27 青岛鼎信通讯股份有限公司 一种电能表用电负荷获取方法、装置、设备及介质
CN117708568A (zh) * 2024-02-02 2024-03-15 智慧眼科技股份有限公司 大语言模型的特征提取方法、装置、计算机设备及介质

Also Published As

Publication number Publication date
US20240152770A1 (en) 2024-05-09
CN113656563A (zh) 2021-11-16
EP4361843A1 (en) 2024-05-01

Similar Documents

Publication Publication Date Title
WO2020228376A1 (zh) 文本处理方法、模型训练方法和装置
WO2022007823A1 (zh) 一种文本数据处理方法及装置
WO2022057776A1 (zh) 一种模型压缩方法及装置
WO2021190451A1 (zh) 训练图像处理模型的方法和装置
WO2022068627A1 (zh) 一种数据处理方法及相关设备
CN111368993B (zh) 一种数据处理方法及相关设备
WO2023160472A1 (zh) 一种模型训练方法及相关设备
WO2023284716A1 (zh) 一种神经网络搜索方法及相关设备
WO2022068314A1 (zh) 神经网络训练的方法、神经网络的压缩方法以及相关设备
WO2022253074A1 (zh) 一种数据处理方法及相关设备
WO2023236977A1 (zh) 一种数据处理方法及相关设备
WO2022001724A1 (zh) 一种数据处理方法及装置
WO2024041479A1 (zh) 一种数据处理方法及其装置
WO2022156561A1 (zh) 一种自然语言处理方法以及装置
WO2021129668A1 (zh) 训练神经网络的方法和装置
WO2023020613A1 (zh) 一种模型蒸馏方法及相关设备
CN113704460A (zh) 一种文本分类方法、装置、电子设备和存储介质
US20240046067A1 (en) Data processing method and related device
CN116432019A (zh) 一种数据处理方法及相关设备
WO2021120177A1 (zh) 编译神经网络模型的方法和装置
WO2023143262A1 (zh) 一种数据处理方法及相关设备
WO2023207665A1 (zh) 一种数据处理方法及相关设备
WO2024017287A1 (zh) 一种模型训练方法及其装置
WO2024109907A1 (zh) 一种量化方法、推荐方法以及装置
CN117035019A (zh) 一种数据处理方法及相关设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22841352

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2022841352

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2022841352

Country of ref document: EP

Effective date: 20240124

NENP Non-entry into the national phase

Ref country code: DE