Systems and methods for speech recognition

By computing context vectors on-the-fly and employing a trained agent to derive tokens with improved halting positions, the method addresses latency and computational cost challenges in speech recognition systems, maintaining accuracy and reducing processing time.

GB2613581BActive Publication Date: 2025-08-20KK TOSHIBA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
GB2021017611
Authority / Receiving Office
GB · GB
Patent Type
Patents
Current Assignee / Owner
Filing Date
2021-12-06
Publication Date
2025-08-20
Estimated Expiration
2041-12-06

AI Technical Summary

Technical Problem

Existing speech recognition systems face challenges in reducing latency and computational cost while maintaining accuracy, particularly in systems using transformer models with end-to-end architectures.

Method used

A method that involves computing a context vector on-the-fly from encoded speech frames, using a trained agent to derive a token based on a predefined condition, and employing a halting selector to improve halting positions, thereby reducing latency and computational cost without compromising accuracy.

Benefits of technology

The method achieves reduced latency and computational cost in speech recognition while maintaining high accuracy by improving halting positions and utilizing reinforcement learning for training the agent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000001_0000
    Figure 00000001_0000
  • Figure 00000002_0000
    Figure 00000002_0000
  • Figure 00000003_0000
    Figure 00000003_0000
Patent Text Reader

Abstract

A computer implemented method for speech recognition, the method comprising: receiving a frame of speech audio 210; encoding the received frame 230; determining a context vector from the encoding of t
Need to check novelty before this filing date? Find Prior Art

Description

FIELD Embodiments described herein relate to systems and methods for speech recognition. 5 BACKGROUND Speech recognition methods and systems receive speech audio and recognise the content of such speech audio, e.g. the textual content of such speech audio. Speech recognition systems include hybrid systems, and may include an acoustic model (AM), 10 pronunciation lexicon and language model (LM) to determine the content of speech audio, e.g. decode speech. Earlier hybrid systems utilized Hidden Markov Models (HMMs) or similar statistical methods for the acoustic model and / or the language model. Later hybrid systems utilize neural networks for at least one of the acoustic model and / or the language model. These systems may be referred to as deep speech 15 recognition systems. C\J Speech recognition systems with end-to-end architectures have also been introduced. In these systems, a single neural network is used into which the acoustic model, pronunciation lexicon and language model can be considered to be implicitly 20 integrated. The single neural network may be a recurrent neural network. More recently, transformer models have been used for speech recognition systems. Transformer models may perform speech recognition using a self-attention mechanism by which the dependencies are captured regardless of their distance. Transformer models may employ an encoder-decoder framework. 25 BRIEF DESCRIPTION OF FIGURES Systems and methods in accordance with non-limiting examples will now be described with reference to the accompanying figures in which: Fig. 1A is an illustration of a voice assistant system in accordance with example embodiments; Fig. 1B is an illustration of a speech transcription system in accordance with example embodiments; 10 15 20 25 30 35 Fig. 1C is a flow diagram of a method for performing voice assistance in accordance with example embodiments; Fig. 1D is a flow diagram of a method for performing speech transcription in accordance with example embodiments; Fig. 2 shows a schematic illustration of a method for speech recognition according to an embodiment; Fig. 3A is a schematic illustration of a method for speech recognition according to an embodiment; Fig. 3B is a schematic illustration of a method for speech recognition according to an embodiment; Fig. 4 is a schematic illustration of the components of a speech recognition method as the method is performed; Fig. 5 is a schematic illustration of a system for performing speech recognition in accordance with example embodiments; Fig. 6 is a flow diagram of a method for pre-processing speech audio; Fig. 7 is a flow diagram of a method for training a speech recognition system; Fig. 8 is a flow diagram of a method for training a speech recognition system according to an embodiment; Fig. 9 shows a plot of loss of during training of systems for speech recognition; Fig. 10 is flow diagram of a speech recognition method; Fig. 11 is a schematic illustration of a method 1300; Fig. 12 (a) is a schematic illustration of a system for performing speech recognition in accordance with example embodiments; Fig. 12 (b) is flow diagram of a method for training a speech recognition system; Fig. 13 shows halting decisions for different heads of an ASR system; Fig. 14 (a) shows halting decisions for an ASR system; Fig. 14 (b) shows halting decisions for an ASR system according to example embodiments; and Fig. 15 is a schematic of hardware for implementing methods and systems in accordance with example embodiments. DETAILED DESCRIPTION According to a first aspect, there is provided a method for speech recognition as recited in claim 1. The disclosed method reduces latency and computational cost in speech recognition. The disclosed method achieves this reduction in latency and computational cost whilst maintaining the quality (e.g. accuracy) of the speech recognition. In the method, a frame of speech audio is received and then encoded. From the encoding, a context 5 vector is determined. The context vector relates to the acoustic information present in the received frame and to historical acoustic information. The context vector is computed on-the-fly; for example, the context vector is determined before a step of checking that a predefined condition is met. The context vector may also be referred to as an interim context vector. 10 The action is derived from the context vector. An action corresponds to a variable that indicates whether the token should be derived. When the action meets a predefined condition, a token is derived from the context vector. For example, the action may be derived from an agent, or a halting selector. 15 From the derived token, a function is executed. For example, the function comprises C\J outputting text or performing a command. The time step (or position) when the action £yj meets the predefined condition may be understood as a halting position. By 1— considering when the action meets a predefined condition, an improved halting position 20 may be obtained. Improving the halting position means that the halting position is small, whilst the quality (e.g. accuracy) of the derived token is maintained. In particular, the halting position may be smaller (or earlier) than a method that relies on an arbitrary condition rather than using the action derived from the context vector. The subsequent step of executing a function based on the token is also performed earlier. Thus, the 25 disclosed method may perform speech recognition with reduced latency (due to the earlier derivation of the token). The computational cost may also be reduced since fewer computations need to be performed before the token is derived. For example, the action is derived from the context vector by way of an agent. The 30 agent comprises a trained model. The agent is trained such that it may determine from the context vector when it is likely that a token should be derived from the context vector. The agent outputs an action. The action is one of the possible moves that the agent can make. An action corresponds to a variable that indicates whether the token should be derived. When the action meets the predefined condition, the token is 35 derived. The agent may be trained such that the halting position is improved. An earlier halting position means that a token is derived from the context vector earlier. For example, the action may have one of two values. For example, the action is binary 5 value. For example, the action is “0” or “1”, or “True” or “False”, or “Yes” or “No”. The action is compared to a predefined condition. For example, when the action is equal to “1”, the predefined condition is satisfied. 10 In an embodiment, deriving an action, by way of the agent, comprises: inputting the context vector into the trained model; determining an action probability (which is also referred to as a first probability) from the trained model; comparing the action probability to a predefined threshold; and setting the action based on the comparison. From the context vector, the action probability (first probability) is determined. The 15 action probability indicates a confidence that a token may be derived at this time step. For example, a high confidence may mean that the derived token is likely to be CM accurate and thus the quality of speech recognition may be maintained. When the £yj action probability is greater than a predefined threshold, the agent outputs an action 1— that would satisfy the predefined condition. For example, when the action probability is 20 greater than or equal to 0.5, the action is set to a value that would satisfy the predefined condition. In an embodiment, determining an action probability (first probability) from the trained model comprises; adding a predetermined bias to the output of the trained model; and 25 applying a sigmoid function to the result of the addition to obtain the action probability. The addition of the predetermined bias reduces the likelihood that the agent sets an action that would satisfy the predefined condition during the early stages of training. This helps the speech recognition method reach adequate accuracy more quickly during training. 30 In an embodiment, the agent comprises a deep neural network. In other examples, the agent may comprise a trained model. The trained model may comprise a recurrent neural network (RNN) or a convolutional neural network (CNN), 35 amongst others. In an embodiment, determining the context vector comprises using the context vector determined from a preceding frame of speech audio. By being computed from the preceding frame, the context vector carries historical information. 5 In an embodiment, determining the context vector comprises determining a second probability that corresponds to an attention weight of a self-attention decoder layer. The second probability represents a confidence in the derived context vector. In other words, the second probability represents a probability that the determined the context vector is acceptable. 10 The second probability is the likelihood that an ASR output (a token) should be derived. This is the consequence of the context vector being accepted. In an embodiment, determining the context vector comprises: multiplying the second 15 probability by an encoder state, the encoder state being derived from the received frame of speech audio. CM £yj The received frame may be encoded by a self-attention encoder. The self-attention 1— encoder comprises self-attention encoder layer. The self-attention encoder layer may 20 comprise a stack of self-attention encoder layers. The encoder state may be calculated using a self-attention encoder layer of an encoder neural network. In an embodiment, the second probability is calculated using a self-attention decoder layer of a decoder neural network. 25 The second probability may be derived from the attention energies. The attention energies are calculated using a self-attention decoder layer of a decoder neural network. 30 In an embodiment, the self-attention decoder layer is a multi-head self-attention decoder layer that comprises a plurality of attention heads, and wherein the second probability is calculated using an attention head of the plurality of attention heads. In an embodiment, determining the context vector comprises determining a first context 35 vector from each of the plurality of attention heads, and concatenating the determined first context vectors to obtain the context vector. The self-attention encoder layer may be a multi-head self-attention encoder layer. The number of attention heads corresponds to the number of heads in the multi-head selfattention decoder layer. The encoder state may be calculated using an attention head 5 of the plurality of attention heads of the multi-head self-attention encoder layer. In an embodiment, the method further comprises adding the determined second probability to an accumulator variable, and wherein responsive to the accumulator variable satisfying a second condition, deriving a token from the context vector; and 10 executing a function based on the token, wherein the function comprises at least one of text output or command performance. The second condition is different from the predefined condition. For example, the second condition comprises a comparison of the accumulator 15 variable to a second predetermined threshold. The satisfying of a second condition provides an additional condition for triggering the derivation of a token. For example, CM the second predetermined threshold may be the number of attention heads. In some £yj examples, the received frame of speech audio may result in actions that do not satisfy 1— the predefined condition. In these cases, the satisfying of the second condition may 20 trigger the derivation of a token instead. Thus, this ensures that derivation of a token and execution of a command is performed. The latency of the speech recognition method may be reduced. The use of the second condition may assist the agent. The second condition may not 25 ensure an execution of a halt on the decoding. A third condition (the maximum look-ahead steps) may force the halt instead. In an alternative embodiment, the action corresponds to a probability. The probability may be referred to as a third probability (or a halting probability). The action is derived 30 from the context vector by way of a module. The module may also be referred to as a halting selector. The halting selector is configured to determine whether to trigger an ASR output at each time step. The halting selector is trained such that it may determine from the 35 context vector when it is likely that a token should be derived from the context vector. The output of the halting selector corresponds to the halting probability. For example, the third probability represents the likelihood of halting an / 1h decoding at a certain encoder timestep j. 5 The halting selector may comprise a trained model. For example the trained model comprises a deep neural network (DNN). According to a second aspect, there is provided a computer implemented method for training a speech recognition system as recited in claim 20. 10 The disclosed method for training a speech recognition relies on the behaviour of the speech recognition system. It does not rely on supervised learning. Instead it relies on reinforcement learning. The trainable agent is rewarded based on prediction correctness and obtained halting position such that it learns improved halting positions 15 whilst maintaining prediction correctness (prediction accuracy). C\J In an embodiment, determining the reward comprises: £yj obtaining a first prediction correctness and a first halting position from a first 1— training epoch; 20 obtaining a second prediction correctness and a second halting position from a second epoch, wherein the first epoch precedes the second epoch; and comparing the first prediction correctness with the second prediction correctness, and comparing the first halting position with the second halting position. 25 In an embodiment, the determined reward has a first value when: the second halting position is greater than the first halting position; the second halting position is equal to the first halting position and the first prediction correctness differs from the second prediction correctness; and the second halting position is smaller than the first halting position and 30 the second prediction correctness indicates that the prediction is correct; The determined reward has a second value when: The second halting position is equal to the first halting position, and the first prediction accuracy is equal to the second prediction accuracy; and The second halting position is smaller than the first halting position, and 35 the first and second prediction accuracies are equal and low; and The determined reward has a third value when the second halting position is smaller than the first halting position and the second prediction accuracy is smaller than the first prediction accuracy, Wherein the first value is larger than the second value and the second value is 5 larger than the third value. A low prediction accuracy indicates that the prediction is incorrect. For example, a low prediction accuracy means that the prediction accuracy is lower than a predetermined value. In an embodiment, the first value is zero, and the second and third values are negative. In an example, determining the context vector comprises: Determining a second probability, wherein the second probability corresponds 15 to an attention weight of a self-attention decoder layer. CM In an embodiment, the method comprises adding the determined second probability to £yj an accumulator variable, and wherein the predefined condition comprises comparing 1— the accumulator variable to a predetermined threshold. CM 20 In an embodiment the predefined condition is satisfied when the accumulator variable is less than the predetermined threshold. According to a further aspect, there is provided a system for speech recognition, the 25 system comprising a processor, the processor configured to: Receive a frame of speech audio; Encode the received frame; Determine a context vector from the encoding of the received frame; Derive an action from the context vector; 30 Responsive to the action satisfying a predefined condition, derive a token from the context vector; and; Execute a function based on the token, wherein the function comprises at least one of text output or command performance. 35 According to another example, there is provided a computer implemented method for speech recognition, the method comprising: Receiving a frame of speech audio; Encoding the received frame; Determining a context vector from the encoding of the received frame; Deriving a third probability from the context vector; Responsive to the third probability satisfying a predefined condition, deriving a token from the context vector; and; Executing a function based on the token, wherein the function 5 comprises at least one of text output or command performance. The method improves accuracy and reduces latency in speech recognition. In the method, a frame of speech audio is received and then encoded. From the encoding, a context vector is determined. The context vector is a vector that relates to the acoustic 10 information present in the received frame and to historical acoustic information. The context vector is computed on-the-fly; for example, the context vector is determined before a step of checking that a predefined condition is met. The context vector may also be referred to as an interim context vector. 15 The third probability may be referred to as a halting probability and represents the likelihood that a token is derived from the context vector for a received frame of speech C\J audio. The third probability is different from the second probability described above. £yj When the halting probability satisfies a predefined condition, a token is derived from 1— the context vector. CM 20 For example, the third probability represents the likelihood of halting an / th decoding at a certain encoder timestep j. The halting probability is derived from the context vector by way of a halting selector. 25 The halting selector comprises a trained model. The halting selector is configured to provide a halting probability. The halting selector takes as input the context vector. The halting selector may enable the determination of robust halting positions. The received frame may be encoded by a self-attention encoder. The self-attention 30 encoder comprises a self-attention encoder layer. The self-attention encoder layer may comprise a stack of self-attention encoder layers. An encoder state may be calculated by the self-attention encoder layer of an encoder neural network. The encoder state is a vector. 35 For example, the context vector is derived using the encoder state. For example, the context vector is calculated using a self-attention decoder layer of a decoder neural network. The self-attention decoder layer may be a multi-head self-attention decoder layer that 5 comprises a plurality of attention heads. The context vector is derived from the attention heads of the plurality of attention heads. The self-attention decoder layer may comprise a stack of self-attention decoder layers. The number of self-attention decoder layers may correspond to the number of self-10 attention encoder layers. In an example, one self-attention decoder layer of the stack of self-attention decoder layers comprises the halting selector. This decoder layer may be the last decoder layer, for example. 15 According to a another example, there is provided a computer implemented method C\J for training a speech recognition system, the method comprising, for a training data that £yj comprises a frame of speech audio and a training token, 1— Encoding the frame; 20 Determining an expected halting probability; Deriving an expected context vector; Deriving a predicted token from the expected context vector; Comparing the predicted token with the training token; Updating weights of the speech recognition system based on said comparison. 25 The expected halting probability is obtained by considering all possible halting positions (encoder time steps), and their halting probabilities (third probabilities). The expected context vector is derived from the expected halting probability and a 30 context vector derived from the encoding of the frame. The comparison of the predicted token with the training token comprises determining a difference between the predicted token and the training token in accordance with a loss function. 35 The methods are computer-implemented methods. Since some methods in accordance with embodiments can be implemented by software, some embodiments encompass computer code provided to a general purpose computer on any suitable carrier medium. The carrier medium can comprise any storage medium such as a floppy disk, 5 a CD ROM, a magnetic device or a programmable memory device, or any transient medium such as any signal e.g. an electrical, optical or microwave signal. The carrier medium may comprise a non-transitory computer readable storage medium. According to a further aspect, there is provided a carrier medium comprising computer readable code configured to cause a computer to perform any of the above described methods. 10 For the purposes of illustration, example contexts in which the subject innovations can be applied are described in relation to Figures 1A-1D. However, it should be understood that these are exemplary, and the subject innovations may be applied in any suitable context, e.g. any context in which speech recognition is applicable. 15 Voice Assistant System CM Figure 1A is an illustration of a voice assistant system 120 in accordance with example £yj embodiments. 1— 20 A user 110 may speak a command 112, 114, 116 to the voice assistant system 120. In response to the user 110 speaking the command 112, 114, 116, the voice assistant system performs the command, which may include outputting an audible response. To receive the spoken command 112, 114, 116, the voice assistant system 120 25 includes or is connected to a microphone. To output an audible response, the voice assistant system 120 includes or is connected to a speaker. The voice assistant system 120 may include functionality, e.g. software and / or hardware, suitable for recognising the spoken command, performing the command or causing the command to be performed, and / or causing a suitable audible response to be output. Alternatively 30 or additionally, the voice assistant system 120 may be connected via a network, e.g. via the internet and / or a local area network, to one or more other system(s) suitable for recognising the spoken command, causing the command to be performed, e.g. a cloud computing system and / or a local server. A first part of the functionality may be performed by hardware and / or software of the voice assistant system 120 and a 35 second part of the functionality may be performed by the one or more other systems. In some examples, the functionality, or a greater part thereof, may be provided by the one or more other systems where these one or more other systems are accessible over the network, but the functionality may be provided by the voice assistant system 120 when they are not, e.g. due to the disconnection of the voice assistant system 120 from the network and / or the failure of the one or more other systems. In these examples, the 5 voice assistant system 120 may be able to take advantage of the greater computational resources and data availability of the one or more other systems, e.g. to be able to perform a greater range of command commands, to improve the quality of speech recognition, and / or to improve the quality of the audible output, while still being able to operate without a connection to the one or more other systems. 10 For example, in the command 112, the user 110 asks “What is X?”. This command 112 may be interpreted by the voice assistant system 120 as a spoken command to provide a definition of the term X. In response to the command, the voice assistant system 120 may query a knowledge source, e.g. a local database, a remote database, or another 15 type of local or remote index, to obtain a definition of the term X. The term X may be any term for which a definition can be obtained. For example, the term X could be a CM dictionary term, e.g. a noun, verb or adjective; or an entity name, e.g. the name of a £yj person or a business. When the definition has been obtained from the knowledge 1— source, the definition may be synthesised into a sentence, e.g. a sentence in the form 20 of “X is [definition]”. The sentence may then be converted into an audible output 112, e.g. using text-to-speech functionality of the voice assistant system 120, and output using the speaker included in or connected in the voice assistant system 120. As another example, in the command 114, the user 110 says “Turn Off Lights”. The 25 command 114 may be interpreted by the voice assistant system as a spoken command to turn off one or more lights. The command 114 may be interpreted by the voice assistant system 120 in a context sensitive manner. For example, the voice assistant system 120 may be aware of the room in which it is located and turn off the lights in that room specifically. In response to the command, the voice assistant system 120 30 may cause one or more lights to be turned off, e.g. cause one or more smart bulbs to no longer emit light. The voice assistant system 120 may cause the one or more lights to be turned off by directly interacting with the one or more lights, e.g. over a wireless connection, such as a Bluetooth connection, between the voice assistant system and the one or more lights; or by indirectly interacting with the lights, e.g. sending one or 35 more messages to turn the lights off to a smart home hub or a cloud smart home control server. The voice assistant system 120 may also produce an audible response 124, e.g. a spoken voice saying ‘lights off’, confirming to the user that the command has been heard and understood by the voice assistant system 120. As an additional example, in the command 116, the user 110 says “Play Music”. The 5 command 116 may be interpreted by the voice assistant system as a spoken command to play music. In response to the command, the voice assistant system 120 may: access a music source, such as local music files or a music streaming service, stream music from the music source, and output the streamed music 126 from the speaker included in or connected to the voice assistant system 120. The music 126 outputted 10 by the voice assistant system 120 may be personalised to the user 110. For example, the voice assistant system 120 may recognise the user 110, e.g. by the properties of the voice of user 110, or may be statically associated with the user 110, then resume the music previously played by the user 110 or play a playlist personalised to the user 110. 15 Speech Transcription System C\J Figure 1B is an illustration of a speech transcription system in accordance with £yj example embodiments. 1— 20 A user 130 may speak to a computer 140. In a response to the user speaking, the computer 140 produces a textual output 142 representing the content of the speech 132. To receive the speech, the computer 140 includes or is connected to a microphone. 25 The computer 140 may include software suitable for recognising the content of the speech audio and outputting text representing the content of the speech, e.g. transcribe the content of the speech. Alternatively or additionally, the computer 140 may be connected via a network, e.g. via the internet and / or a local area network, to one or more other system(s) suitable for recognising the content of the speech audio 30 and outputting text representing the content of the speech. A first part of the functionality may be performed by hardware and / or software of the computer 140 and a second part of the functionality may be performed by the one or more other systems. In some examples, the functionality, or a greater part thereof, may be provided by the one or more other systems where these one or more other systems are accessible over the 35 network, but the functionality may be provided by the computer 140 when they are not, e.g. due to the disconnection of the computer 140 from the network and / or the failure of the one or more other systems. In these examples, the computer 140 may be able to take advantage of the greater computational resources and data availability of the one or more other systems, e.g. to improve the quality of speech transcription, while still being able to operate without a connection to the one or more other systems. 5 The outputted text 142 may be displayed on a display included in or connected to the computer 140. The outputted text may be input to one or more computer programs running on the computer 140, e.g. a word processing computer program or a web browser computer program. 10 Voice Assistance Method Figure 1C is a flow diagram of a method 150 for performing voice assistance in accordance with example embodiments. Optional steps are indicated by dashed lines. The example method 150 may be implemented as one or more computer-executable 15 instructions executed by one or more computing devices, e.g. the hardware 700 described in relation to Figure 7. The one or more computing devices may be or CM include a voice assistant system, e.g. the voice assistant system 120, and / or may be £yj integrated into a multi-purpose computing device, such as a desktop computer, laptop 1— computer, smartphone, smart television, or games console. CM 20 In step 152, speech audio is received using a microphone, e.g. a microphone of a voice assistant system or a microphone integrated into or connected to a multi-purpose computing device. As the speech audio is received, the speech audio may be buffered in a memory, e.g. a memory of a voice assistant system or a multi-purpose computing 25 device. In step 154, the content of the speech audio is recognised. The content of speech audio may be recognised using methods described herein, e.g. the method 200 of Fig. 2, the method 300A of Fig. 3A, or the method 300B of Fig. 3B. Prior to the use of such 30 methods, the audio may be pre-processed, e.g. using the method 600 of Fig. 6 or aspects thereof. The recognised content of the speech audio may be text, syntactic content, and / or semantic content. The recognised content may be represented using one or more vectors. Additionally, e.g. after further processing, or alternatively, the recognised content may be represented using one or more tokens. Where the 35 recognised content is text, each token and / or vector may represent a character, a phoneme, a morpheme or other morphological unit, a word part, or a word. In step 156, a command is performed based on the content of the speech audio. The performed command may be, but is not limited to, any of the commands 112, 114, 116 described in relation to Fig. 1A, and may be performed in the manner described. The 5 command to be performed may be determined by matching the recognised content to one or more command phrases or command patterns. The match may be approximate. For example, for the command 114 which turns off lights, the command may be matched to phrases containing the words “lights” and “off’, e.g. “turn the lights off’ or “lights off”. The command 114 may also be matched to phrases that approximately 10 semantically correspond to “turn the lights off”, such as “close the lights” or “lamp off’. In step 158, an audible response is output based on the content of the speech audio, e.g. using a speaker included in or connected to a voice assistant system or multipurpose computing device. The audible response may be any of the audible responses 15 122, 124, 126 described in relation to Fig. 1A, and may be produced in the same or a similar manner to that described. The audible response may be a spoken sentence, CM word or phrase; music; or another sound, e.g. a sound effect or alarm. The audible £yj response may be based on the content of the speech audio in itself and / or may be 1— indirectly based on the content of the speech audio, e.g. be based on the command 20 performed, which is itself based on the content of the speech audio. Where the audible response is a spoken sentence, phrase or word, outputting the audible response may include using text-to-speech functionality to transform a textual, vector or token representation of a sentence, phrase or word into spoken audio 25 corresponding to the sentence, phrase or word. The representation of the sentence or phrase may have been synthesised on the basis of the content of the speech audio in itself and / or the command performed. For example, where the command is a definition retrieval command in the form “What is X?”, the content of the speech audio includes X, and the command causes a definition, [def], to be retrieve from a knowledge source. 30 A sentence in the form “X is [def]’ is synthesised, where X is from the content of the speech audio and [def] is content retrieved from a knowledge source by the command being performed. As another example, where the command is a command causing a smart device to 35 perform a function, such as a turn lights off command that causes one or more smart bulbs to turn off, the audible response may be a sound effect indicating that the function has been or is being performed. As indicated by the dashed lines in the figures, the step of producing an audible 5 response is optional and may not occur for some commands and / or in some implementations. For example, in the case of a command causing a smart device to perform a function, the function may be performed without an audible response being output. An audible response may not be output, because the user has other feedback that the command has been successfully completed, e.g. the light being off. 10 Speech Transcription Method Figure 1D is a flow diagram of a method 160 for performing speech transcription in accordance with example embodiments. The example method 160 may be implemented as one or more computer-executable instructions executed by one or 15 more computing devices, e.g. the hardware 700 described in relation to Figure 7. The one or more computing devices may be a computing device, such as a desktop CM computer, laptop computer, smartphone, smart television, or games console. CM 1— In step 162, speech audio is received using a microphone, e.g. a microphone 20 integrated into or connected to a computing device. As the speech audio is received, the speech audio may be buffered in a memory, e.g. a memory of a computing device. In step 164, the content of the speech audio is recognised. The content of speech audio may be recognised using methods described herein, e.g. the method 200 of Fig. 25 2, the method 300A of Fig. 3A, or the method 300B of Fig. 3B. Prior to the use of such methods, the audio may be pre-processed, e.g. using the method 600 of Fig. 6 or aspects thereof. The recognised content of the speech audio may be textual content, syntactic content, and / or semantic content. The recognised content may be represented using one or more vectors. Additionally, e.g. after further processing, or 30 alternatively, the recognised content may be represented using one or more tokens. Where the recognised content is text, each token and / or vector may represent a character, a phoneme, a morpheme or other morphological unit, a word part, or a word. In step 166, text is output based on the content of the speech audio. Where the 35 recognised content of the speech audio is textual content, the outputted text may be the textual content, or may be derived from the textual content as recognised. For example, the textual content may be represented using one or more tokens, and the outputted text may be derived by converting the tokens into the characters, the phonemes, the morphemes or other morphological units, word parts, or words that they represent. Where the recognised content of the speech audio is or includes semantic 5 content, output text having a meaning corresponding to the semantic content may be derived. Where the recognised content of the speech audio is or includes syntactic content, output text having a structure, e.g. a grammatical structure, corresponding to the syntactic content may be derived. 10 The outputted text may be displayed. The outputted text may be input to one or more computer programs, such as a word processor or web browser. Further processing may be performed on the outputted text. For example, spelling and grammar errors in the outputted text may be highlighted or corrected. In another example, the outputted text may be translated, e.g. using a machine translation system. 15 Figure 2 -Flow diagram of method C\J Fig. 2 is flow diagram of a speech recognition method according to an embodiment. In £yj step 210, a frame of speech audio is received. The frame of speech audio is derived 1— from an audio signal comprising speech. For example, the speech audio comprises 20 audio of a voice of a user. The frame of speech audio may be preprocessed prior to being received. How the frame of speech audio is pre-processed and obtained from an audio signal will be described later. The audio signal may be obtained from a sound capture apparatus such as a microphone. The frame of speech audio may be received as part of a plurality of frames of speech audio. A frame of speech audio may be 25 referred to as a window of speech audio. For example, the window may have a duration of 25 ms. The plurality of frames of speech audio may be referred to as a chunk of speech audio. In step 230, the frame of speech audio is encoded. The encoding of the frame speech 30 audio represents the frame of speech audio. The frame of speech audio may be encoded using an encoder neural network, e.g. a self-attention encoder neural network, and / or another type of machine-learned encoder, e.g. a kernel method encoder, such as a decision tree encoder or a Gaussian process encoder. Alternatively or additionally, the frame of speech audio may be encoded using a programmed 35 encoder and / or encoding method. For example, the frame of speech audio may be encoded using an algorithm such as a fast Fourier transform algorithm. In particular, the frame of speech audio may be encoded as part of a plurality of frames of speech audio, e.g. as part of a chunk of speech audio. Each frame of the plurality of frames of speech audio may be encoded simultaneously, e.g. each frame of chunk of 5 speech audio may be encoded simultaneously. The chunk of speech audio may be encoded using a self-attention encoder as described below. In step 240, a context vector, c, is determined (step 240-a), an action (a) is derived (240-b), and it is determined whether the obtained action satisfies a predetermined 10 condition (250). In step 240-a, the context vector is determined based on the encoding of the frame of speech audio in step 240-a. The determination of the context vector is described in further detail below. Briefly, the context vector is based on the acoustic information of 15 the encoded frame. It may also carry historical acoustic information (for example, from previous frames of speech audio). The context vector is also referred to as an interim CM context vector. As will be described later, the interim context vector may be obtained £yj for each time step (frame) in an autoregressive fashion (that is, based on its past 1— values). CM 20 In step 240-b, an action is derived from the context vector. For example, the action is derived using an agent. The agent comprises a trained neural network. The agent implements a policy denoted TTe. The agent comprises parameters 0 which are trainable parameters. The parameters 9 may also be referred to as weights. For 25 example, the neural network is implemented as a two-layer DNN. The agent takes as input the context vector. The agent’s policy TTe maps the context vector to an action (a). The agent may be understood as a module or algorithm that takes a certain action based on its interaction with a surrounding environment. In this case the environment is 30 the ASR system. The agent interacts with the ASR system. The agent takes a state as input. The state is a configuration that the agent finds itself in. For example the state is represented by the context vector. The agent takes the context vector as input. An action is one of the possible moves the agent can make. There may be a finite number of possible moves, for example the agent can emit an action of 1 or 0. The policy TTe is 35 the strategy implemented by the agent to determine the next action based on the current state. The trained neural network of the agent may be implemented as a two-layer DNN. For example, the DNN comprises of two fully-connected layers, where the input and output dimensions of the first layer are {D, D}, and those of the second layer are {D, 1}, where D is the dimension of the context vector. Alternatively, the agent comprises a neural 5 network that comprises a two-layer recurrent neural network (RNN), with the same dimensions as for the DNN. In step 250, it is determined whether the obtained action satisfies a predetermined condition. If the condition is met, the method proceeds to step 260. When the condition 10 is met, a decision to halt is made. The decision to halt refers to halting step 240. As will be described later, step 240 may be performed at the decoder end of transformer ASR. For example, step 240 may be performed by a decoder layer of a decoder neural network. Step 240 may be referred to as a decoding step. 15 In step 260, a token is derived. If the condition is not met, the method returns to step CM 240-a, where an interim context vector and action probability are determined. Step 240 £yj is then repeated on a subsequent frame of speech audio. 1— 20 Optionally, satisfying the predetermined condition comprises determining whether the action is equal to a predetermined value. For example, the condition is considered to be met if the action probability is equal to “1”. In step 260, a token is derived. In the speech recognition method, when the speech 25 audio is recognised as text, the token may represent a character, phoneme, morpheme or other morphological unit, word part, or word. In step 270, a function is executed based on the derived token. The executed function includes at least one of command performance and / or text output. 30 Additionally and optionally, as will be described in relation to the following figures, performing step 240 may include calculating further context vectors and calculating a combined context vector. Performing step 240 may also include processing the context vector or a combined context vector using one or more linear layers. Performing the 35 step 240 may also include processing the context vector, combined context vector, or output of the one or more linear layers with a classification layer. The output of the classification layer may be a plurality of probabilities or scores, e.g. a vector of probabilities or scores, with each probability or score indicating the likelihood that a given token is correct. The classification layer may be a cross entropy layer, a softmax layer, or a variation or equivalent thereof. The derived token may be the token having 5 the greatest corresponding probability or score or may be selected probabilistically based on the probabilities or scores, e.g. tokens having greater probabilities or scores being more likely to be selected. The probabilities or scores may be used in conjunction with a joint decoder which also utilizes a language model, which outputs probabilities or scores for each token based on tokens that have been previously 10 output. Such a joint decoder may calculate joint probabilities or scores based on both the language model probabilities or scores and the classification layer probabilities or scores. The token may then be derived as the token having the greatest combined probability or score, may be selected probabilistically based on the combined probabilities or scores, e.g. tokens having greater combined probabilities or scores 15 being more likely to be selected. C\J Inference with DRL-HS-DACS - variation 1 £yj Fig. 3A is a schematic illustration of a method 300A according to an embodiment. 1— Method 300A may be used to implement step 240 described in relation to Fig. 2, for 20 example. The method 300A relates to a decoder layer of a decoder neural network. The decoder layer may be referred to as a self-attention decoder layer. The decoder neural network may be referred to as a self-attention decoder. The decoder layer and the decoder 25 neural network will be described further below. The decoder neural network may comprise one or more decoder layers ( / ). Method 300A comprises an initialisation step 330A. In step 330A, the context vector is initialised. The context vector is denoted c^-. Here, h denotes the number of attention 30 heads, “i” represents the decoder step, represents the encoder time steps (and corresponds to the frame of speech audio being considered. The above expressions will be described in more detail below. The expressions “context vector”, “attention head”, “decoder step”, “encoder time step” 35 relate to a transformer ASR, where the transformer ASR has been streamlined with decoder-end adaptive computation steps (DACS). The transformer ASR is further 10 15 20 streamlined to comprise combining the attention weights across the heads (when more than one head is included) and to trigger the ASR to output at the same timestep for all heads. This is referred to as head synchronous decoder-end adaptive computation steps (HS-DACS). The method 300A may be referred to as deep reinforcement learning head synchronous decoder-end adaptive computation steps (DRL-HS-DACS). Here DRL refers to the use of an agent as described herein. HS refers to the combining of the attention weights across the heads (when more than one head is included) and to trigger the ASR to output at the same timestep for all heads. DACS refers to the accumulation of an attention during the decoding step. The DRL-HS-DACS algorithm belongs to the monotonic attention family, through which the attention weight can be immediately worked out from each encoder state in a strict left-to-right manner. As will be explained below, the DRL-HS-DACS sub-layer in a self-attention decoder layer may implement the method 300A. In method 300A, each decoder layer ( / ) is taken separately. In other words the steps of method 300A are performed for each decoder layer ( / ) of the decoder neural network. In step 330A, the context vector is initialised. For example, the context vector is initialised to zero. o = 0. For each frame of speech audio ( / ) until a condition is met, the following steps are carried out. In step 340A, a probability is determined. The probability is denoted ph-lij. To obtain the probability, attention energies are first computed. For example, taking the decoding step / of the Ith decoder layer, by a certain head h, the attention energy of timestep j is calculated as: f Equation (1) ".........vC ' 30 In equation 1, q and k are the decoder and encoder states. The attention energy eUij is then passed to onto a sigmoid unit to produce a probability: Equation (2) The probability (p1^) physically represents the confidence that headh attains at timestep j to conclude the current decoding process. The probability of equation (2) may be referred to as a second probability. The probability of equation (2) is computed 5 by the attention heads. The probability of equation (2) may be also referred to as attention weight, or as a halting probability. The second probability is different from the halting probability described in relation to Equation (11). The halting probability of Equation (11) may be referred to as a third probability. 10 In step 350A, an interim context vector (d'hij) is calculated. For example, the interim context vector is prompted for each time step in an autoregressive fashion as follows: Equation (3) In equation (3), represents the interim context vector from a previous encoder step j-1, and represents an encoder state at time step j. The term c^-i is 15 deprecated (e.g. set to 0) when / =1. Note that the interim context vector is computed on-the-fly and carries all the acoustic information from history. The context vector is computed first and then leads to a halting decision (the halting decision will be described below). 20 Steps 340A and 350A are performed for each attention head h. After all self-attention heads h are considered, step 360A is performed. 25 In step 360A, the interim context vectors obtained for each attention head h are concatenated (c1^. It will be understood that in arrangements where there is a single attention head (h =1), step 360A is optional. The context vector from step 350A may then be used instead of the concatenated vector. 30 In step 370A, an action probability (p’aij) is derived. The concatenated context vector is sent immediately to the agent model where an action probability is derived. Note, that the interim context vector is calculated up to timestep j. The action probability (plaiJ) is a probability computed by the agent model. The action probability (plaij) may be referred to as a first probability. As will be described later, the action probability (plaiJ) is used to derive an action that dictates a halting action. The action probability (p’aij) is obtained as: Equation (4) ™ SignK;kl(i>NN(cU ) ~~ 5 The agent implements a policy He. In equation (4), rfe represents the agent’s policy of the Ith decoder layer, which maps the context vector c to the probabilities of action ^aiJ given the parameters 0 of the agent model. 10 The bias term b added to the DNN's output deters the agent from halting during the early stages of training, allowing the ASR module to access the full speech and reach an adequate level of accuracy as soon as possible. For example, the bias term b may be any negative value. In a non-limiting example, b is -4. Note that even though the action is sampled at a single timestep, it is nevertheless subject to all the preceding 15 frames. In step 380A, an action a’ij is calculated from the probabilities of action p’a ij . For example, the action aZy has a binary value. For example, the action aZy has a value of 0 or 1. The action may be obtained as follows. If the policy provides a probability smaller 20 than 0.5, then the 'continue' action (a=0) is selected, or otherwise a 'halt' action (a=1) is performed on the decoding. This action may be obtained as follows: . fo <0.5. Equation (5) 11 otherwise. Steps 370A and 380A are performed by the agent. 25 In step 390A, it is checked whether the action azv meets a condition (first condition). For example, the condition is: “Is action value = 1 (a'ij= 1) ?”. If a'ij= 1 a halt action is performed and, for each decoder layer I, the method 300A is ended. If the condition is not met, the method 300A is repeated for a subsequent timestep (i.e. a subsequent 30 value of j). Inference with DRL-HS-DACS- venation 1 (with accumulator) Fig. 3B is a schematic illustration of a method 300B according to another embodiment. Method 300B may be used to implement step 240 described in relation to Fig. 2, for example. 5 Method 300B is similar to method 300A of Fig. 3A. Method 300B also relates to a decoder layer. Method 300B may also be referred to as DRL-HS-DACS. For each decoder layer I, the following steps are performed. 10 An initialisation step 330B is performed. Step 330B is similar to step 330A except that, in addition, an accumulator variable acd, is initialised. For example, the accumulator variable is initialised to zero. 15 For each frame of speech audio ( / ) until a condition is met, the following steps are carried out. Step 340B is carried out to obtain a second probability. In step 350B, an interim context vector (dhij) is calculated. Step 340B and Step 350B are the same as Steps 340A and 20 350A of Fig. 3A. In addition, in the method 300B, an additional step 345B of adding the second probability to the accumulator variable is performed. Step 345B is carried out for each self-attention head. Step 345B may be carried out concurrently with step 350B. 25 Steps 340B, 345B and 350B are performed for each attention head h. After all selfattention heads h are considered, step 360B is performed. Step 360B is then carried out. Step 360B is the same as step 360A. 30 Step 370B is then carried out. Step 370B is the same as step 370A. Step 380B is then carried out. Step 380B is the same as step 380A. Step 390B is then carried out. Step 390B is similar to as step 390A. In addition to 35 checking whether the action a’ij meets a condition as for step 390A (which may be referred to as the first condition), it is also checked whether the accumulator variable meets a certain condition (which may be referred to as the second condition). For example, it is checked whether the accumulator variable exceeds a predefined threshold (second threshold). In an example, the predefined threshold is the number of self-attention heads (H). 5 Method 300B is ended when action a'ij meets a condition (first condition) and / or accumulator variable meets a certain condition (second condition). The second condition has the effect of regularising the scale of attention weights used 10 in the context vector computation, by avoiding that the model gets trapped into overfitting due to the unrestricted magnitude of the context vector. The purpose of the second condition is to be a backup criterion for halting the determination of the context vector 240, 250 and for deriving a token. The agent (as 15 described in relation to steps 370B to 380B) may issue an action that triggers the halting of the method 300B in accordance with the first condition. The agent may issue CM the action and the first condition may be met earlier than the accumulator variable £yj condition is met. In other words, the first condition may be met before the second 1— condition is met. CM 20 In some cases, the second condition is met before the first condition is met. Thus, having the second condition enables step 240 to be halted earlier and a token to be derived (step 260) earlier. Thus, latency may be reduced. 25 Workflow of DRL-HS-DA CS Fig. 4 is a schematic illustration of the components 400 of a speech recognition method as the method is performed. Fig. 4 shows an example of values that some of the components (states or variables) described in methods 300A and 300B may have. In particular, Fig. 4 illustrates a snapshot of the components at different encoder 30 timesteps ( / ). Fig. 4 relates to a single attention head. Fig. 4 shows the evolution of the method as the encoder timesteps increase from j = 1 to j = 6 (from left to right in the figure). The encoder 430 states comprise e1, e2, e3, e4, e5 and e6. e, represents encoder 35 state e at encoder time step j. The encoder states are generated by an encoder layer as described in relation to step 230 of Fig. 2, for example. The encoder states may correspond to encoder state dj described in relation to equation 3 and S350B. Halting probabilities 440 are calculated for each time step. The halting probabilities are 5 obtained as described in relation to step 340B. The calculated halting probabilities 440 are accumulated in an accumulator variable 445. At each time step j, the halting probability for timestep j is added to the accumulator variable. As j increases, the value held in the accumulator variable also increases. For example, as shown in Fig. 4, from j = 1 to j = 6, the calculated halting probabilities are 0.1, 0.2, 0.3, 0.2, 0.2, 0.1, and the 10 accumulator values from j =1 to j = 5 are 0.1, 0.3, 0.6, 0.8, 1.0. Interim context vectors 450 are calculated from the encoder states. The context vectors 450 are calculated using equation (3). For example, using the halting probabilities 440 and encoder states 430: at j =1, c1 = 0.1*e1; at j =2, c2 = c1 + 0.2xe2; at j =3, c3 = c2 15 + 0.3xe3; at j =4, c4 = c3 + 0.2xe4. CM The interim context vectors 450 are fed into an agent 470. The agent 470 corresponds £yj the agent described in relation to 240, 370B, and / or 380B. 1— 20 The actions 480 derived for each time step are obtained as described for step 380B, for example. The derived actions from j =1 to j = 4 may be 0, 0, 0, and 1. In the example of Fig. 4, an action value a'ij = 1 is obtained at timestep j = 4. Conversely, an accumulator value acd = H = 1 is obtained at j = 5. In this example, 25 there is only one attention head so H = 1. Therefore, referring to the conditions described in step 390B or 390A, the first condition is satisfied earlier (j = 4) than the second condition (which would only be satisfied at j=5). Thus, the first condition of step 390A or 390B enables the computation to be halted earlier. A token may then be derived earlier. The computation of interim context vectors may stop at j = 4. Thus, the 30 first condition of 390A or 390B may enable a reduction in the number of computation steps. In other words, in this example, the computation halts at timestep 4 (j = 4) with the action 480 '1' taken by the agent 470. The halting probabilities accumulated 445 until 35 the halting position (j = 4) is 0.8, which is lower than the threshold of 1 reached at timestep 5. This, leads to a reduction of computation steps. The methods for speech recognition described above may be described by pseudocode below: Algoritiun 1, DRL-HS-DACS Inference for Transformer ASR Input: encoder states decoder states input length maximum look-ahead steps number of heads number of decoder layers agent policy tt#. i Initialization: i = 1, = Oas), fo = 0 2 while (eos) do 0? 12 24 3 4 .5' 6 $ 9 10 11 12 13 14 15 lf» 17 IS 19 20 21 ■>.? 23 for I 1 to Nd do ucci = 0 4,0 = o for j = 1 to miniO^i + M, T) do for A = 1 to H do t.h o- . p. ■ 4 — bigm oid (——=— j £ , Ip aeci end ci = Concat (cb *.....cz ?) ■P ■ ■ — f zd A Pa t,j = Bernoulli(pa £,4 if >H or a1^ = 1 then | break end end ci := c<3 end = Output Layer (c- <z) £ 4»= 1 24 end In the pseudocode (algorithm 1), <sos> is a token representing a start of the sentence, and <eos> is a token representing an end of a sentence. The other variables and parameters shown in algorithm 1 corresponds described in relation to method 300A and 300B. At lines 4 and 5, initialisation step 330B is performed. At lines 8 to 10, for each attention head {for h = 1 to H), the halting probability is determined (step 340B), the accumulator is updated (step (345B), and an interim context vector is calculated 5 (step 350B). At line 12, the interim context vector is concatenated (Step 360B). At lines 13 and 14, for an encoder timestep ( / ), the action probability (step 370B) and the action (step 380B) are derived. Line 14 of algorithm corresponds to equation 5. At Line 16, the “break” represents a halt action where the derivation of the context vector is halted. In line 19, a context vector di is obtained; the context vector for the decoder layer I is set 10 to the interim context vector that has been computed so far. In line 20, f, represents the time step at which the algorithm has halted. In other words, f, provides an indication of when the halting decision was made (i.e. the halting position). At line 20 {t, = max(f,,j)), t, is set to the larger of a current value of ti (for example from a different decoder layer), or j (which is the halting position for the current decoder layer. In line 22, a token y, is 15 derived for each decoder step ( / ). The token is derived from the context vector dJd> of the last decoder layer I = Na. At line 23, the decoder step variable ( / ) is incremented. CM With reference to the system of Fig. 500, the OutputLayer(.) in line 22 may correspond £yj to the linear and classification layer 528, the joint online decoder 530, and / or the 1— language model 540. CM 20 In algorithm 1, there are three measures that may halt the decoding step. These comprise the first condition and the second condition that have been described previously. A further condition (condition 3, or the third condition) is the condition shown in line 6 of the algorithm 1. The third condition is that the encoder time step ( / ) 25 reaches an upper limit, the upper limit being the smaller of ti-i+M, or T. T represents the length of the chunk of speech audio. M represents the maximum look-ahead steps. M represents an arbitrary upper limit that is used to restrict the computation. As explained previously, the first condition may provide an earlier halting position. The second and third conditions are provided as backup criteria for obtaining halting positions. 30 Fig 5. Architecture Fig. 5 is a schematic illustration of a system for performing speech recognition in accordance with example embodiments. The system 500 may be implemented using one or more computer-executable instructions on one or more computing devices, e.g. the hardware described below. The system 500 may also be referred to as an ASR system, an ASR module or a speech recognition system, or speech recognition module. The system 500 may be implemented using one or more computer-executable instructions on one or more computing devices, e.g. the hardware 900 described in relation to Fig. 15. The system 500 is based on a Transformer architecture. A transformer architecture is a type of encoder-decoder framework with both ends consisting of stacked layers based on pure attention mechanisms. In a transformer based ASR system, a convolutional neural network (CNN) based front-end is employed to enhance the feature extraction and conduct subsamplings. Each encoder layer comprises a cascade of two sub-layers, as a multi-head self-attention module and a pointwise feed-forward network (FFN). Layer normalisation is also applied on their output to facilitate model convergence. As for the decoder layer, apart from the sublayers present at the encoder side, a third multi-head cross-attention module is also present between them, in order to produce the speech-to-text alignments. In an example of such an ASR system, the cross-attention sub-layer may reduce the possibility in performing online decoding. This is reflected in the dot-product attention mechanism adopted by the Transformer: Attention / Q, K, V) = softmaxf )V\ Vdk Where K and V e ^Txdk are identical and stand for the matrix of encoder states with T timesteps, and Q e is the vector of decoder state at a certain decoding step. The product Q and K, also known as the attention energy, is scaled down by the square root of the dk, which denotes the dimension of the above states. The softmax function applies a global normalisation. The above requires a full input sequence, and this may not be used in online ASR systems. In the system 500, a different sub-layer is used. The system 500 according to embodiments of the present invention is described below. The system 500 comprises a self-attention encoder 510. The self-attention encoder 510 may be a chunkwise self-attention encoder. The self-attention encoder receives a chunk of speech. The chunk of speech audio includes a plurality of frames of audio. The self- attention encoder 510 encodes the plurality of frames in the chunk of speech audio to produce corresponding encodings for the plurality of frames of speech audio. The encoding of the frames of speech audio in the chunk may be substantially simultaneous. The number of frames of speech audio in the chunk may be referred to 5 as Nc. The chunk of speech audio may be complemented by Ni left frames of speech audio, e.g. frames received prior to the frames in the chunk, and right frames Nr of speech audio, e.g. frames received after the frames in the chunk. The left frames and the right frames are used to provide context for the encoding of the chunk of speech audio, but it is the encodings of the frames of speech audio in the chunk that are used 10 in decoding. The latency in encoding may be limited to the number of right frames of speech audio, e.g. the length of audio that N, frames represents. Nc, Ni and Nr, may be equal to one another. In an implementation Nc, Ni and Nr may be 64. The self-attention encoder 510 includes one or more convolutional neural network 15 layers 512. The use of one or more convolutional neural network layers 512 may improve extraction of acoustic features from the frames of speech audio in the chunk CM and perform subsampling on the frames in the chunk of speech audio. In an £yj implementation, the one or more convolutional neural network layers 512 may be two 1— identical convolutional neural network layers having 256 kernels of size 3x3 with a 20 stride of 2 x 2 that reduces the frame rate by 2-fold. The one or more convolutional neural network layers produce an output for subsequent layers. The self-attention encoder 510 further includes a positional encoding layer 514. The positional encoding layer 514 augments the output of the one or more convolutional 25 neural network (CNN) layers with sequence order information, e.g. information indicating the position of output of the CNN corresponding to a given frame compared to other frames encoder. The self-attention encoder 510 further includes one or more self-attention encoder 30 layers 516. Each self-attention encoder layer may have two sub-layers: a self-attention sub-layer and a position-wise feed forward sub-layer. The self-attention layer may be a multi-head attention layer. Each self-attention encoder layer may use residual connections and layer normalisation after each sub-layer. The input to a first of the one or more self-attention encoder layers 516 is the output of the positional encoding layer 35 514. The input to subsequent layers of the one or more self-attention encoder layers is the output of the preceding self-attention encoder layer. In an implementation, the one or more self-attention encoder layers 516 may be 12 self-attention encoder layers. The encoding of the frame speech audio represents the frame of speech audio. For 5 example, each self-attention encoder layer 516 generates an encoding of the frame of speech audio that contain information about the frame of speech audio. For example, the encoding contains information about which parts of the inputs are relevant to each other. 10 Each self-attention encoder layer 516 may generate an encoding as follows. From a vector inputted into the self-attention encoder layer, a query (Q), a key (K), and a value (V) matrix are obtained, the Q, K, and V matrices are obtained by multiplying the input with corresponding weight matrices that are trained. A score (or attention energy) is then obtained by multiplying Q and K. The score is normalised (e.g. by dividing by the 15 square root of d*, which denotes the dimension of the above states. The normalised score is then multiplied by V matrix. The result is the output of a self-attention encoder CM layer. CM 1— The system 500 comprises a self-attention decoder 520. The self-attention decoder 20 520 receives as an input a previous output, e.g. a previously output token. The self-attention decoder 520 comprises one or more embedding layers 522. The one or more embedding layers 522 process the output token to an embedding of the output token, e.g. a vector embedding. In an implementation, the embedding has a 25 dimensionality of 256, e.g. is a vector having 256 elements. The self-attention decoder 520 comprises a positional encoding layer 524. The positional encoding layer 514 augments the embedding with sequence order information, e.g. information indicating the position of the token in an output sequence 30 of tokens, such as a phrase or sentence. The self-attention decoder 520 comprises one or more self-attention decoder layers 526. Each self-attention decoder layer may have three sub-layers: a self-attention sublayer; a deep reinforcement learning, head synchronous, decoder adaptive 35 computation steps (DRL-HS-DACS) sub-layer, and a position-wise feed forward sublayer. Each self-attention decoder layer may have three sub-layers, and the DRL-HS- DACS layer is in the cross-attention sub-layer of the three. The DRL-HS-DACs sublayer comprises an agent and performs the steps 240, 300A or 300B described herein. Each self-attention decoder layer may use residual connections and layer normalisation after each sub-layer. A first of the one or more self-attention decoder 5 layers receives the augmented embedding as an input, i.e. the output of the positional encoding layer. Subsequent self-attention decoder layers receive the output of a preceding self-attention decoder layer. By way of the attention mechanism, the selfattention decoder layers also access encodings of frames produced by the selfattention encoder 510. In an implementation, the one or more self-attention decoder 10 layers 526 may be 6 self-attention decoder layers, the dimensions of the self-attention and DRL-HS-DACS sub-layers for each self-attention decoder layer may be 256, the position-wise feedforward sub-layer of each self-attention decoder layer may have 2048 units, and each self-attention decoder layer may include four attention heads. 15 The self-attention decoder 520 comprises linear and classification layers 528. The linear and classification layers process the output of the self-attention decoder layers to CM determine a plurality of probabilities or scores, e.g. a vector of probabilities or scores, £yj with each probability or score indicating the likelihood that a given token is correct. The 1— classification layer may be a cross entropy layer, a softmax layer, or a variation or 20 equivalent thereof. The system 500 comprises a joint online decoder 530. The joint online decoder receives the plurality of probabilities or scores from the linear and classification layers 528 of the self-attention decoder 520. The joint decoder 530 also utilizes a language 25 model 540 which outputs probabilities or scores for each token based on tokens that have been previously output. Such a joint decoder may calculate joint probabilities or scores based on both the language model probabilities or scores and the probabilities or scores received from the linear and classification layers of the self-attention decoder. The joint probabilities or scores may each be a weighted sum of a language model 30 probability or score and a received probability or score. The joint decoder may also utilize a Connectionist Temporal Classification (CTC) score to perform decoding. The joint probabilities or scores may be further based on the CTC score, and each joint probability or score may be a weighted sum of a language model probability or score, a received probability or score, and the CTC score. A joint score may be defined as 35 ActcSctc + Atsr + AimSim where Sctc is the CTC score, sr is the received probability or score, Sim is the language model probability or score, Actc, Ar and Aim are weighting parameters. Each of the weighting parameters may be between zero and one. The weighting parameters may sum to one. These joint probabilities or scores may be used to derive a token by any of the methods described in relation to step 260, e.g. by selecting the token having the greatest probability or score or probabilistically. Beam 5 search may also be used in deriving the token. The system 500 comprises the language model 540. The language model may be a deep language model implemented using a neural network. For example, the language model may be implemented using a Long Short Term Memory Network. 10 Obtaining frames of audio Fig. 6 is a flow diagram of a method 600 for pre-processing speech audio, e.g. processing speech audio prior to utilizing the processed speech audio for speech recognition and / or training a speech recognition system 600. Optional steps are 15 indicated by dashed lines. The example method 600 may be implemented as one or more computer-executable instructions executed by one or more computing devices, CM e.g. the hardware 700 described in relation to Figure 7. CM 1— In step 610, the speech audio is split into frames. Each frame may be a window of 20 speech audio. In an implementation, each frame may be a 25ms window of speech audio with a 10ms shift In step 620, acoustic features are extracted for each frame of speech audio. The acoustic features may be extracted using a filter bank. In an implementation, the 25 acoustic features may be 80-dimensional filter-banks together with 3-dimensional pitch-related information. In step 630, cepstral mean and variance normalisation is performed on the acoustic features. Cepstral mean and variance normalization is optional. Cepstral mean and 30 variance normalization may be applied to the acoustic features in training. In step 640, the acoustic features for Nc frames, where Nc is a chunk size, are spliced together to form a chunk of speech audio. The chunk size may be defined as the number of frames of speech audio per chunk. 35 In step 650, the chunk of speech audio is complemented with acoustic features for Ni prior frames and acoustic features for Nr subsequent frames. Training Fig. 7 is a flow diagram of a method 700 for training a speech recognition system. The 5 speech recognition system may be the speech recognition system 500 of Fig. 5. As described above, the system 500 comprises an agent 500b. The agent 500b corresponds to the agent described above in relation to 470, 380B, 370B, 380A, 370A, 240. The agent 500b comprises its own parameters, 0. 10 The ASR system 500 and the agent 500b are trained together. The system 500 and the agent 500b are trained using the same training data. The parameters of the system 500 and the parameters 0 of the agent 500b are updated together. However, the manner in which the parameters 0 of the agent 500b are updated differs from how the parameters of the ASR network are updated. The ASR network parameters are 15 updated by way of an ASR training step 720, while the agent parameters 0 are updated by way of a policy gradient training step 730. The ASR system 500 and the agent 500b CM are trained using different loss functions. For ease of understanding, the ASR training £yj 720 will be described first and separately from the policy gradient training 730. The 1— policy gradient training 730 will be described below in relation to Fig. 8. CM 20 The weights of the speech recognition system 500 are updated in step 720. The system 500 comprises a plurality of weights. The self-attention decoder layer of the speech recognition system 500 includes a first plurality of weights of a greater plurality of weights. 25 The updating of weights described in step 720 concerns the parameters of the system 500 but does not relate to the agent parameters 0. Agent parameters 0 are updated using a different method 730, which is described further below. 30 The following steps are performed for each training pair of a training set. Each training pair 710 includes a plurality of frames of speech audio and a sequence of training tokens. The training sequence of tokens may also be described as a gold standard sequence or reference sequence. The training sequence of tokens may have be or be derived from an indication by a human of the contents of an utterance to which the 35 plurality of frames of speech audio correspond. For example, a sequence of tokens representing the word, phrase(s) or sentence(s). A sequence of tokens is derived from the plurality of frames of speech audio. For each frame a token may be derived using the steps 230 to 260 of method 200, steps 330A to 390A of method 300A, or step 3030B to 390B of method 300B. The above steps may 5 be implemented by speech recognition system 500. Where the sequence of tokens includes a plurality of tokens, further tokens of the sequence of tokens may be arrived by applying the above steps to remaining frames of the plurality of frames of speech audio. Deriving a sequence of tokens and updating the weights of the speech recognition system comprise the following steps. Two variations may be used and each will be described separately. 15 The first variation concerns training of a system for implementing method 300A. C\J First variation - training of speech recognition network £yj i. Each frame is encoded as described in relation to step 230. ii. For each self-attention decoder layer ( / ) of a decoder neural network, an 20 initialisation step is performed. The initialisation step corresponds to step 330A. ill. For each frame, each self-attention head (h) is considered in turn, a halting probability is determined as described in relation to step 340A, and an interim context vector is calculated as described in relation to step 350A. 25 iv. The calculated interim context vectors are then concatenated as described in relation to step 360A. v. An action probability p'a / j is then derived as described in relation to step 370A. 30 vi. From the action probability, and action a'ij is derived as described in relation to step 380A. vii. It is then checked whether action a'ij meets a condition, as described in relation 35 to step 390A. If the condition is met, a halt action is performed, and the decoding step for a self-attention decoder layer (I) is completed. 5 viii. Steps ii. to vii. are repeated for each decoder layer until the final decoder layer ( / = Nd) is reached. For each decoder layer ( / ), a context vector di is obtained. At the final decoder layer, a context vector c^ / for the final decoder layer is obtained. ix. A token is then derived as described in step 260 and in relation to Fig. 5. For example, as described in Algorithm 1 above, the token is derived from the context vector of the final decoder layer cNdi. 10 X. An update 720 of the parameters is then performed for each decoder layer. The update is based on a difference between the derived sequence of token and the training sequence of token in accordance with a loss function. The first plurality of weights are updated based on a difference between the derived sequence of 15 tokens and the training sequence of tokens in accordance with a loss function. xt Further weights of the greater plurality of weights may also be updated. For CM example, weights for one or more other self-attention decoder layers or other CM i— layer types, e.g. linear layer, of a decoder may also be updated. Other weights of the greater plurality of weights which relate to other parts of the speech CM 20 recognition system may also be updated. For example, the encodings of each frame of speech audio may also be generated using an encoder including a second plurality of weights of the greater plurality of weights. The second plurality of weights may also be updated based on the difference between the derived sequence of tokens and the training sequence of tokens in accordance 25 with a loss function. Weights may be updated using backpropagation. The loss function may be a cross-entropy loss function. The loss function may include a Connectionist Temporal Classification (CTC) component. The loss function may be a multi-objective loss function including a cross-entropy 30 component and a CTC component. A cross-entropy loss function of the multiobjective loss function may be used to update the first plurality of weights and other weights of the decoder. A cross-entropy loss function of the multiobjective loss function may be used to update the second plurality of weights in the encoder. A CTC loss function of the multi-objective loss function may be 35 used to update the second plurality of weights in the encoder. For ease of explanation, update step 720 has been described as occurring for each training pair. However, it should be noted that in some variations, the update step 720 may occur for only some of the training pairs, e.g. for every Nth training pair. In these cases, the update of the weights is based on the 5 difference between each of N derived sequences of tokens and corresponding training sequence of tokens since the last update, and may be calculated in accordance with a loss function. For example, the update may be based on the average of the losses calculated for each of the derived sequences of tokens and corresponding training sequences of tokens. Such methods for updating 10 the weights may be referred to as batch update or mini-batch methods. The second variation concerns training of a system for implementing method 300B. 15 Second variation - training of speech recognition network i. Each frame is encoded as described in relation to step 230. ii. For each self-attention decoder layer ( / ) of a decoder neural network, an initialisation step is performed. The initialisation step corresponds to step 330B. iii. For each frame, each self-attention head ( / 7) is considered in turn, a halting probability is determined as described in relation to step 340B, and an interim context vector is calculated as described in relation to step 350B. The halting probability is also accumulated in an accumulator variable as described in relation to step 345B. 25 iv. The calculated interim context vectors are then concatenated as described in relation to step 360B. v. An action probability p’aij is then derived as described in relation to step 370B. 30 vi. From the action probability, and action a'ij is derived as described in relation to step 380B. vii. It is then checked whether action a'ij meets a condition, as described in relation to step 390B. The condition may comprise a first condition and a second 35 condition. If the condition is met, a halt action is performed, and the decoding step for a self-attention decoder layer ( / ) is completed. The effect of using the second condition is to regularise the scale of attention weights used in the context vector computation. For example, the effect of the second condition is to regularise the scale of attention weights in the bottom 5 decoder layers. This reduces the chance that model overfits due to the unrestricted magnitude of dij. For example, the halting probability p^ij, which is used in the context vector computation, may have a value between 0 and 1. This value is accumulated in the accumulator variable. The accumulator variable may become very large as the frames are moved from left to right (that 10 is, as j is incremented). This may happen in the bottom decoder layers (that is, small values of / ). This is due to the modelling ability of the Transformer model, which also happens in non-streaming systems. In particular, the attentions of the bottom decoder layers may be invalid, that is, they may not correctly attend to the input frame. The halting probability would be multiplied with the encoder 15 states, so these invalid attentions may be added to the interim context vectors, which would cause problems in the decoding. By having the second condition, CM the computation of the context vector may be halted and the effect of the invalid £yj attentions may be reduced. In turn, this may reduce the potential decline in ASR 1— accuracy. The effect of using the second condition is described further in 20 relation to Fig. 9. viii. Steps ii. to vii. are repeated for each decoder layer until the final decoder layer ( / = Nd) is reached. For each decoder layer ( / ), a context vector di is obtained. At the final decoder layer, a context vector d‘di for the final decoder layer is 25 obtained. ix. A token is then derived as described in step 260 and in relation to Fig. 5. For example, as described in Algorithm 1 above, the token is derived from the context vector of the final decoder layer dMi. 30 x. An update 720 of the parameters is then performed for each decoder layer. The update 720 is as described in step (x.) of the first variation. Policy Gradient training 35 Fig. 8 shows a flow diagram of a method 800 for training a speech recognition system. In particular, the method 800 relates to the training of agent 500b of the speech recognition system 500. Method 800 may be used together with either the first or second variation described in relation to Fig. 7. In method 800, the system 500 and agent 500b are trained for at least two successive 5 epochs, E-1 and E. Epoch E-1 may be referred to as a first epoch, while epoch E may be referred to as a second epoch. E-1 precedes E. Epoch E is the current epoch, and Epoch E-1 is the previous epoch. The number of epochs is the number of times the learning algorithm passes through 10 the entire training dataset. In one epoch, the internal model parameters have been updated by each sample in the training dataset. As described above, in an arrangement, an update to the model parameters may be performed only after every A / training pairs (mini-batch method, with batch size of N). In this case, an epoch comprises one or more batches of N training pairs. N is the number of training pairs in 15 a mini-batch. N is also referred to as the mini-batch size. CM The ASR system 500 may a decoder neural network that comprises one or more £yj decoder layers ( / ). Each decoder layer may comprise an agent. 1— 20 The ASR system 500 and one of the agents of the decoder layer are updated at the same time every mini-batch. As there are more than one agent in the decoder, each agent is sequentially trained for consecutive O mini-batches; that is, one agent is trained for consecutive O mini-batches, and then another agent is trained. For example, if O is 3, the whole system is trained as follows: {(ASR, agentO), (ASR, agentO), (ASR, 25 agentO), (ASR, agentl), (ASR, agentl), (ASR, agentl), (ASR, agent2), (ASR, agent2), (ASR, agent2), ...}. In other words, the ASR system 500 and a first agent (agentO) are trained together for 3 consecutive mini-batches; the ASR system 500 and a second agent (agentl) are trained together for a subsequent 3 consecutive mini-batches; and the ASR system 500 and a third agent (agent2) are trained together for a subsequent 3 30 consecutive mini-batches. The ASR network is trained for every mini-batch, but the agent being trained is shifted every O mini-batches. O is the number of mini-batches where the same agent is updated along with the ASR module. D is a number of tokens (decoding steps) in each mini-batch. D is a dynamic 35 value that changes with each training pair in certain mini-batch since each training pair may have a different number of tokens. In an example where 0 = 4, the mini-batch used and the agent being trained may follow the following sequence: {(mini-batch 1, agentl), (mini-batch 2, agentl), (mini-batch 3, agentl), (mini-batch 4, 5 agentl)}, {(mini-batch 5, agent2), (mini-batch 6, agent2), (mini-batch 7, agent2), (mini-batch 8, agent2)}, ... Since there are multiple agents, the agent that is trained with the ASR module switches 10 after every N* 0 training pairs. The method 800 comprises the following steps. In step 810, a training data pair is received. Step 810 is the same as step 710 for 15 example. CM In step 860 a token is derived. Step 860 corresponds to step 260. Note that the derivation of a token is also performed as part the training of the ASR system 500 as T— described in relation to Fig. 7. Therefore, the derivation of the token in step 860 may be 20 the same as the derivation of the token as described in relation to Fig. 7. For example the token may be derived using steps i. to ix. of either the first variation or second variation described in relation to Fig. 7. In step 830, policy gradient training is performed. Step 830 corresponds to step 730 of 25 Fig. 7. Step 830 comprises the following steps. In step 880, prediction correctness is obtained. Prediction correctness is obtained by comparing the derived token from step 860 with the corresponding training token from step 810. For example, if the derived token matches the training token, then the 30 prediction is correct, otherwise, the prediction is incorrect. Thus, prediction correctness may have one of two values, e.g. correct or incorrect, true or false, or 1 or 0. In step 870, halting positions from the current epoch Ke (second epoch) and a previous epoch (first epoch) Ke-i are obtained. Ke is referred to as the second halting position. 35 Ke-i is referred to as the first halting position. Halting positions are determined for each decoder layer ( / ). Thus, a set of first halting positions, represented by K'e-i, and a set of second halting positions, represented by K'e are obtained in step 870. For convenience, the superscripts 7’ are not included below, however, it will be understood that the halting position may relate to different layer. Halting positions are determined for the each decoder step ( / ). This enables a comparison of the halting positions obtained in 5 the first epoch and in the second epoch, for each decoder layer separately, and for each decoder step. In step 890, a reward is determined. The reward is determined for each decoder layer ( / ). The reward is determined for the agent in each decoder layer. The reward is 10 determined for each decoder step ( / ). The reward is dependent on the variation of the halting position and the prediction correctness of that particular decoder step. The reward is referred to as R. The reward is a reward of a policy gradient algorithm. The reward is a feedback used to measure the success or failure of the agent’s action. The reasoning behind the use of the reward and the policy gradient algorithm approach will 15 be provided further below. The purpose of the reward is to update the weights 8 of the agent model such that the halting position is improved, i.e. lowered. At each encoder CM timestep ( / ), whichever action taken by the agent is admitted, and said action is £yj accepted by assigning a non-negative reward, or rejected by assigning a negative 1— reward. The agent will learn to take proper actions through a number of such 20 examples. Some rejected actions may be more heavily penalised and thus a further non-negative reward, having smaller value (that is, a negative value that has a larger magnitude), may also be used. 25 The reward reflects the effect that the agent brings to the environment. For example, the effect is measured in terms of ASR accuracy and computational cost. ASR accuracy may be measured in terms of prediction correctness, which is as described above. Computation cost may be measured in terms of halting time, which is as 30 described above. The reward R is designed as a function of the variation of ASR accuracy and computational cost observed as the training proceeds. The general idea is that at each new data iteration, the policy would be either approved if the accuracy is preserved 35 with an appropriate halting position, or punished given the accuracy declines regardless of the change in computational cost. To ensure rational rewards are allocated to the agent, the following assumptions are made: (1) Generally, the ASR module keeps improving the accuracy on the training set as the 5 data iterates; (2) The later the agent halts the decoding step, it is more likely that the ASR accuracy is high. This is based on the fact that an offline ASR system always outperforms its online counterpart; (3) If the agent discerns the same or a later halting position at the current data iteration 10 compared with the previous one, any degradation in ASR accuracy is attributed to the ASR module and the agent is not penalised; (4) However, if the agent decides an earlier halting position and that results in reduced ASR accuracy, then the agent is responsible and will be penalised for its action. 15 20 Also, to ensure the efficiency of training and avoid involving uncertain gradients, nonzero rewards would only be assigned to the time steps that are directly related to the final 'halt' action of the decoding step, while the others are treated as neutral (assigned with zero reward). As the weights of the ASR 500 are updated simultaneously with the parameters 0 of the agent, the potential variation of the ASR accuracy may be attributed both to the training of the ASR 500, and the to the training of the agent 500b. The above assumptions help differentiate the effect of the agent from the effect of the ASR as training progresses. 25 The reward determined in step 890 is used update the weights of the agent in accordance with the following equations: Equation (6) Equation (7) Equation (6) represents a gradient ascent method where the parameters 8 are obtained by maximising J(0). a is a learning rate. In an example, a may be 0.010, 0.001 or 0.005. 5 Equation (7) shows an approximation for the gradient of the objective function J(0) (VeJ(0)). In Eqn (7), SG() is a function that stops the gradient of the ASR components from entering the computation. SG(.) stops the gradients of the ASR network from being included into that of the agent network during training. For example, the SG(.) function is configured such that the gradient of context vector Ck is taken off from the 10 gradient computation of aK in equation 7. ak is the action for the current encoder time step K. Ck is a context vector for the current encoder time step K. Rk is the reward determined for the encoder time step K. 15 For each decoding step of each training pair, the agent action at the same encoder time step, having index K, is considered in policy gradient training. Equation (7) relates to back-propagation and VnJ(6) refers to the gradient of the agent DNN (tts) when action ak is taken, given the context vector Ck,. The gradient of Ck 20 relates to the learning of the ASR network training progresses. The gradient of Ck blocked from equation (7) by the SG(.) function. V6 represents a derivative with respect to 0, and iTe is the policy applied by the agent. D is the total number of output tokens in the N training pairs (a mini-batch). 25 The reward Rk is obtained for the encoder time step K. The reward Rk is obtained as described below in relation to Table 1. Equation (7) is used as the loss function for training the agent model. 30 The derivative (output of equation 7) comprises computing the derivative for each decoding step ( / ) of each training pair individually, and averaging derivatives over the D tokens (decoding steps). This is to facilitate training. Rk, 3k and CKare not averaged. One of the agents is updated after every N training pairs. The mini-batch size (N) used for the training of the agent is the same as that used for training the ASR module. How equations (6) and (7) are obtained is described further below. The update step is 5 further described in relation to step 895. An example of the reward is provided in table 1 below. The reward may have one of three values. The first value is used to accept an agent action. E.g. the first value is a non-negative value. The second value is used to moderately penalise the agent action. 10 E.g. the second value is a small negative values. The third value is used to heavily penalise the agent action. E.g. the third value is a large negative value. The first value is greater than the second value, which is in turn greater than the third value. Table 1. Reward scheme of the policy gradient algorithm adopted for agent training, with regard to variations of prediction correctness and halting position. 0? 12 24 Ke = Ke-i Ke >Kei Ke <Ke i „1 Ke T 0 0 / =>x 0 0 -10, Ke X => / 0 0 0 X =>x -1, Ke = 0 0 -1, Ke In Table 1, the left most column represent the prediction correctness from the first epoch (E-1) to the second epoch (E). For example, in the first row, the first column indicates that the prediction was correct in the first epoch and in the second epoch. In the third row, the first column indicates that the prediction was incorrect for the first 20 epoch, but correct for the second epoch. The second column represents the scenarios where the second halting position(KE) is equal to the first halting position (Ke-i). The third column represents the scenarios where the second halting position(KE) is greater than the first halting position (KE-i). The fourth column represents the scenarios where the second halting position(KE) is less than the first halting position (Ke-i). 25 The rewards are as follows. When: the second halting position is greater than the first halting position; or the second halting position is equal to the first halting position and the prediction correctness has changed between the first and second epoch; or, the second halting position is less than the first halting value and the prediction at the second epoch is correct, the reward has a first value. 5 In the example of table 1, the first value has a value of “0”. However, it will be understood that other non-negative values could also be used. When: the second halting position equal to the first halting position and the prediction 10 correctness has not changed between the first and second epoch; or, the second halting position is less than the first halting value and the predictions at the first and second epochs are incorrect, the reward has a second value. In the example of table 1, the second value has a value of “-1”. However, it will be understood that another negative value could also be used. 15 When: C\J the second halting position is less than the first halting position and the £yj prediction correctness was correct in the first epoch but incorrect in the second epoch, 1— the reward has a third value. 20 In the example of table 1, the third value has a value of “-10”. However, it will be understood that another negative value could also be used. The third value is less than (that is, more negative than) the second value. Table. 1 defines the reward scheme adopted by the policy gradient algorithm, with 25 respect to all agent behaviours that might be encountered during system training. The rows of the table enumerate the four variations of prediction correctness for the same decoding step between two successive epochs (E-1 and E), with each corresponding to three possible changes of the halting position (Ke-i vs. Ke) as presented by the columns. The explanation towards the table is provided as below: 30 a. prediction remains correct ('J -> V): for all the variations of halting position, a penalty of -1 is only given to the action that repeatedly halts at the last timestep T by force, because normally the online decoding shouldn't constantly reach the end of speech. On the contrary, any other Ke # T are admitted since they might be produced 35 out of the optimal policy at a certain point of optimisation. As the actions are made monotonically on the encoder states, we could always believe that the 'halt' decision is made at the earliest timestep in its own right. b. prediction collapses from correct to incorrect (^ -> x): Based on assumption 4, a large penalty of -10 is given to the action that causes an earlier halting position at the 5 current epoch (Ke <Ke-i) encouraging the agent to halt later, while the equal (Ke = Ke-i) or a later (Ke >Ke-i) halting positions are accepted according to assumption 3. c. prediction builds from incorrect to correct (x -> ^): in this case, all new halting positions are approved since the validity of the old ones at the previous epoch is unknown due to the incorrect prediction. Moreover, the situation would definitely fall 10 into either of the above two rows at the next epoch, and it's never late to take further measures afterwards. d. prediction remains incorrect (x -> x): similar to variation b, the action to halt is moderately penalised if it creates a halting position earlier than before. Note that if Ke = Ke-i = 1, the agent should also be discouraged from halting as Ke cannot recede further 15 on the time axis. C\J Additionally and optionally, the initial prediction correctness and halting position of all £yj decoding steps are set to 'x' and T for the first epoch, and the two factors are tracked 1— throughout the entire training process. CM 20 Returning now to Fig. 8, in summary, in step 890, a reward Rk is determined for a current encoder time step K. Although the reward has been described for a single decoder layer, it will be understood that a reward is determined for each decoder layer of the self-attention decoder network. 25 In step 895, the reward for agent for each of the of the Transformer decoder layers are updated separately and sequentially in the bottom-to-top order. The update for the agent in each decoder layer is in accordance with in equation 6 and 7. 30 Additionally and optionally, in update step 895, for the agent in each decoder layer, an update is performed every after every N training pairs (where N is the batch size of the mini-batch method). 0 represents a number of mini-batches. After training an agent with 0 consecutive mini-batches, the agent being trained is changed. The purpose of using more than one mini-batch to train an agent is to prevent the legacy of the 35 preceding agent being abruptly carried over to the next one, so that each agent is offered a better chance to develop a stable policy within the period. xt CM CM Note that during system training, the halting position produced by the agent is handled independently of that given by the accumulation threshold, with the latter only serving as a means of regularisation. Whilst for inference whichever appears earlier would 5 truncate the decoding process. The pseudocode of inference is presented in algorithm 1. For example, in relation to the training of the agent policy described in relation to Fig. 8, the accumulation threshold does not appear in determination of the reward 890 or the determination of correctness 880, or the weight update 895. 10 In relation to the policy gradient training 730 and the steps in 830, a further explanation for how equation (7) is obtained is provided below. The agent 500b explores the earliest halting positions entirely by itself; no training data for halting position is provided. The agent relies on the behavior of the ASR. A deep 15 reinforcement learning approach is used such that the agent is able to learn from its own experience during training. In the framework of reinforcement learning, each decoding step in a decoder layer can be formulated as a Markov decision process (MDP). The agent takes an action A at 20 each timestep given the environment state S, and instantly receives a reward R based on the effects it causes to the environment. A new state is therefore generated and the process goes on until a stopping criterion is met. The resulted sequence of the above elements is known as a trajectory r. Si, , % ,¾ .4k, 25 where S and A are embodied as the interim context vector c and binary action a respectively, and K is the number of computation steps before the agent decides to halt. According to the assumption of reward hypothesis, the objective of a deep 30 reinforcement learning (DRL) agent is to maximise the expected reward r received along the trajectory t, as it follows the policy tt9: The parameters 0 can be effectively solved by maximising J(&) via gradient ascent, as 35 expressed in equation (6) The Policy gradient theorem indicates that the derivative of the expected reward can be computed as the expectation of the product of the reward and the logarithm of the policy: Vs o Correspondingly, in the context of the proposed ASR system, for each decoding step ( / ), the derivative is given as: K 10 where SG( ) means to stop the gradient of the ASR components from entering the computation. The expectation term implies that all possible halting positions should be taken into account. To avoid the issue of high time complexity, the derivative is approximated by averaging that of all the decoding steps within a mini-batch of training utterances: j 15 t where D is the total number of output tokens in the mini-batch. The approximation can be analogous to the Markov-chain Monte-Carlo (MCMC) sampling technique. This presents a diversity of trajectories for the gradient calculation. It also allows the agent to be optimised jointly with the ASR module. 20 By applying the assumption (1) to (4) described above, the above expression may be expressed in the form shown in equation (7). DACS - An example of an ASR method 25 A description of a method of speech recognition according to an example is provided next. The method is referred to as a decoder adaptive computation steps (DACS) ASR. The method may be implemented in an architecture similar to that of Fig. 5. However, the DACS ASR architecture does not include the DRL-HS-DACS sub-layer. 30 The DACS ASR method is summarised by way of a pseudocode below (Algorithm 2). Algorithm 2 - DACS Inference for Transformer ASR 0? 12 24 i 2 3 4 5 7 8 9 1® 11 12 13 14 15 16 17 18 19 2® 21 Input: encoder states k(v), decoder states q, length Tf maximum look-ahead step Af, number of heads / / , number of decoder layers A^. Initialization: yo = (ms), to = 0 while i / (eo^) do A - .....i for I = Ito Na do tor h = Ito II do . . h. / ri ' = 0 for j = 1 to min(tj™i 4- Af, T) do k,q_T — sigmoid if acc+!' > 1 then | break end end / d = yy rhA S Z-mi—1 Pi, m { rn 4 = max(C j ) end 4 = ConcatfcH,..., ti = max(h,4) end 22 end In Algorithm 2, the context vector 0¾ is computed at line 15 after the encoder timesteps (line 8) have been traversed. The decision to halt (line 11 and 12) is made first, and 5 then the context vector is calculated. HS-DACS -An example of an ASR method A description of a method of speech recognition according to another example is provided next. The method is referred to as a head synchronous decoder adaptive 10 computation steps (HS-DACS) ASR. The method may be implemented in an architecture similar to that of Fig. 5. However, the HS-DACS ASR architecture does not comprise the DRL-HS-DACS sub-layer. Algorithm 3 - HS-DACS Inference for Transformer ASR Input: encoder states k(v), decoder states q, length T, maximum look-ahead step Af, number of heads / / , number of decoder layers A^. Initialization: = (sm), to ■= 0 while + (eos) do for I = 1 to Nd do ac(Nl = 0 for j — 1 to min(tj»i + M. T) do for / ? --- 1 to II do p*'.- = sigmoid () ' ' ' "V i .44 += p^ end u 12 if aeeN1 >H then | break end 13        end 0? 12 24 M IS M 17 18 19 20 for h — Ito H do I JM ,.44 , / 4 4 = >x 14 | i £—<m~~l ’■ i.m !n end cj = C’oncat(cJ’\ + = max(t», j) end 2i end In Algorithm 3, the context vector (Nj is computed at line 15 after the encoder timesteps have been traversed. The decision to halt (line 10 and 11) is made first, and then the context vector is calculated. 10 Compared to the HS-DACS method (shown in algorithm 3) that triggers the ASR output with the accumulation threshold alone, methods and systems 200, 300A, 300B and 500 improve the halting positions by inspecting the acoustic information gathered up to each timestep. The acoustic information corresponds to the interim context vector. For example, the acoustic information may be gathered by an agent. The ASR output will be emitted immediately if the agent takes a positive action, rather than waiting until a fixed threshold is reached by the accumulation. This effectively alleviates the weak attention problem occurring at many decoding steps. The agent models applied on the Transformer decoder layers are trained with the policy gradient method, where the reward scheme of the agent actions is based on the variations of ASR accuracy and computational cost observed on the training data, as described herein in relation to Fig. 7 and Fig. 8. 5 Results of experiments conducted on AIShell-1, Tedlium-2 and Librispeech datasets are described below and show that methods 200, 300A, 300B and system 500 achieve reductions in computational cost while maintaining the similar ASR performance. 10 Experimental Results - DRL-HS-DACS Experiments investigating the performance of speech recognition system 500 trained using the second variation of the training method described in relation to the Fig. 7 and using method 300B of Fig. 3B are described below. The method may be described as a DRL-HS-DACS based transformer automatic speech recognition (ASR). 15 The performance of the DRL-HS-DACS ASR has been verified on three datasets: CM AIShell-1 Chinese task, and Tedlium-2 and Librispeech English tasks. The £yj performance is shown in the below tables with the comparison to other reference 1— systems. CM 20 The input to all systems are 80-dimensional filterbank features plus 3-dimensional pitch-related parameters. Speed perturbation is conducted on the training data of AIShell-1 and Tedlium-2, while SpecAugment is applied on Tedlium-2 and Librispeech. The output labels for AIShell-1 include 4231 characters, and for Tedlium-2 and 25 Librispeech are 1000 and 5000 BPE tokenised word-pieces respectively. The architectures of the online ASR system are as follows. An identical front-end is shared among the tasks, which comprises 2 CNN layers of 256 kernels with the size of 3*3 and the stride of 2*2, so that the frame-rate can be reduced by 4 times. The 30 encoder stacks 12 standard self-attention layers, and utilises the chunk-wise streaming strategy as in as described herein, where the size of left, central and right chunks are the same as 64 frames. The attention dimension, number of heads and the size of FFN units of the encoder are {256, 4, 2048} for AIShell-1 and Tedlium-2, and {512, 8, 2048} for Librispeech. The decoder comprises 6 DRL-HS-DACS based self-attention layers 35 with the same parameters as the encoder of each task. The size of the agent’s hidden layer is set equal to the attention dimension. The joint CTC / attention training is conducted for all tasks with the weight of 0.3 to speedup convergence. We train the models for AIShell-1, Tedlium-2 and Librispeech with the total number of epochs and initial learning rate of {50, 10}, {100, 1} and {120, 5} respectively, following the Noam weight decay scheme with 25000 warm-up steps. The consecutive training steps O for each agent model is set to 10, and the bias term b added to the agent output is given as -4. The maximum look-ahead step M is not applied to the training process. During inference, the CTC score is also incorporated with the weight of {0.3, 0.3, 0.4} for the tasks in the order above. External language models are trained as well in order to rescore the n-best hypotheses produced from the beam-search decoding, which are a 650- unit 2-layer Long Short Term Memory (LSTM) network for AlShelU and a 2048-unit 4-layer LSTM for Tedlium-2 and Librispeech. The latency restriction M is set to 16. Table 2, 3 and 4 show the results of the proposed online ASR system on the three datasets in term of character / word error rate (CER / WER). For a sequence of tokens, the CER / WER may be obtained as (S+D+l) / N, where S is the number of substitutions, D is the number of deletions, I is the number of insertions, and N is the number of characters in the reference sequence. For fair comparisons, reference systems with the similar architecture and external language model used in our experimental setup are selected. From the results, one can observe that on all tasks, the DRL-HS-DACS model is able to obtain very close ASR performance to that of the HS-DACS counterpart. Specifically, even lower error rates are delivered by the proposed system on the test sets of AIShell-1 (6.7% CER) and Tedlium-2 (8.3% WER), as well as the test-clean set of Librispeech (2.6% WER), outperforming the previous state-of-the-art results of 6.8% CER, 8.4% WER and 2.7% WER achieved by the HS-DACS system. Table 5 compares the DRL-HS-DACS algorithm with the HS-DACS in respect of the computational cost measured with the r-value: xt CM CM i— CM which computes the ratio between the adaptive computation steps N-,h and the length of input T, with both terms summed over Nd decoder layers, H attention heads and L decoding steps of an utterance. The lower the r-value is, the less computational cost is committed in the decoding process. The numbers reported in Table 5 are the average 5 r-values for all the utterances within the test set. The DRL-HS-DACS based system achieves significant reductions in r-value compared with the HS-DACS baseline, with the relative gains of 40.0%, 32.8% and 53.4% on the test set of AISHell-1, Tedlium-2 and the test-clean / other set of Librispeech respectively. The lower computational cost implies that for most decoding steps, the agent optimised halting positions are earlier 10 than that produced by the fixed threshold alone, facilitating the ASR outputs to be emitted faster. Buiuiej} uo pioqsejq} uoije / nLunooe jo - S0VdSH-~13(J - sj / nsay lejueuj / jedxj K'O WO WO WO WO 49'0 an 9170 09'0 S3¥G-SH-Wa OVCFSH p«H0O aaqio uuop r«Riau 1 HRSW IW qxwhuqn ■qo^suqn pw >IFMSIV $ wx 4'9 9T X9 tn 9X5 4Z 9'9 tn jwuojsimi sava-SH 8'9 Z.7 9’9 $ 4 ^uuo^«Tui,$ova 1‘4 £,'2 8'9 ST .xw>wa :»'sa 9'6 W -'- OO c£ ST '• UOpU0«V p343ggpx 1'9 9'7 0'9 tn di>uw.pm?.ix ___________________________SSL. jmpo J3i|P livrap }S91 >' ^■J RMAi npwfepqn «» (¾ SH3M) W« to pj<>M > 02 12 24 rg r$ sova-s 11 i ho Kg £'6 .miuojswJi S3WSH OH - wwpsmui VWW ................................................................................................WH) Vg jouuojsiuui 'WWHPU «<> **« io® p<>M *£ W1 4'9 ii j^uMojwvax 8’9 4'9 3tttKyxm«x $;W<1"SH 1'4 £'9 £“4 K9 S'4 - J3ttuojsmx voo ^nw>v ouquo 4'9 - jMiuojsinox .....................................................................................................^BQ... ' HIRSIV (¼ «8©) x <wx Experiments investigating the performance of speech recognition system 500 trained using the second variation of the training method described in relation to the Fig. 7 in comparison to the first variation of the training method described in relation to Fig. 7 are described below. 5 To explore the effects of the accumulation threshold H in regularising the multiple attention heads, a control experiment has been conducted on AIShell-1 with the agent working alone (that is, as described in relation to the first variation of the training method of Fig. 7). The ASR inference performance is also investigated. The 10 comparison of ASR performance and computational cost between the DRL-HS-DACS systems with (method 300B) and without (method 300A) the threshold is provided in Table. 6. The system trained and inferred without the threshold (method 300A, first training 15 variation) achieves lower r-value compared with the (method 300B, second training variation). Declines in CER are seen on both the dev and the test sets with the relative CM losses of 10.3% and 22.4% respectively. When the threshold is not present (as in £yj method 300A and the first training variation), the unrestricted halting probabilities can 1— easily distribute across the entire encoders states, corrupting the context vectors during 20 the initial stages of training. Consequently, the agents tend to halt the decoding early, so as to avoid propagating the invalid acoustic information to the following computations. This results in the reduced r-value at the cost of degraded ASR accuracy. Fig. 9 shows a plot of ASR loss on the dev set of the above systems during training. The system with only the agent (method 300A, first variation) converges faster 25 at the beginning, but soon over-fits to the training data. The loss stays constantly higher than that of the system trained with the threshold (method 300B, second training variation), which also explains the declines in ASR accuracy. Inference with Cumulative attention algorithm 30 Fig. 10 is flow diagram of a speech recognition method according to another embodiment. In step 1210, a frame of speech audio is received. Step 1210 corresponds to step 210 of Fig. 2, for example. In step 1230, the frame of speech audio is encoded. Step 1230 corresponds to step 35 230 of Fig. 2, for example. In step 1240, a context vector, c, is determined (step 1240-a), a halting probability is derived (1240-b), and it is determined whether the obtained halting probability satisfies a predetermined condition (1250). 5 In step 1240-a, the context vector is determined based on the encoding of the frame of speech audio in step 1240-a. The determination of the context vector is described in further detail below. Briefly, the context vector is based on the acoustic information of the encoded frame. It may also carry historical acoustic information (for example, from previous frames of speech audio). The context vector is also referred to as an interim 10 context vector. As will be described later, the interim context vector may be obtained for each time step (frame) in an autoregressive fashion (that is, based on its past values). In step 1240-b, a halting probability is derived from the context vector. For example, the 15 halting probability is derived using a trainable model. The model may be referred to as a halting selector. The halting selector comprises a trained neural network. The halting CM selector comprises parameters 0 which are trainable parameters. The parameters 0 £yj may also be referred to as the weights of the halting selector. For example, the neural 1— network is implemented as a single or multilayer DNN. The halting selector takes as 20 input the context vector. The halting selector then maps the context vector to a halting probability. The halting probability represents the likelihood of halting a decoding step at a particular timestep. 25 The trained neural network of the halting selector may be implemented as a single / multi-layer deep neural network (DNN). For example, the DNN has an output dimension of one. In an example, the DNN comprises two fully-connected layers, where the input and output dimensions of the first layer are {D, D}, and those of the 30 second layer are {D, 1}, where D is the dimension of the context vector. Alternatively, the halting selector comprises a neural network that comprises a two-layer recurrent neural network (RNN), with the same dimensions as for the DNN. In step 1250, it is determined whether the obtained halting probability satisfies a 35 predetermined condition. If the condition is met, the method proceeds to step 1260. When the condition is met, a decision to halt is made. The decision to halt refers to halting step 1240. As will be described later, step 1240 may be performed at the decoder end of 5 transformer ASR. For example, step 1240 may be performed by a decoder layer of a decoder neural network. Step 1240 may be referred to as a decoding step. In step 1260, a token is derived. Step 1260 corresponds to step 260 of Fig. 2, for example. If the condition is not met, the method returns to step 1240, where an interim 10 context vector and a halting probability are determined. Step 1240 is then repeated on a subsequent frame of speech audio. Optionally, satisfying the predetermined condition comprises determining whether the halting probability is greater than or equal to a predetermined value. For example, the 15 condition is considered to be met if the halting probability is greater than or equal to “0.5”. CM £yj In step 1260, a token is derived. In the speech recognition method, when the speech 1— audio is recognised as text, the token may represent a character, phoneme, morpheme 20 or other morphological unit, word part, or word. In step 1270, a function is executed based on the derived token. The executed function includes at least one of command performance and / or text output. 25 Additionally and optionally, as will be described in relation to the following figures, performing step 1240 may include calculating further context vectors and calculating a combined context vector. Performing step 1240 may also include processing the context vector or a combined context vector using one or more linear layers. Additionally or optionally, performing the steps 1240, and 1260 may also include 30 processing the context vector, combined context vector, or output of the one or more linear layers with a classification layer. The output of the classification layer may be a plurality of probabilities or scores, e.g. a vector of probabilities or scores, with each probability or score indicating the likelihood that a given token is correct. The classification layer may be a cross entropy layer, a softmax layer, or a variation or 35 equivalent thereof. The derived token may be the token having the greatest corresponding probability or score or may be selected probabilistically based on the probabilities or scores, e.g. tokens having greater probabilities or scores being more likely to be selected. The probabilities or scores may be used in conjunction with a joint decoder which also utilizes a language model, which outputs probabilities or scores for each token based on tokens that have been previously output. Such a joint decoder 5 may calculate joint probabilities or scores based on both the language model probabilities or scores and the classification layer probabilities or scores. The token may then be derived as the token having the greatest combined probability or score, may be selected probabilistically based on the combined probabilities or scores, e.g. tokens having greater combined probabilities or scores being more likely to be 10 selected. Inference with Cumulative attention algorithm - cross attention layer Fig. 11 is a schematic illustration of a method 1300 according to an embodiment. Method 1300 may be used to implement step 1240 described in relation to Fig. 10, for 15 example. C\J The method 1300 relates to a decoder layer of a decoder neural network. The decoder £yj layer may be referred to as a self-attention decoder layer. The decoder neural network 1— may be referred to as a self-attention decoder. The decoder layer and the decoder 20 neural network will be described further below. The decoder neural network may comprise one or more decoder layers ( / ). The decoder layers may be stacked. Stacking of layers means that the output of one layer is fed as input into a subsequent layer. Optionally, the method 1300 relates to the last decoder layer of the stack of decoder 25 layers. The remaining decoder layers of the stack of decoder layers are equipped with the self-attention module and perform language modelling. The stack of decoder layers is described in relation to Fig. 12 (a). By last decoder layer, it is meant the decoder layer whose output is not passed to another decoder layer. For example, instead, the output is passed to an output layer. The output layer may comprise a linear and / or a 30 classification layer. Applying the method 1300 to the last layer only enhances ASR accuracy as well as improves (reduces) latency. Alternatively, method 1300 may also be applied to other layers of the decoder neural network. 35 Method 1300 comprises an initialisation step 1330. In step 1330, the context vector is initialised (c^ao). The context vector is denoted ¢ / ½. Here, h is an index denoting an attention head. There may be H attention heads, “i” represents the decoder step, represents the encoder time steps (and corresponds to the frame of speech audio 5 being considered). The above expressions will be described in more detail below. The expressions “context vector”, “attention head”, “decoder step”, “encoder time step” relate to a transformer ASR. The transformer ASR is streamlined to comprise combining the attention weights across the heads (when more than one head is 10 included) and to trigger the ASR to output at the same timestep for all heads. This is referred to as head synchronous decoder-end adaptive computation steps (HS-DACS). The method 1300 may be referred to as Cumulative Attention (CA). CA refers to the triggering of an ASR output based on accumulation of acoustic information at each 15 encoding time step ( / ). When more than one attention head is included, the attention heads of the same decoder layer are synchronised to have a unified halting position. CM Synchronising the attention heads alleviates the problem caused by the distinct £yj behaviour of individual heads. 1— 20 Method 1300 may be applied to the last decoder layer of the decoder neural network. In step 1330, the context vector is initialised. For example, the context vector is initialised to zero. 0% = 0. 25 For each frame of speech audio ( / ) until a condition is met, the following steps are carried out. In step 1340, an attention weight (aAj) is determined. To obtain the attention weight, attention energies (eAy) are first computed. For example, taking the decoding step i of 30 the last decoder layer, by a certain head h, the attention energy ehij of timestep j is calculated as: / , Equation (8) V dk In equation 8, q and k are the decoder and encoder states. The attention energy ehij is then passed to onto a sigmoid unit to produce a monotonic attention weight: = Sigmoid(e^,7) Equation (9) The sigmoid unit scales the energy to the range (0, 1), without accessing the entire input sequence. The outcome of equation 9 represents the relevance of the encoder state to the current decoding step ( / ). In step 1350, an interim context vector (Vy) is calculated. For example, an interim context vector is generated at each time step ( / ) in an autoregressive manner as follows: Equation (10) xt CM CM 10 In equation (10), o^j-i represents the interim context vector from a previous encoder step j-1, and represents an encoder state at time step j. The term d\j.i is discarded (e.g. set to 0) when j = 1. The interim context vector carries all the processed acoustic information accumulated at the current time step. 15 Note that the interim context vector is computed on-the-fly and carries all the acoustic information from history. The context vector is computed first and then used to derive a halting probability. Steps 1340 and 1350 are performed for each attention head h. After all self-attention heads h are considered, step 1360 is performed. In step 1360, the interim context vectors obtained for each attention head h are concatenated (¾). For example, the concatenated context vector may be obtained as 25 Cij = Concat(c1y, .... c^j). It will be understood that in arrangements where there is a single attention head (h =1), step 1360 is optional. The context vector from step 1350 may then be used instead of the concatenated vector. In step 1370, a halting probability (pij) is derived. The concatenated context vector (cy) is sent immediately to the halting selector where a halting probability (pij) is derived. Note, that the interim context vector is calculated up to timestep j. The halting probability (pij) is obtained as: j = Sigmoid(Halt-Select(cj.,) + r + <) Equation (11) 10 15 The halting probability (pzJ represents the likelihood of halting the decoding step at timestep j, given the acoustic features accumulated so far by all the attention head (Cij). The halting probability of equation (11) may be referred to as a third probability. The third probability is different from the second probability described in relation to Equation (2).The third probability (Equation (11)) has a similar physical meaning and functionality as the first probability of Equation (4). In Equation (11), the parameters r denotes a bias term that is initialised to a predetermined value, and e is an additive Gaussian noise applied only during training in order to encourage the discreetness of pij. During inference, e is not included. For example, r can have any negative value. For example, r is -4. The “HaltSelectQ” is applied by the halting selector which is described herein, cy is the concatenated context vector as described above. In step 1380, it is checked whether the halting probability py meets a condition (fourth condition). For example, the condition is: “Is halting probability pij >0.5 ?”. If the condition is met, the method 1300 is ended, and an ASR output is triggered (e.g. by sending the context vector cy to an output layer to predict the ASR output). If the condition is not met, the method 1300 is repeated for a subsequent timestep (i.e. a subsequent value of j). 25 During CA inference, pij is monotically computed at each timestep from j = 1, and the decoding step i would be halted at the earliest j where, for example, py >0.5. Note that the decision to halt (halting decision) is based on the whole encoding history, since the halting probability is obtained from the interim context vector. The method for speech recognition described in relation to Fig. 10 and Fig. 11 may be described by pseudocode below. Algorithm 4. Cumulative Attention Inference for Transformer ASR Input: encoder states k(v), decoder states g, input length T\ number of heads H. t 3 4 4 7 8 9 10 n 12 13 14 is 16 17 18 Initialization: i = 1, yo — to = 0 while (ms) do = 0 for j = I to T do for h — Ito H do = Sigmoid (----=^-—) / ?. n ; h h Cpy = cm~-i '1" end Cj , = Goncatfct .... c-.,) ' '■ :J ■ c : J ■* Pi^ = HaliSeteet^c^j) if pij 0.5 then | break end end 0? 12 24 Ci := c,.„ G = max(G.....lt j) pi = OutpntLayer(c4 z += 1 19 end In the pseudocode (algorithm 4), <sos> is a token representing a start of the sentence, and <eos> is a token representing an end of a sentence. The other variables and parameters shown in algorithm 4 correspond to those described in relation to method 5 1300. At line 3, initialisation step 1330 is performed. At lines 5 to 8, for each attention head (for h = 1 to H), the attention weight is determined (step 1340), and an interim context vector is calculated (step 1350). At line 9, the interim context vector is concatenated (Step 1360). At line 10, for an encoder timestep ( / ), the halting probability (step 1370) is derived. Line 10 of algorithm corresponds to equation 11. At line 11, it is 10 checked if the halting probability meets a condition (step 1380). At Line 12, the “break” represents a halt action where the iteration through encoder time steps (line 4) is halted. In line 15, a context vector c, is set to the concatenated interim context vector that has been computed so far. In line 16, t-, represents the time step at which the algorithm has halted, for a particular decoder step ( / ). In other words, t provides an 15 indication of when the halting decision was made (i.e. the halting position). At line 16 (t = maxtfi-ij)), ti is set to the larger of a current value of ti-i, or j (which is the halting position for the current decoder layer). At line 17, a token y is derived for each decoder step ( / ). The token is derived from the context vector c, of the last decoder layer. At line 18, the decoder step variable ( / ) is incremented. With reference to the system of 1500, the OutputLayerf.) in line 17 may correspond to the linear and classification layer 528, the joint online decoder 530, and / or the language model 540. 5 In algorithm 4, the decoding step may be halted by a halting probability pij >0.5. This may be referred to as a fourth condition or condition 4. Architecture for Cumulative attention algorithm The ASR system 1500 will be described next. The training of the ASR system 1500 will 10 be described afterwards, with reference to Fig. 12 (a). Fig. 12 (a) shows a schematic illustration of a system for performing speech recognition in accordance with example embodiments. The system 1500 may be implemented using one or more computer-executable instructions on one or more computing 15 devices, e.g. the hardware described below. The system 1500 may also be referred to as an ASR system, an ASR module or a speech recognition system, or speech CM recognition module. CM 1— The system 1500 may be implemented using one or more computer-executable 20 instructions on one or more computing devices, e.g. the hardware 900 described in relation to Fig. 15. The ASR system 1500 is a transformer system similar to the ASR system 500 described in relation to Fig. 5, except for the decoder neural network. 25 ASR system 1500 comprises a self-attention encoder 1510. The self-attention encoder 1510 corresponds to the self-attention encoder 510 of Fig. 5. ASR system 1500 comprises a self-attention decoder 1520. The self-attention decoder 30 1520 is similar to the self-attention decoder 520 except that the self-attention decoder layers 1525 and 1526 are different. The embedding layer 1522 corresponds to layer 522 of fig. 5. The positional encoding layer 1524 corresponds to layer 524 of Fig. 5. Linear and Classification Layer 1528 corresponds to layer 528 of Fig. 5. The language model 1540 and Joint online decoder 1530 also respectively correspond to layer 540 35 and 530 of fig. 5. The self-attention decoder 1520 comprises a stack of self-attention decoder layers. For example, the self-attention decoder 1520 comprises a stack of L self-attention decoder layers. Each of the first L-1 self-attention decoder layers 1525 have the following configuration. The first L-1 layers 1525 correspond to the self-attention decoder layers 5 other than the last self-attention decoder layer 1526. Each self-attention decoder layer 1525 comprises two sub-layers: a self-attention sub-layer and a position-wise feed forward sub-layer. Each self-attention decoder layer 1525 has the same configuration and operates in the same way as a self-attention encoder layer 516. The input to a selfattention decoder layer 1525 goes into the self-attention sub-layer and then goes into 10 the feed-forward network. Each self-attention decoder layer 1525 performs language modelling. Each self-attention decoder layer 1525 may use residual connections and layer normalisation after each sub-layer. A first of the one or more self-attention decoder 15 layers 1525 receives the augmented embedding as an input, i.e. the output of the positional encoding layer. Subsequent self-attention decoder layers receive the output CM of a preceding self-attention decoder layer. In an implementation, the one or more self- £yj attention decoder layers 1525 may be 6 self-attention decoder layers, the dimensions 1— of the self-attention sub-layer for each self-attention decoder layers may be 256, the 20 position-wise feedforward sub-layer of each self-attention decoder layer 1525 may have 2048 units, and each self-attention decoder layer may include four attention heads. The last self-attention decoder layer 1526 comprises a cascade of a multi-head self-25 attention sub-layer, a multi-head cross-attention sub-layer, and a feed-forward network sub-layer (FFN). Layer normalisation is also applied at their output to facilitate model convergence. Step 1240 or method 1300 are performed in the multi-head crossattention sub-layer of the last decoder layer 1526. For ease of language, this sub-layer will be referred to as the last decoder layer. The last decoder layer implements the 30 halting selector 1500b. The halting selector 1500b implements the method of Fig. 10 or method 1300 of Fig. 11 and is trained as described in relation to Fig. 12 (b). Training for Cumulative Attention Fig. 12 (b) is a flow diagram of a method 1700 for training a speech recognition system 35 1500. The speech recognition system 1500 may implement the method described in Fig. 10 and Fig. 11. The system 1500 comprises a halting selector 1500b. The halting selector 1500b corresponds to the halting selector described above in relation to 1240 and 1300. The halting selector 1500b is trained together with the ASR module 1500, using the same loss function 5 The ASR system 1500 and the halting selector 1500b are trained together. The system 1500 and the halting selector 1500b are trained using the same training data. The parameters of the system 1500 and the parameters of the halting selector 1500b are updated together. The ASR system 1500 and the halting selector 1500b are trained using the same loss function. The following steps are performed for each training pair of a training set. Each training pair 1710 includes a plurality of frames of speech audio and a sequence of training tokens. The training sequence of tokens may also be described as a gold standard sequence or a reference sequence. The training sequence of tokens may be derived 15 from an indication by a human of the contents of an utterance to which the plurality of frames of speech audio correspond. For example, a sequence of tokens representing CM the word, phrase(s) or sentence(s). CM 1— A sequence of tokens is derived from the plurality of frames of speech audio. For each 20 frame a token may be derived using the steps 1230 to 1260 of method 1200, or steps 1330 to 1380 of method 1300. The above steps may be implemented by speech recognition system 1500. Where the sequence of tokens includes a plurality of tokens, further tokens of the 25 sequence of tokens may be arrived at by applying the above steps to remaining frames of the plurality of frames of speech audio. Deriving a sequence of tokens and updating the weights of the speech recognition system comprise the following steps. 30 i. Each frame is encoded as described in relation to step 1230. ii. The encoder states of the encoder layers are fed to the last decoder layer 1526 of the decoder neural network 1520. 35 iii. For each encoder time step ( / ), the halting probability pij is derived, as described above in relation to steps 1330, 1340, 1350, 1360, and 1370. iv. A distribution halting hypotheses is then derived. The distribution of halting 5 hypotheses (¾) is obtained as: j -■1 = Pi,j ri1 Equation (12) fc=l 0? 12 24 - aij is the expected value of pij when considering all possible halting positions of the current decoding step ( / ). In this case, it is assumed the halting selector may 10 choose every time step ( / ) as a halting position with its own halting probability Pij. To include all halting positions (halting hypothesis), the expectation of halting probabilities at the current decoding step is computed. In Equation 12, the halting probability pij is multiplied by each of the result of the subtraction of the halting probability at each previous time step from 1 to / -1. 15 - Since the halting selector assigns hard decisions, making the system parameters non-differentiable, an expected value of the context vector c, is taken into account, by marginalising all possible halting positions. A hard-decision means that it is indicated which timestep is the halting position without considering any other timesteps on the probability basis. Marginalising all 20 possible halting positions means that all halting positions are considered. By the system parameters being non-differentiable, it is meant that, in this case, as the halting probability (output of the halting selector) is not utilised, the parameters of the halting selector is separated from the rest of the ASR system, thus the parameters cannot be updated together with the ASR module, resulting 25 in the halting selector parameters being non-differentiable to the cross-entropy loss function. v. The expected context vector is computed as: T c? “ Equation (13) j : In equation 13, Cij is the concatenated context vector and is obtained as described above in relation to steps 1330, 1340, 1350, and 1360, and ay is as described above. 5 vi. The expected context vector of Equation (13) is then directed to a feed-forward network and to obtain a predicted ASR output. For example, the ASR output is a token that is derived as described in Fig. 12 (a) or algorithm 4. vii. The predicted ASR output is then directed to a loss function to perform a weight 10 update 1720 of the parameters. The weight update is based on a difference between the derived sequence of token and the training sequence of token in accordance with a loss function. For example, the loss function is a cross-entropy loss function. The weight update is similar to the weight update 720 described in relation to Fig. 7. However, in this case, the weight update 1720 relates to weights of the entire ASR 15 system 1500 (including the weights of the halting selector 1500b). C\J Experimental results with CA algorithm £yj Experiments investigating the performance of the speech recognition system 1500 are 1— described in relation to Fig. 13, Fig. 14(a) and Fig. 14(b). System 1500 may implement 20 the method of Fig. 10 or 11 and is trained as described in relation to Fig. 12. The performance of the CA algorithm has been verified on two datasets, namely, AIShell-1 Chinese task, and the Librispeech English tasks. The performance is shown in the below tables with the comparison to other reference systems. 25 The system implementing the CA algorithm is also referred to as the CA transformer. The datasets are prepared as follows. Speed perturbation is applied to AIShell-1, while SpecAugment is conducted on Librispeech. The acoustic features are 80-dimensional 30 filterbank coefficients with 3-dimensional pitch information. The vocabulary of the datasets includes 4231 Chinese characters for AIShell-1, and 5000 BPE tokenised word-pieces for Librispeech. The architectures of the online ASR system are as follows. An identical front-end is 35 shared among the tasks, which comprises 2 CNN layers of 256 kernels with the width of 3x3 and the stride of 2x2, so that the frame-rate can be reduced by 2 folds. The 0? 12 24 encoder stacks 12 standard self-attention layers, and utilises the chunk-wise streaming strategy as in as described herein, where the size of left, central and right chunks are {64, 64, 32} frames. The number of heads, attention dimension, and the size of FFN units at each encoder layer are {4, 256, 2048} for AIShell-1 and {8, 512, 2048} for 5 Librispeech. The decoder comprises 6 layers with the same parameters as the encoder for each task. For the system implementing the CA algorithm, the last decoder layer comprises the halting selector. The joint CTC / attention training is conducted for all tasks with the weight of 0.3 to 10 speedup convergence. The learning rate of both tasks follows the Noam weight decay scheme with initial learining rate, warmup step, and number of epochs set as {1.0, 25000, 50} for AIShell-1, and {5.0, 25000, 120} for Librispeech. An external language model (LM) trained with the texts of the training set is incorporated to rescore the beam search (beam width=10) hypotheses decoded by the system, where the LM is a 650-15 unit 2-layer Long Short Term Memory (LSTM) network for Al Shell-1, a and a 2048-unit 4-layer LSTM for Librispeech. Tables 6, 7 and 8 show the results of the proposed online ASR system on the three datasets in term of character / word error rate (CER / WER). 20 For fair comparisons, reference systems with the similar architecture and external language model used in the system implementing the CA algorithm are selected. For example, both the MoChA and HS-DACS based reference systems are trained with only one cross-attention layer (D = 1), except for the HS-DACS on Librispeech which 25 has three cross attention layers (D = 3 as models with D = 1 or 2 failed to converge well). Here, D represents the number of decoder layers from the top (i.e. last layer) that have cross-attention sub-layers. If D = 1, then only the very top layer has a crossattention sub-layer. Table 6. Character error rates (CERs%) on AI-Shell-1 Model dev test Offline TramfomKT [8] 6.7 Online MMA-MoChA Transformer

[15] 7.5 BS-DEC Transformer

[19] 6.4 7.3 MoChA Transformer 6.4 7.2 HS-DACS Transformer 6.3 7.0 CA Transformer 6.3 7.0 Table 7. Word error rates (WERs%) on Librispeech Model dev test clean oilier dean oilier Offline Transformer (ours) 2.4 6.0 2.6 6.1 Online CIFRO] - 33 9.6 Triggered attention [18| - 2.8 7.2 BS-DEC Transformer [ 19] 2.5 6.S 2.7 7.1 MoC h A Tram former 2.8 7.1 3.1 7.4 HS-DACS Transformer 2.4 6.6 2.6 6.6 CA Transformer 2.5 6.7 2.7 6.8 0? 12 24 As shown in Table 6 and Table 7, the CA transformer obtains improved accuracies. With regard to the reproduced MoChA and HS-DACS models, on AIShell-1, CA obtains 5 a relative gain of 2.8% when compared with MoChA, and similar performance to HS-DACS. As for Librispeech is concerned, CA outperforms MoChA in both clean and noisy conditions with the relative gains of 16.1% and 10.8%, respectively. Moreover, CA still achieves comparable WERs to HS-DACS, given fewer cross-attention layers were used in the CA system. The latency of the CA transformer during inference has also been measured and compared to the reference MoChA and HS-DACS systems. The latency is determined as a corpus-level latency from: 15 where A / denotes the total number of utterances in the dataset, | / | is the number of output tokens in each utterance, and the difference (b* - t^i) between the boundary of the right input chunk b*i where the halting position is located, and the actual boundary of the output token bki. The actual boundary bki may be obtained from a hidden Markov model (HMM) forced alignment. Since there might be ASR errors in the hypothesis sequence that will result in faulty latency computation, only b* / of the correctly decoded 5 tokens is included in the above equation. Though this might lead to different denominators in in the above equation for latency, the comparison of latency is still reasonable given that similar ASR accuracies are achieved by all three systems. Also, as all the online attention mechanisms in our experiments are independently performed at each decoding step, the halting positions may not be monotonic. Thus, when 10 computing the latency, b* is synchronised to the furthest timestep ever seen in the decoding process (see Algorithm. 4 line 16). 0? 12 24 Table 8 presents the latency levels of MoChA, HS-DACS and CA based systems evaluated on AIShell-1 and Librispeech datasets. In order to have a fair comparison to 15 CA, in both MoChA and HS-DACS, the maximum look-ahead steps (M) is not applied during the decoding process. On AlShell-1, it is observed that the latency levels of both systems seem to be reasonable when compared to the offline system, while on Librispeech, it is noticed that the latency levels were close to the offline system, due to the redundant heads that cannot capture valid attentions. In order to reduce the 20 latency, a maximum look-ahead step of M = 16 is imposed during recognition only for the Librispeech task. One can observe that CA (without M) achieves better latency levels than MoChA and HS-DACS on both AIShell-1 (without M) and on Librispeech (with M). Table 8. Latency (frames) on AIShell-1 and Librispeech Model AIShell-1 Librispeech <1ev test dev test cleaii other deaf) other offline 232.8 257.0 497.9 440.7 528.5 463.8 MoChA 90.1 92.5 295.2 256.4 303.1 271.2 HS-DACS 53.4 54.2 1.63.8 145.0 156.1 146.5 CA 52.8 51.8 68.1 63.5 68.5 65.5 25 The poor latency performance given by MoChA and HS-DACS might be explained by looking at the halting decisions of various heads to generate the ASR outputs, as shown in Fig. 13 and Fig. 14 (a). Fig. 13 shows eight sub-plots, with each sub-plot corresponding to the output one of the eight attention heads of the MoChA system. The sub-plot are shown in order and correspond to the attention heads one to four (row 1, left to right) and attention heads five to eight (row 2,, left to right). Each sub-plot is a colour map showing an output sentence (vertical axis) against the input (horizontal axis), with the colour representing a halting decision. A bright colour indicates that 5 decoding has been halted, while dark represents that no halting decision is obtained (so decoding is not stopped) . The input may be understood as the index of the audio frame or the encoder index (j). The output corresponds to the sequence of tokens {_HE,_MUST,_HAVE,_REALI,Z ,ED, J, _WAS, _A, -STRANGER, _AND, -WISHED, _TO, _TENDER, _HIS, -HOSPITALITY, _TO, _ME, J, -ACCEPTED, JT , 10 -GRATEFULLY, _l, -CLASPED, _HIS, _HAND, _HE, -PRESSED, _MINE, <eos>}. It can be observed from Fig. 13 that heads 2, 3 and 6 in MoChA are mostly unable to halt the decoding and have to rely on the truncation executed by the maximum look-ahead steps. For these heads, in most cases the MoChA cannot halt decoding, 15 resulting in MoChA failing to halt, since the halting position is subject to the head making the latest decision. Intead, the MoChA relies on a maximum look-ahead step to C\J halt. In more detail, for head 2, the halting decisions (the bright regions) are not £yj monotonic. For heads 3 and 6, the halting decision are not obtained for all the output 1— tokens (the maximum look-ahead step is instead use to halt the decoding). CM 20 Fig. 14 (a) shows halting decisions for the HS-DACS system. In Fig. 14 (a) the horizontal and vertical axes are the same as for Fig. 13. The colour indicates the halting decision (corresponding to phJij in line 7 of Algorithm 3). Bright colours indicate when decoding is halted, while dark represents that no halting decision is obtained. 25 From Fig. 14 (a), it can be observed that some halting positions are far away from the previous one, and the halting position of the next decoding step goes back to normal. This can be seen, for example, in the decoding step of ‘_HAVE’ and the first ‘J’. It is perceivable that the halt is done by the maximum look-ahead steps. The accumulation of halting probabilities in HS-DACS heads fails to exceed the joint-threshold (number of 30 heads, 8) at certain decoding steps, making the inference process reach the end of speech at early stages. For example, the halting decisions (the bright regions) are not monotonic. Fig. 14 (b) shows the halting probabilities for the CA transformer. In Fig. 14(b) the horizontal and vertical axes are the same as for Fig. 13. The colour indicates the 35 halting probability (corresponding to in line 10, 11 of Algorithm 4). Bright colours indicate when decoding is halted (i.e. the condition in line 11 of algorithm 4 is met), while dark represents that no halting decision is obtained. Unlike the MoChA (Fig. 13) and the HS-DACS (Fig. 14(a)), the halting decisions in the 5 CA transformer are made monotonically and always in time. Although CA might also have redundant heads, these heads can be backed up by the other functioning ones, since all of them are synchronised and the halting decision is based on the overall acoustic information. 10 Computer hardware Fig. 15 is a schematic of the hardware that can be used to implement methods and systems in accordance with embodiments described herein. It should be noted that this is just one example and other arrangements can be used. 15 The hardware comprises a computing section 900. In this particular example, the components of this section will be described together. However, it will be appreciated CM they are not necessarily co-located. CM 1— Components of the computing system 900 may include, but not limited to, a processing 20 unit 913 (such as central processing unit, CPU), a system memory 901, a system bus 911 that couples various system components including the system memory 901 to the processing unit 913. The system bus 911 may be any of several types of bus structure including a memory bus or memory controller, a peripheral bus and a local bus using any of a variety of bus architecture etc. The computing section 900 also includes 25 external memory 915 connected to the bus 911. The system memory 901 includes computer storage media in the form of volatile / or non-volatile memory such as read-only memory. A basic input output system (BIOS) 903 containing the routines that help transfer information between the elements within 30 the computer, such as during start-up is typically stored in system memory 901. In addition, the system memory contains the operating system 905, application programs 909 and program data 909 that are in use by the CPU 913. Also, interface 925 is connected to the bus 911. The interface may be a network 35 interface for the computer system to receive information from further devices. The interface may also be a user interface that allows a user to respond to certain commands et cetera. In this example, a video interface 919 is provided. The video interface 919 comprises a 5 graphics processing unit 919 which is connected to a graphics processing memory 921. Graphics processing unit (GPU) 919 is particularly well suited to the training of the speech recognition system due to its adaptation to data parallel operations, such as 10 neural network training. Therefore, in an embodiment, the processing for training the speech recognition system may be divided between CPU 913 and GPU 919. It should be noted that in some embodiments different hardware may be used for the training the speech recognition system and for performing speech recognition. For 15 example, the training of the speech recognition system may occur on one or more local desktop or workstation computers or on devices of a cloud computing system, which CM may include one or more discrete desktop or workstation GPUs, one or more discrete £yj desktop or workstation CPUs, e.g. processors having a PC-oriented architecture, and a 1— substantial amount of volatile system memory, e.g. 16GB or more. While, for example, 20 the performance of speech recognition may use mobile or embedded hardware, which may include a mobile GPU as part of a system on a chip (SoC) or no GPU; one or more mobile or embedded CPUs, e.g. processors having a mobile-oriented architecture, or a microcontroller-oriented architecture, and a lesser amount of volatile memory, e.g. less than 1GB. For example, the hardware performing speech recognition 25 may be a voice assistant system 120, such as a smart speaker, or a mobile phone including a virtual assistant. The hardware used for training the speech recognition system may have significantly more computational power, e.g. be able to perform more operations per second and have more memory, than the hardware used for performing tasks using the agent. Using hardware having lesser resources is possible because 30 performing speech recognition, e.g. by performing inference using one or more neural networks, is substantially less computationally resource intensive than training the speech recognition system, e.g. by training one or more neural networks. Furthermore, techniques can be employed to reduce the computational resources used for performing speech recognition, e.g. for performing inference using one or more neural 35 networks. Examples of such techniques include model distillation and, for neural networks, neural network compression techniques, such as pruning and quantization. Whilst certain embodiments have been described, these embodiments have been presented by way of example only, and are not intended to limit the scope of the inventions. Indeed, the novel devices, and methods described herein may be 5 embodiedin a variety of other forms; furthermore, various omissions, substitutions and changes in the form of the devices, methods and products described herein may be made without departing from the scope of the invention as defined by the appended claims. 10 15

Claims

1. A computer implemented method for speech recognition, the method comprising:receiving a frame of speech audio;encoding the received frame;5 determining a context vector from the encoding of the received frame;deriving an action for the received frame from the context vector determined from the received frame using a trained model, the action corresponding to a variable indicating whether a token should be derived;responsive to the action satisfying a predefined condition, deriving the token 10 from the context vector; and;executing a function based on the token, wherein the function comprises at least one of text output or command performance.

2. A method according to claim 1, wherein the action is derived by way of an agent, 15 wherein the agent comprises the trained model, and wherein deriving the action C\l comprises:inputting the context vector into the trained model;v— determining a first probability from the trained model;comparing the first probability to a predefined threshold; and20 setting the action based on the comparison.

3. A method according to claim 2, wherein determining the first probability from the trained model comprises;adding a predetermined bias to an output of the trained model; and25 applying a sigmoid function to the result of the addition to obtain the firstprobability.

4. A method according to claim 2, or 3, wherein the agent comprises a deep neural network.

305. A method according to any of claims 2 to 4, wherein the first probability is calculated using a self-attention decoder layer of a decoder neural network.

6. A method according to claim 5, wherein determining the context vector comprises35 using a context vector determined from a preceding frame of speech audio.

7. A method according to claim 5 or 6, wherein determining the context vector comprises:determining a second probability, wherein the second probability corresponds to 5 an attention weight of the self-attention decoder layer.

8. A method according to claim 7, wherein determining the context vector comprises: multiplying the second probability by an encoder state, the encoder state being derived from the received frame of speech audio.

109. A method according to any of claims 5 to 8 wherein the self-attention decoder layer is a multi-head self-attention decoder layer that comprises a plurality of attention heads, and wherein the second probability is calculated using an attention head of the plurality of attention heads.1510. A method according to claim 9, wherein determining the context vector comprises determining a first context vector from each of the plurality of attention heads, and concatenating the determined first context vectors to obtain the context vector.20 11. A method according to any of claims 7 to 10, comprising adding the determinedsecond probability to an accumulator variable, and wherein,responsive to the accumulator variable satisfying a second condition, deriving a token from the context vector; andexecuting a function based on the token, wherein the function comprises at 25 least one of text output or command performance.

12. A method according to claim 1, wherein the action corresponds to a third probability, wherein the action is derived by way of a halting selector comprising the trained model, the halting selector being configured to generate the third probability, 30 wherein the third probability represents a probability that a token should be derived from the context vector.

13. A computer implemented method for training a speech recognition system, the method comprising, for training data that comprises a frame of speech audio and a 35 training token,1015encoding the frame of speech audio;determining a context vector from the encoding of the frame;deriving, by way of an agent that comprises a trainable model, an action from the context vector;responsive to the action satisfying a predefined condition, deriving a predicted token from the context vector;determining a prediction correctness by comparing the predicted token with the training token, wherein the prediction correctness indicates that the prediction is correct when the predicted token matches the training token;obtaining a halting position based on the predicted token, wherein the halting position represents a time step at which the predefined condition is satisfied;determining a reward based on the determined prediction correctness and the obtained halting position; andupdating weights of the agent based on the determined reward.

14. A method according to claim 13, wherein determining the reward comprises:obtaining a first prediction correctness and a first halting position from a first training epoch;obtaining a second prediction correctness and a second halting position from a second epoch, wherein the first epoch precedes the second epoch; andcomparing the first prediction correctness with the second prediction correctness, and comparing the first halting position with the second halting position.

15. A method according to claim 14 wherein:25 the determined reward has a first value when:the second halting position is greater than the first halting position; or,the second halting position is equal to the first halting position and the first prediction correctness differs from the second prediction correctness; or,the second halting position is smaller than the first halting position and30 the second prediction correctness indicates that the prediction is correct;the determined reward has a second value when:the second halting position is equal to the first halting position, and the first prediction accuracy is equal to the second prediction accuracy; orthe second halting position is smaller than the first halting position, and35 the first and second prediction accuracies are equal and low; andthe determined reward has a third value when the second halting position is smaller than the first halting position and the second prediction accuracy is smaller than the first prediction accuracy,wherein the first value is larger than the second value and the second value is 5 larger than the third value.

16. A method according to claim 15, wherein the first value is zero, and the second and third values are negative.10 17. A method according to any of claims 13 to 16, wherein determining the contextvector comprises:determining a second probability, wherein the second probability corresponds to an attention weight of a self-attention decoder layer; andadding the determined second probability to an accumulator variable, and15 wherein satisfying the predefined condition comprises comparing the accumulator variable to a predetermined threshold.V XI^M 18. A method according to claim 17 wherein the predefined condition is satisfied whenthe accumulator variable is less than the predetermined threshold.CM 2019. A carrier medium comprising computer readable code configured to cause a computer to perform a method according to any of the preceding claims.

20. A system for speech recognition, the system comprising a processor, the processor25 configured to:receive a frame of speech audio;encode the received frame;determine a context vector from the encoding of the received frame;derive an action for the received frame from the context vector determined from30 the received frame using a trained model, the action corresponding to a variable indicating whether a token should be derived;responsive to the action satisfying a predefined condition, derive the token from the context vector; and;execute a function based on the token, wherein the function comprises at least 35 one of text output or command performance.

Citation Information

Patent Citations

  • Speech recognition systems and methods

    GB2600987A