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

Add sequence_features #19

Open elmarhaussmann opened 7 years ago

elmarhaussmann commented 7 years ago

People seem to want to extract the value of a specific feature along the sequence to visualize it. E.g., for the "sentiment neuron":

>>> print(mdl.sequence_features('great product!', 2388))
[ 0.01258736  0.03544582  0.09762047  0.14658478  0.13112086  0.1182572
  0.20108429  0.55418217  0.54974681  0.53858727  0.52452445  0.51187605
  0.50210464  0.48934704  0.50488353  0.83780205  1.1202054 ]

Includes padding (2 bytes in front, one byte in end). Only accepts single string as input.