1
$\begingroup$

I am trying to create a language generation model to generate very short sentences/words, like a rapper name generator. The sentences in my dataset are anywhere between 1 word and 15 words (3-155 characters). So far, I have tried LSTM's with 1-3 layers and inputs as subwords and characters. The results so far are not that great, I am getting ~0.5 crossentropy loss and ~50% accuracy.

My inputs are like a sliding window with prepadding, (eg. (for a batch) Inputs = [[0,0,0,1], [0,0,1,2]...[n-4,..n-1]], outputs=[[0,0,1,2], ...[n-3,n-2,n-1,n]]) where 0 is padding, 1 is the start token and n is the end token. Outputs are 1 hot encoded.

The model is an embedding layer, few lstm and dropout layers, followed by time distributed dense and then a dense layer.

My doubt is, is accuracy a right metric, I am using it because at the end, I am making a classification for 4 output values. Another one is, will a transformer be suitable for this, since I want to generate small sentences, (which are nouns) and models like GPT/ Bert are more suitable for capturing dependency between long sentences.

$\endgroup$
  • 1
    $\begingroup$ Hi. Can please put your main question in the title? $\endgroup$ – nbro Sep 13 '20 at 15:25
  • $\begingroup$ @nbro updated, is that okay? $\endgroup$ – ctlr Sep 13 '20 at 15:28
  • $\begingroup$ That seems more explicit and specific. Thanks! $\endgroup$ – nbro Sep 13 '20 at 15:28
1
$\begingroup$

I wouldn't say accuracy in the next word prediction is a good global metric. It would depend on the length of sentences. It's always difficult to predict the first word, cos you don't have any context. And having at least one word in the context it's easier. As long as your error rate is averaged among all predicted words, the accuracy could be higher if the lengths of sentences are higher. So the value of 0.5 doesn't tell much. The fact that you improved accuracy by 0.1 for instance on the same dataset means one method is better than another. Also, people measure perplexity and it's more sensitive to small changes of loss than accuracy. That's why I suggest you to measure perplexity. This metric also depends on lengths of sentences, that's why you should only compare 2 models trained on the same dataset. What about GPT and Transformer, they were invented to solve one of the issues of LSTMs (they're not capable to memorize a very large context), that's why transformers would be better for long sentences, but they would also be better for short I think due to their attention mechanist, which has many useful properties.

$\endgroup$
  • $\begingroup$ You mean to suggest perplexity, I think you made an error when writing "That's why I suggest you to measure accuracy." $\endgroup$ – ctlr Sep 13 '20 at 15:20
  • $\begingroup$ Sorry, yeah, I meant perplexity $\endgroup$ – Michael Solotky Sep 13 '20 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.