Questions tagged [transformer]

For questions related to the transformer, which is a deep machine learning model introduced in 2017 in the paper "Attention Is All You Need", used primarily in the field of natural language processing (NLP).

Filter by
Sorted by
Tagged with
0
votes
0answers
6 views

RNN or Transformer architecture on texts with ony little grammar

I'm currently working on business documents like for example invoices. I'd like to extract information similar to named entity recognition (classification on token level). So, this in not continuous ...
0
votes
0answers
11 views

What BERT predicts when the token supposed to be masked is not masked?

I am reading the BERT paper. In the paper, they say that: Although this allows us to obtain a bidirec- tional pre-trained model, a downside is that we are creating a mismatch between pre-training and ...
0
votes
0answers
27 views

Bigger models get higher losses

I'm training a model with the transformer encoder architecture on a given fixed set of data. The task I'm solving has a trivial approximation which consists in copying part of the input to the output, ...
0
votes
0answers
15 views

Transformer Language model produces only <pad> tokens when generating new sentences

I am training a word-level language model using the transformer module available in Pytorch. I am getting a really good training loss and the model is able to reproduce the sentences in the training ...
2
votes
1answer
36 views

Any comparison between transformer and RNN+Attention on the same dataset?

I am wondering what is believed to be the reason for superiority of transformer? I see that some people believe because of the attention mechanism used, it’s able to capture much longer dependencies. ...
5
votes
2answers
79 views

What is the purpose of Decoder mask (triangular mask) in Transformer?

I'm trying to implement transformer model using this tutorial. In the decoder block of the Transformer model, a mask is passed to "pad and mask future tokens in the input received by the decoder&...
0
votes
0answers
50 views

Transformer Language Model generating meaningless text

I currently learning on Transformers, so check my understanding I tried implementing a small transformer-based language model and compare it to RNN based language model. Here's the code for ...
1
vote
0answers
27 views

How are weight matrices in attention trained?

I have been looking into transformers lately and been reading tons of tutorials. All of them address the intuition behind attention, which I understand, but they treat training the weight matrices for ...
0
votes
0answers
28 views

How to implement or avoid masking for transformer?

When it comes to using Transformers for image captioning is there any reason to use masking? I currently have a resnet101 encoder and am trying to use the features as the input for a transformer model ...
4
votes
0answers
26 views

Are there transformer-based architectures that can produce fixed-length vector encodings given arbitrary-length text documents?

BERT encodes a piece of text such that each token (usually words) in the input text map to a vector in the encoding of the text. However, this makes the length of the encoding vary as a function of ...
0
votes
1answer
36 views

BERT: After pretraining 880000 step, why fine-tune not work? [closed]

I am using pretraining code from https://github.com/NVIDIA/DeepLearningExamples Pretrain parameters: ...
0
votes
0answers
39 views

How to input a given sequence to a transformer (or an RNN) with probability of occurrence?

I'm experimenting with music and transformers, and I have sequences $S$ of shape: $(B,L,N)$ where $B$ is the batch size, $L$ is the sequence length, and $N=12$ are the number of musical notes with ...
0
votes
0answers
13 views

How to use an image tensor for caption generation with Transformer-XL or BERT?

I am fairly new to transformers and deep learning in general so please be kind, I am currently working on a project that will caption images using either Transformer-XL or BERT, however, I am not sure ...
2
votes
1answer
61 views

What is the weight matrix in self-attention?

I've been looking into self-attention lately, and in the articles that I've been seeing, they all talk about "weights" in attention. My understanding is that the weights in self-attention ...
1
vote
1answer
52 views

How is BERT different from the original transformer architecture?

As far as I can tell, BERT is a type of Transformer architecture. What I do not understand is: How is Bert different from the original transformer architecture? What tasks are better suited for BERT,...
0
votes
0answers
16 views

Why BERT last 4 Layers should be considered to extract word embeddings?

In most of the cases the embedding vectors of last 4 layers of BERT are summed up to represent the tokens embedding. I've tried to explore but haven't found any strong reason/resource on why we should ...
0
votes
0answers
12 views

What is the best NLP model for handeling a rapid extension of the production data for a question answeing task

I'm lately writing a chat-bot to answer questions about children's fantasy books I save to my database . When a user opens a book it loads the chat-bot for the given book . I don't need it to work on ...
3
votes
1answer
102 views

How can Transformers handle arbitrary length input?

The transformer, introduced in the paper Attention Is All You Need, is a popular new neural network architecture that is commonly viewed as an alternative to recurrent neural networks, like LSTMs and ...
0
votes
0answers
48 views

Using transformer but masking in reverse direction/smart sampling for desired final word?

I'm trying to generate rhymes, so it would be very helpful to have a language model where I could input a final word, and have it output a sequence of words that ends with that word. I could train my ...
2
votes
0answers
84 views

What is the memory complexity of the memory-efficient attention in Reformer?

When I read the paper, Reformer: The Efficient Transformer, I cannot get the same complexity of the memory-efficient method in Table 1 (p. 5), which summarizes time/memory complexity of scaled dot-...
1
vote
0answers
46 views

Is it good practice to save NLP Transformer based pre-trained models into file system in production environment

I have developed a multi label classifier using BERT. I'm leveraging Hugging Face Pytorch implementation for transformers. I have saved the pretrained model into the file directory in dev environment. ...
3
votes
1answer
331 views

What exactly are the “parameters” in GPT-3's 175 billion parameters and how are they chosen/generated?

When I studied neural networks, parameters were learning rate, batch size etc. But even GPT3's ArXiv paper does not mention anything about what exactly the parameters are, but gives a small hint that ...
0
votes
1answer
45 views

What is the big fuzz about SHA-RNN versus Transformers?

In his paper introducing SHA-RNN (https://arxiv.org/pdf/1911.11423.pdf) Stephen Merity states that neglecting one direction of research (in this case LSTMs) over another (transformers) merily because ...
0
votes
0answers
22 views

Comparing English and Spanish Queries using NLP

I am trying to see whether there are differences in sentences between the topics in 2 languages ie English and Spanish. Eg. (Face masks are mandatory, la mascarilla es obligatoria) but this stretched ...
2
votes
1answer
42 views

Do transformers have success in other domains different than NLP?

Everybody knows how successful transformers have been in NLP. Is there known work on other domains (e.g that also have a sequential natural way of occurring, such as stock price prediction or other ...
0
votes
1answer
43 views

Transformers - is the self attention matrix softmax output (layer 1) symmetric?

Let's assume, that we embedded a vector of length 49 into a matrix using 512-d embeddings. If we then multiply the matrix by it transposed version we receive a matrix of 49 by 49. Which is symmetric. ...
0
votes
0answers
42 views

What are the training and optimization technique to train GPT-2 with 1.5B parameters?

I am able to train 345M parameter GPT-2 using DialoGPT on Reddit data topics like AskReddit, Askmen, AskWomen, casualConvo, etc. And I using AWS p3dn.24xlarge instance with 256GB GPU. It is trained ...
2
votes
0answers
37 views

How to understand the matrices used in the Attention layer?

Attention-scoring mechanism seems to be a commonly-used component in various seq2seq models, and I was reading about the original "Location-based Attention" in Bahadanau well-known paper at https://...
0
votes
1answer
29 views

Why does the BERT NSP head linear layer have two outputs?

Here's the code in question. https://github.com/huggingface/transformers/blob/master/src/transformers/modeling_bert.py#L491 ...
1
vote
0answers
35 views

Transformer encoding for regression

I have a string of characters encoding a molecule. I want to regress some properties of those molecules. I tried using an LSTM that encodes all one hot encdoed characters, and then I take the last ...
2
votes
0answers
37 views

Can you use transformer models to do autocomplete tasks?

I've researched online and seen many papers on the use of RNNs (like LSTMs or GRUs) to autocomplete for, say, a search engine, character by character. Which makes sense since it inherently predicts ...
1
vote
1answer
85 views

Why does this multiplication of $Q$ and $K$ have a variance of $d_k$, in scaled dot product attention?

In scaled dot product attention, we scale our outputs by dividing the dot product by the square root of the dimensionality of the matrix: The reason why is stated that this constrains the ...
5
votes
1answer
176 views

What is the intuition behind the dot product attention?

I am watching Attention all you need, In that what is the intuition behind the dot product attention? $$A(q,K, V) = \sum_i\frac{e^{q.k_i}}{\sum_j e^{q.k_j}} v_i$$ becomes: $$A(Q,K, V) = softmax(QK^...
2
votes
0answers
89 views

What is the time complexity of the forward pass and back-propagation of the sequence-to-sequence model with and without attention?

I keep looking through the literature, but can't seem to find any information regarding the time complexity of the forward pass and back-propagation of the sequence-to-sequence RNN encoder-decoder ...
12
votes
3answers
6k views

Why does the transformer do better than RNN and LSTM in long-range context dependencies?

I am reading the article How Transformers Work where the author writes Another problem with RNNs, and LSTMs, is that it’s hard to parallelize the work for processing sentences, since you have to ...
0
votes
1answer
95 views

Can you train Transformers sequentially?

I’m currently trying to train a BART, which is a denoising Transformer created by Facebook researchers. Here’s my Transformer code ...
1
vote
1answer
79 views

Transformer for speech recognition?

(1) Are there examples that transformer have better accuracy than RNN end-to-end model like RNN-transducer for speech recognition? (2) Can transformer be used for online speech recognition which ...
1
vote
0answers
37 views

Is it possible to do token classification using a model such as GPT-2?

I am trying to use PyTorch's transformers as a part of a research project to do sentiment analysis of several types of review data (laptop and restaurant). To do this, my team is taking a token-...
2
votes
0answers
33 views

How does positional encoding work in the transformer model?

In the transformer model, to incorporate positional information of texts, the researchers have added a positional encoding to the model. How does positional encoding work? How does the positional ...
1
vote
0answers
31 views

Tensorflow based implementation of Text classification with any variation of BERT(ALBERT/XLNET)

Do you have any reference you can point me to for doing Text classification using any variation of BERT(albert or XLnet) with a TF implementation. I am not sure how to deploy torch based models, so ...
1
vote
1answer
47 views

How does the regression layer in the localization network of a spatial transformer work?

I am trying to understand the spatial transformer network mentioned in this paper https://papers.nips.cc/paper/5854-spatial-transformer-networks.pdf. I am clear about the last two stages of the ...
2
votes
0answers
38 views

Pretrained Models for Keyword-Based Text Generation

I'm looking for an implementation that allows me to generate text based on a pre-trained model (e.g. GPT-2). An example would be gpt-2-keyword-generation (click here for demo). As the author notes, ...
2
votes
1answer
83 views

How does transformer leverage GPU which trains faster than RNN?

How does transformer leverage GPU which trains faster than RNN? I understand the parameter space of the transformer might be significantly larger than that of the RNN. But why does the transformer ...
2
votes
0answers
66 views

Position of layer normalization in transformer model

In Attention Is All You Need paper: That is, the output of each sub-layer is $LayerNorm(x+Sublayer(x))$, where $Sublayer(x)$ is the function implemented by the sub-layer itself. We apply dropout to ...
2
votes
1answer
168 views

Is the Mask Needed for Masked Self-Attention During Inference with GPT-2

My understanding is that masked self-attention is necessary during training of GPT-2, as otherwise it would be able to directly see the correct next output at each iteration. My question is whether ...
4
votes
2answers
89 views

Are embeddings in multi-lingual language models comparable across languages?

Facebook has just pushed out a bigger version of their multi-lingual language model XLM, called XLM-R. My question is: do these kind of multi-lingual models imply, or even ensure, that their ...
1
vote
0answers
85 views

How to use TPU for real-time low-latency inference?

I use Google's Cloud TPU hardware extensively using Tensorflow for training models and inference, however, when I run inference I do it in large batches. The TPU takes about 3 minutes to warm up ...
2
votes
0answers
147 views

Why is the transformer for time series forecasting faster than RNN?

I've been reading different papers which implements the Transformer for time series forecasting. Most of the them are claiming that the training time is significantly faster then using a normal RNN. ...
2
votes
0answers
24 views

How to train a transformer text-to-text model on counterexamples?

Is it possible to update the weights of a vanilla transformer model using counterexamples alongside examples? For example, from the PAWS data set, given the phrases "Although interchangeable, the ...
11
votes
2answers
2k views

Why would you implement the position-wise feed-forward network of the transformer with convolution layers?

The Transformer model introduced in "Attention is all you need" by Vaswani et al. incorporates a so-called position-wise feed-forward network (FFN): In addition to attention sub-layers, each of the ...