vinhkhuc / JFastText

Java interface for fastText

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jenyashvartsman opened this issue · comments

@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

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

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?

fasttext version fastText-0.1.0

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.

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

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.