Text information extraction

The method addresses the memory and processing constraints of existing text extraction models by training a smaller language model from a larger one, optimizing hyperparameters to enable efficient text extraction on resource-limited devices.

WO2024189326A1PCT designated stage expired Publication Date: 2024-09-19SPROUT AI LTD
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
PCT/GB2024/050631
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-10
Filing Date
2024-03-08
Publication Date
2024-09-19

AI Technical Summary

Technical Problem

Existing text information extraction models require significant computer memory and processing resources due to their large number of parameters, limiting their use in devices with limited storage and processing capabilities, such as smartphones.

Method used

A method involving a two-stage training process where a larger pre-trained language model is fine-tuned using a smaller dataset to generate a second, smaller language model with fewer parameters, which is then used for text extraction, optimizing hyperparameters through Bayesian optimization to reduce memory usage and improve computation speed.

Benefits of technology

The approach allows for efficient text information extraction on devices with limited resources while maintaining performance, as the smaller model achieves comparable results to the larger model with reduced memory and computation requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure GB2024050631_19092024_PF_FP_ABST
    Figure GB2024050631_19092024_PF_FP_ABST
Patent Text Reader

Abstract

A text information extraction system, comprising: an input for receiving text data; an output for outputting text information; and one or more processors configured to: obtain a first model; update the first model using a first dataset comprising a plurality of first example input texts each comprising a first target sequence of one or more text units, wherein the first model is updated to improve performance at a task of generating a first output text comprising the first target sequence from a first example input text; generate a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtain a second model; train the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model; receive, by way of the input, text data; extract text information from the input text data using the trained second model; output, by way of the output, text information.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] Text information extraction

[0002] Field

[0003] The present invention relates to a text information extraction system and method.

[0004] Background

[0005] Various text information extraction applications use machine learning models to identify relevant words in text.

[0006] In many applications, processing of the text must be performed on a device with limited storage and computer processing resource. There is a continuing need to provide models that use less computer memory and have a faster computation time.

[0007] Summary

[0008] According to a first aspect, there is provided a text information extraction system, comprising: an input for receiving text data; an output for outputting text information; and one or more processors configured to: obtain a first model; update the first model using a first dataset comprising a plurality of first example input texts each comprising a first target sequence of one or more text units, wherein the first model is updated to improve performance at a task of generating a first output text comprising the first target sequence from a first example input text; generate a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtain a second model; train the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model; receive, by way of the input, text data; extract text information from the input text data using the trained second model; output, by way of the output, text information.

[0009] In one example, generating the second output text comprises taking the second input text as input to the updated first model to generate a next text unit, wherein the next text unit is taken as the first text unit in the second output text, and repeatedly running the updated first model to generate further text units in the second output text taking the previously generated text units together with the second input text as input to the updated first model.

[0010] In one example, each first example input text comprises one or more further target sequences of one or more text units followed by a further text comprising the further target sequence of one or more text units.

[0011] In one example, obtaining the first model comprises training a first language model.

[0012] In one example, obtaining the second model comprises training a second language model.

[0013] In one example, generating the second dataset comprises generating a plurality of second output texts using the updated first model, and for each of the plurality of second output texts, determining whether the second output text meets a set of one or more criteria, wherein the second output text is included in the second dataset as a second example input text responsive to meeting the set of one or more criteria.

[0014] In one example, the system is an embedded device.

[0015] In one example, updating the first model comprises performing an optimisation process to determine values for one or more hyper-parameters of the first model. In one example, the optimisation process comprises performing a Bayesian optimization.

[0016] In one example, the Bayesian optimization uses a Tree Parzen Estimator.

[0017] In one example, the optimisation process uses a performance metric generated by a first discriminator model.

[0018] In one example, the first discriminator model comprises a second language model.

[0019] In one example, the second model comprises the second language model.

[0020] In one example, the first discriminator model is trained to provide an indication of whether an input is generated by a person or a model, and wherein the first discriminator model takes a first output text output from the first model as input to generate the performance metric.

[0021] In one example, the method further comprises determining a recommendation based on the extracted text information.

[0022] In one example, the text data is received from a user device and wherein the output is provided to a service provider, and wherein the output text information corresponds to the determined recommendation.

[0023] According to a further aspect, there is provided a computer implemented method comprising: obtaining a first model; updating the first model using a first dataset comprising a plurality of first example input texts each comprising a first target sequence of one or more text units, wherein the first model is updated to improve performance at a task of generating a first output text comprising the first target sequence from a first example input text; generating a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtaining a second model; training the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model.

[0024] According to a further aspect, there is provided a computer implemented method of text information extraction, comprising: receiving, by way of an input, text data; extracting text information from the input text data using a second model trained according to the method; outputting, by way of an output, text information.

[0025] According to another aspect, there is provided a non-transitory computer readable storage medium comprising computer readable code configured to cause a computer to perform the method. According to another aspect, there is provided a carrier medium comprising computer readable code configured to cause a computer to perform any of the above methods. According to another aspect, there is provided a non-transitory computer readable storage medium comprising program instructions stored thereon that are executable by a computer processor to perform any of the above described methods. 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, 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.

[0026] According to another aspect, there is provided a system, comprising a second model trained according to the method.

[0027] According to another aspect, there is provided a text information extraction system, comprising: an input for receiving text data; an output for outputting text information; and one or more processors configured to: obtain a first model; update the first model using a first dataset comprising a plurality of first example input texts each comprising a first target sequence of one or more text units; generate a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtain a second model; train the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model; receive, by way of the input, text data; extract text information from the input text data using the trained second model; output, by way of the output, text information.

[0028] According to another aspect, there is provided a system, comprising: an input for receiving text data; an output for outputting text information; and one or more processors configured to: obtain a first model; update the first model using a first dataset comprising a plurality of first example input texts each comprising a first target sequence of one or more text units; generate a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtain a second model; train the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model.

[0029] According to another aspect, there is provided a computer implemented method comprising: obtaining a first model; updating the first model using a first dataset comprising a plurality of first example input texts each comprising a first target sequence of one or more text units; generating a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtaining a second model; training the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model.

[0030] According to another aspect, there is provided a text information extraction system, comprising: an input for receiving text data; an output for outputting text information; and one or more processors configured to: obtain a first model; generate a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtain a second model; train the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model; receive, by way of the input, text data; extract text information from the input text data using the trained second model; output, by way of the output, text information.

[0031] According to another aspect, there is provided a system, comprising: an input for receiving text data; an output for outputting text information; and one or more processors configured to: obtain a first model; generate a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtain a second model; train the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model.

[0032] According to another aspect, there is provided a computer implemented method comprising: obtaining a first model; generating a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtaining a second model; training the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model.

[0033] Brief Description of Figures

[0034] Figure 1 is a schematic illustration of a method of training a second model to perform text information extraction according to an embodiment;

[0035] Figure 2(a) is a schematic illustration of the structure of an example first model, which may be used in the method of Figure 1 according to an embodiment;

[0036] Figure 2(b) shows a schematic illustration of an example process of updating the first model which may be performed in S2 of the method of Figure 1;

[0037] Figure 2(c) shows an example of a first discriminator model;

[0038] Figure 3 is a schematic illustration of an example method of using the updated first model to generate a third training dataset in S3 of the method of Figure 1 ;

[0039] Figure 4 is a schematic illustration of an example of a method performed in S4 of Figure 1 ;

[0040] Figure 5(a) shows an example process of training the second model in S6 of Figure 1;

[0041] Figure 5(b) is a schematic illustration of the structure of an example second model;

[0042] Figure 6 shows an example method of text information extraction using the trained second model;

[0043] Figure 7(a) is a schematic illustration of an example method pre-training a first language model;

[0044] Figure 7(b) is a schematic illustration of a method pre-training a second language model; Figure 8(a) shows a schematic illustration of a system in accordance with an embodiment;

[0045] Figure 8(b) shows a schematic illustration of a text information extraction system in accordance with an embodiment;

[0046] Figure 9(a) is a schematic illustration of a system comprising the text information extraction system according to an embodiment;

[0047] Figure 9(b) is a schematic illustration of a method performed by the system shown in Figure 9(a) according to an example.

[0048] Detailed Description

[0049] Various information extraction applications use machine learning models to identify relevant words in text. For example, a machine learning model may be used to process insurance claims. The text submitted in an insurance claim may be processed by a trained model to identify the appliance that the insurance claim relates to. An example insurance claim may comprise the text “When moving house, our SuperBright 5.0 TV was broken". A trained model may be used to identify the TV model from the text - in this example, the text to be extracted is: SuperBright 5.0.

[0050] A few-shot learning approach may be used to train a model to perform text information extraction. In such approaches, a first training stage, also referred to as a pre-training stage, may be performed using a large general training dataset. For example, a large language model may be pre-trained using a large corpus of general text data. A second training stage, also referred to as a fine-tuning training stage, may then be performed using a very small corpus of labelled data that is specific to the text extraction task - a specific dataset. For example, a specific training dataset comprising insurance claim texts (e.g. “When moving house, our SuperBright 5.0 TV was broken") and a label indicating the relevant words to be extracted for each text (SuperBright 5.0) can be used to further train a pre-trained large language model in a supervised manner to extract relevant words from insurance claim texts. In a few-shot learning approach, the specific dataset may comprise fewer than 30 examples, or even fewer than 20 examples.

[0051] Other approaches may even omit the fine-tuning training stage. Since a large language model is often trained against many different tasks (for example, translation, summarisation, question and answer, etc), the large language model may be able to learn from the general training dataset that it must also infer the desired task from the input prompt. Further fine-tuning training of the model (i.e. further updating of the model parameters, such as the weights and biases of the model layers) is then not required for the model to perform a specific task.

[0052] However, the language models used in such learning approaches have a large number of parameters, in order that various different specific tasks could be learned, for example by using a very small dataset during the fine tuning stage. In particular, a model that is used without a fine-tuning training stage may have an extremely large number of parameters in order to learn language and also learn how to spot patterns from an input prompt from the general dataset, in order to perform tasks a smaller model would require fine tuning training to do.

[0053] This means that once fully trained, the final model requires a large amount of working memory to run. This limits the use of such models in embedded devices for example, such as smartphones, since large amounts of memory are required to store the model and to run the model. Although for some applications, fine-tuning training of a smaller pre-trained language model with a larger specific training dataset may achieve the required performance, such larger specific datasets may not be readily available for every use case.

[0054] Figure 1 is a schematic illustration of a method of training a second model to perform text information extraction according to an embodiment.

[0055] The method comprises a step S1, comprising obtaining a first model. In this step, a pre-trained first language model is obtained. The first language model is a larger language model, i.e. having a larger number of trainable parameters than the second language model. For example, the first language model comprises a larger number of attention layers than the second language model. The step S1 may comprise a process of pre-training the first language model using a general dataset. An example of a pretraining process that may be used in this step will be described in relation to Figure 7(a) below.

[0056] The method further comprises a step S2, in which a fine-tuning update process is performed on the first model, in order to improve the performance of the first model in relation to the task of generating training examples for text extraction. In this step, the first model is updated to improve performance at the task of generating a first output text from a first input text using a first dataset comprising a plurality of first example input texts each comprising a first target sequence of one or more text units. The first model is updated to improve performance at generating a first output text comprising the first target sequence from an input first input text. An example of a fine tuning update process that may be used in this step will be described in relation to Figure 2 below. In this step, the hyper-parameters of the first model may be optimised.

[0057] Once updated, the first model is used to generate a training data set for text extraction, in S3. An optional step, S4, is then performed to filter this training data set to provide the second data set. In S3 and S4, a second dataset is generated using the first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the first model, including the second output text in the second dataset as a second example input text, and including the second target sequence corresponding to the second input text in the second dataset as a second example output text. This is described in more detail in relation to Figures 3 and 4 below.

[0058] In S5, a second model is obtained. In this step, a pre-trained second language model is obtained. The second language model is a smaller language model, i.e. having a smaller number of trainable parameters than the first language model. The step S5 may comprise a step of pre-training the second language model using a general dataset. An example of a pre-training process that may be used in this step will be described in relation to Figure 7(b) below.

[0059] In S6, the second model is trained using the second data set generated by the larger first model. In this step, the second model is trained to identify a third target sequence of one or more text units in a third input text using the second dataset. This is described in more detail in relation to Figure 5 below.

[0060] The second model is a smaller model than the first model. For example, the second model may be more than 4 times smaller than the first model. For example, the second model may be more than 10 times smaller than the first model. For example, the second model may be more than 20 times smaller than the first model. The second model is trained to perform text extraction in a supervised manner using a large dataset generated by the first model. The second model comprises a smaller number of parameters than the first model. For example, the second model comprises a smaller number of attention layers than the first model. This allows the second model, once trained, to be stored and run on devices having limited storage - for example embedded devices, or CPUs. Using the trained second model to perform text extraction uses less computer memory than to run the first model, and results in a faster computation time without sacrificing performance at the resulting text extraction.

[0061] Due to the larger number of attention layers, the first model is able to perform few shot or zero shot learning. For example, it may be able to achieve the same or greater performance as the second model at a specific language task, having been trained on a smaller number of examples or on no examples. Although trained on a smaller number or no examples, the first model is able to generate examples of a sufficient quality for use training the second model.

[0062] Figure 2(a) is a schematic illustration of the structure of an example first model 21 , which may be used in the method of Figure 1 according to an embodiment.

[0063] The first model 21 comprises a first, larger, language model 33. Although a specific large language model 33 is described here, various large language models are known and can be used, for example large GPT models such as GPT-3, GPT-J and GPT- NEO, seq2seq models such as TO and BLOOM, or models such as Chinchilla or Gopher. The first language model 33 may be capable of generating in principle any language output, in other words a general language output. The first language model 33 may be large enough that few shot or zero shot learning capabilities are possible. For example, the first model 21 may comprise greater than or equal to 1.3 billion parameters. The first model may be greater than or equal to 5 GB in size. The first model may comprise greater than or equal to 2 billion parameters. The first model may be greater than or equal to 10 GB in size. The first model may comprise greater than or equal to 6 billion parameters. The first model may be greater than or equal to 24 GB in size. The first model may comprise greater than or equal to 2 billion parameters and less than or equal to 8 billion parameters. The first model may be smaller than or equal to 32 GB and greater than or equal to 10 GB in size. The first model may comprise greater than or equal to 6 billion parameters and less than or equal to 8 billion parameters. The first model may be smaller than or equal to 32 GB and greater than or equal to 24 GB in size. The first model 21 is capable of learning few shot or zero shot learning. For example, a specific large language model that could be used as the first language model 33 is GPT-J-6B, which comprises 6 billion parameters, 28 layers, and is around 25GB in size.

[0064] The size of the first model 21 may be selected depending on the hardware used to update the first model 21. For example, the first model 21 may be generated with a number of parameters such that it is small enough to update on a single large server GPU.

[0065] The first language model 33 comprises a plurality of attention layers 27. In this example, the first language model 33 comprises a transformer decoder. For example, the first model 21 may comprise greater than or equal to 28 attention layers. The first model may comprise greater than or equal to 40 attention layers. The first model may comprise greater than or equal to 50 attention layers. The number of layers for the first model 21 is selected such that the first model 21 is capable of few shot or zero shot learning. In one example, the layers are autoregressive. In one example, the layers are unidirectional.

[0066] Figure 2(b) shows a schematic illustration of an example process of updating the first model 21 which may be performed in S2 of the method of Figure 1 described above. An outline of the structure of the example first model 21 shown in Figure 2(a) and this process will now be described. In the process, the first model 21 is updated to improve performance at a task of predicting the next word in a sequence, given an input sequence of one or more words. Prior to performance of the method described here, the first part 24 and the second part 25 of the first model 21 - corresponding to the first language model 33 - have been pre-trained using a general dataset. In this example, during the fine-tuning update process performed in S2, the parameters of the first model 21, including the weights and biases of the model layers, are not modified. However, the hyper-parameters of the first model 21 are fine-tuned to improve the performance at the generation task. In particular, hyper-parameters associated with the selector 32 are optimised. In other examples however, during the fine-tuning update process performed in S2, the parameters of the first model 21 are updated to improve performance, as well as or instead of the hyper-parameters.

[0067] The fine-tuning process in S2 is performed using a first data set of examples. The first data set is smaller than the second data set used to train the second model in S5 of the method. The first data set may comprise only a small number of examples. For example, the first data set may comprise less than 30 examples. The first data set may comprise less than 20 examples. The first data set may comprise greater than or equal to 5 examples. The examples in the first data set are prepared manually in this example.

[0068] The first data set comprises first example input texts. The example described here relates to processing of insurance claims, and in particular extracting a TV model make from an insurance claim. Extracting a TV model from the text of an insurance claim may be a difficult task, since there are a large number of possible available TV models, and generally users may use a variation on the TV model name, for example using only some of the words or using the words out of order. Each first example input text comprises: a first TV model followed by a sentence incorporating the first TV model, a second TV model followed by a sentence incorporating the second TV model, a third TV model followed by a sentence incorporating the third TV model, and a fourth TV model. The fourth TV model is a first target sequence of text units. An example first example input text is:

[0069] Model A3546;

[0070] My son dropped the Model A3546 TV;

[0071] XD4 TV;

[0072] We spilled water on the XD4 TV;

[0073] Model 5; The Model 5 television was stolen;

[0074] Model AX1;

[0075] The first example input text comprises a further target sequence of one or more text units (“Model A3546"), followed by a further text comprising the further target sequence, a yet further target sequence of one or more text units (“XD4 TV"), followed by a yet further text comprising the yet further target sequence, and a final further target sequence of one or more text units (“Model 5”), followed by a final further text comprising the final further target sequence. The first target sequence then follows the final further text. The first target sequence is located at the end of the first example input text. In this example, the first target sequence of text units is “Model AX ’.

[0076] The first data set further comprises first example output texts, which are used to train the first discriminator model 211 as will be described below. Each first example output text may comprise a sentence incorporating the fourth TV model from a first example input text for example - the first target sequence of text units. An example first example output text is:

[0077] I dropped my Model AX1 TV down the stairs

[0078] Here, a first example input text and a first example output text both comprise the same first target sequence of text units. However, first example output texts may comprise different target sequences - for example, some first example output texts may comprise TV models that are not included in any first example input texts, and vice versa.

[0079] The first model 21 is updated to improve performance at the task of generating a first output text from a first input text. The process performed during this update for the single first example input text shown above will now be described in order to illustrate the method and the first model 21. The first output text is generated one token at a time. Thus in a first step, the first example input text is taken as input to the tokeniser 22.

[0080] The tokeniser 22 takes the first example input text and outputs a sequence of tokens representing the first example text, from a vocabulary of Di possible tokens. An example tokeniser is a Byte-Pair Encoding based tokeniser, however various tokenisers may be used. For example, a modified version of a BPE tokenizer may be used in some examples. An example modified version of a BPE tokenizer is described here: https: / / huggingface.co / docs / transformers / tokenizer summary#bytelevel-bpe . A tokenizer capable of handling expected inputs and outputs is selected. For example, where the first model 21 is used to generate text containing a TV model, as described in the example below, a BPE may work well, since TV models are unlikely to exist in most datasets, whereas it is rare to have out of vocabulary tokens using a BPE.

[0081] The vocabulary may comprise a set of 50,000 tokens for example (Di = 50, 000). A token may represent a word or a part of a word. Special tokens, such as tokens representing a start or end of a sentence, may also be included in the vocabulary. Each token may be represented by a different integer number for example, so that an input word is converted to a positive integer number corresponding to its token (for example).

[0082] The tokeniser 22 outputs a first sequence of tokens corresponding to the input first example input text. The number of tokens output will vary between different examples, depending on the number of words in the text. The output first sequence of tokens from the tokeniser 22 is then taken as input to the first model 21. The tokeniser 22 outputs a sequence of Ti tokens corresponding to the first example input text.

[0083] The first model 21 comprises a first part 24, comprising stored token representations and stored absolute positional representations 24. The first part 24 is part of the first language model 33.

[0084] This first part 24 of first model 21 comprises a first set of stored token representations. Each token representation is a stored vector having length di, where each vector corresponds to a token from the vocabulary. In this example di=2560. The dimension di is sometimes referred to as the hidden size of the first model 21. Where the vocabulary comprises 50, 000 tokens, the first set of token representations comprises 50,000 token representations - also referred to as token embeddings. For each token in the first sequence of tokens, the corresponding token representation is looked up from the first set of stored token representations. A sequence of token representations is therefore generated. The first part 24 also comprises a first set of positional representations, where each positional representation is a stored vector having length di, where each vector corresponds to an absolute position in the first input sequence of tokens. The number of vectors in the first set of positional representations is ki. For example, ki may be the size of a context window used in the pre-training stage in S1. In this example, ki=2048. For each token in the first sequence of tokens, the positional representation corresponding to the position of the token in the first sequence is looked up from the first set of stored positional representations. Thus for the first token in the sequence, the first positional representation is retrieved, for the second token, the second positional representation is retrieved, and so on. The positional representations are also referred to as positional encodings.

[0085] For each token in the first sequence, an element-wise addition of the token representation and the positional representation is performed, to produce a single vector corresponding to the token. This sequence of Ti vectors, each of length di, corresponding to the first sequence of tokens is output from the first part 24 of the first model 21 and taken as input to a second part 25 of the first model 21. The second part 25 comprises one or more transformer blocks 26. In this example, there are 32 transformer blocks.

[0086] Each transformer block 26 comprises an attention module 27, followed by an addition and layer normalisation 28, a feed forward neural network 29 and a further addition and layer normalisation 29. The attention module 27 is a self-attention module. In this example, the attention module 27 is a multi-headed attention module. In this example, the attention module 27 has 32 attention heads.

[0087] During the update process in S2, the sequence of vectors output from the first part 24 of the first model 21 is taken as input to the first transformer block 26. The sequence of vectors is used to populate a kixdi input matrix h, where each vector from the sequence forms a row in the input matrix starting with the first row, with the remaining ki-Ti rows populated with zero values.

[0088] The attention module 27 in the first transformer block 26 comprises three stored matrices of values. In particular, the attention module 27 comprises a key weight matrix WKI , a query weight matrix WQI and a value weight matrix Wvi . Each of these is a dixdi dimensional matrix. A key matrix Ki is then calculated as the matrix product IIWKI , a query matrix Qi is calculated as the matrix product IIWQI and a value matrix Vi is calculated as the matrix product Wvi. Each of these is a kixdi matrix.

[0089] The query matrix Qi is then split into 32 separate matrices, one for each attention head, along the column dimension. This results in 32 separate query matrices Qiaeach of dimension kix(di / 32). The same process is performed for the key and value matrices.

[0090] The scores used for self-attention are then calculated for each attention head. A matrix product is calculated between the query matrix and the transposed key matrix for each attention head - QaiKaiT. For each attention head, the query matrix has dimension kix(di / 32) and the transposed key matrix has dimension (di / 32)xki in this example. A kixki matrix of scores is output for each attention head. The scores represent, for the token being processed (the score matrix row), the attention of the model on each other token in the sequence (the score matrix columns). This step can be performed in a single calculation across all attention heads by combining the matrices for each attention head into a single three dimensional matrix.

[0091] An attention mask is then applied to the output score matrix for each attention head, to mask out the scores corresponding to future tokens. In other words, for the first row in the score matrix, all entries other than the first entry are masked (by setting to a very large negative number), so that when processing the first token, the full attention is on the first token. For the second row, all entries other than the first two entries are masked, and so on. A softmax function is applied to the result, giving a final score matrix Sai for each attention head. In some examples, a scaling may be applied, in other examples the fully connected layer and activation functions are such that a scaling step is not used.

[0092] The matrix product of the score matrix Sai with the value matrix Vai, SaiVai, is then taken for each attention head, resulting in a kix(di / 32) output matrix for each attention head. Again, this may be performed in a single calculation across all attention heads by combining the matrices. The outputs from the attention heads are then merged. The vectors corresponding to each token (the output matrix row entries) for each attention head are concatenated, and these are formed into a kixdi matrix Ai , where each row corresponds to a token in the sequence. The matrix product of this matrix Ai with a stored projection matrix Pi is taken, A1P1. The stored projection matrix Pi is a dixdi matrix. The output of the attention module 27 is Oi=AiPi, a kixdi matrix.

[0093] This output matrix Oi is taken as input to the first addition and layer normalisation module 28. In the first addition and layer normalisation module 28, an element wise addition is performed between the output matrix Oi from the attention module 27 and the input matrix h to the attention module 27, I1+O1. A layer normalisation is then performed on the result.

[0094] The output from the first addition and layer normalisation module 28 is taken as input to the feed forward neural network module 29. The feed forward neural network module 29 comprises two fully connected layers. A Gaussian Error Linear Unit (GELU) activation function is used. The first layer has 4di neurons, the second layer has di neurons. Each token output from the addition and layer normalisation module 28 is taken as input separately to the neural network, so that a sequence of ki vectors is output from the neural network module 29.

[0095] The output from the neural network module 29 is taken as input to the second addition and layer normalisation module 28, which performs an element-wise addition with the input to the feed forward neural network module 29, and then a layer normalisation.

[0096] The output of the second addition and layer normalisation module 28 is formed into a kixdi matrix - this forms the input matrix h to the next transformer block 26. The kixdi matrix output from the final transformer block 26 corresponds to the output of the second part 25 of the first model 21.

[0097] During the fine tuning update stage in S2, the first model 21 is run to predict the next word in a sequence. Outputs from the second part 25 of the first model 21 are taken as input to a generator head 31. A vector comprising the values from the row Ti of the kixdi matrix output from the second part 25 of the first model 21 , corresponding to the last token in the first example input text, is taken as input to the generator head 31 in the first step, which will be described below.

[0098] The generator head 31 comprises a fully connected neural network layer, having dimension Di - the size of the vocabulary. The fully connected layer outputs a score corresponding to each token in the vocabulary - a Di length vector. A softmax function is applied to the output Di length vector, to produce a vector y of probability values, each value corresponding to a token in the vocabulary. This represents the probability that the next token (i.e. the first token of the first output text in the first step described here) corresponds to each token in the vocabulary.

[0099] The output of the generator head 31 is taken as input to the selector 32. The selector 32 generates the predicted next token from the vector y of probability values. In one example, the selector 32 performs a non-deterministic selection of the token, based on the vector y of probability values. A non-deterministic selection may provide improved performance, since outputs comprising sub-word tokens in unusual orders may be expected (for example TV models). In one example, the selector 32 performs a stochastic selection of the token, based on the vector y of probability values. For example, the selector 32 may perform a sampling step to select the predicted token based on the probabilities. Such sampling techniques add variation.

[0100] For example, a sampling may be performed to select an output token from the K tokens with the highest probabilities, where K is a hyper-parameter, and is a positive integer. In this approach, the K tokens with the highest probabilities are extracted, and a token sampled from the K tokens based on the probability values. This is referred to as a Top-K approach. Alternatively, a Top-P approach may be used. In this approach, a set of top tokens are again extracted, where the set of tokens is the smallest number whose probabilities add to a value greater than or equal to P. P is a hyper-parameter, and is a value between 1 and 0. An approach in which both P and K are enabled may be used, where P acts after K - in other words, the top K tokens are extracted, and then the top P tokens within these are extracted if fewer. In this approach, P and K are both hyper-parameters. Alternatively, a Beam Search approach may be used for example. In this example, a Contrastive Search approach is used by the selector 32. In a contrastive search approach, the token xtat position t in the sequence is selected as: arg ve where v is a token in the set V(K)of the K tokens with the highest probabilities for the position t in the sequence. K and a are hyper-parameters. p0(v|x<t) refers to the probability value output for the token v and the position t (which is the first token in the first output text in the first step described here). s hv,hx^ is the cosine similarity between token representations:

[0101] The second term is a penalty for tokens which are similar to the previous tokens in the sequence x<t- in the first step described here, this is the tokens in the first example input text.

[0102] In this example, the selector 32 also applies a set of one of more rules when performing the selection, in addition to the non-deterministic selection step. In this example, the selector 32 enforces that a token may not repeat more than R times. For example, a token that has been returned as output for the previous R tokens may be removed from the set of K tokens for example. R is a further hyper-parameter. In this example, the selector 32 also enforces a maximum output sequence length E. E is a further hyper-parameter.

[0103] For the next time step, the predicted token is then appended to the sequence of tokens corresponding to the first example input text, and the result is taken as input to the first model 21 again, to predict the next token in the sequence. A vector comprising the values from the next row of the kixdi matrix output from the second part 25 of the first model 21 is taken as input to the generator head 31 , which again outputs a vector y of probability values. The selector 32 then selects the next token based on these probability values. This process is repeated, until E tokens are outputted or until an end token is outputted. The tokens are then converted to the corresponding sequence of text. In this manner, the first model 21 predicts a first output text from the first example input text.

[0104] The first output text is then used to generate a performance metric. The performance metric is used to perform the optimisation of the hyper-parameters of the first model 21. In this example, the hyper-parameters which are updated are K, a, R and E, which are described above.

[0105] In this example, the performance metric is generated using a first discriminator model 211. The first discriminator model 211 is also trained during S2. During S2, for some iterations, the first example output text from the first data set is taken as input to the first discriminator model 211. The first example output texts are provided with a label 0, indicating that they are not generated by the first model 21. For these iterations, no input is taken to the first model 21 , and the hyper-parameters of the first model 21 are not updated. However, parameters of the first discriminator model 211 are updated. Text output from the first model 21 is provided with a label 1 , indicating that it is generated by the first model 21. The output of the discriminator 211 is a probability that the input text is “fake” (i.e. generated by the first model 21), where an output closer to 1 indicates a higher probability that the input text was generated by the first model 21.

[0106] An iteration in which the output text generated by the first model 21 is taken as input to the first discriminator model 211 will first be described. For these iterations, the parameters of the first discriminator model 211 are updated, and the hyper-parameters of the first model 21 are updated.

[0107] The output text generated by the first model 21 is taken as input to the first discriminator model 211. An example of the first discriminator model 211 is shown in Figure 2(c). The first discriminator model 211 comprises a second language model 34. The second language model 34 has the same structure as the second language model 34 that will be described in more detail below in relation to Figure 5(b). Description of this structure will therefore not be repeated here. The second language model 34 may be pre-trained prior to the performance of the method of S2 in the same manner as described in more detail below in relation to Figure 5(b). However, the second language model 34 used in S2 of the process is a separate instance of the model to that used in S6 of the process and described in relation to Figure 5(b). That is, although having the same structure and being pre-trained in the same manner, there are two separate models used, with parameters updated separately.

[0108] The first discriminator model 211 further comprises a tokeniser 42. The same tokeniser 42 as described in relation to Figure 5(b) below may be used. The output text generated by the first model 21 is taken as input to the tokeniser 42.

[0109] The first discriminator model 211 has the objective to predict whether the output text which was taken as input to the first discriminator model 211 was generated by the first model 21. The sequence of tokens output by the tokeniser 42 is processed by the second language model 34 in the discriminator in the same manner as described below in relation to Figure 5(b). An output from the second part 45 of the second language model 34 is then taken as input to a discriminator head 213. The discriminator head 213 comprises a sequence-level binary classifier. A k2xd2 matrix is output from the second part 45 of the second language model 34. The discriminator head 72 comprises a fully connected matrix layer having dimension 1. The weights of this layer are trainable parameters of the first discriminator model 211. A sigmoid activation function is applied to the output of the fully connected layer, to produce a probability that the sequence was generated by the first model 21. This probability value is the first discriminator output.

[0110] The first discriminator model 211 comprises a number of trainable parameters, which can be expressed as a vector 0Di. The parameters include the token representation values EDI , the relative and absolute position representation values, the attention layer weights, and the neural network layer weights from the second language model 34, and the discriminator head 213 weights. The parameters are initialised at the pretrained values. The update process searches for a parameter vector 0Diso that the difference between the output tokens and the expected output tokens is minimised. A process of updating 0Diby computing the gradient of a loss function and updating 0DI using the computed gradient and an optimiser function is performed. A binary cross entropy loss may be used for the discriminator loss, in which:

[0111] Lfli= —zlogz + (1 — z)log(l — z) where z is the probability value output from the discriminator head 213 for the sequence and z is the label - 1 if the sequence is an output text sequence generated by the first model 21 and 0 if an example output text sequence taken from the first dataset.

[0112] In this step, the gradient of the loss LDI with respect to each of the trainable parameters of the discriminator model 211 is determined through back-propagation. The gradient is then used to determine the updated parameters, using an optimiser function. This family of update methods is known as gradient descent (GD), generally defined iteratively as: where PD is the learning rate, which defines how quickly the parameters are updated. An AdamW optimization algorithm may be used for example.

[0113] An output of the first discriminator model 211 where the input was an output text generated by the first model 21 is then used to update the hyper-parameters of the first model 21, in this example K, a, R and E, as described above. The output of the first discriminator model 211 is used as a performance metric to optimise the hyperparameter values in an optimisation step 213. The output of the first discriminator model 211 may be the probability value output by the first discriminator model 211 or may be the loss determined from this output. Various methods of optimising hyperparameters may be used in this step. An example method is described in Hyperopt: a Python library for model selection and hyperparameter optimization, Bergstra et al, Computational Science & Discovery, 8(1):14008, 2015, the entire contents of which are incorporated by reference herein.

[0114] A Bayesian optimisation process is used in this example. An example optimisation process 213 will be described.

[0115] Prior to performing S2, a domain of hyperparameter search space is defined. For example, a range of values for each hyper-parameter is manually defined.

[0116] The objective function used in the optimisation comprises the first model 21 and the first discriminator model 211. Given a set of hyper-parameter values, a first example input text is taken as input to the first model 21 , and the generated first output text taken as input to the first discriminator model 211. The output of the first discriminator model 211 is the output of the objective function in this example, given the set of hyperparameter values. Alternatively, the loss may be used as the output of the objective function (i.e. the performance metric). The output of the first discriminator model 211 is a probability that the input text is generated by the first model 21. By updating the hyper-parameters of the first model 21 to minimize this performance metric, the first model 21 performance will be improved - in other words it will generate output texts that are more likely to be mistaken for real texts by the first discriminator model 211. Since the second language model 34 used in the first discriminator model 211 has the same structure as the second language model 34 used in the second model 40 described below, this improves the performance of the first model 21 at generating training data for the second model 40. The first discriminator model 211 thus outputs a score to be minimized, given a set of hyper-parameters.

[0117] For the first five iterations in which the output text from the first model 21 is taken as input to the first discriminator model 211 , the set of hyper-parameters for the first model 21 is randomly selected for each iteration. The output of the first discriminator model 211 is used only to train the first discriminator model 211 , but not to select the hyperparameters of the first model 21. For each iteration, the set of hyper-parameter values used and the corresponding first discriminator model 211 output value O is stored. The set of hyper-parameter values comprises the set of values of K, a, R and E that gave the particular output.

[0118] After the first five iterations, these stored data points are sorted by output value and divided into two groups based on a pre-determined output threshold. The threshold may be a quantile. The first group comprises the data points with output value below the threshold - the best outputs. The first group may be the upper quartile for example. The second group comprises the data points with output value above the threshold - the worst outputs.

[0119] For each hyper-parameter, two probability distributions are then constructed using Parzen Estimators. For example, for the hyper-parameter K, a first probability distribution l(K) is constructed to model p(K|O) where O is below the threshold, and a second probability distribution g(K) is constructed to model p(K|O) where O is above the threshold. These probability distributions are the priors. They are constructed using an average of kernels centered on the previously generated data points. The expected improvement is equivalent to l(K) / g(K). The value of K to be used for the next iteration is sampled to maximise the expected improvement. This is done for each hyperparameter, until the next set of hyper-parameter values is generated.

[0120] The first model 21 is then updated with the next set of hyper-parameters. For the next iteration, a first example output text from the first data set may be taken directly to the first discriminator model 211, and the parameters of the first discriminator model 211 updated as described above (without changing the hyper-parameters of the first model 21). Alternatively, the next example input text is taken from the first data set as input to the first model 21 , and the above described process repeated. In particular, a new data point is stored comprising the set of hyper-parameter values and the new first discriminator model 211 output. The data points are again sorted by output value, and the probability distributions updated. The values of the hyper-parameters to be used for the next iteration are then sampled to maximise the expected improvement.

[0121] This process is iterated for the entire first data set. This may correspond to 25 iterations for example.

[0122] Small changes to the hyper-parameters associated with the selector 32 in particular can result in more accurate generation of training data for the second model 40. In one example, a value of K of greater than 50 is returned. In one example, a value of K of greater than 200 is returned. Larger values of K may provide improved performance since it is likely that words corresponding to multiple tokens are included in the first model output (for example TV models). In one example, a value of R of 2 or 3 is returned. In one example a value of E of around 100 is returned.

[0123] As described above, during the update process in S2, the first model 21 predicts a first output text from the first example input text. This is done iteratively, by generating the output text one word at a time. The first example output text is also used to train the first discriminator model 211. The output of the first discriminator model 211 is used as a performance metric to optimize the hyper-parameters of the first model 21. During the update process performed in S2 in this example, the input to the first model 21 comprises an example insurance claim, and then on the next line the TV model from the claim as a human might type it. By doing this, the first model 21 is able to look for a certain pattern in the way insurance claims are written and pay attention to the most likely part of the insurance claim where a TV model may be located.

[0124] As has been described in relation to Figure 1, once the fine-tuning update is complete, the updated first model 21 is then used to generate a third training dataset in S3. A schematic illustration of this process is shown in Figure 3. The updated first model 21 is used as a generative model in this step.

[0125] In this step, examples of relevant text to be extracted - second target sequences - are taken as input to the first model 21. In the example being described here, the relevant text corresponds to television models. The first model 21 is run in inference mode, to generate a predicted sequence of text - a second output text. In this step, a second output text (“ / dropped my Model A3558 TV” in this example) is generated from a second target sequence (“Model A3558 TV” in this example) using the first model 21. The second target sequences may be obtained automatically, for example by extracting a set of TV models from a database for example.

[0126] The second output text is generated one token at a time. Thus in a first step, the second target sequence corresponding to the television model is taken as input to the tokeniser 22 - in this example, this is “Model A3558". The sequence of tokens is then processed by the updated first model 21 in the same manner as described above in the fine-tuning stage. The generator head 31 of the first model 21 outputs a vector of length Di corresponding to the final token in the second target sequence. This vector comprises a probability value corresponding to each token in the vocabulary, corresponding to the predicted probability of that token being the next word in the sequence - i.e. the first word in the second output text. This is taken as input to the selector 32, which selects the predicted token as has been described previously.

[0127] The predicted token is then appended to the sequence of tokens corresponding to the second target sequence, and the result is taken as input to the first model 21 again, to predict the next token in the sequence. This is continued until E tokens are predicted, or until an end of sentence token is predicted (if sooner). The first model 21 is run as an autoregressive model, to generate text based on an input second target sequence. The predicted sequence of tokens (i.e. excluding the initial sequence of one or more words) - which will be the second output text “I dropped my Model A3558 TV” in this example - is then included in the third data set as a second example input text. The second target sequence is included in the third data set as the label corresponding to the second example input text - a second example output text.

[0128] The first model 21 is run repeatedly in this manner to generate a large data set of training examples. For example, the third data set may comprise greater than or equal to 200 examples. For example, the third data set may comprise greater than or equal to 1000 examples. For example, the third data set may comprise less than or equal to 2000 examples. For example, the third data set may comprise greater than or equal to 200 examples and less than or equal to 2000 examples. The examples are labelled examples that can be used to train a model to extract text information for the specific use case. By using a limited number of training examples generated using the first model 21, divergence problems caused by extrapolating too many samples from an initial dataset may be mitigated.

[0129] Returning to Figure 1 , an optional step, S4, is then performed to filter the third data set to product a second data set for use training the second model 40. An example of this step is shown in Figure 4. The third data set may be used directly to train the second model 40. However, the performance of the second model 40 is dependent on the quality of the second dataset used to train the second model 40. The second dataset used to train the second model 40 is generated by the first model 21. The first model 21 can be used to generate a large number of examples for the second training data set, and the highest quality examples can be automatically selected for inclusion in the second training data set, with the lowest quality examples being discarded.

[0130] In this example, the filtering step S4 is performed automatically using a set of one or more conditional rules. In one example, the set of rules comprises one or more of:

[0131] • IF “second target sequence” not in “second output text” THEN discard “second output text” - this rule determines whether the second target sequence of one or more tokens corresponding to the TV model which was taken as input to the first model 21 is included in the sequence of tokens output from the first model 21 - corresponding to the second output text. If not, then the second output text is discarded. • IF “second output text” is the same as a previous output text THEN discard “second output text” - this rule discards repeated outputs.

[0132] • IF “second output text” is the same as “second target sequence” THEN discard “second output text” - this rule discards outputs that simply repeat the input.

[0133] • IF “second output text” is less than X tokens THEN discard “second output text”. In one example, X may be 10. This rule discards outputs that are too short.

[0134] • IF “second output text” is more than Y tokens THEN discard “second output text”. In one example, Y may be 128. This rule discards outputs that are too long.

[0135] • IF “second output text” has score less than Z THEN discard “second output text”. The score may be generated by summing the probability values output from the generator head 31 corresponding to each selected token in the “second output text”, and taking the average. In one example, X may be 0.7. This rule discards outputs that were generated with low probability values.

[0136] The second data set is then used to train a second model 40 to extract text information from input text data. As described above, the second dataset comprises a large number of training examples. Each training example comprises a second example input text (or tokens representing a second example input text), which was generated by the first model 21. Each training example also comprises a label corresponding to the second target sequence of one or more text units to be extracted - a second example output text corresponding to the second target sequence that was taken as input to the first model 21 to generate the second example input text. Thus one example from the second data set comprises the second example input text:

[0137] “I dropped my Model A3558” and the second example output text:

[0138] “A3558”

[0139] The second example input texts and the second example output texts in the second dataset may comprise sequences of one or more tokens. In other words, the tokenised form used as input to the first model 21 and output from the first model 21 may be used directly in the second training data set. Alternatively, and in the example described herein, the tokens are converted to text before storing in the second data set, so that the second example input texts and the second example output texts comprise text - i.e. machine encoded characters. The process of training the second model will now be described in relation to Figure 5(a) and (b).

[0140] Figure 5(a) shows an example process of training the second model in S6 of Figure 1. Figure 5(b) is a schematic illustration of the structure of an example second model 40, which may be used in the method of Figure 1 according to an embodiment. In this example, the second model 40 comprises a smaller language model 34 - also referred to here as the second language model 34. The second model 40 is a smaller model than the first model 21 - in other words, the second model 40 has fewer trainable parameters than the first model 21. Although a specific second language model is described here, various language models are known and can be used for text extraction, including for example BERT-base, deBERTa-v3, RoBERTa-base or bigbird. For example, deBERTa-v3-xsmall, -small, -base, or -large may be used. These models are trained to effectively handle inputs of any size. BERT and RoBERTa have a 512 token limit.

[0141] In this example, the second model 40 comprises a transformer encoder. The second model 40 comprises one or more attention layers 27. In this example, the second model 40 comprises a bidirectional transformer encoder. In one example, the second model 40 comprises one or more bidirectional layers. The second model 40 may be less than 500 MB in size. The second model 40 may be less than 300 MB in size for example.

[0142] An outline of the structure of the example second model 40 and the training process performed in S6 will now be described. In this training process, the second model 40 is trained to predict an extracted text sequence from an input sequence.

[0143] In this example, prior to performance of the method described here, the second language model 34 has been pre-trained using a general dataset. The initial values of the trainable parameters of the second language model 34 are therefore those resulting from the pre-training process. By pre-training the second language model 34, the training process performed in S6 may be performed with a smaller number of examples. The fine-tuning training process in S6 is performed using the second data set of training examples generated in S3 and S4. The process performed during training for the single training example from this dataset shown above will now be described in order to illustrate the method.

[0144] The second example input text is taken as input to a tokeniser 42. The tokeniser may be the same as tokeniser 22 used in S2, or it may be a different tokeniser using a different vocabulary for example. In this example, a different vocabulary is used, comprising 128, 000 tokens. In one example, a sentencepiece tokenizer is used. A tokenizer capable of handling expected inputs and outputs is selected. For example, where the second model 21 is used to generate text containing a TV model, as described in the example below, a BPE may work well since TV models are unlikely to exist in most datasets. An example tokeniser is a Byte-Pair Encoding tokeniser, however various tokenisers may be used. For example, a modified version of a BPE tokenizer as described in the link may be used in some examples: https: / / hugqingface.co / docs / transformers / tokenizer summary#bytelevel-bpe . A BPE based encoder may work well since it is rare to have out of vocabulary tokens.

[0145] The tokeniser 22 outputs a sequence of T2 tokens corresponding to the second example input text. The number of tokens output will vary between different example second example input texts, depending on the number of words in the text. The sequence of tokens from the tokeniser 42 - referred to here as the second sequence of tokens - is then taken as input to the second model 40. In some examples, input token sequences are truncated to 128 tokens to reduce training time.

[0146] The second model 40 comprises a first part 44, comprising stored token representations and stored positional representations.

[0147] This first part 44 comprises a second set of stored token representations. Each token representation is a stored vector having length d2, where each vector corresponds to a token from the vocabulary. In this example d2=384. In some examples, d2 is less than di. The dimension d2 is sometimes referred to as the hidden size of the second model 40. The values of these vector elements are trainable parameters of the second model 40. For each token in the second sequence of tokens, the corresponding token representation is looked up from the second set of stored vectors. A sequence of token representations is therefore generated.

[0148] The first part 44 also comprises a second set of 2p positional representations, where each positional representation is a stored vector having length d2. In this example, the positional representations are relative positional representations, where each vector corresponds to a relative position of a pair of tokens in the input sequence. The number of vectors in the second set is 2p, where p is selected as a maximum relative distance. In this example, p is selected as 512. The values of the vector elements for the vectors in the second set of positional representations are also trainable parameters of the second model 40. The second set of positional representations form a 2pxd2 matrix R, with each row corresponding to a relative position. Using relative positional representations makes it easier to deal with sequences over 512 tokens. In other examples, however, relative positional representations may not be used.

[0149] The first part 44 also comprises a third set of positional representations, where each positional representation is a stored vector having length d2, where each vector corresponds to an absolute position in the input sequence. The number of vectors in the third set of positional representations is k2. The third set of positional representations are absolute positional representations. The values of the vector elements for the vectors in the third set of stored positional representations are also trainable parameters of the second model 40. For each token in the second sequence of tokens, the absolute positional representation corresponding to the position of the token in the second sequence is looked up from the third set of stored positional representations.

[0150] For each token in the second sequence, a token representation is retrieved. This second sequence of token representations, each a vector of length d2, corresponding to the second sequence of tokens is output from the first part 44 of the second model 40 and taken as input to a second part 45 of the second model 40, which comprises one or more transformer blocks 46. In this example, there are 12 transformer blocks. In some examples, the second model 40 comprises fewer transformer blocks than the first model 21. Each transformer block 46 comprises an attention module 47, followed by an addition and layer normalisation 48, a feed forward neural network 49 and a further addition and layer normalisation 49. The attention module 47 is a self-attention module. In this example, the attention module 47 is a multi-headed attention module. In this example, the attention module 47 has 12 attention heads.

[0151] During the training process in S6, the second sequence of token representations output from the first part 44 of the second model 40 is taken as input to the first transformer block 46. The attention module 47 in the transformer block 46 comprises a first set of three stored matrices of values, where the values are trainable parameters of the second module 40. In particular, the attention module 47 comprises a key weight matrix WK2, a query weight matrix WQ2 and a value weight matrix Wv2. Each of these is a d2xd2 dimensional matrix. The input sequence of token representations is used to populate a k2xd2 input matrix I2, where each token representation forms a row in the input matrix starting with the first row, with the remaining rows k2-T2 rows populated with zero values. A key matrix K2 is then calculated as the matrix product I2WK2, a query matrix Q2 is calculated as the matrix product I2WQ2 and a value matrix V2 is calculated as the matrix product I2WV2. Each of these is a k2xd2 matrix.

[0152] The attention module 47 further comprises a second set of two stored matrices of values, where the values are trainable parameters of the second module 40. In particular, the attention module 47 comprises a relative key weight matrix WRK2, and a relative query weight matrix WRQ2. Each of these is a d2xd2 dimensional matrix. A relative key matrix KR2 is then calculated as the matrix product between the positional representation matrix R and the relative key weight matrix, RWRK2, and a relative query matrix QR2 is calculated as the matrix product RWRQ2. Each of these is a 2pxd2 matrix.

[0153] The query matrix Q2 is then split into 12 separate matrices, one for each attention head, along the column dimension. This results in 12 separate query matrices Cha each of dimension The same process is performed for the key and value matrices, and the relative key and relative value matrices.

[0154] The scores used for self-attention are then calculated for each attention head. A matrix of attention scores is calculated for each attention head. For one attention head, the (n, m)th element (corresponding to the nth row and mth column) of the attention score matrix is calculated as:

[0155] The resulting k2xk2 matrix of attention scores is output for each attention head. The scores represent, for the token being processed (the score matrix row), the attention of the model on each other token in the sequence (the score matrix columns). A scaling of -^= is applied to the scores. A softmax function is applied to the result, giving a final V 3d2score matrix S2a for each attention head.

[0156] The matrix product of the score matrix S2a with the value matrix V2a, S2iV2i, is then taken for each attention head, resulting in a output matrix for each attention head. Again, this may be performed in a single calculation across all attention heads by combining the matrices. The outputs from the attention heads are then merged. The vectors corresponding to each token (the output matrix row entries) for each attention head are concatenated, and these are formed into a k2xd2 matrix A2, where each row corresponds to a token in the sequence. The matrix product of this matrix A2 with a stored projection matrix P2 is taken, A2P2. The stored projection matrix P2 is a d2xd2 matrix, where the elements are trainable parameters of the second model 40. The output of the attention module is C>2=A2P2, a k2xd2 matrix.

[0157] This output matrix O2 is taken as input to the first addition and layer normalisation module 48. In the first addition and layer normalisation module 48, an element wise addition is performed between the output matrix O2 from the attention module 47 and the input matrix I2 to the attention module 47, I2+O2. A layer normalisation is then performed on the result.

[0158] The output from the first addition and layer normalisation module 48 is taken as input to the feed forward neural network module 49. The feed forward neural network module 49 comprises two fully connected layers. A Gaussian Error Linear Unit (GELU) activation function is used. The first layer has 4d2 neurons, the second layer has d2 neurons. Each token output from the addition and layer normalisation module 48 is taken as input separately to the neural network, so that a sequence of k2 vectors is output from the neural network module 49.

[0159] The output from the neural network module 24 is taken as input to the second addition and layer normalisation module 48, which performs an element-wise addition with the input to the feed forward neural network module 49, and then a layer normalisation.

[0160] The output of the second addition and layer normalisation module 48 is formed into a k2xd2 matrix - this forms the input matrix I2 to the next transformer block 46. The positional representation matrix R is used for each transformer block 46. For the final transformer block 46, the query matrix and the relative query matrix are generated using the absolute positional representation corresponding to the token as input, rather than the output from the previous transformer block 46.

[0161] The k2xd2 matrix output from the final transformer block 46 corresponds to the output of the second part 45 of the second model 40. Each of the rows in this matrix is then processed separately in the subsequent training steps. A vector comprising the values from the first row is taken as input to a classifier head 52 in the second model 40.

[0162] A first example classifier head 52 will now be described. In the first example, the classifier head 52 comprises a fully connected layer having dimension 1. The weights of this layer are trainable parameters of the second model 40. A sigmoid activation function is applied to the output of the fully connected layer, to produce a probability that the token corresponds to a token in the second example output text. This probability value is the model output, xtfor the token i in the sequence.

[0163] The second example output text from the training data set - corresponding to the second target sequence {“A3558”) - is also taken as input to the tokeniser 22, which generates a second target sequence of one or more tokens. The tokenised second example input text is then compared to the second target sequence of tokens to label each token in the second example input text as corresponding to the second target sequence (1) or not (0). For example the second example input text is:

[0164] I dropped my Model A3558’ The tokeniser 42 converts this sequence to:

[0165] [1, 273, 3227, 312, 4848, 336, 3377, 6769, 1341, 2] where each token represents:

[0166] [“[CLS]”', “_l” , “-dropped” , “_my” , “-Model”, “_A”, “35”, “58”, “[SEP]”].

[0167] “A3558” corresponds to the second target sequence.

[0168] The tokens corresponding to these words are therefore labelled 1, with the other tokens labelled as 0, as shown below: x = [0, 0, 0, 0, 0, 1 , 1 , 1 , 0],

[0169] For each token in the second example input text, the model output xtis then compared with the corresponding label xtin order to update the trainable parameters of the second model 40.

[0170] In particular, the second model 40 comprises a number of trainable parameters, which can be expressed as a vector 02. The parameters include the token representation values, the position representation values, the attention layer weights, the neural network layer weights and the classifier layer weights. The update process searches for a parameter vector 02 so that the difference between the model output and the expected output is minimised. The initial parameters of the first part 44 and the second part 45 are set by the pre-training process. The parameters of the classifier head 52 are randomly initialised. In S6, a process of updating 02 sequentially by computing the gradient of a loss function updating 02 using the computed gradient and an optimiser function is performed. A binary cross entropy loss may be used, in which: i)log(l - %])

[0171] The gradient of the loss L2 with respect to each of the trainable parameters of the model is determined through back-propagation. The gradient is then used to determine the updated parameters, using an optimiser function. This family of update methods is known as gradient descent (GD), generally defined iteratively as: dL292= 92— u2— - 22 2d02where 2 is the learning rate, which defines how quickly the parameters are updated. An AdamW optimization algorithm may be used for example. The update may be performed in batches, based on a batch average.

[0172] In this first example classifier head 52, each token is classified as either belonging to the second target sequence or not. This approach may be selected when the second example input text may have multiple occurrences of the second target sequence for example.

[0173] In an alternative approach, the second example classifier head 52 classifies each token as to whether it corresponds to a start of the second target sequence and whether it corresponds to an end of the second target sequence. In this second example, the classifier head 52 comprises a fully connected layer having dimension 2. The weights of this layer are trainable parameters of the second model 40. The fully connected layer outputs a first value and a second value for each token in the input sequence. The first values corresponding to each token are formed into a vector having length k2, and a softmax function is applied, to produce a probability that each token in the sequence corresponds to the start token in the second example output text. This vector of probability values is a first model output, Xs. The second values corresponding to each token are formed into a second vector having length k2, and a softmax function is applied, to produce a probability that each token in the sequence corresponds to the end token in the second example output text. This vector of probability values is a second model output, Xs.

[0174] The tokenised first example input text is compared to the second target sequence to generate a first label, which is a “one hot” encoding xsof length k2, where the entry corresponding to the start token is set to 1, with all other entries set to 0. For example, the second example input text:

[0175] I dropped my Model A3558’ corresponds to the first label:

[0176] Xs= [0, 0, 0, 0, 0, 1, 0, 0, 0],

[0177] The tokenised second example input text is also compared to the second target sequence to generate a second label, which is a “one hot” encoding xeof length k2, where the entry corresponding to the end token is set to 1, with all other entries set to 0. For example, the second example input text:

[0178] “I dropped my Model A3558” corresponds to the second label: xe= [0, 0, 0, 0, 0, 0, 0, 1, 0],

[0179] The second model outputs, Xsand x® , are then compared with the corresponding labels xeand xsin order to update the trainable parameters of the second model 40.

[0180] In this example, a cross entropy loss may be used, in which:

[0181] The gradient of the loss L2 with respect to each of the trainable parameters of the second model is determined through back-propagation. The gradient is then used to determine the updated parameters, using an optimiser function. This family of update methods is known as gradient descent (GD), generally defined iteratively as: dL2

[0182] 92= 92— u2— -

[0183] 2 2 2d02where p2 is the learning rate, which defines how quickly the parameters are updated. An AdamW optimization algorithm may be used for example. The update may be performed in batches, based on a batch average.

[0184] In this second example, the second model 40 is trained to find the start and end positions of the text string - the start and end of the second target sequence. The second model 40 classifies each token as either the start token (or not) or end token (or not). A cross entropy loss is performed at the token level, i.e. across the length of the sequence, k2. This approach may be selected when it is expected that there is a single occurrence of the second target sequence in the second example input text.

[0185] Once trained, the second model 40 can be used for text information extraction. For example, the second model 40 described herein is trained to extract TV model information from insurance claims. Once trained, the second model 40 can be run in inference mode to extract TV model information from input insurance claims.

[0186] Figure 6 is a method of text information extraction using the trained second model 40 according to an embodiment. In S11, the trained second model 40 is obtained. The trained second model 40 may be obtained by performing the method described in relation to Figure 1 above.

[0187] In S12, input text data is received. The input text data may be received from a user device or a server device for example. In this example, the method is used to extract text information from an insurance claim. The input text data therefore corresponds to an insurance claim. For example, the input text data may be:

[0188] My Model Brightscreen TV was stolen.

[0189] In S13, text information extraction is performed on the input text data using the trained second model 40. The input text data is processed in the same manner as the second example input texts are processed in S6 described above. In particular, the input text data is tokenised using the tokeniser 42, and the resulting sequence of tokens taken as input to the trained second model 40. In an example in which the classifier head 52 is a classifier head according to the first example, a probability value is output corresponding to each token in the input text data, indicating the probability that the token corresponds to a television model in this example. A consecutive sequence of one or more tokens are then identified as corresponding to the text to be extracted from the probability values. For example, the token having the highest probability value is first identified as corresponding to text to be extracted. The probability values corresponding to the adjacent tokens are then compared to a threshold value. If the probability value is higher than the threshold value, then the token is identified as corresponding to text to be extracted. The next token adjacent to this token is then considered, and so on until a token having a probability value below the threshold value is reached. In some examples, postprocessing is performed in a case where the identified sequence comprises more than one token. For example, it is determined whether the first token in the identified sequence corresponds to the start of a word. If not, the input text data is flagged - for example for manual review or for a request to the user for more information. The probability value corresponding to the token is also assessed - if it is below a predetermined threshold then the input text data is again flagged. The same process is performed for the final token in the sequence. The identified sequence of tokens is then converted to text, and is provided as the extracted text information.

[0190] In an alternative example in which the classifier head 52 is a classifier head according to the second example, the second model 40 outputs two probability values corresponding to each token in the sequence - a first probability value which is the probability that the token corresponds to a start token of the text to be extracted, and a second probability value which is the probability that the token corresponds to an end token of the text to be extracted. The token corresponding to the highest first probability value is identified as the start token and the token corresponding to the highest second probability value is identified as the end token. If the end token is prior to the start token, an error message is output, and the input text data is sent for further processing - for example it may be manually processed.

[0191] In this example, the text “Brightscreen TV” should be extracted as the output text information in S13. In S14, the extracted text, Brightscreen TV in this example, is outputted. For example, the extracted text is sent to a separate server corresponding to a service provider. Further processing may be performed based on the extracted text. For example, the service provider server may perform further processing to approve or deny the insurance claim based on the extracted text.

[0192] As has been described previously, obtaining the first model 21 in S1 described above may comprise pre-training a first language model 33. Although a specific pre-training method is described here, various methods of training large language models are known and can be used, for example a training method that may be used to train Gopher using The Pile dataset is described in https: / / arxiv.org / pdf / 2112.11446.pdf .

[0193] Figure 7(a) is a schematic illustration of an example method pre-training a first language model 33 which may be performed in S1 of the method of Figure 1 according to an embodiment. The first language model 33 is pre-trained as part of a generative model 90.

[0194] The method is performed using a large text dataset. Various large datasets for language modelling are known, for example The Pile (described in “The Pile: An 800GB Dataset of Diverse Text for Language Modeling”, Gao et al, arXiv:2101.00027 ). https: / / huggingface.co / spaces / bigscience / BigScienceCorpus describes an example training dataset that is used to pre-train BLOOM. In one example, the large text dataset comprises a number of sub datasets, each relating to a different language task. Such datasets enable few or zero shot learning to generalise well, since many different tasks are represented in the training data. A further example training dataset is described in Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., & Sutskever, I. (2019). Language Models are Unsupervised Multitask Learners.

[0195] The first language model 33 may be pre-trained in a distributed way against 1024 A100 GPUs for a period of several days or even several months for example.

[0196] The text in the training data set is tokenized. For example, the training dataset may be taken as input to the tokeniser 22, or may be available already in a suitable tokenised form. Sequences of ki+1 tokens are randomly extracted from the dataset. For an extracted sequence, the first ki tokens are then taken as input to the first language model 33. The number of tokens ki taken as input is referred to as the context window. Each input sequence is processed in the same manner as described above in relation to Figure 2(a) by the first part 24 and second part 25 of the first language model 33. An output from the second part 25 is then taken as input to a first language model head 71. As has been described previously, a kixdi matrix is output from second part 25 of the first model 21. The final row of this matrix, corresponding to the kith token in the input sequence, is taken as input to the first language model head 71. The matrix product of this output with a transposed token embedding matrix is taken. The token embedding matrix comprises the first set of stored token representations, and is a Dixdi matrix, where each row comprises the elements of a token representation. The matrix product of the output of the second part 25 (corresponding to the kith token) with the transposed token embedding matrix gives a Di length vector. A softmax is applied to give a probability that the next token in the sequence corresponds to each token in the vocabulary.

[0197] The generative model 90, comprising the first language model 33, comprises a number of trainable parameters, which can be expressed as a vector 0’i. The parameters include the token representation values, the position representation values, the attention layer weights and the neural network layer weights from the first language model 33. The parameters are randomly initialised. The update process searches for a parameter vector 0’i so that the difference between the (ki + 1 )th token in the sequence extracted from the dataset and the generative model 90 output is minimised. A process of updating 0’i sequentially by computing the gradient of a loss function ^- and updating 0’i using the computed gradient and an optimiser function is performed. A cross entropy loss may be used, in which: where y'vis the vth entry from a one hot encoding representing the ki+1 th token in the sequence and y'vis the vth entry from the vector of probability values output from the generative model 90. The gradient of the loss L’i with respect to each of the trainable parameters of the generative model 90 is determined through back-propagation. The gradient is then used to determine the updated parameters, using an optimiser function. This family of update methods is known as gradient descent (GD), generally defined iteratively as: is the learning rate, which defines how quickly the parameters are updated.

[0198] A warm up period may be used, which is an initial training period in which the learning rate is increased. For example, the learning rate may be increased linearly over the warm up period. For example, the warm up period may be selected as 6% of the total training steps.

[0199] In one example, a learning rate scheduler is used, for example a cosine scheduler or a linear scheduler. A learning rate scheduler uses a pre-defined schedule to adjust the learning rate as the training progresses. The learning rate scheduler may use a single cycle, where the final set converges to zero update. Examples of learning rate schedulers are described https: / / huggingface.co / docs / transformers / main_classes / optimizer_schedules#transform ers.get_cosine_schedule_with_warmup.

[0200] An AdamW optimization algorithm may be used for example. Other optimization algorithms that may be used include Adafactor and RMSprop. This process is performed for each sequence extracted from the training corpus. The update may be performed in batches, based on a batch average.

[0201] Although an example method of pre-training a first language model 33 has been described, various other methods of pre-training a first language model 33 may be used in this step. For example, a pre-training process for GPT-3 is described in “Language Models are Few-Shot Learners”, Brown et al, arXiv:2005.14165, the entire contents of which are incorporated by reference herein. Furthermore, although an example method of pre-training a first language model 33 has been described, various pre-trained language models are available, and S1 may alternatively comprise simply retrieving an already available pre-trained language model. As has been described previously, obtaining the second model 21 in S5 described above may comprise pre-training a second language model 34. Figure 7(b) is a schematic illustration of a method pre-training a second language model 34 which may be performed in S5 of the method of Figure 1 according to an embodiment.

[0202] The method is performed using a large text dataset. Various large datasets for language modelling are known, for example English Wikipedia (https: / / dumps.wikimedia.org / enwiki / ) and the Bookcorpus (described in Zhu et al, “Aligning books and movies: Towards story-like visual explanations by watching movies and reading books”, Proceedings of the IEEE International Conference on Computer Vision, pages 19-27, 2015). Sequences of text are extracted from the training data set. This text is then tokenized. For example, the training dataset may be taken as input to the tokeniser 42, or may be available already in a suitable tokenised form.

[0203] In this example pre-training method, a third language model 35 is used to pre-train the second language model 34. In the pre-training stage, the third language model 35 is included in a generator model and the second language model 34 is included in a discriminator model. The third language model 35 has a similar structure to the second language model 34. However, the third language model 35 is twice the depth of the second language model 35 - in this example, there are 24 transformer blocks in the third language model 35.

[0204] A Masked Language Model training approach is used. This approach simulates that the transformer attention mechanism looks at the context around a token to determine the meaning. In asking the second model to identify masked tokens, the second model improves at analysing the surrounding context looking for meaning. Although a Masked Language Model training approach is described here, in some other examples, instead of masking tokens, the tokens are replaced with spelling mistakes and then the model is trained to correct the mistake. This also results in the model understanding how a token is linked with the surrounding text, meaning the models is also able to understand grammar.

[0205] For each sequence of tokens taken from the training data-set, 15% of the tokens are randomly replaced with a mask token. The generator has the objective to predict the token from the vocabulary corresponding to each masked token. The sequence of tokens including the mask tokens is processed in the same manner as described above in relation to Figure 5(b) by the first part 74 and second part 75 of the third language model 35. In particular, the first part 74 and second part 75 of the third language model 35 act on an input sequence in the same manner as the first part 44 and second part 45 of the second language model 34, with the only difference being the increased number of transformer layers in the second part. An output from the second part 75 is then taken as input to a third language model head 72. A k2xd2 matrix is output from second part 75 of the third language model 35. The rows of this matrix which correspond to a mask token in the input sequence are identified. Each of these is taken as input in turn to the third language model head 72. The third language model head 72 comprises a fully connected layer, having dimension D2. The weights of this layer are trainable parameters. The third language model head 72 generates a D2 length vector corresponding to a masked token in the sequence. A softmax is applied to give a probability that the masked token in the sequence corresponds to each token in the vocabulary. This vector of probability values is the generator model output, b for the masked token in the sequence.

[0206] The generator model comprises a number of trainable parameters, which can be expressed as a vector 0G. The parameters include the token representation values, here referred to as EG, the relative position and absolute representation values of the third language model 35, the attention layer weights and the neural network layer weights of the third language model 35, and the weights of the third language model head 72. These parameters are randomly initialised. The update process searches for a parameter vector 0G SO that the difference between the model output for the masked tokens and the expected output for the masked tokens is minimised. A process of updating 0G by computing the gradient of a generator loss function and updating 0G using the computed gradient and an optimiser function is performed. A cross entropy loss may be used for the generator loss: where bvis the vth entry from a one hot encoding representing the actual token corresponding to the masked token in the input sequence and bv~ is the vth entry from the vector of probability values output from the third language model head 72 for the masked token.

[0207] After the forward pass with the generator model is performed, a backward pass is performed with respect to the generator loss. In this step, the gradient of the generator loss LG with respect to each of the trainable parameters of the generator model 0G is determined through back-propagation. The gradient is then used to determine the updated parameters of the generator model 0G, using an optimiser function. This family of update methods is known as gradient descent (GD), generally defined iteratively as: where PG is the learning rate, which defines how quickly the parameters are updated. An AdamW optimization algorithm may be used for example.

[0208] After updating the trainable parameters of the generator model, those of the discriminator model are updated. In the training pass, a forward pass is run for the discriminator using inputs produced by the generator. In particular, for each masked token in the generator input, the token in the vocabulary corresponding to the highest probability in the generator model output is selected. The masked token is replaced with the predicted token. This completed sequence is then taken as input to the discriminator model, which comprises the second language model 34. The discriminator then has the objective to predict which tokens have been generated by the generator. The sequence of tokens is processed by the second language model 34 in the discriminator in the same manner as described above in relation to Figure 5(b).

[0209] An output from the second part 45 of the second language model 34 is taken as input to a second language model head 73. The second language model head 73 comprises a token-level binary classifier. A k2xd2 matrix is output from second part 45 of the second language model 34. Each of the rows is then processed separately by the second language model head 73. A vector comprising the values from the first row of the matrix output from the second language model 34 is taken as input to the second language model head 72. The second language model head 72 comprises a fully connected layer having dimension 1. The weights of this layer are trainable parameters. A sigmoid activation function is applied to the output of the fully connected layer, to produce a probability that the token was generated by the third language model 35. This probability value is the second language model output, ztfor the token i in the sequence.

[0210] The discriminator model also comprises a number of trainable parameters, which can be expressed as a vector 0D. The parameters include the token representation values ED, the relative and absolute position representation values, the attention layer weights, and the neural network layer weights from the second language model 34, and the second language model head 72 weights. The parameters are randomly initialised. The update process searches for a parameter vector 0D SO that the difference between the output tokens and the expected output tokens is minimised. A process of updating 0D by computing the gradient of a loss function and updating 0D using the computed

[0211] OVD gradient and an optimiser function is performed. A binary cross entropy loss may be used for the discriminator loss, in which: f)log(l - zt) where ztis the probability value output from the second language model head 73 for the token i in the sequence and ztis 1 if the token i is a masked token and 0 if not. y is the weight of the discriminator loss (compared to the generator loss), which in this example is set to 50.

[0212] After the discriminator forward pass is run using an input produced by the generator, a backward pass with respect to the discriminator loss is thus performed to update 0D. The token embeddings of the discriminator are set as:

[0213] ED= sg(EG~) + EA

[0214] EAis initialised as a zero matrix, and sg is a stop gradient operator, so that gradients are propagated in this step only through EA. In this step, the gradient of the loss LD with respect to each of the trainable parameters of the discriminator model is determined through back-propagation. The gradient is then used to determine the updated parameters, using an optimiser function. This family of update methods is known as gradient descent (GD), generally defined iteratively as: where D is the learning rate, which defines how quickly the parameters are updated. An AdamW optimization algorithm may be used for example.

[0215] This process is repeated to train the generator and the discriminator in a generator adversarial network manner. The update may be performed in batches, based on a batch average. Once pre-trained, the second language model 34 is then used in S6 as has been described previously.

[0216] Although an example method of pre-training a second language model 40 has been described, various other methods of pre-training a second language model may be used in this step. An example pre-training process for BERT-base is described in “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding”, Devlin et al, arXiv:1810.04805v2, the entire contents of which are incorporated by reference herein. Although an example method of pre-training a second language model has been described, various pre-trained language models are available, and S5 may alternatively comprise retrieving an available pre-trained language model.

[0217] Figure 8(a) shows a schematic illustration of a system 1 in accordance with an embodiment. In use, the system 1 performs a method of training a second model for text information extraction. For example, the system 1 may perform a method of training a second model which has been described with reference to the above figures. For example, the system 1 may perform the method of training a second model which has been described with reference to Figure 1.

[0218] The system 1 comprises an input 11 , a processor 3, a working memory 9, an output 13, and storage 7. The system 1 takes input text and generates a trained second model. The input text data comprises machine readable text, comprising character code data. The input may comprise plain text or a file of character codes. The input may comprise a TXT or DOC file for example. The system 1 is a computing system. It may comprise an end-user system such as a personal computer, and / or a server for example.

[0219] The processor 3 is coupled to the storage 7 and accesses the working memory 9. The processor 3 may comprise logic circuitry that responds to and processes the instructions in code stored in the working memory 9. Although a single processor 3 is shown in the figure, it is to be understood that the system 1 may comprise two or more processors, which may be located in the same system 1 or be located remotely, and be configured to perform different parts of the processing and transmit data between them. For example, the system 1 may comprise a graphics processing unit (GPU) module (comprising one or more GPUs) and a general central processing unit (CPU) module (comprising one or more CPUs), where various operations are implemented by the GPU module, and other operations are implemented by the CPU module.

[0220] For example, certain matrix operations may be performed by the GPU module. In one example, certain operations performed during fine-tuning of the first model (as described in S2 of Figure 1 for example) are performed by a GPU module. For example, the tokenisation may be performed on a CPU module, whereas the forward pass of the first model 21 and first discriminator model 211 , and the backward pass of the first discriminator model 211 may be performed on a GPU module. The optimisation of the hyper-parameters of the first model 21 may be performed on a CPU module. The fine-tuning training of the second model (as described in S6 of Figure 1 for example) may be performed by a GPU module and CPU module, where the tokenisation may be performed on a CPU module, whereas the forward and backward pass may be performed on a GPU module. Pre-training of the first language model and the second language model may also be performed using the GPU module and CPU module for example, or on a different system. The optional filtering step performed in S4 described above may be performed on a CPU.

[0221] The update of the first model 21 performed in S2 may be performed using different parts of the system to the training of the second model in S6 in some examples. An example system that may be used to update a first model 21 according to an example comprises: two RTX 3090 GPUs, each comprising 24GB of vRAM, a 24 core (48 thread) threadripper CPU, 128GB RAM and a 4TB fast SSD. The GPU vRAM may be at least double the memory size of the first model 21. The process of training the second model 40 in S6 may be performed on a 6GB NVIDIA GPU or a mobile / M1 / M2 GPU. The RAM size may be around double the vRAM size. A 2 thread CPU may be used.

[0222] A computer program 5 is stored in storage 7. The storage 7 is accessed by the processor 3 and the stored code 5 is retrieved and executed by the processor 3. In particular, when executed, computer program code 5 embodying the methods of training the second model described above, for example in the method described in relation to Figure 1 , is represented as a software product stored in the working memory 9, as illustrated in the figure. Execution of the code 5 by the processor 3 will therefore cause various embodiments as described herein to be implemented.

[0223] The processor 3 also accesses the input module 11 and the output module 13. The input and output modules or interfaces 11 , 13 may be a single component or may be divided into a separate input interface 11 and a separate output interface 13.

[0224] The input module 11 comprises an input for receiving the text data. The input may be a receiver or port for receiving data from an external storage medium or through a communication network. The input text may be stored in storage 7.

[0225] The output module 13 comprises an output. The output may comprise a transmitter or port for transmitting data to an external storage medium or through a communication network. The output may write data in a stored file, which may be stored on the system 1 or on a separate storage medium such as a CD ROM, a magnetic device or a programmable memory device.

[0226] The storage 7 is communicatively coupled with the processor 3. The storage 7 may contain data that is used by the code 5 when executed by the processor 3. As illustrated, the storage 7 is local memory that is contained in the device. Alternatively however, the storage 7 may be wholly or partly located remotely, for example, using cloud based memory that can be accessed remotely via a communication network (such as the Internet). The code 5 is also stored in the storage 7. The code 5 is placed in working memory 9 when executed. The system 1 may be located in a common system with hardware for inputting and outputting data. Alternatively, the system 1 may be a remote system 1 , which receives text data transmitted from a separate unit, and transmits output data to another separate unit (for example a user computer comprising a screen). For example, the system may be implemented on a cloud computing system, which receives and transmits data.

[0227] Usual procedures for the loading of software into memory and the storage of data in the storage unit 7 apply. The code 5 can be embedded in original equipment, or can be provided, as a whole or in part, after manufacture. For instance, the code can be introduced, as a whole, as a computer program product, which may be in the form of a download, or can be introduced via a computer program storage medium, such as an optical disk. Alternatively, modifications to existing dialogue manager software can be made by an update, or plug-in, to provide features of the described embodiments.

[0228] While it will be appreciated that the described embodiments are applicable to any computing system, the example computing system illustrated in Figure 8(a) provides means capable of putting various embodiments, as described herein, into effect. In use, the system 1 receives text data through data input 11. The program 5, executed on processor 3, outputs data corresponding to the trained second model through the output 13.

[0229] Once trained, the second model is then used to extract information from text data. The method of extracting information from text data using the trained second model may be performed on the same system that performs the method of training the second model. Alternatively, once trained, the second model may be loaded onto a different system and the method of extracting information from text data performed on the different system.

[0230] Figure 8(b) shows a schematic illustration of a text information extraction system 2 in accordance with an embodiment. In use, the text information extraction system 2 performs a method of extracting information from text. For example, the text information extraction system 2 may perform a method of extracting information from text which has been described with reference to the above figures. For example, the text information extraction system 2 may perform the method which has been described with reference to Figure 6.

[0231] The text information extraction system 2 comprises an input 81 , a processor 84, a working memory 89, an output 83, and storage 87. The text information extraction system 2 takes an input text and generates output text. The input text data comprises machine readable text, comprising character code data. The input may comprise plain text or a file of character codes. The input may comprise a TXT or DOC file for example. The output text data also comprises machine readable text, comprising character code data. The output may comprise plain text or a file of character codes. The output may comprise a TXT or DOC file for example.

[0232] The text information extraction system 2 is a computing device. It may be an end-user device such as a personal computer, or a server for example. In one example, the text information extraction system 2 is an embedded device, such as a smart phone for example. For example, many embedded devices such as smart phones comprise processors configured to efficiently implement transformer based models. Since the second model is smaller than the first model, in some examples the second model may be implemented using only CPUs for example, meaning that usage of a GPU module can be avoided during execution of the second model.

[0233] The processor 84 is coupled to the storage 87 and accesses the working memory 89. The processor 84 may comprise logic circuitry that responds to and processes the instructions in code stored in the working memory 89. Although a single processor 84 is shown in the figure, it is to be understood that the text information extraction system 2 may comprise two or more processors, which may be located in the same text information extraction system 2 or be located remotely, and be configured to perform different parts of the processing and transmit data between them.

[0234] A computer program 85 is stored in storage 87. The storage 87 is accessed by the processor 84 and the stored code 85 is retrieved and executed by the processor 84. In particular, when executed, computer program code 85 embodying the methods of extracting text described above, for example in the method described in relation to Figure 6, is represented as a software product stored in the working memory 89, as illustrated in the figure. Execution of the code 85 by the processor 84 will therefore cause various embodiments as described herein to be implemented. The code 85 comprises the trained second model.

[0235] The processor 84 also accesses the input module 81 and the output module 83. The input and output modules or interfaces 81 , 83 may be a single component or may be divided into a separate input interface 81 and a separate output interface 83.

[0236] The input module 81 comprises an input for receiving the text data. The input may be a receiver or port for receiving data from an external storage medium or through a communication network. The input text may be stored in storage 87.

[0237] The output module 83 comprises an output. The output may comprise hardware, such as a display component. Alternatively, the output may be a transmitter for transmitting data through a communication network.

[0238] The storage 87 is communicatively coupled with the processor 84. The storage 87 may contain data that is used by the code 85 when executed by the processor 84. As illustrated, the storage 87 is local memory that is contained in the device. Alternatively however, the storage 87 may be wholly or partly located remotely, for example, using cloud based memory that can be accessed remotely via a communication network (such as the Internet). The code 85 is also stored in the storage 87. The code 85 is placed in working memory 89 when executed.

[0239] The text information extraction system 2 may be located in a common device with hardware for inputting and outputting data. Alternatively, the text information extraction system 2 may be a remote text information extraction system 2, which receives text data transmitted from a separate unit, and transmits output data to another separate unit (for example a user device comprising a screen). For example, the device may be implemented on a cloud computing system, which receives and transmits data.

[0240] Usual procedures for the loading of software into memory and the storage of data in the storage unit 87 apply. The code 85 can be embedded in original equipment, or can be provided, as a whole or in part, after manufacture. For instance, the code can be introduced, as a whole, as a computer program product, which may be in the form of a download, or can be introduced via a computer program storage medium, such as an optical disk. Alternatively, modifications to existing dialogue manager software can be made by an update, or plug-in, to provide features of the described embodiments.

[0241] While it will be appreciated that the described embodiments are applicable to any computing device, the example computing device illustrated in Figure 8(b) provides means capable of putting various embodiments, as described herein, into effect. In use, the text information extraction system 2 receives text data through data input 81. The program 85, executed on processor 84, outputs text data through the output 83.

[0242] Figure 9(a) is a schematic illustration of a system comprising the text information extraction system 2 described in relation to Figure 8(b), together with a user device 10 and a service provider device 12. The user device 10 is a computing device, such as a smart phone or a computer for example, which transmits and receives signals via a communication network such as the Internet. The text information extraction system 2 comprises a server, which transmits and receives signals via a communication network such as the Internet. In this example, the service provider is a provider of insurance services. The service provider device 12 comprises a separate server, where data is transmitted and received by the service provider device 12 via a communication network such as the Internet.

[0243] Figure 9(b) is a schematic illustration of a method performed by the system shown in Figure 9(a) according to an embodiment. In the method, a user submits an insurance claim. In this example, the user uses the user device 10 to submit the claim through a web-based portal or through an app. For example, the user accesses a portal in a web browser running on the user device 10 or an app running on the user device 10 which implements a chat bot. The user inputs the insurance claim text as part of the interaction with the chat bot. The text data is then sent from the user device 10 to the service provider device 12 in S90. Alternatively, the user may email the insurance claim text to the service provider 12 from the user device 10 for example, or the user may speak the information during a voice call, which is then converted to the insurance claim text at the service provider 12. The service provider device 12 receives the input text in S91 by one such method, and sends the input text to the text information extraction system 2 in S92. Although in this example, the insurance claim text is provided to the text extraction system 2 via the service provider 12, alternatively, the user device 10 may send the information directly to the text extraction system 2, or the text extraction may be performed on the user device.

[0244] The text information extraction system 2 receives the input text in S93. The text information extraction system 2 then performs text extraction using a trained second model in S94, as has been described above. For example, the text information extraction system 2 extracts one or more relevant sequences of text from the input text. For example, the text information extraction system 2 may extract the TV model from the input text. The text information extraction system 2 may extract additional text information from the input text, for example item age, purchase cost, details around the incident, etc. using the same method.

[0245] The text information extraction system 2 then determines a recommendation based on the extracted text. In this example, the text information extraction system 2 first queries a database using the extracted text information to retrieve further information, for example a replacement cost for the TV model in this example. The database may be stored on the text information extraction system 2 or may be stored on a separate system, where the text information extraction system 2 transmits the request and receives the requested information over a communication network.

[0246] The text information extraction system 2 in this example stores information relating to the insurance policy of the user. For example, this information may be the standard terms of the insurance policy issued by the service provider for all users. The text information extraction system 2 then checks the extracted text information, and any further information retrieved, against the policy information to determine if the incident is covered by the policy. For example, the stored policy information may comprise a set of rules. The rules are then applied to the extracted text and / or to further information retrieved based on the extracted text. For example, one such rule may comprise “IF replacement cost is less than C, THEN recommend to approve claim”, where C is some threshold amount, below which the claim is automatically paid out. The rule is applied to the replacement cost retrieved from the database using the extracted text. The stored policy information may further comprise text information, for example, the text of the policy document, which is searched based on the extracted text information. If it is determined that the incident is covered by the policy, the text extraction system 2 sends a message to the service provider system 12 recommending to approve the claim and including the amount of the replacement cost to be paid. Further information indicating why the claim should be approved may be included. If it is determined that the incident is not covered by the policy, the text extraction system 2 sends a message to the service provider system 12 recommending to deny the claim, and information indicating why the claim has been denied (for example, replacement value exceeds policy limit). If there is not sufficient information to determine whether the incident is covered by the policy, the text extraction system 2 sends a message to the service provider system 12 recommending to request further information, and noting the further information that must be provided (for example, “TV model”).

[0247] The service provider device 12 sends an indication of the outcome to the user device 10 in S98. The indication may be that the claim is approved and the amount will be paid out, that the claim is denied and information indicating why the claim has denied, or that sufficient information was not provided, and a request for the further information (for example please provide the make and model of the appliance). This information may be provided to the user through an app, for example using a chatbot, email or voice message for example.

[0248] In an alternative example, the text information extraction system 2 sends the extracted text to the service provider device 12. The service provider device 12 receives the extracted text and processes the text to determine an outcome. For example, the service provider device 12 approves or denies the insurance claim based on the extracted text. The service provider device 12 sends an indication of the outcome to the user device 10. In an alternative example, the text extraction is performed on the user device, and the extracted text sent to the service provider device 12 for processing.

[0249] In the examples described above, only a single type of text information (e.g. a TV model) is extracted from input text data. However, in other examples, two or more types of text information may be expected. For example, the claim text may be searched for the TV model and the age of the TV. In such cases, a multi-class classifier may be used in the classifier head 52. A cross entropy loss may be used, across the categories (the different target sequences). It will be understood that the invention is not limited to the embodiments abovedescribed and various modifications and improvements can be made without departing from the concepts described herein. Except where mutually exclusive, any of the features may be employed separately or in combination with any other features and the disclosure extends to and includes all combinations and sub-combinations of one or more features described herein.

Claims

CLAIMS:

1. A text information extraction system, comprising: an input for receiving text data; an output for outputting text information; and one or more processors configured to: obtain a first model; update the first model using a first dataset comprising a plurality of first example input texts each comprising a first target sequence of one or more text units, wherein the first model is updated to improve performance at a task of generating a first output text comprising the first target sequence from a first example input text; generate a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtain a second model; train the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model; receive, by way of the input, text data; extract text information from the input text data using the trained second model; output, by way of the output, text information.

2. The system of claim 1, wherein generating the second output text comprises taking the second input text as input to the updated first model to generate a next text unit, wherein the next text unit is taken as the first text unit in the second output text, and repeatedly running the updated first model to generate further text units in the second output text taking the previously generated text units together with the second input text as input to the updated first model.

3. The system of claim 1, wherein each first example input text comprises one or more further target sequences of one or more text units followed by a further text comprising the further target sequence of one or more text units.

4. The system according to claim 1 , wherein obtaining the first model comprises training a first language model.

5. The system according to claim 1 , wherein obtaining the second model comprises training a second language model.

6. The system according to claim 1, wherein generating the second dataset comprises generating a plurality of second output texts using the updated first model, and for each of the plurality of second output texts, determining whether the second output text meets a set of one or more criteria, wherein the second output text is included in the second dataset as a second example input text responsive to meeting the set of one or more criteria.

7. The system according to claim 1 , wherein the system is an embedded device.

8. The system according to claim 1, wherein updating the first model comprises performing an optimisation process to determine values for one or more hyperparameters of the first model.

9. The system according to claim 8, wherein the optimisation process comprises performing a Bayesian optimization.10 The system according to claim 9, wherein the Bayesian optimization uses a Tree Parzen Estimator.

11. The system according to claim 8, wherein the optimisation process uses a performance metric generated by a first discriminator model.

12. The system according to claim 11, wherein the first discriminator model comprises a second language model.

13. The system according to claim 12, wherein the second model comprises the second language model.

14. The system according to claim 11, wherein the first discriminator model is trained to provide an indication of whether an input is generated by a person or a model, and wherein the first discriminator model takes a first output text output from the first model as input to generate the performance metric.

15. The system according to claim 1 , further comprising determining a recommendation based on the extracted text information.

16. The system according to claim 15, wherein the text data is received from a user device and wherein the output is provided to a service provider, and wherein the output text information corresponds to the determined recommendation.

17. A computer implemented method comprising: obtaining a first model; updating the first model using a first dataset comprising a plurality of first example input texts each comprising a first target sequence of one or more text units, wherein the first model is updated to improve performance at a task of generating a first output text comprising the first target sequence from a first example input text; generating a second dataset using the updated first model, wherein generating the second dataset comprises generating a second output text from a second input text comprising a second target sequence of one or more text units using the updated first model, including the generated second output text in the second dataset as a second example input text, and including the second target sequence in the second dataset as a second example output text; obtaining a second model; training the second model to identify a third target sequence of one or more text units in a third input text using the second dataset, wherein the second model comprises fewer parameters than the first model.

18. A computer implemented method of text information extraction, comprising: receiving, by way of an input, text data;extracting text information from the input text data using a second model trained according to the method of claim 17; outputting, by way of an output, text information.

19. A non-transitory computer readable storage medium comprising computer readable code configured to cause a computer to perform the method of claim 17.

20. A system, comprising a second model trained according to the method of claim 17.

Citation Information

Cited By

  • Knowledge question and answer method, device and equipment and storage medium

    CN116561277A

  • Knowledge-based question-and-answer methods, devices, equipment, and storage media

    CN116561277B

  • Knowledge extraction method for network security intention understanding, electronic equipment and storage medium

    CN120163149A

  • Text generation method and electronic equipment

    CN121579657A

  • Intelligent order identification method and system based on semantic similarity analysis

    CN121960434A