I installed fastText following the instructions for Python:
Installing collected packages: pybind11, fasttext
Found existing installation: fasttext 0.8.3
Uninstalling fasttext-0.8.3:
Successfully uninstalled fasttext-0.8.3
Running setup.py install for fasttext ... done
Successfully installed fasttext-0.8.22 pybind11-2.2.4
It's Python 3.7.
The model was trained on Ubuntu with the only release (v0.1.0).
As you see, strangely, some input string values work fine, and some do not. For example model.predict('TEST 2') works - a label and probability are returned - but model.predict('TEST 3') causes fastText to spill its guts.
import fastText
model = fastText.load_model('model.bin')
>>> model.predict('example example example')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/fastText/FastText.py", line 138, in predict
probs, labels = zip(*pairs)
ValueError: not enough values to unpack (expected 2, got 0)
>>> model.predict('test')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/fastText/FastText.py", line 138, in predict
probs, labels = zip(*pairs)
ValueError: not enough values to unpack (expected 2, got 0)
>>> model.predict('test TEST')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/fastText/FastText.py", line 138, in predict
probs, labels = zip(*pairs)
ValueError: not enough values to unpack (expected 2, got 0)
>>> model.predict('example example example')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/fastText/FastText.py", line 138, in predict
probs, labels = zip(*pairs)
ValueError: not enough values to unpack (expected 2, got 0)
>>> model.predict('TEST 2')
(('__label__true',), array([1.00001001]))
>>> model.predict('TEST 3')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/fastText/FastText.py", line 138, in predict
probs, labels = zip(*pairs)
ValueError: not enough values to unpack (expected 2, got 0)
>>> model.predict('THIS IS NOT A test.')
(('__label__true',), array([1.00001001]))
Maybe there is some incompatibility between the latest version of Python and the latest release, which is a year old?
Hi @bittlingmayer ,
Could you please test the following and paste the result here?
import fastText
model = fastText.load_model('model.bin')
model.f.predict("TEST 3\n", 1, 0.0)
(please note the newline \n at the end of the string)
also, can you check what the command line returns?
./fasttext predict-prob model.bin - and type TEST 3 + return.
Regards,
Onur
Trying now
>>> import fastText
>>> model = fastText.load_model('model.bin')
>>> model.f.predict("TEST 3\n", 1, 0.0)
[]
For the command line, I download separately and built using make, that is, it's using a different binary. The response was simply a blank line, no error.
./fastText-0.1.0/fasttext predict-prob model.bin -
TEST 2
__label__true 1
TEST 3
I will try to find where the binary is that the Python lib uses, so that I can use the exact same one.
Is there a verbosity flag for predict-prob?
Here is the model.bin by the way. (Renamed to .txt to work around GitHub's restrictions. Just rename it back to .bin.)
model.txt
I'm getting the same issue and it is caused by trying to * an empty predictions list (no tuples). Therefore zip(*predictions) is None thereby leaving nothing to unpack and the unpacking error.
predictions = self.f.predict(text, k, threshold)
probs, labels = zip(*predictions)
For example,
self.f.predict('asdfs', k=1, threshold=0.5) == []
[i for i in zip(*predictions)] == []
Hi @bittlingmayer , @christian-storm ,
The issue should be fixed by the commit 2936e07.
I am closing the issue. Feel free to re-open it if you still observe the problem.
Thank you for reporting!
Best regards,
Onur
Hi,
here is my code:
from utilities import *
import tensorflow as tf
import numpy as np
MODE = 'train'
URL = 'http://www.manythings.org/anki/fra-eng.zip'
FILENAME = 'fra-eng.zip'
BATCH_SIZE = 64
EMBEDDING_SIZE = 256
RNN_SIZE = 512
NUM_EPOCHS = 15
ATTENTION_FUNC = 'concat'
lines = read_file(URL, filename=FILENAME)
lines = (lines,'utf-8')
raw_data = []
for line in str(lines).split('\n'):
raw_data.append(line.split('\t'))
print(raw_data[-5:])
raw_data = raw_data[:-1]
raw_data_en, raw_data_fr = list(zip(*raw_data))
raw_data_en = [normalize_string(data) for data in raw_data_en]
raw_data_fr_in = ['
raw_data_fr_out = [normalize_string(data) + '
i am getting the value error for this as:
raw_data_en, raw_data_fr = list(zip(*raw_data))
ValueError: not enough values to unpack (expected 2, got 0)
Please help me to solve that
Most helpful comment
I'm getting the same issue and it is caused by trying to * an empty predictions list (no tuples). Therefore zip(*predictions) is None thereby leaving nothing to unpack and the unpacking error.
For example,