vinhkhuc / JFastText

Java interface for fastText
Other
228 stars 100 forks source link

Trying to load .ftz model and getting "wrong file format" #36

Open jenyashvartsman opened 6 years ago

jenyashvartsman commented 6 years ago

@lidalei can you please advise

import com.github.jfasttext.JFastText;

public class ApiExample { public static void main(String[] args) { JFastText jft = new JFastText();

    jft.loadModel("nlpData/model.ftz");

    // Do label prediction
    String text = "What is the most popular game in the US ?";
    JFastText.ProbLabel probLabel = jft.predictProba(text);
    System.out.printf("\nThe label of '%s' is '%s' with probability %f\n",
            text, probLabel.label, Math.exp(probLabel.logProb));
}

}

Output: Model file has wrong file format! Process finished with exit code 1

lidalei commented 6 years ago

Which version of fastText do you use to load this model? And which version did you use to train the model?

jenyashvartsman commented 6 years ago

version 0.3

com.github.vinhkhuc jfasttext 0.3

the model itself i didnt trained wit JFastText with but with fasttext. i checked the model on fasttext and it is working ok but for some resone it cant be loaded on JFastText. the only thing i can think on is that this model is very large (693 MB), might be an issue with loading this size?

jenyashvartsman commented 6 years ago

fasttext version fastText-0.1.0

lidalei commented 6 years ago

Could you try to use https://github.com/lidalei/JFastText? If it did not work, I am afraid you have to re-train your model.

Aurelius84 commented 6 years ago

what's the difference between 0.3.0 and this version (https://github.com/lidalei/JFastText) ? I just met "wrong file format" when I train model with fasttext from Facebook command and load model using JFastText==0.3.0 (Maven)??

Best Regards

lidalei commented 6 years ago

https://github.com/lidalei/JFastText uses the newest version fastText. So if you encounter this error, you should upgrade your fastText and re-train your models.