Hi, we're building a wrapper around the C++ fastText library so that we can use it in a web server.
I have a question regarding concurrency.
Is it safe to initialize a single FastText object and have it be used by multiple threads to call FastText::Predict? Or can it be only used by one thread at a time?
Hi @fabubaker,
Yes, the method FastText::predict is thread safe. It allocates the necessary State variable (see fasttext.cc#L445). Please note that you can also use the method predictLine, which directly returns the labels as string instead of IDs in the vocabulary.
Best,
Edouard
Most helpful comment
Hi @fabubaker,
Yes, the method
FastText::predictis thread safe. It allocates the necessaryStatevariable (see fasttext.cc#L445). Please note that you can also use the methodpredictLine, which directly returns the labels asstringinstead of IDs in the vocabulary.Best,
Edouard