openai / generating-reviews-discovering-sentiment

Code for "Learning to Generate Reviews and Discovering Sentiment"
https://arxiv.org/abs/1704.01444
MIT License
1.51k stars 379 forks source link

range of values for the sentiment neuron #21

Closed mbnik closed 7 years ago

mbnik commented 7 years ago

Here is my sample code:

from encoder import Model model=Model() text = ['it was a nice day','it was a great day','it was a bad day','It was a wonderful day','It was an excellent day','It was a super excellent day','It was such a bad bad day ','It was such a bad bad bad day'] text_features = model.transform(text)

17.660 seconds to transform 8 examples

for i in range(len(text)): sentiment = text_features[i, 2388] print(text[i],sentiment)

Here is the result:

it was a nice day 0.012658 it was a great day 0.371533 it was a bad day -0.499269 It was a wonderful day 0.503395 It was an excellent day 0.44557 It was a super excellent day 0.623401 It was such a bad bad day -0.858701 It was such a bad bad bad day -1.04497

My questions are: 1-what is the range for sentiment values? 2-is there any specific range for negative, positive and neutral sentiments?

ahirner commented 7 years ago

@mbnik Histograms of the "sentiment neuron" after seeing positive and negative reviews are provided in the blog-post (or paper). I've fixed it to +1.0 and -1.5 to -1.0 for generating new sequences with decent results.

cerisara commented 7 years ago

I've tried to apply the model onto the Stanford sentiment dataset, and can't reproduce these histograms: the avg value of neuron 2387, 2388 or 2389 are the same for both pos and neg examples. I must have a buggy code, but just to be sure: did anyone managed to reproduce these histograms on the movie review dataset ?

rstjobs commented 7 years ago

its mentioned in the blog "sentiment classifier by taking a linear combination of these units, learning the weights of the combination via the available supervised data" Still not able to figure out how to get Sentiment neuron? Please give us a idea here

Newmu commented 7 years ago

@rstjobs This blog post discusses a way of finding the sentiment unit