0

How does GPT3 or other model goes from next word prediction to do Sentiment analysis, Dialogs, Summaries, Translation .... ?

what is the idea and algorithms ? How does it work ?

F.e. generating paragraph is generate next word then the next ..next..

On the other hand Sentiment analysis task is paragraph of text is Good/Bad, which is a classification ? Extracting meaningful sentence from paragraph is even more different task.

How do we go from next token to ...... !


Andre thanks for the replies.

It seems my question is not clear enough. So let me elaborate. Next-token prediction can be trained on normal text corpus.

word1 w2 w3 w4 .....

Next Sentiment can be trained on sentence=>marker=>label

sent1: word1 w2 w3 w4 ..... marker label1
sent2: word1 w2 w3 w4 ..... marker label2
sent3: word1 w2 w3 w4 ..... marker label3
....

It is no longer corpus-next-token-generation. It is next-token generation. The problem is you need to have the LABALED data !!

How about text summation ... lets use keyword extraction (and eventually sentence selection based on those keywords) Again u need even more complex labeling.

  paragraph1 => kw1
  paragraph1 => kw2
  paragraph2 => kw3
  paragraph3 => kw4         

it still can be thought of as next-token prediction but you need again specialized LABELED data.

So my question given ONLY corpus text, how do you do the Sentiment, Text summary .... etc ?

Otherwise GPT3 is simply scaled DNN with thousands of man hours for labeling data !!

WHERE is the LEAP ?

Wicket
  • 125
  • 7
sten
  • 7,028
  • 9
  • 41
  • 63

2 Answers2

1

GPT-3 is a few-shot learning Natural Language Generator.

It's possible to adapt those generic models to perform specific tasks, such as classification, translation, summaries, etc.

For such, we need to:

  1. Fine-tune the model for the desired task
  2. Pre-process the query
  3. Query the NLG (call API)
  4. Post-process the answer

Example:

1- Fine tuning:

This is a tweet sentiment classifier


Tweet: "I loved the new Batman movie!"
Sentiment: Positive
###
Tweet: "I hate it when my phone battery dies."
Sentiment: Negative
###
Tweet: "My day has been "
Sentiment: Positive
###
Tweet: "This is the link to the article"
Sentiment: Neutral
###

2- Query sample:

This new music video blew my mind

2.1 - Pre-process query (encapsulate the query in the same format as found in the the fine tuning):

Tweet: "This new music video blew my mind"
Sentiment:

3 - Query the API. The expected result should be:

 Positive
###

4 - Post-processing / format:

  • Remove trailing spaces, '###' and any other extra line.
  • Try to exact-match result between ['Positive', 'Neutral', 'Negative']
  • If any other answer is found, handle the errors.

I hope this example is clarifying enough. You can find more information on the documentation and on examples.

Andre Goulart
  • 528
  • 2
  • 20
  • thanks ... this explains how to use it. I was looking of the algorithm's i.e. once u have a model that can just predict the next word to a process that can do not just that but also Sentiment or Summary. Not interested of the model per se or the structure of the NN, but the LEAP to do such different things ? – sten Jan 10 '22 at 04:11
  • GPT-3 is a Natural Language Generator. It just generates the next word, period. It doesn't even know if it's being used for Summary, Sentiment, Classification.... Those are just ways to tweak the model. The LEAP might be training it on a very generic dataset, so it can not only generate text about any subject, but also complete any kind of task. – Andre Goulart Jan 10 '22 at 19:08
  • so if u have only next-word prediction how do u do sentiment for example. For sentiment you need a text as input and label as output. Next-word prediction does not help u at all. – sten Jan 11 '22 at 04:08
  • 1
    You persuade the model to output a label as the next word, just like I did in the example. Please, read the documentation and examples. If your doubt is about how the model works, I recommend reading about Transformers and Attention based models. – Andre Goulart Jan 11 '22 at 14:44
  • so in a sense u make it predict after a full sentence not after every word. And this assumes you have the Labels to train the BIG GPT3 model. i assumed it was trained only on general text to just predict next-word.. and then they algorithimically solve for the other tasks – sten Jan 11 '22 at 20:01
  • It has a full sentence as an input. And one single word (at time) as output. The GPT3 is trained on general text, just to predict the next word, but you can persuade it to work as a classifier by: 1. Fine-tunning it with phrases and labels. Or 2. Showing the expected pattern on the input, as I showed on the example. – Andre Goulart Jan 11 '22 at 21:11
0

I think this is a good question. To be honest, I have exactly the same feeling too. I don't think I fully understand the answer provided by Andre quite yet. Here are some additional information on InstructGPT that I found useful in trying to find answer to the question.

I think the question perhaps can be paraphrase as: in supporting say instruction, do we use chatgpt output and feed back to chatgpt? Or we we go through a different sub-system to do the training?

To answer the question, I found InstructGPT useful. In their words:

InstructGPT, thus, is the underlying stack that sits beneath ChatGPT. Its core difference with GPT is that InstructGPT uses a human feedback approach in the fine-tuning process, where humans show a set of outputs to the GPT model once it has been pre-trained thourhg the InstructGPT framework.

This is the paper on InstructGPT from openai Team: https://cdn.openai.com/papers/Training_language_models_to_follow_instructions_with_human_feedback.pdf.

The diagram on Page 3 shows the architecture in how the subsequent training is done. From this diagram, one can see the labeled data is then use to feed to the gpt training. The gpt training would be performed by openai (or maybe whoever has the model and the training infrastructure in place).

There are other resources that I found more readable, such as: https://fourweekmba.com/instructgpt/

MonaPy
  • 11
  • 3
  • GPT3 is not meant for sentiment analysis, but as Andre is saying, you can hack it to do so via fine-tuning. This is basically Transfer Learning, because the majority of the model was trained for one purpose and you'll now use it for something else. There are different ways to do it, and it would be an interesting project idea, that I'm sure others have tried. – ryanwebjackson Jun 16 '23 at 13:55