plasticityai / magnitude

A fast, efficient universal vector embedding utility package.
MIT License
1.63k stars 120 forks source link

pad_to_length doesn't work when using concatenated Magnitude vectors in call to query() #50

Open ParikhKadam opened 5 years ago

ParikhKadam commented 5 years ago

Code to reproduce:

from pymagnitude import MagnitudeUtils, Magnitude
size = 384
vecs1 = Magnitude(MagnitudeUtils.download_model('glove/medium/glove.6B.100d'))
vecs2 = Magnitude(MagnitudeUtils.download_model('fasttext/medium/wiki-news-300d-1M-subword'))
vecs = Magnitude(vecs1, vecs2)
sents = [["I", "read", "a", "book"], ["I", "read", "a", "magazine"]]
a = vecs.query(sents, pad_to_length=size, pad_left=False, truncate_left=False)
print(a.shape)

Output: (2, 4, 400)

I don't need an alternative but I want this to work in my project.. So, please solve it as soon as possible..

Thank you..

ParikhKadam commented 5 years ago

Just created a pull request which I think might solve this issue.. Please take a look and update it as soon as possible @AjayP13

https://github.com/plasticityai/magnitude/pull/51