Fasttext: Is FastText::Predict thread safe?

Created on 28 Mar 2019  路  1Comment  路  Source: facebookresearch/fastText

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?

Most helpful comment

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

>All comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ereday picture ereday  路  3Comments

a11apurva picture a11apurva  路  3Comments

pengyu picture pengyu  路  3Comments

hughbzhang picture hughbzhang  路  3Comments

yasonk picture yasonk  路  3Comments