Training method, device and medium for text processing neural network

By using the product of the gating matrix and its transposed matrix and the unit matrix to determine the loss value and adjusting the gating matrix parameters when training the hybrid expert network, the orthogonalization of the gating matrix and the diversity of the expert network are achieved, solving the current problem of There is a problem of insufficient model optimization in technology and the text processing capabilities are improved.

CN116306862BActive Publication Date: 2024-09-06BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310015785.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-04
Publication Date
2024-09-06
Estimated Expiration
2043-01-04

AI Technical Summary

Technical Problem

When the existing technology trains a hybrid expert network, it usually only uses the loss value based on the final output of the model and the real result to adjust the model parameters, failing to specifically optimize some modules, resulting in the possibility of further improvement in the model's prediction ability.

Method used

By determining the intermediate matrix based on the product of the gating matrix and its transposed matrix, and then determining the first loss value based on the intermediate matrix and the identity matrix, and using the first loss value to adjust the parameters of the gating matrix to orthogonalize the gating matrix, Thus, an expert network capable of processing different types of word segmentation is trained.

Benefits of technology

This enables the trained neural network to process different types of word segmentations, has corresponding physical meanings, and improves the prediction ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116306862B
    Figure CN116306862B
Patent Text Reader

Abstract

The present disclosure provides a training method, device and medium for text processing neural network, which relates to the field of artificial intelligence, and specifically to natural language processing and deep learning technology. The method includes: obtaining a sample input of the neural network, the sample input includes multiple word segmentations; obtaining a gating matrix in the neural network, the gating matrix is ​​used to calculate the correlation between each of the multiple word segmentations and each of the multiple expert networks in the neural network, and the multiple expert networks are used to strengthen the multiple word segmentations; based on the product of the gating matrix and the transposed matrix of the gating matrix, determining an intermediate matrix; based on the intermediate matrix and the unit matrix, determining a first loss value; and based on the first loss value, adjusting the parameters of the gating matrix to obtain a trained neural network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence, specifically to natural language processing and deep learning technology, and in particular to a training method for a text processing neural network, a training device for a text processing neural network, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.

[0003] Pre-trained language models are a technology that has developed rapidly in the field of natural language processing in recent years. Generally speaking, by increasing the scale of pre-trained models, the models can achieve better results.

[0004] The methods described in this section are not necessarily methods that have been previously conceived or employed. Unless otherwise indicated, it should not be assumed that any method described in this section is considered to be prior art simply because it is included in this section. Similarly, unless otherwise indicated, the issues mentioned in this section should not be considered to have been recognized in any prior art. Summary of the invention

[0005] The present disclosure provides a training method for a text processing neural network, a training device for a text processing neural network, an electronic device, a computer-readable storage medium, and a computer program product.

[0006] According to one aspect of the present disclosure, there is provided a training method for a text processing neural network, comprising: obtaining a sample input of the neural network, the sample input comprising a plurality of word segmentations; obtaining a gating matrix in the neural network, the gating matrix being used to calculate the correlation between each of the plurality of word segmentations and each of a plurality of expert networks in the neural network, the plurality of expert networks being used to strengthen the plurality of word segmentations; determining an intermediate matrix based on the product of the gating matrix and a transposed matrix of the gating matrix; determining a first loss value based on the intermediate matrix and a unit matrix; and adjusting parameters of the gating matrix based on the first loss value to obtain a trained neural network.

[0007] According to one aspect of the present disclosure, there is provided a training device for a text processing neural network, comprising: a first acquisition unit, configured to acquire a sample input of the neural network, the sample input comprising a plurality of word segmentations; a second acquisition unit, configured to acquire a gating matrix in the neural network, the gating matrix being used to calculate the correlation between each of the plurality of word segmentations and each of a plurality of expert networks in the neural network, the plurality of expert networks being used to strengthen the plurality of word segmentations; a first determination unit, configured to determine an intermediate matrix based on the product of the gating matrix and a transposed matrix of the gating matrix; a second determination unit, configured to determine a first loss value based on the intermediate matrix and a unit matrix; and a first parameter adjustment unit, configured to adjust the parameters of the gating matrix based on the first loss value to obtain a trained neural network.

[0008] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above method.

[0009] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the above method.

[0010] According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program implements the above method when executed by a processor.

[0011] According to one or more embodiments of the present disclosure, by determining an intermediate matrix based on the product of a gating matrix and its transposed matrix, and then determining a first loss value based on the intermediate matrix and a unit matrix, and adjusting the parameters of the gating matrix using the first loss value, the gating matrix can be orthogonalized, and different expert networks obtained after training can be used to process different types of word segmentations, thereby having corresponding physical meanings.

[0012] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The accompanying drawings exemplarily illustrate the embodiments and constitute a part of the specification, and together with the text description of the specification, are used to explain the exemplary implementation of the embodiments. The embodiments shown are for illustrative purposes only and do not limit the scope of the claims. In all drawings, the same reference numerals refer to similar but not necessarily identical elements.

[0014] Figure 1 A schematic diagram showing an exemplary system in which the various methods described herein may be implemented according to an embodiment of the present disclosure;

[0015] Figure 2 A flowchart of a training method for a text processing neural network according to an exemplary embodiment of the present disclosure is shown;

[0016] Figure 3 A schematic diagram of a neural network according to an exemplary embodiment of the present disclosure is shown;

[0017] Figure 4 A flowchart of a training method for a text processing neural network according to an exemplary embodiment of the present disclosure is shown;

[0018] Figure 5 A structural block diagram of a training device for a text processing neural network according to an exemplary embodiment of the present disclosure is shown; and

[0019] Figure 6 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0020] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0021] In the present disclosure, unless otherwise specified, the use of the terms "first", "second", etc. to describe various elements is not intended to limit the positional relationship, timing relationship, or importance relationship of these elements, and such terms are only used to distinguish one element from another element. In some examples, the first element and the second element may refer to the same instance of the element, and in some cases, based on the description of the context, they may also refer to different instances.

[0022] The terms used in the description of various examples in this disclosure are only for the purpose of describing specific examples and are not intended to be limiting. Unless the context clearly indicates otherwise, if the number of elements is not specifically limited, the element can be one or more. In addition, the term "and / or" used in this disclosure covers any one of the listed items and all possible combinations.

[0023] In the related art, when training a hybrid expert network, the parameters of the model are usually adjusted by using the loss value based on the final output of the model and the true result (ground truth), but some modules in the hybrid expert network are not specially optimized, so the predictive ability of the model may be further improved.

[0024] To solve the above problems, the present invention determines an intermediate matrix based on the product of a gating matrix and its transposed matrix, and then determines a first loss value based on the intermediate matrix and a unit matrix, and uses the first loss value to adjust the parameters of the gating matrix, thereby orthogonalizing the gating matrix and enabling different expert networks obtained after training to be used to process different types of word segmentation, thereby having corresponding physical meanings.

[0025] The embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.

[0026] Figure 1 FIG. 1 is a schematic diagram of an exemplary system 100 in which various methods and apparatuses described herein may be implemented according to an embodiment of the present disclosure. Figure 1 , the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. The client devices 101, 102, 103, 104, 105, and 106 may be configured to execute one or more applications.

[0027] In an embodiment of the present disclosure, the server 120 may run one or more services or software applications that enable execution of a training method for a neural network.

[0028] In some embodiments, server 120 may also provide other services or software applications that may include non-virtualized environments and virtualized environments. In some embodiments, these services may be provided as web-based services or cloud services, such as provided to users of client devices 101, 102, 103, 104, 105, and / or 106 under a software as a service (SaaS) network.

[0029] exist Figure 1 In the configuration shown, the server 120 may include one or more components that implement the functions performed by the server 120. These components may include software components, hardware components, or a combination thereof that can be executed by one or more processors. Users operating client devices 101, 102, 103, 104, 105, and / or 106 may in turn utilize one or more client applications to interact with the server 120 to utilize the services provided by these components. It should be understood that a variety of different system configurations are possible, which may differ from the system 100. Therefore, Figure 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.

[0030] The user can use client devices 101, 102, 103, 104, 105 and / or 106 to perform human-computer interaction. The client device can provide an interface that enables the user of the client device to interact with the client device. The client device can also output information to the user via the interface. Figure 1 Only six client devices are depicted, but one skilled in the art will appreciate that the present disclosure may support any number of client devices.

[0031] Client devices 101, 102, 103, 104, 105 and / or 106 may include various types of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptop computers), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, game systems, thin clients, various messaging devices, sensors or other sensing devices, etc. These computer devices may run various types and versions of software applications and operating systems, such as MICROSOFT Windows, APPLE iOS, UNIX-like operating systems, Linux or Linux-like operating systems (such as GOOGLE Chrome OS); or include various mobile operating systems, such as MICROSOFT Windows Mobile OS, iOS, Windows Phone, Android. Portable handheld devices may include cellular phones, smart phones, tablet computers, personal digital assistants (PDAs), etc. Wearable devices may include head-mounted displays (such as smart glasses) and other devices. Game systems may include various handheld game devices, Internet-enabled game devices, etc. Client devices are capable of executing various different applications, such as various Internet-related applications, communication applications (such as email applications), short message service (SMS) applications, and may use various communication protocols.

[0032] The network 110 may be any type of network known to those skilled in the art that may support data communications using any of a variety of available protocols, including but not limited to TCP / IP, SNA, IPX, etc. By way of example only, the one or more networks 110 may be a local area network (LAN), an Ethernet-based network, a token ring, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a public switched telephone network (PSTN), an infrared network, a wireless network (e.g., Bluetooth, WIFI), and / or any combination of these and / or other networks.

[0033] Server 120 may include one or more general purpose computers, dedicated server computers (e.g., PC (personal computer) servers, UNIX servers, mid-range servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and / or combination. Server 120 may include one or more virtual machines running virtual operating systems, or other computing architectures involving virtualization (e.g., one or more flexible pools of logical storage devices that may be virtualized to maintain a server's virtual storage device). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.

[0034] The computing units in the server 120 may run one or more operating systems including any of the above operating systems and any commercially available server operating systems. The server 120 may also run any of a variety of additional server applications and / or middle-tier applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.

[0035] In some implementations, server 120 may include one or more applications to analyze and consolidate data feeds and / or event updates received from users of client devices 101, 102, 103, 104, 105, and 106. Server 120 may also include one or more applications to display data feeds and / or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.

[0036] In some embodiments, the server 120 may be a server of a distributed system, or a server combined with a blockchain. The server 120 may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. A cloud server is a host product in a cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private servers (VPS) services.

[0037] The system 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of the databases 130 may be used to store information such as audio files and video files. The databases 130 may reside in various locations. For example, the data repository used by the server 120 may be local to the server 120, or may be remote from the server 120 and may communicate with the server 120 via a network-based or dedicated connection. The databases 130 may be of different types. In some embodiments, the database used by the server 120 may be a database, such as a relational database. One or more of these databases may store, update, and retrieve data to and from the database in response to a command.

[0038] In some embodiments, one or more of the databases 130 may also be used by applications to store application data. The databases used by the applications may be different types of databases, such as a key-value store, an object store, or a conventional store backed by a file system.

[0039] Figure 1 The system 100 may be configured and operated in various ways to enable the application of various methods and apparatuses described in the present disclosure.

[0040] According to one aspect of the present disclosure, a training method for a text processing neural network is provided. Figure 2 As shown, the training method of the neural network includes: step S201, obtaining a sample input of the neural network, the sample input including a plurality of segmented words; step S202, obtaining a gating matrix in the neural network, the gating matrix being used to calculate the correlation between each of the plurality of segmented words and each of the plurality of expert networks in the neural network, the plurality of expert networks being used to strengthen the plurality of segmented words; step S203, determining an intermediate matrix based on the product of the gating matrix and the transposed matrix of the gating matrix; step S204, determining a first loss value based on the intermediate matrix and the unit matrix; and step S205, adjusting the parameters of the gating matrix based on the first loss value to obtain a trained neural network.

[0041] Therefore, by determining the intermediate matrix based on the product of the gating matrix and its transposed matrix, and then determining the first loss value based on the intermediate matrix and the unit matrix, and using the first loss value to adjust the parameters of the gating matrix, the gating matrix can be orthogonalized, and different expert networks obtained after training can be used to process different types of word segmentation, thereby having corresponding physical meanings.

[0042] The neural network in the present disclosure can be, for example, a Mix of Experts (MoE) network based on a large-scale pre-trained model. Simply put, the MoE model increases the number of feed-forward network (FFN) modules in the Transformer structure. Each feed-forward network acts as an expert, and different word segmentations (also called tokens or symbols, token) are selectively distributed to different experts for calculation to achieve the strengthening of word segmentation (for example, feature vectors representing word segmentation). Word segmentation can include tokens corresponding to single words or words in the input text, and can also include tokens corresponding to special symbols. Special symbols may include, for example, the beginning of a sentence symbol [CLS], symbols [SEP] used to segment different sentences or at the end of a sentence, and so on. In the MoE model, the routing module is one of the most core modules, and the function of the routing module is to distribute the input word segmentation to the corresponding expert network.

[0043] In some embodiments, the training method disclosed herein can be used in the pre-training stage of a large-scale language model; it can also be used in the fine-tuning stage to obtain a neural network capable of performing specific text processing tasks, which is not limited here.

[0044] In some embodiments, the routing module is generally composed of a gate matrix d is the dimension of the word segmentation (e.g., the feature vector representing the word segmentation) (e.g. Figure 1 Where d = 6), e is the number of expert networks. Figure 3 As shown, the dimension of word segmentation is d=6, and the number of expert networks is e=4. Using the gating matrix, the correlation between each word segmentation and each expert network can be calculated.

[0045] In step S203, the product of the gating matrix and the transposed matrix of the gating matrix can be directly used as the intermediate matrix, that is, W e =W T ·W, where W is the gating matrix, W e In some embodiments, the product of the gating matrix and the transposed matrix of the gating matrix may also be subjected to other processing, such as multiplying with other matrices, or adding other matrices between the gating matrix and the transposed matrix of the gating matrix to obtain an intermediate matrix, which is not limited here.

[0046] According to some embodiments, the dimension of the intermediate matrix is ​​the same as the number of the multiple expert networks In this way, each row / column in the intermediate matrix can correspond to an expert network, so that each expert network has a specific and different physical meaning.

[0047] In step S204, various methods may be used to determine the first loss value based on the intermediate matrix and the identity matrix. However, it should be noted that the first loss value should be in direct proportion to the difference between the intermediate matrix and the identity matrix I, that is, the closer the intermediate matrix is ​​to the identity matrix, the smaller the first loss value is.

[0048] According to some embodiments, the first loss value may be a mean square loss between the intermediate matrix and the identity matrix, expressed as L=MSE(W e ,I), where L is the first loss value.

[0049] Therefore, by adjusting the parameters of the gate matrix based on the first loss value, the gating matrix can be orthogonalized.

[0050] In some embodiments, in addition to the above-mentioned first loss value, a second loss value can also be calculated based on the sample results output by the neural network and the actual processing results to adjust the parameters of the neural network.

[0051] According to some embodiments, Figure 4 As shown, the training method of the neural network may also include: also including: step S406, obtaining a real processing result corresponding to the sample input; step S407, matching multiple expert networks with multiple word segmentations based on the gating matrix; step S408, for each of the multiple word segmentations, in response to determining that there is at least one expert network matching the word segmentation in the multiple expert networks, using at least one expert network to strengthen the word segmentation to obtain an intermediate result corresponding to the word segmentation; and step S409, in response to determining that there is no expert network matching the word segmentation in the multiple expert networks, directly determining the word segmentation as the intermediate result corresponding to the word segmentation; step S410, processing the intermediate results of each of the multiple word segmentations to obtain a sample processing result; step S411, determining a second loss value based on the real processing result and the sample processing result; and step S412, adjusting the parameters of the neural network based on the second loss value to obtain a trained neural network.

[0052] Therefore, by using the second loss value to adjust the parameters of the neural network, the trained neural network can output more accurate text processing results.

[0053] According to some embodiments, step S407, matching multiple expert networks with multiple word segmentations based on the gating matrix may include: determining the correlation between each of the multiple expert networks and each of the multiple word segmentations based on the product of the sample input and the gating matrix; and matching the multiple expert networks with the multiple word segmentations based on the correlation between each of the multiple expert networks and each of the multiple word segmentations. Thus, through the above manner, it is possible to obtain an accurate correlation between the expert networks and the word segmentations, thereby obtaining a more appropriate matching result between the multiple expert networks and the multiple word segmentations.

[0054] In some embodiments, the correlation between each expert network and each word segment can be expressed as S=softmax(X·W), where Indicates the correlation between each expert network and each word segment. It is understandable that the correlation between each expert network and each word segment can also be determined in other ways, which are not limited here.

[0055] According to some embodiments, based on the correlation between each expert network in the multiple expert networks and each of the multiple segmented words, matching the multiple expert networks with the multiple segmented words may include: for each of the multiple segmented words, using the correlation between the segmented word and each of the multiple expert networks, determining an expert network matching the segmented word in the multiple expert networks. Thus, segmented word-based routing is implemented, that is, the most relevant expert network is selected by the segmented word.

[0056] According to some embodiments, matching multiple expert networks with multiple word segmentations based on the correlation between each expert network in the multiple expert networks and each word segmentation in the multiple word segmentations may include: for each expert network in the multiple expert networks, using the correlation between the expert network and each word segmentation in the multiple word segmentations, determining the word segmentation that matches the expert network in the multiple word segmentations. Thus, expert-based routing is achieved, that is, the most relevant word segmentation is selected by the expert network. It should be noted that under this method, some word segmentations may not be selected by any expert network, then these word segmentations may not be processed by any expert network, and these word segmentations (for example, feature vectors representing the word segmentations) may be directly used as corresponding intermediate results.

[0057] According to another aspect of the present disclosure, a training device for a text processing neural network is provided, such as Figure 5As shown, the device 500 includes: a first acquisition unit 510, configured to acquire a sample input of a neural network, the sample input including a plurality of segmented words; a second acquisition unit 520, configured to acquire a gating matrix in the neural network, the gating matrix being used to calculate the correlation between each of the plurality of segmented words and each of the plurality of expert networks in the neural network, the plurality of expert networks being used to strengthen the plurality of segmented words; a first determination unit 530, configured to determine an intermediate matrix based on the product of the gating matrix and the transposed matrix of the gating matrix; a second determination unit 540, configured to determine a first loss value based on the intermediate matrix and the unit matrix; and a first parameter adjustment unit 550, configured to adjust the parameters of the gating matrix based on the first loss value to obtain a trained neural network. It can be understood that the operations and Figure 2 The operations of step S201 to step S205 are similar and will not be described in detail here.

[0058] According to some embodiments, the device 500 may further include (not shown in the figure): a third acquisition unit, configured to acquire a real processing result corresponding to the sample input; a matching unit, configured to match multiple expert networks with multiple word segmentations based on a gating matrix; a reinforcement unit, configured to, for each of the multiple word segmentations, in response to determining that there is at least one expert network matching the word segmentation in the multiple expert networks, use at least one expert network to reinforce the word segmentation to obtain an intermediate result corresponding to the word segmentation; and in response to determining that there is no expert network matching the word segmentation in the multiple expert networks, directly determine the word segmentation as the intermediate result corresponding to the word segmentation; a processing unit, configured to process the intermediate results of each of the multiple word segmentations to obtain a sample processing result; a third determination unit, configured to determine a second loss value based on the real processing result and the sample processing result; and a second parameter adjustment unit, configured to adjust the parameters of the neural network based on the second loss value to obtain a trained neural network.

[0059] According to some embodiments, the matching unit may include: a first determination subunit, configured to determine the correlation between each of the multiple expert networks and each of the multiple word segmentations based on the product of the sample input and the gating matrix; and a matching subunit, configured to match the multiple expert networks with the multiple word segmentations based on the correlation between each of the multiple expert networks and each of the multiple word segmentations.

[0060] According to some embodiments, the matching subunit may include: a second determination subunit configured to determine, for each of the multiple word segmentations, an expert network matching the word segmentation in the multiple expert networks by utilizing the correlation between the word segmentation and each of the multiple expert networks.

[0061] According to some embodiments, the matching subunit may include: a third determination subunit configured to determine, for each expert network in the multiple expert networks, a word segment matching the expert network in the multiple word segments by utilizing the correlation between the expert network and each word segment in the multiple word segments.

[0062] According to some embodiments, the dimension of the intermediate matrix may be the same as the number of the plurality of expert networks.

[0063] According to some embodiments, the first loss value may be a mean square loss between the intermediate matrix and the identity matrix.

[0064] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0065] According to an embodiment of the present disclosure, an electronic device, a readable storage medium and a computer program product are also provided.

[0066] refer to Figure 6 , a block diagram of an electronic device 600 that can be used as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0067] like Figure 6 As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0068] Multiple components in the device 600 are connected to the I / O interface 605, including: an input unit 606, an output unit 607, a storage unit 608, and a communication unit 609. The input unit 606 can be any type of device that can input information to the device 600. The input unit 606 can receive input digital or character information, and generate key signal input related to user settings and / or function control of the electronic device, and can include but is not limited to a mouse, a keyboard, a touch screen, a trackpad, a trackball, a joystick, a microphone and / or a remote control. The output unit 607 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator and / or a printer. The storage unit 608 can include but is not limited to a disk, an optical disk. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver and / or a chipset, such as Bluetooth TM devices, 802.11 devices, WiFi devices, WiMax devices, cellular communication devices, and / or the like.

[0069] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning network algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as a training method for a neural network. For example, in some embodiments, the training method for a neural network may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the training method for the neural network described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the training method for a neural network in any other appropriate manner (e.g., by means of firmware).

[0070] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0071] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0072] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0073] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0074] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0075] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.

[0076] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0077] Although the embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it should be understood that the above-mentioned methods, systems and devices are merely exemplary embodiments or examples, and the scope of the present invention is not limited by these embodiments or examples, but only by the claims after authorization and their equivalent scope. Various elements in the embodiments or examples can be omitted or replaced by their equivalent elements. In addition, each step can be performed in an order different from that described in the present disclosure. Further, the various elements in the embodiments or examples can be combined in various ways. It is important that with the evolution of technology, many elements described herein can be replaced by equivalent elements that appear after the present disclosure.

Claims

1. A training method for a text processing neural network, comprising: Obtaining a sample input of the neural network, wherein the sample input includes a plurality of segmented words; Obtaining a gating matrix in the neural network, the gating matrix being used to calculate the correlation between each of the multiple word segmentations and each of the multiple expert networks in the neural network, the dimension of the gating matrix being based on the dimension of the feature vector representing the word segmentation and the number of the multiple expert networks, the multiple expert networks being used to strengthen the multiple word segmentations; Determine an intermediate matrix based on the product of the gating matrix, other matrices and the transposed matrix of the gating matrix, wherein the dimension of the intermediate matrix is ​​the same as the number of the multiple expert networks, and each row or column in the intermediate matrix corresponds to an expert network among the multiple expert networks, so that each of the multiple expert networks has a specific and different physical meaning; Determining a first loss value based on the intermediate matrix and the identity matrix; as well as Based on the first loss value, adjusting the parameters of the gating matrix to obtain a trained neural network, Wherein, strengthening the multiple participles includes: Determine, based on the product of the sample input and the gating matrix, the relevance of each of the plurality of expert networks to each of the plurality of segmentations; For each of the multiple expert networks, using the correlation between the expert network and each of the multiple participles, determining a participle matching the expert network from the multiple participles; For each of the multiple participles, In response to determining that at least one expert network among the multiple expert networks matches the word segment, strengthening the word segment using the at least one expert network to obtain an intermediate result corresponding to the word segment; and In response to determining that there is no expert network matching the word segment in the multiple expert networks, the word segment is directly determined as an intermediate result corresponding to the word segment.

2. The method according to claim 1, further comprising: Obtaining a true processing result corresponding to the sample input; Based on the gating matrix, matching the multiple expert networks with the multiple word segmentations; For each of the multiple participles, In response to determining that at least one expert network among the multiple expert networks matches the word segment, strengthening the word segment using the at least one expert network to obtain an intermediate result corresponding to the word segment; and In response to determining that there is no expert network matching the segmented word among the multiple expert networks, directly determining the segmented word as an intermediate result corresponding to the segmented word; Processing each of the plurality of intermediate word segmentation results to obtain a sample processing result; Determining a second loss value based on the true processing result and the sample processing result; as well as Based on the second loss value, the parameters of the neural network are adjusted to obtain a trained neural network.

3. The method according to claim 2, wherein: Based on the gating matrix, matching the multiple expert networks with the multiple word segmentations includes: Determining the relevance of each of the plurality of expert networks to each of the plurality of word segments based on a product of the sample input and the gating matrix; and The multiple expert networks are matched with the multiple word segments based on the relevance of each expert network in the multiple expert networks to each word segment in the multiple word segments.

4. The method according to claim 3, wherein: Based on the correlation between each expert network in the multiple expert networks and each of the multiple word segments, matching the multiple expert networks with the multiple word segments includes: For each of the multiple word segments, an expert network matching the word segment is determined in the multiple expert networks by using the correlation between the word segment and each of the multiple expert networks.

5. The method according to claim 3, wherein: Based on the correlation between each expert network in the multiple expert networks and each of the multiple word segments, matching the multiple expert networks with the multiple word segments includes: For each of the multiple expert networks, a word segment matching the expert network is determined from the multiple word segments by using the correlation between the expert network and each of the multiple word segments.

6. The method according to claim 1, wherein: The first loss value is a mean square loss between the intermediate matrix and the identity matrix.

7. A training device for a text processing neural network, comprising: A first acquisition unit is configured to acquire a sample input of the neural network, wherein the sample input includes a plurality of segmented words; a second acquisition unit, configured to acquire a gating matrix in the neural network, the gating matrix being used to calculate the correlation between each of the multiple word segmentations and each of the multiple expert networks in the neural network, the dimension of the gating matrix being based on the dimension of the feature vector representing the word segmentation and the number of the multiple expert networks, the multiple expert networks being used to strengthen the multiple word segmentations; A first determining unit is configured to determine an intermediate matrix based on a continuous product of the gating matrix, other matrices and a transposed matrix of the gating matrix, wherein the dimension of the intermediate matrix is ​​the same as the number of the multiple expert networks, and each row or column in the intermediate matrix corresponds to an expert network among the multiple expert networks, so that each of the multiple expert networks has a specific and different physical meaning; A second determining unit is configured to determine a first loss value based on the intermediate matrix and the identity matrix; as well as A first parameter adjustment unit is configured to adjust the parameters of the gating matrix based on the first loss value to obtain a trained neural network. Wherein, strengthening the multiple participles includes: Determine, based on the product of the sample input and the gating matrix, the relevance of each of the plurality of expert networks to each of the plurality of segmentations; For each of the multiple expert networks, using the correlation between the expert network and each of the multiple participles, determining a participle matching the expert network from the multiple participles; For each of the multiple participles, In response to determining that at least one expert network among the multiple expert networks matches the word segment, strengthening the word segment using the at least one expert network to obtain an intermediate result corresponding to the word segment; and In response to determining that there is no expert network matching the word segment in the multiple expert networks, the word segment is directly determined as an intermediate result corresponding to the word segment.

8. The apparatus according to claim 7, further comprising: A third acquisition unit is configured to acquire a real processing result corresponding to the sample input; A matching unit, configured to match the plurality of expert networks with the plurality of word segmentations based on the gating matrix; The strengthening unit is configured to, for each of the plurality of segmented words, In response to determining that at least one expert network among the multiple expert networks matches the word segment, strengthening the word segment using the at least one expert network to obtain an intermediate result corresponding to the word segment; and In response to determining that there is no expert network matching the segmented word among the multiple expert networks, directly determining the segmented word as an intermediate result corresponding to the segmented word; A processing unit, configured to process the intermediate results of each of the plurality of word segmentations to obtain a sample processing result; A third determining unit is configured to determine a second loss value based on the real processing result and the sample processing result; as well as The second parameter adjustment unit is configured to adjust the parameters of the neural network based on the second loss value to obtain a trained neural network.

9. The device according to claim 8, wherein: The matching unit comprises: A first determination subunit is configured to determine the correlation between each of the plurality of expert networks and each of the plurality of word segments based on the product of the sample input and the gating matrix; and The matching subunit is configured to match the multiple expert networks with the multiple word segmentations based on the correlation between each expert network in the multiple expert networks and each word segmentation in the multiple word segmentations.

10. The device according to claim 9, wherein: The matching subunit comprises: The second determination subunit is configured to determine, for each of the multiple word segments, an expert network matching the word segment in the multiple expert networks by using the correlation between the word segment and each of the multiple expert networks.

11. The device according to claim 9, wherein: The matching subunit comprises: The third determination subunit is configured to determine, for each of the multiple expert networks, a word segment matching the expert network from among the multiple word segments by using the correlation between the expert network and each of the multiple word segments.

12. The device according to claim 7, wherein: The first loss value is a mean square loss between the intermediate matrix and the identity matrix.

13. An electronic device comprising: at least one processor; as well as a memory communicatively coupled to the at least one processor; in The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.

14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6.

15. A computer program product comprising a computer program, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.