Improving contrastive loss for dual encoder retrieval models with same tower negatives
By employing a contrastive loss function with same tower negatives and a shared projection layer, the dual encoder retrieval models effectively align embeddings, enhancing retrieval performance and preventing overfitting, thus addressing the inefficiencies in existing dual encoder architectures.
Patent Information
- Application Number
- PCT/US2023/023831
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-13
- Filing Date
- 2023-05-30
- Publication Date
- 2024-10-17
AI Technical Summary
Dual encoder retrieval models face inefficiencies due to embeddings from two encoders often not mapping into coinciding parameter spaces, leading to less effective information retrieval and increased risk of overfitting.
The implementation of a contrastive loss function with same tower negatives (SamToNe) during training, which applies a bi-directional in-batch sampled softmax loss to ensure that question and response embeddings are generated in the same parameter space, using a shared projection layer to improve embedding alignment and prevent overfitting.
This approach enhances the quality of embeddings, improves retrieval performance by aligning question and answer embeddings, and reduces overfitting, resulting in more accurate and efficient dual encoder models for information retrieval tasks.
Smart Images

Figure US2023023831_17102024_PF_FP_ABST
Abstract
Description
IMPROVING CONTRASTIVE LOSS FOR DUAL ENCODER RETRIEVAL MODELSWITH SAME TOWER NEGATIVESCROSS-REFERENCE TO RELATED APPLICATIONS
[0001] This application claims the benefit of and priority to U.S. Patent Application No. 18 / 299,841, entitled “Improve Dual Encoder Retrieval Efficiency With Parameter Sharing In Projection Layer”, filed April 13, 2023, the entire disclosure of which is incorporated herein by reference.BACKGROUND
[0002] Natural language processing (“NLP”) tasks such as question answering or other information retrieval typically rely upon a language model that has been pre-trained on world knowledge. Large language models (“LLMs”) such as Bidirectional Encoder Representations from Transformers (“BERT”) and Text-to-Text Transfer Transformer (“T5”) can capture a large amount of world knowledge, acquired from a text corpus on which they are trained. Some models use a dual encoder arrangement. This type of architecture employs twro encoders, each of which encodes an input (such as a piece of text) into an embedding. Here, the model is optimized based on similarity metrics in the embedding space.
[0003] Two such dual encoder arrangements are a Siamese dual encoder (SDE), and an asymmetric dual encoder (ADE). In the SDE approach, parameters are shared across the two encoders. The ADE approach uses two distinctly parameterized encoders, where only some or no parameters are shared. These dual encoder approaches may provide excellent performance in a wide range of information retrieval and question answering tasks. They are also suitable in products because the embedding index of dual encoders can grow dynamically for newly discovered or updated documents and passages without retraining the encoders. In contrast, generative neural networks used for question answering need to be retrained with new data. This advantage makes dual encoders more robust to freshness. However, how the parameter sharing is done in a given dual encoder arrangement can significantly impact model performance, and, ultimately, the usefulness of the information provided in response to a query.
[0004] Moreover, dual encoders may be trained according to a contrastive loss function. This can move the embeddings of the queries and answers from the same positive examples closer to each other, and the embeddings from negative examples to be farther away. The contrastive loss training may be done with in-batch negatives. Here, for each question, the system may use the passages that answer all the other questions within the batch as negatives. At indexing time, the corpus of all documents may be encoded through bulk inference and indexed. To run retrieval at inference time, a query may be encoded, and the most relevant documents of the query can be retrieved by a Nearest Neighbors Search. However, theembeddings of the two encoders may not map into coinciding parameter spaces. This can result in a less efficient and less effective model.BRIEF SUMMARY
[0005] The technology explores enhanced dual encoder architectures. This includes improving the dual encoder retrieval quality via an approach referred to herein as contrastive loss with same tower negatives (or “SamToNc”). This approach can be particularly beneficial, by way of example, for question answering-type scenarios. Given a query q and a corpus of retrieval candidates, the goal is to retrieve k relevant candidates,Each candidate may be, e.g., a phrase, a sentence, a passage, or a document. This enhanced approach is also particularly beneficial from the perspective of regularization. Regularization improves the quality of embedding, which can prevent overfitting in the neural network, improve the accuracy of the trained model, and most importantly, improve the retrieval quality. The technology may be particularly beneficial in embedding-based retrieval systems, as well as embedding systems that create the dense representation of the input contents, e.g., web pages, queries, video, images etc. The embedding created can be used as an information container of the original input, and thus can be used as a feature / an input of dow nstream tasks in lieu of the original document, which may be too lengthy to be processed by a model (especially a model implemented on a client computing device w’ith limited processing power or other constraints).
[0006] According to one aspect, a computer-implemented machine learning dual encoder system is provided. The system comprises: a token embedder layer section associated with a first input and a second input and configured to generate token embeddings; an encoder layer section configured to receive the token embeddings from the token embedder layer and configured to generate encodings based on the token embeddings: a projection layer configured to receive the encodings from the encoder section and to generate a set of projections, wherein the projection layer is shared by the dual encoder system; and an embedding space configured, based on the set of projections, to generate a question embedding and a response embedding, the question and response embeddings for use in identifying a set of candidate responses to an input question. The embedding space is configured during training according to a contrastive loss that applies same tower negatives to generate the question and response embeddings.
[0007] The contrastive loss may apply a bi-directional in-batch sampled loss. The bi-directional inbatch sampled loss may be a softmax loss. The softmax loss may only consider contrastive estimation between a target example pair and in-batch sampled negative pairs during the training.
[0008] Alternatively or additionally, the token embedder layer section may have a first token embedding section associated with the first input and a second token embedding section associated withthe second input. Here, during training, the first input may be a query and the second input may be a candidate responsive to the query.
[0009] Alternatively or additionally, the encoder layer section may have a first encoder section configured to receive the token embeddings from the token embedder layer and to generate first ones of the encodings, and a second encoder section configured to receive the token embeddings from the token embedding layer and to generate second ones of the encodings. In this case, the token embedder layer section may have a first token embedding section associated with the first input and configured to generate first ones of the token embeddings, and a second token embedding section associated with the second input and configured to generate second ones of the token embeddings. Here, the first encoder section is configured to receive the first token embeddings from the first token embedding section, while the second encoder section is configured to receive the second token embeddings from the second token embedding section.
[0010] Alternatively or additionally, the dual encoder system may be an asymmetric dual encoder arrangement having dual encoding towers in which the projection layer is a common projection layer for the dual encoding towers, and there is no parameter sharing between corresponding portions of the token embedder layer or between corresponding portions of the encoder layer section. Here, the token embedder layer and the encoder layer section may be distinctly parameterized.
[0011] Alternatively or additionally, the dual encoder system may be a Siamese dual encoder arrangement. Moreover, the dual encoder system may be configured to provide the set of candidate responses to the input question.
[0012] According to another aspect, a computer-implemented method is provided that comprises: generating, by a token embedder layer section of a dual encoder system, token embeddings, wherein the token embedder layer section is associated with a first input and a second input: generating, by an encoder layer section of the dual encoder system, encodings based on the token embeddings from the token embedder layer section; generating, by a projection layer of the dual encoder system, a set of projections, wherein the projection layer is shared by the dual encoder system; and generating based on the set of projections, by an embedding space of the dual encoder system, a question embedding and a response embedding, the question and response embeddings for use in identifying a set of candidate responses to an input question; wherein the embedding space is configured during training according to a contrastive loss that applies same tower negatives to generate the question and response embeddings.
[0013] The method may further comprise identifying the set of candidate responses to the input question, and providing one or more candidate responses of the set of candidate responses to a client computing device. Alternatively or additionally, the contrastive loss may apply a bi-directional in-batchsampled loss. The bi-directional in-batch sampled loss may be a softmax loss. The softmax loss may only consider contrastive estimation between a target example pair and in-batch sampled negative pairs during the training.
[0014] Alternatively or additionally, the token embedder layer section may have a first token embedding section associated with the first input and a second token embedding section associated with the second input. Here, during training, the first input is a query and the second input is a candidate responsive to the query.
[0015] Alternatively or additionally, the encoder layer section may have a first encoder section receiving the token embeddings from the token embedder layer and generating first ones of the encodings, and a second encoder section receiving the token embeddings from the token embedding layer and generating second ones of the encodings. Alternatively or additionally, the dual encoder system may be an asymmetric dual encoder arrangement having dual encoding towers in which the projection layer is a common projection layer for the dual encoding towers, and there is no parameter sharing between corresponding portions of the token embedder layer or between corresponding portions of the encoder layer section.BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Fig. 1 illustrates an example system and sample question answering interaction in accordance with aspects of the technology.
[0017] Fig. 2 illustrates a Transformer-type architecture for use in accordance with aspects of the technology.
[0018] Fig. 3A illustrates a Siamese dual encoder and Fig. 3B illustrates an asymmetric dual encoder in accordance with aspects of the technology.
[0019] Figs. 4A-C illustrate examples of asymmetric dual encoders in accordance with aspects of the technology.
[0020] Fig. 5 presents a table comparing performance of different dual encoder arrangements in accordance with aspects of the technology.
[0021] Fig. 6 illustrates a chart for relative performance improvements of different dual encoder models on QA retrieval tasks in accordance with aspects of the technology.
[0022] Figs. 7A-E graphically present clustered question and answer results for different dual encoder models in accordance with aspects of the technology.
[0023] Fig. 8 presents a table evaluating different dual encoders, measured for retrieval accuracy according to the Open Domain Natural Questions data set.
[0024] Fig. 9 presents a table evaluating the scaling effects for different dual encoders on the Open Domain Natural Questions data set.
[0025] Figs. 10A-B are plots of the impact of model size on the performance of different dual encoder architectures.
[0026] Fig. 11 presents a table evaluating the scaling effect on various retrieval tasks for different dual encoder architectures.
[0027] Fig. 12 illustrates a set of plots showing embedding space analysis in accordance with aspects of the technology.
[0028] Fig. 13 presents a table comparing different dual encoders with and without same tower negatives in accordance with aspects of the technology.
[0029] Figs. 14A-B illustrate plots for dual encoders with and without same tower negatives for selected data sets in accordance with aspects of the technology.
[0030] Fig. 15 presents a table of test results corresponding to the plots of Figs. 14A-B, in accordance with aspects of the technology.
[0031] Fig. 16 presents a table for zero-shot evaluation on BEIR benchmarks in accordance with aspects of the technology.
[0032] Fig. 17 presents a plot for selected BEIR benchmarks in accordance with aspects of the technology.
[0033] Figs. 18A-B illustrate embedding distance distributions for different models trained with and without same tower negatives, in accordance with aspects of the technology
[0034] Figs. 19A-B illustrate a system for use with aspects of the technology.
[0035] Fig. 20 illustrates an example method in accordance with aspects of the technology.DETAILED DESCRIPTION
[0036] The technology relates to systems and methods that employ neural network models having dual encoder architectures. One technical benefit of the approaches discussed herein involves architectural improvements. Another technical benefit involves the training methodology and training loss / objective improvement. The methodology can be used for any type of architectures, even without any parameter sharing. Optimal performance may be reached by performing parameter sharing (in the projection layer) and with SamToNe. The models may be used in a wide variety of applications and scenarios as discussed herein.
[0037] For instance, Fig. 1A illustrates an example involving a question answering system 100 for handing user queries and other input. This can be applicable to users for on-line searching, book or newsrecommendations, shopping, etc. The system 100 may include one or more processors 102 and memory 104 for storing data. In one example, the memory 104 may store one or more trained LLMs. A user 106 can formulate a query or other input on their client device 108, which may be, e.g., a laptop or desktop computer, a tablet PC, a mobile phone or PDA, a smartwatch, a smart home appliance, smart devices on automobiles, etc. The query is sent to the system 100 via a network 110. The system applies an LLM to the query in view of an information corpus. It may interact with the user via one or more turns in a conversation in order to select and / or recommend certain content. The user input and system commentary may be presented via the app displayable to the user 106 on a graphical user interface (GUI) 112 of the user’s client device 110 and / or audibly via a speaker.
[0038] In this example, the interaction between the system and the user can help to refine a set of suggested content based on the user’s interest. Exemplary dialogue between the system (e.g., 114a, 114b and 114c) and the user (e.g.., 116a, 116b and 116c) is illustrated. Each dialogue element 114 or 116 constitutes a turn in the conversation. In this example, the user may be interested in books about air travel. By asking targeted questions, the system is able to refine the query and then generate a set of recommendations for presentation to the user. For instance, in this example, the initial query may be refined across several turns to determine that the user is most interested in books about the history of air travel with regard to unpowered flight. Based on this, the system may generate a list of relevant books regarding paragliding and hot air ballooning.EXAMPLE SYSTEMS AND METHODS
[0039] As noted above, one or more LLMs may be employed in the system 100. While there are a number of different possible system configurations, they each incorporate LLMs. According to one aspect, LLMs based on an encoder approach, such as the Transformer architecture, may be employed.General Transformer Architecture
[0040] By way of example only, a general Transformer architecture is presented in Fig. 2. In particular, system 200 of Fig. 2 is implementable via a computer program by processors of one or more computers in one or more locations. The system 200 receives an input sequence 202 (e.g., a query) and processes the input sequence 202 to transduce the input sequence 202 into an output sequence 204 (e.g., an answer). The input sequence 202 has a respective network input at each of multiple input positions in an input order and the output sequence 204 has a respective network output at each of multiple output positions in an output order.
[0041] System 200 can perform any of a variety of tasks that require processing sequential inputs to generate sequential outputs. System 200 includes an attention-based sequence transduction neural network 206, which in turn includes an encoder neural network 208 and a decoder neural network 210. The encoderneural network 208 is configured to receive the input sequence 202 and generate a respective encoded representation of each of the network inputs in the input sequence. An encoded representation is a vector or other ordered collection of numeric values. The decoder neural network 210 is then configured to use the encoded representations of the network inputs to generate the output sequence 204. Generally, both the encoder 208 and the decoder 210 are attention-based. In some cases, neither the encoder nor the decoder includes any convolutional layers or any recurrent layers. The encoder neural network 208 includes an embedding layer (input embedding) 212 and a sequence of one or more encoder subnetworks 214. The encoder neural 208 network may N encoder subnetworks 214.
[0042] The embedding layer 212 is configured, for each network input in the input sequence, to map the network input to a numeric representation of the network input in an embedding space, e g., into a vector in the embedding space. The input sequence can be tokenized and then the tokens are embedded by the embedding layer. For instance, tokenization can involve splitting input text such as a sentence or a paragraph into chunks (e.g., individual words) referred to as tokens.
[0043] The embedding layer 212 then provides the numeric representations of the network inputs to the first subnetwork in the sequence of encoder subnetworks 214. The embedding layer 212 may be configured to map each network input to an embedded representation of the network input and then combine, c.g., sum or average, the embedded representation of the network input with a positional embedding of the input position of the network input in the input order to generate a combined embedded representation of the network input. In some cases, the positional embeddings are learned. As used herein, "learned” means that an operation or a value has been adjusted during the training of the sequence transduction neural network 206. In other cases, the positional embeddings may be fixed and are different for each position.
[0044] The combined embedded representation is then used as the numeric representation of the network input. Each of the encoder subnetworks 214 is configured to receive a respective encoder subnetwork input for each of the plurality of input positions and to generate a respective subnetwork output for each of the plurality of input positions. The encoder subnetwork outputs generated by the last encoder subnetwork in the sequence are then used as the encoded representations of the network inputs. For the first encoder subnetwork in the sequence, the encoder subnetwork input is the numeric representations generated by the embedding layer 212, and, for each encoder subnetwork other than the first encoder subnetwork in the sequence, the encoder subnetwork input is the encoder subnetwork output of the preceding encoder subnetwork in the sequence.
[0045] Each encoder subnetwork 214 includes an encoder self-attention sub-layer 216. The encoder self-attention sub-layer 216 is configured to receive the subnetwork input for each of the plurality of inputpositions and, for each particular input position in the input order, apply an attention mechanism over the encoder subnetwork inputs at the input positions using one or more queries derived from the encoder subnetwork input at the particular input position to generate a respective output for the particular input position. In some cases, the attention mechanism is a multi-head attention mechanism as shown. In some implementations, each of the encoder subnetworks 214 may also include a residual connection layer that combines the outputs of the encoder self-attention sub-layer with the inputs to the encoder self-attention sub-layer to generate an encoder self-attention residual output and a layer normalization layer that applies layer normalization to the encoder self-attention residual output. These two layers are collectively referred to as an “Add & Norm” operation in Fig. 2.
[0046] Some or all of the encoder subnetworks can also include a position-wise feed-forward layer 218 that is configured to operate on each position in the input sequence separately. In particular, for each input position, the feed- forward layer 218 is configured receive an input at the input position and apply a sequence of transformations to the input at the input position to generate an output for the input position. The inputs received by the position-wise feed-forward layer 218 can be the outputs of the layer normalization layer when the residual and layer normalization layers are included or the outputs of the encoder self-attention sub-layer 216 when the residual and layer normalization layers are not included. The transformations applied by the layer 218 will generally be the same for each input position (but different feed-forward layers in different subnetworks may apply different transformations).
[0047] In cases where an encoder subnetwork 214 includes a position-wise feed-forward layer 218 as shown, the encoder subnetwork can also include a residual connection layer that combines the outputs of the position-wise feed-forward layer with the inputs to the position-wise feed-forward layer to generate an encoder position-wise residual output and a layer normalization layer that applies layer normalization to the encoder position-wise residual output. As noted above, these two layers arc also collectively referred to as an "Add & Norm" operation. The outputs of this layer normalization layer can then be used as the outputs of the encoder subnetwork 214.
[0048] Once the encoder neural network 208 has generated the encoded representations, the decoder neural network 210 is configured to generate the output sequence in an auto-regressive manner. That is, the decoder neural network 210 generates the output sequence, by at each of a plurality of generation time steps, generating a network output for a corresponding output position conditioned on (i) the encoded representations and (ii) network outputs at output positions preceding the output position in the output order. In particular, for a given output position, the decoder neural network generates an output that defines a probability distribution over possible network outputs at the given output position. The decoder neuralnetwork can then select a network output for the output position by sampling from the probability distribution or by selecting the network output with the highest probability.
[0049] Because the decoder neural network 210 is auto-regressive, at each generation time step, the decoder network 210 operates on the network outputs that have already been generated before the generation time step, i.e., the network outputs at output positions preceding the corresponding output position in the output order. In some implementations, to ensure this is the case during both inference and training, at each generation time step the decoder neural network 210 shifts the already generated network outputs right by one output order position (i.e.. introduces a one position offset into the already generated network output sequence) and (as will be described in more detail below) masks certain operations so that positions can only attend to positions up to and including that position in the output sequence (and not subsequent positions). While the remainder of the description below describes that, when generating a given output at a given output position, various components of the decoder 210 operate on data at output positions preceding the given output positions (and not on data at any other output positions), it will be understood that this type of conditioning can be effectively implemented using shifting.
[0050] The decoder neural network 210 includes an embedding layer (output embedding) 220, a sequence of decoder subnetworks 222, a linear layer 224, and a softmax layer 226. In particular, the decoder neural network can include N decoder subnetworks 222. However, while the example of Fig. 2 shows the encoder 208 and the decoder 210 including the same number of subnetworks, in some cases the encoder 208 and the decoder 210 include different numbers of subnetworks. The embedding layer 220 is configured to, at each generation time step, for each network output at an output position that precedes the current output position in the output order, map the network output to a numeric representation of the network output in the embedding space. The embedding layer 220 then provides the numeric representations of the network outputs to the first subnetwork 222 in the sequence of decoder subnetworks.
[0051] In some implementations, the embedding layer 220 is configured to map each network output to an embedded representation of the network output and combine the embedded representation of the network output with a positional embedding of the output position of the network output in the output order to generate a combined embedded representation of the network output. The combined embedded representation is then used as the numeric representation of the network output. The embedding layer 220 generates the combined embedded representation in the same manner as described above w ith reference to the embedding layer 212.
[0052] Each decoder subnetwork 222 is configured to, at each generation time step, receive a respective decoder subnetwork input for each of the plurality of output positions preceding the corresponding output position and to generate a respective decoder subnetwork output for each of theplurality of output positions preceding the corresponding output position (or equivalently, when the output sequence has been shifted right, each network output at a position up to and including the current output position). In particular, each decoder subnetwork 222 includes two different attention sub-layers: a decoder self-attention sub-layer 228 and an encoder-decoder attention sub-layer 230. Each decoder self-attention sub-layer 228 is configured to, at each generation time step, receive an input for each output position preceding the corresponding output position and, for each of the particular output positions, apply an attention mechanism over the inputs at the output positions preceding the corresponding position using one or more queries derived from the input at the particular output position to generate a updated representation for the particular output position. That is, the decoder self-attention sub-layer 228 applies an attention mechanism that is masked so that it does not attend over or otherwise process any data that is not at a position preceding the current output position in the output sequence.
[0053] Each encoder-decoder attention sub-layer 230, on the other hand, is configured to, at each generation time step, receive an input for each output position preceding the corresponding output position and, for each of the output positions, apply an attention mechanism over the encoded representations at the input positions using one or more queries derived from the input for the output position to generate an updated representation for the output position. Thus, the encoder-decoder attention sub-layer 230 applies attention over encoded representations while the decoder self-attention sub-layer 228 applies attention over inputs at output positions.
[0054] In the example of Fig. 2, the decoder self-attention sub-layer 228 is shown as being before the encoder-decoder attention sub-layer in the processing order within the decoder subnetwork 222. In other examples, however, the decoder self-attention sub-layer 228 may be after the encoder-decoder attention sub-layer 230 in the processing order within the decoder subnetwork 222 or different subnetworks may have different processing orders. In some implementations, each decoder subnetwork 222 includes, after the decoder self-attention sub-layer 228, after the encoder-decoder attention sub-layer 230, or after each of the two sub-layers, a residual connection layer that combines the outputs of the attention sub-layer with the inputs to the attention sub-layer to generate a residual output and a layer normalization layer that applies layer normalization to the residual output. These two layers being inserted after each of the two sub-layers, both referred to as an "Add & Norm" operation.
[0055] Some or all of the decoder subnetwork 222 also include a position-wise feed-forward layer 232 that is configured to operate in a similar manner as the position-wise feed-forward layer 218 from the encoder 208. in particular, the layer 232 is configured to, at each generation time step: for each output position preceding the corresponding output position: receive an input at the output position, and apply a sequence of transformations to the input at the output position to generate an output for the output position.The inputs received by the position-wise feed-forward layer 232 can be the outputs of the layer normalization layer (following the last attention sub-layer in the subnetwork 222) when the residual and layer normalization layers are included or the outputs of the last attention sub-layer in the subnetwork 222 when the residual and layer normalization layers are not included. In cases where a decoder subnetwork 222 includes a position-wise feed-forward layer 232, the decoder subnetwork can also include a residual connection layer that combines the outputs of the position-wise feed-forward layer with the inputs to the position-wise feed-forward layer to generate a decoder position-wise residual output and a layer normalization layer that applies layer normalization to the decoder position-wise residual output. These two layers are also collectively referred to as an "Add & Norm" operation. The outputs of this layer normalization layer can then be used as the outputs of the decoder subnetwork 222.
[0056] At each generation time step, the linear layer 224 applies a learned linear transformation to the output of the last decoder subnetwork 222 in order to project the output of the last decoder subnetwork 222 into the appropriate space for processing by the softmax layer 226. The softmax layer 226 then applies a softmax function over the outputs of the linear layer 224 to generate the probability distribution (output probabilities) 234 over the possible network outputs at the generation time step. The decoder 210 can then select a network output from the possible network outputs using the probability distribution, to output final result 204.
[0057] According to aspects of the technology, variations on the Transformer-type architecture can be used. These may include T5, Bidirectional Encoder Representations from Transformers (BERT), Language Model for Dialogue Applications (LaMDA), and / or Pathways Language Mode (PaLM) type architectures. Different types of models may be used for each encoder path in the dual encoder arrangement.Dual Encoder Approaches
[0058] In models employing dual encoder architectures, each encoder encodes arbitrary inputs that may differ in type or granularity, such as queries, images, answers, passages, or documents, by way of example. The model has two encoders, where each is a transformer that encodes a question or an answer. Each encoder first produces a fixed-length representation for its input and then applies a projection layer to generate the final embedding.
[0059] As noted above, there are different types of dual encoder arrangements that can be used with LLMs. One is the Siamese dual encoder, an example of which (300) is shown in Fig. 3A. Another is the asymmetric dual encoder, an example of which (320) is shown in Fig. 3B. As shown in Figs. 3A and 3B, both arrangements include a token embedder layer, an encoder layer, a projection layer and an embedding space.
[0060] A text string may be converted into a vector via a dictionary, in which sub-tokens (e.g., words or sub-words such as syllables) are created and then mapped to vectors that are applied to the encoder layer. The output of encoder layer passes to projection layer, and the output of the projection layer is passed to the embedding space for question embedding (“Q-embedding”) and answer embedding (“A-embedding”). The output from the model may include a set of relevant answers to the input question.
[0061] In the SDE encoder 300, parameters are shared between the two encoding paths (or “towers”) for the question and the answer. In the ADE encoder 320, each encoding path is distinctly parameterized for the question and the answer. The SDE encoder 300 approach, with maximal parameter sharing, may outperform the ADE encoder 320 approach where no parameters are shared. However, some applications may require certain asymmetry in the dual encoding paths, as multi-modal information may need an asymmetric encoder. By way of example, asymmetry may be necessary when there is a mixed-input source such as a webpage with different types of content such as text, imagery, audio, ads, structured forms, etc. Another example is to use a small tower for query encoding and a much larger tower for answer encoding. Here, for instance, answer encoding can be performed offline, where a more robust, heavier encoder could be used to obtain high-quality embeddings. In comparison, query encoding may be performed online, so a lighter encoder can be used to provide faster responses.
[0062] Figs. 4A-C illustrate three variations of the general ADE encoder 320, where parameters are shared in different parts of the model. In particular, example 400 of Fig. 4A is an ADE-type encoder having a shared token embedder between the two encoding paths. Here, the encoders and projection layers are distinctly parameterized. Example 420 of Fig. 4B is similarly arranged, but with the shared token embedder being frozen. In this variation, the token embedding is frozen during fine-tuning.
[0063] Token embedders are the lowest layers close to the input text. In ADEs, token embedders are initialized from the same set of pre-trained parameters, but fine-tuned separately. One way to bring ADEs closer to SDEs in terms of performance is to share the token embedders between the two towers, as in the arrangement of Fig. 4A, or alternatively, to simply freeze the token embedders during training as in the arrangement of Fig. 4B.
[0064] Example 440 of Fig. 4C is an ADE -type encoder with a common projection layer but no sharing at the other layers. Here, the token embedders and encoders are distinctly parameterized. How parameters are shared in each arrangement may have a significant impact on how well an LLM is able to perform a particular task.
[0065] It has been found that sharing parameters in token embedders and projection layers between the two encoders improves the efficacy of the ADE architecture. In particular, sharing the projection layeras in example 440 of Fig. 4C enables that ADE architecture to achieve performance results comparable to or even better than the performance results for an SDE. As discussed further below, an analysis of the embeddings was performed for the various arrangements by projecting and clustering them into 2- dimensional space using a variation of stochastic neighbor embedding (SNE) called t-SNE, which is discussed, for instance, in “Visualizing data using t-sne” by van der Maaten et al., in the Journal of Machine Learning Research (2008).
[0066] The analysis has shown that without sharing projection layer, ADEs tend to embed the inputs of the two encoder towers into disjoint embedding spaces, which may hinder the quality of retrieval. In contrast, projection layer sharing can significantly boost system performance.
[0067] According to one aspect of the technology, the dual encoder model is trained by optimizing the contrastive loss with an in-batch sampled soft-max according to:where <?,: is a question and a* is a candidate answer, o, is ground-truth answer, or a positive sample, for qi. All other answers a, in the same batch B are considered as negative samples during training, ris the softmax temperature and sim is a similarity function to measure the relevance between the question and the answer. In one scenario, cosine distance may be used as the similarity function according to:Testing and Analysis
[0068] The dual encoder architectures of Figs. 4A-C were evaluated on six question-answering retrieval tasks from AIS MARCO (see, e.g., “Ms marco: A human generated machine reading comprehension dataset” by Nguyen ct al., 2016) and MultiRcQA (see, e.g., “MultiRcQA: A crossdomain evaluation for retrieval question answering models by Guo et al., 2021). In MS MARCO, testing considered the relevant passages as answer candidates, while for the five QA datasets in MultiReQA the answer candidates were individual sentences. The testing further validated the conclusion on an open domain question-answering task, Open Domain NaturalQuestions, where the retrieval candidates are context passages.
[0069] To initialize the parameters of dual encoders, pre-trained T5 1 .1 encoders were employed (see, e.g. , “Exploring the limits of transfer learning with a unified text-to-text transformer” by Raffel et al., 2020). The average embeddings of the T5 encoder’s outputs were taken and sent to a projection layer to get the final embeddings. The projection layers were randomly initialized, with variance scaling initialization with scale 1.0. For the retrieval, mean embeddings were used from the encoder towers. To make a faircomparison, the same hyper-parameters were applied across all the models for the fine-tuning with Adafactor optimizer (see, e.g., “Adafactor: Adaptive learning rates with sublinear memory cost” by Shazeer and Stern, 2018), using learning rate 10-3and batch size 512. The models were fine-tuned for 20,000 steps, with linear decay of learning rate from 10-3to 0 at the final steps. The fine-tuned models were benchmarked with precision at 1 (P@1 ) and mean reciprocal rank (MRR) on the QA retrieval tasks.
[0070] The results from this arc shown in Tabic 1 of Fig. 5, where performance of an SDE architecture (see 300 in Fig. 3A) is compared against a general ADE architecture without parameter sharing (see 320 in Fig. 3B). ADE-STE, ADE-FTE and ADE-SPL are the ADEs with shared token-embedders (400 in Fig. 4A), frozen token-embedders (420 in Fig. 4B), and shared projection-layers (440 in Fig. 4C), respectively. Two other models were evaluated, BERT-DE, which stands for BERT Dual-Encoder (see, e.g., “BERT: Pre-training of deep bidirectional transformers for language understanding” by Devlin et al., 2019), and USE-QA (see, e.g., “Multilingual universal sentence encoder for semantic retrieval” by Yang et al., 2020), which were the baselines reported in MultiReQA referenced above. In this table, results are reported for precision at 1(P@1)% and Mean Reciprocal Rank (MRR)% on QA retrieval tasks. The most performant models are marked in bold.
[0071] SDE and ADE are the two most distinct dual-encoders in terms of parameter sharing. The experiment results in Table 1 show that, on QA retrieval tasks, ADE performs consistently worse than SDE. This may be understood because at inference time, the two distinct encoders in ADE that do not share any parameters, map the questions and the answers into two parameter spaces that are not perfectly aligned. However, for SDE, parameter sharing enforces the embeddings from the two encoders to be in the same space.
[0072] As noted above, there are situations where asymmetry in the dual encoders is necessary, or otherwise desirable depending on the task to be performed. Thus, the ADE-TE, ADE-FTE and ADE-SPL arrangements may be particularly beneficial. Evaluated on MS MARCO and MultiReQA, the results in Table 1 show that both freezing (ADE-FTE, as in 420 of Fig. 4B) and sharing (ADE-STE, as in 400 of Fig. 4A) token embedders bring consistent improvements for ADEs. The ADE-SPL arrangement (440 in Fig. 4C) presents another way of improving retrieval quality of ADEs, which is to share the projection layers between the two encoders. Table 1 shows that sharing projection layers significantly improves the quality of ADEs.
[0073] Fig. 6 illustrates a chart 600 for relative performance improvements of different models relative to ADE on QA retrieval tasks. Here, AMRR = (MRR - MRRADE) / MRRADE) x 100. As in Fig. 6, ADE-SPL (curve 610) performs on-par and, sometimes, even better than SDE (curve 602). This observation reveals that sharing projection layers is a valid and beneficial approach to enhance the performance of the model.
[0074] To further substantiate the results, the question and answer embeddings were first generated from the NaturalQuestions eval set, and then t-SNE (see, e.g., “Visualizing data using t-sne” referenced above) was used to project and cluster the embeddings into 2-dimensional space. For efficiently clustering with t-SNE, questions and answers were randomly sampled (400 each), from the NQ eval set. Figs. 7A-E graphically present question (blue / darker) and answer (orange / lighter) results for SDE, ADE, ADE-STE, ADE-FTE and ADE-SPL, respectively. In Figs. 7A (SDE) and 7E (ADE-SPL), the question and answer datapoints are intermixed, while in Figs. 7B (ADE), 7C (ADE-STE) and 7D (ADE-FTE), the answer datapoints are on the left side while the question datapoints are on the right side. In particular, it can be seen that, for ADE, ADE-STE and ADE-FTE that have separate projection layers, the question and answer embeddings are projected and clustered into two disjoint groups. In comparison, ADE-SPL that shares the projection layers, the embeddings of questions and answers are not separable by t-SNE, which is similar to the behavior of SDE. This verifies that the projection layer plays an important role in bringing together the representations of questions and answers, and may be a key for retrieval performance.
[0075] Table 2 of Fig. 8 presents results of an evaluation of different dual encoders, measured as top- k retrieval accuracy on Open Domain Natural Questions (development set). The baselines are derived from DRP (see, e.g., “Dense passage retrieval for open-domain question answering” by Karpukhin et al., 2020) with golden labels and 7 (D-G7) or 127 (D-G 127) negative examples. This evaluation was done using the top-k accuracy (k ∈ {5, 20, 100}). As shown, the SDE and ADE-SPL approaches perform competitively on the OpenQA passage retrieval task.
[0076] To assess the impact of model size, the dual-encoders were fine-tuned and evaluated with initialization from T5 1.1-small (approximately 77 million parameters), -base (approximately 250 million), and -large (approximately 800 million) on MS MARCO and OpenNQ. Table 3 in Fig. 9, the plots in Figs. 10A-B, and Table 4 in Fig. 11 show that, across different model sizes, sharing projection layers consistently improved the retrieval performance of ADE, and ADE-SPL performed competitively with SDE (see 1010 v 1002 in Fig. 10A, and 1020 v 1012 in Fig. 10B). In particular, Table 3 presents an evaluation of the scaling effect on Open Domain Natural Questions, using top-k retrieval accuracy, with dual encoders initialized from T5 1.1 -small, -base, and -large checkpoints. The most performant models are bolded. In Figs. 10A- B, the impact of model size on the performance of different dual encoder architectures is illustrated, measured by MRR on the eval set of MS MARCO (Fig. 10A), and Top-20 Accuracy on development set of Open Domain NQ (Fig. 10B). And Table 4 presents an evaluation of the scaling effect on MS MARCO QA retrieval tasks, using Precision at 1 (P@ 1) % and Mean Reciprocal Rank (MRR) %, with dual encoders initialized from T5 1.1 -small, -base, and -large checkpoints. The most performant models are also bolded in this table.Same Tower Negatives Approach for Improved Training Objective
[0077] In some instances, a shared projection layer for the ADE-SPL arrangement may not be guaranteed to map the embeddings of the two encoder towers into coinciding parameter spaces. An improved training objective may be employed to achieve this. In particular, this approach involves contrastive loss with same tower negatives (SamToNe). It is shown, via various tests, that this approach is not only competitive with existing approaches, but can achieve significant improvements on various metrics averaged across tasks. It also is highly beneficial as a regularizer of the embedding space. Fig. 12 illustrates a set of plots showing embedding space analysis for two data sets (MS MARCO and SearchQA), using the ADE-SPL arrangement without (top) and with (bottom) SamToNe. SearchQA is described, by way of example, in “SearchQA: A New Q&A Dataset Augmented with Context from a Search Engine” by Dunn et al., 2017, the entire disclosure of which is incorporated by reference herein. The results illustrate how the embeddings of the dual encoder towers for question and answer are more efficiently mapped into common parameter spaces using same tower negatives.
[0078] One way to train a dual encoder model is optimizing an in-batch sampled softmax loss for contrastive learning. A slightly modified version of the loss function presented above is:where p* is a batch of retrieval candidates (akin to the candidate answers a* in the earlier equation). Here, i stands for the index of ground-truth / positive pair of (query, passage), j stands for the indices of any passages within the batch, including i, and k stands for the indices of negative passages within the batch. As a concrete example, suppose there are 4 pairs of (q[l], p[l]) (q[4], p[4]). if i = 1, then j will be(1,2,3,4), and k (2,3,4). Here, p, is the ground-truth relevant passage for the query qiin the batch p*, where all the other passages pk(k ≠ i) arc treated as the negative examples for contrastive learning.
[0079] Bi-directional m-batch sampled softmax loss may be applied to improve the embedding quality of both towers, where the contrastive loss is computed for both query to passage matching and passage to query matching. The in-batch sampled softmax loss is a contrastive loss that only considers the contrastive estimation between the target example pair {qi, pi}, and the in-batch sampled negative pairs {qi, pj} (j ≠ i). Improving the contrast among the embeddings of the queries can improve the quality of the retrieval (e.g., the answer to a given question).Here, the second term in the denominator is the contribution from the same tower negatives.
[0080] This approach can be viewed as a regularized version of the in-batch sampled softmax loss, where the second term in the denominator is a regularizer. When query embeddings are not well distributed, max sim(qi, qj) » max sim(qi, pj), the second term in the denominator will dominate the contribution from the negative examples. Thus, it will drive the separation of the query embeddings in contrastive learning.
[0081] Testing has shown the significant advantages to this approach. For instance, the following includes results on five (5) question-answering (QA) retrieval tasks including MS MARCO and MultiReQA. For MS MARCO, the retrieval candidates were are relevant passages, and for the 4 tasks in MultiReQA, the retrieval candidates were answer sentences. To make a fair comparison across the results of the experiments, the same fine-tuning hyperparameters were applied to all our model variants. The models were optimized for 20, 000 steps using Adafactor optimizer, with softmax temperature τ = 0.01, batch size 512, and a linearly decaying learning rate starting from 10-3to 0 at the final step. The finetuned models were benchmarked using precision at 1 (P@1) and mean reciprocal rank (MRR).
[0082] Table 5 of Fig. 13 illustrates results for three different model types: ADE, ADE-SPL, and SDE, both without (upper rows) and with (lower rows) the SamToNe approach. This table shows precision at 1 (P@l) % and Mean Reciprocal Rank (MRR) % on QA retrieval tasks. The best-performing models for each task and metric are highlighted in bold. As shown in this table, the SamToNe approach greatly improves the retrieval performance of both SDE and ADE-SPL models. Moreover, using this approach, ADE-SPL models can outperform SDE ones, especially for TriviaQA and SearchQA, by a statistically significant margin.
[0083] To assess the impact of the model size, an evaluation was performed on the dual encoders initialized from T5 1 .1 -base (on the order of -250 million parameters), T5 1.1 -large (on the order of — 800 million parameters), and T5 1.1 -XXL (on the order of ~ 11 billin parameters). The plots in Figs. 14A-B and Table 6 of Fig. 15 show that the SamToNe approach consistently improves the performance of dual encoders across different model sizes. In particular, the impact of model sizes on the performance of different dual encoder architectures is presented in Figs. 14A-B, measured by MRR on the evaluation set of MS MARCO (Fig. 14A) and SearchQA (Fig. 14B). Table 6 illustrates precision at 1 (P@1) % and Mean Reciprocal Rank (MRR) % on QA retrieval tasks.
[0084] The efficacy of the dual encoders trained with SamToNe can be further demonstrated with regard to BEIR (see, e.g., BEIR: A heterogeneous benchmark for zero-shot evaluation of information retrieval models, by Thakur et al., 2021), a heterogeneous benchmark for zeroshot evaluations. BEIR has 18 information retrieval datasets across 9 domains, including Bio-Medical, Finance, News, Twitter, Wikipedia, StackExchange, Quora, Scientific, and Misc (with MS Marco being excluded from the zero-shot comparison as many baseline models use it as training data). The majority of the BEIR datasets have binary query relevance labels. The other datasets have 3-level or 5-level relevance judgements.
[0085] As BEIR was evaluating generalization capabilities and SDEs are commonly used for general purpose retrieval (see, e.g., Large dual encoders are generalizable retrievers by Ni et al., 2021), a focus was on evaluating the impact of SamToNe on BEIR using the SDE architecture. In this evaluation, the model fine-tuned with MS MARCO was reused. Evaluated with the same setting as GTR (Generalizable T5- based dense Retrievers) as discussed in the Ni article, SamToNe has demonstrated strong performance on BEIR, as shown in Table 7 of Fig. 16 as well as the plot of Fig. 17. Table 7 presents NDCG(®10 for zeroshot evaluation on BEIR benchmarks after fine-tuning on MSMarco. The best-performing models for each task are highlighted in bold, while the best scores between SDE and SDE employing the SamToNe approach are underscored. The plot of Fig. 17 illustrates the relative improvement ofNDCG@10 (%) on BEIR tasks, by applying SamToNe on SDE. In view of this, it can be seen that, on average, SamToNe improves NDCG@10 by 1.4% for SDE with XXL size. SDE trained with the SamToNe approach significantly outperform BM-25, a sparse retrieval method, and GTR, a dense retrieval method that shares the same architecture and the same model size as SDE but fine-tuned with different corpora.
[0086] Returning to Fig. 12, as shown in the top row, for MS MARCO and SearchQA, the ADE-SPL architecture generates two connected but topologically separable embedding spaces for questions (blue / darker) and answers (orange / lighter). Applying the SamToNe approach (beyond the shared projection layers) helps ensure the adjacency of the embeddings from a ground truth pair. The efficacy of the SamToNe approach is illustrated in the bottom half of Fig. 12, where it is shown to map the embeddings of the two encoder towers into coinciding parameter spaces.
[0087] Moreover, to further understand the role of the SamToNe approach as a regularizer for embedding distances, the distribution of the distances between the embeddings of the queries and their top- 1 retrieval results were evaluated in the test set of MS MARCO and SearchQA. Figs. 18A-B illustrate the distributions of embedding distances between the queries and their nearest neighbor documents, for different models trained with or without the SamToNe approach. The embedding distance was measured by cosine similarity, where 1.0 means perfect alignment with a range of [—1.0, 1.0], As shown in Figs. 18A-B, employing SamToNe drastically shifted the distribution of the (query, top-1 retrieval result) pairs towards 1.0, demonstrating the regularizing effect of SamToNe over the embedding distances.
[0088] Thus, via evaluation on QA retrieval tasks and zero-shot generalization benchmarks, it is demonstrated that training with the SamToNe approach can significantly improve the dual encoder retrieval quality. With t-SNE maps of query and document embeddings, it is shown that the embedding spaces fromthe two encoding towers ofmodels trained with SamToNe are better aligned. The distributions of similarity distances between the embeddings of queries and their nearest neighbors empirically explain the efficacy of SamToNe from a regularization perspectiveExample Computing Architecture
[0089] The dual encoder technology discussed herein may be trained on one or more tensor processing units (TPUs), CPUs or other computing in accordance with the features disclosed herein. One example computing architecture is shown in Figs. 19A and 19B. In particular, Figs. 19A and 19B are pictorial and functional diagrams, respectively, of an example system 1900 that includes a plurality of computing devices and databases connected via a network. For instance, computing device(s) 1202 may be implemented as a cloud-based server system. Databases 1904, and 1906 may store, e.g., a corpus of answer candidates and / or trained image models, respectively. The server system may access the databases via network 1908. Client devices may include one or more of a desktop computer 1910 and a laptop or tablet PC 1912, for instance that present a particular question from a user, and / or to view' the answer(s) provided by the system in accordance with a given dual encoder arrangement as discussed here, which could be provided to the user via a web-based service, app or other program. Other client devices may include handheld devices including a personal communication device such as a mobile phone or PDA 1914 or a tablet 1916. Another example is a w'earable device 1918 such as a smartwatch (or head- mounted display device).
[0090] As shown in Fig. 19B, each of the computing devices 1902 and 1910-1918 may include one or more processors, memory, data and instructions. The memory stores information accessible by the one or more processors, including instructions and data (e.g., models) that may be executed or otherwise used by the processor(s). The memory may be of any type capable of storing information accessible by the processor(s), including a computing device-readable medium. The memory is a non-transitory medium such as a hard-drive, memory card, optical disk, solid-state, etc. Systems may include different combinations of the foregoing, whereby different portions of the instructions and data are stored on different types of media. The instructions may be any set of instructions to be executed directly (such as machine code) or indirectly (such as scripts) by the processor(s). For example, the instructions may be stored as computing device code on the computing device-readable medium. In that regard, the terms “instructions”, “modules” and “programs” may be used interchangeably herein. The instructions may be stored in object code format for direct processing by the processor, or in any other computing device language including scripts or collections of independent source code modules that are interpreted on demand or compiled in advance.
[0091] The processors may be any conventional processors, such as commercially available CPUs,TPUs, graphical processing units (GPUs), etc. Alternatively, each processor may be a dedicated devicesuch as an ASIC or other hardware-based processor. Although Fig. 19B functionally illustrates the processors, memory, and other elements of a given computing device as being within the same block, such devices may actually include multiple processors, computing devices, or memories that may or may not be stored within the same physical housing. Similarly, the memory may be a hard drive or other storage media located in a housing different from that of the processors), for instance in a cloud computing system of server 1902. Accordingly, references to a processor or computing device wall be understood to include references to a collection of processors or computing devices or memories that may or may not operate in parallel.
[0092] The computing devices may include all of the components normally used in connection with a computing device such as the processor and memory described above as well as a user interface subsystem for receiving input from a user and presenting information to the user (e.g., text, imagery, videos and / or other graphical elements). The user interface subsystem may include one or more user inputs (e.g., at least one front (user) facing camera, a mouse, keyboard, touch screen and / or microphone) and one or more display devices (e.g., a monitor having a screen or any other electrical device that is operable to display information (e.g., text, imagery and / or other graphical elements). Other output devices, such as speaker(s) may also provide information to users.
[0093] The user-related computing devices (e.g., 1910-1918) may communicate with a back-end computing system (e.g., server 1902) via one or more networks, such as network 1908. The network 1908, and intervening nodes, may include various configurations and protocols including short range communication protocols such as Bluetooth™, Bluetooth LE™, the Internet, World Wide Web, intranets, virtual private networks, wide area networks, local networks, private networks using communication protocols proprietary to one or more companies, Ethernet, WiFi and HTTP, and various combinations of the foregoing. Such conununication may be facilitated by any device capable of transmitting data to and from other computing devices, such as modems and wireless interfaces.
[0094] In one example, computing device 1902 may include one or more server computing devices having a plurality of computing devices, e.g., a load balanced server farm or cloud computing system, that exchange information with different nodes of a network for the purpose of receiving, processing and transmitting the data to and from other computing devices. For instance, computing device 1902 may include one or more server computing devices that are capable of communicating with any of the computing devices 1910-1918 via the network 1908. The computing device 1902 may implement a back-end server (e.g., a cloud-based question answering server), which receives queries from desktop computer 1910, laptop / tablet PC 1912, mobile phone or PDA 1914, tablet 1916 or wearable device 1218.
[0095] Resultant information (e.g., answers to one or more questions) or other data derived from the approaches discussed herein may be shared by the server with one or more of the client computing devices. Alternatively or additionally, the client device(s) may maintain their own databases, models, etc.
[0096] Fig. 20 illustrates an exemplary method 2000 in view of the above discussion. At block 2002, the method includes generating, by a token embedder layer section of a dual encoder system, token embeddings, wherein the token embedder layer section is associated with a first input and a second input. At block 2004, the method includes generating, by an encoder layer section of the dual encoder system, encodings based on the token embeddings from the token embedder layer section. At block 2006, the method includes generating, by a projection layer of the dual encoder system, a set of projections, wherein the projection layer is shared by the dual encoder system. And at block 2008, the method includes generating based on the set of projections, by an embedding space of the dual encoder system, a question embedding and a response embedding, the question and response embeddings for use in identifying a set of candidate responses to an input question. As shown in block 2010, the embedding space is configured during training according to a contrastive loss that applies same tower negatives to generate the question and response embeddings.
[0097] As discussed above, it can be seen than sharing projection layer between the two encoders enables ADEs to perform competitively with SDEs. By directly probing the embedding space, it has been demonstrated that the shared projection layers map the embeddings of the two encoder towers into coinciding parameter spaces, which is highly beneficial for improving the retrieval quality of the dual encoder model. By way of example, the two encoder towers may implement a BERT-type encoder in one tower, and a visual-type encoder in the other tower. In one scenario, the asymmetric towers can model heterogeneous data (e.g., a text tower + a visual tower, a text tower + a multimodal tower, etc.). In another scenario, the system may employ encoders of different sizes (a small tower + a large tower).
[0098] Although the technology herein has been described with reference to particular embodiments, it is to be understood that these embodiments are merely illustrative of the principles and applications of the present technology. It is therefore to be understood that numerous modifications may be made to the illustrative embodiments and that other arrangements may be devised without departing from the spirit and scope of the present technology as defined by the appended claims.
Claims
CLAIMS1. A computer-implemented machine learning dual encoder system, comprising: a token embedder layer section associated with a first input and a second input and configured to generate token embeddings; an encoder layer section configured to receive the token embeddings from the token embedder layer and configured to generate encodings based on the token embeddings; a projection layer configured to receive the encodings from the encoder section and to generate a set of projections, wherein the projection layer is shared by the dual encoder system; and an embedding space configured, based on the set of projections, to generate a question embedding and a response embedding, the question and response embeddings for use in identifying a set of candidate responses to an input question; wherein the embedding space is configured during training according to a contrastive loss that applies same tower negatives to generate the question and response embeddings.
2. The dual encoder system of claim 1 , wherein the contrastive loss applies a bi-directional in-batch sampled loss.
3. The dual encoder system of claim 2, wherein the bi-directional in-batch sampled loss is a softmax loss.
4. The dual encoder system of claim 3, wherein the softmax loss only considers contrastive estimation between a target example pair and in-batch sampled negative pairs during the training.
5. The dual encoder system of claim 1, wherein the token embedder layer section has a first token embedding section associated with the first input and a second token embedding section associated with the second input.
6. The dual encoder system of claim 5, wherein during training the first input is a query and the second input is a candidate responsive to the query.
7. The dual encoder system of claim 1, wherein the encoder layer section has: a first encoder section configured to receive the token embeddings from the token embedder layer and to generate first ones of the encodings; anda second encoder section configured to receive the token embeddings from the token embedding layer and to generate second ones of the encodings.
8. The dual encoder system of claim 7, wherein the token embedder layer section has: a first token embedding section associated with the first input and configured to generate first ones of the token embeddings; a second token embedding section associated with the second input and configured to generate second ones of the token embeddings; the first encoder section is configured to receive the first token embeddings from the first token embedding section; and the second encoder section is configured to receive the second token embeddings from the second token embedding section.
9. The dual encoder system of claim 1, wherein the dual encoder system is an asymmetric dual encoder arrangement having dual encoding towers in which the projection layer is a common projection layer for the dual encoding towers, and there is no parameter sharing between corresponding portions of the token embedder layer or between corresponding portions of the encoder layer section.
10. The dual encoder system of claim 9, in which the token embedder layer and the encoder layer section are distinctly parameterized.
11. The dual encoder system of claim 1 , wherein the dual encoder system is a Siamese dual encoder arrangement.
12. The dual encoder system of claim 1, wherein the dual encoder system is configured to provide the set of candidate responses to the input question.
13. A computer-implemented method, comprising: generating, by a token embedder layer section of a dual encoder system, token embeddings, wherein the token embedder layer section is associated with a first input and a second input; generating, by an encoder layer section of the dual encoder system, encodings based on the token embeddings from the token embedder layer section; generating, by a projection layer of the dual encoder system, a set of projections, wherein theprojection layer is shared by the dual encoder system; and generating based on the set of projections, by an embedding space of the dual encoder system, a question embedding and a response embedding, the question and response embeddings for use in identifying a set of candidate responses to an input question; wherein the embedding space is configured during training according to a contrastive loss that applies same tower negatives to generate the question and response embeddings.
14. The method of claim 13, further comprising: identifying the set of candidate responses to the input question; and providing one or more candidate responses of the set of candidate responses to a client computing device.
15. The method of claim 13, wherein the contrastive loss applies a bi-directional in-batch sampled loss.
16. The method of claim 15, wherein the bi-directional in-batch sampled loss is a softmax loss.
17. The method of claim 16, wherein the softmax loss only considers contrastive estimation between a target example pair and in-batch sampled negative pairs during the training.
18. The method of claim 13, wherein: the token embedder layer section has a first token embedding section associated with the first input and a second token embedding section associated with the second input; and during training the first input is a query and the second input is a candidate responsive to the query.
19. The method of claim 13, wherein: the encoder layer section has a first encoder section receiving the token embeddings from the token embedder layer and generating first ones of the encodings; and the encoder layer section has a second encoder section receiving the token embeddings from the token embedding layer and generating second ones of the encodings.
20. The method of claim 13, wherein the dual encoder system is an asymmetric dual encoder arrangement having dual encoding towers in which the projection layer is a common projection layer forthe dual encoding towers, and there is no parameter sharing between corresponding portions of the token embedder layer or between corresponding portions of the encoder layer section.
