# Convert Gensim FastText to spaCy-readable Word2Vec format for terms.teach recipe

**URL:** <https://support.prodi.gy/t/convert-gensim-fasttext-to-spacy-readable-word2vec-format-for-terms-teach-recipe/3386>\
**Category:** Uncategorized\
**Tags:** spacy, terms, solved, gensim\
**Created:** [September 10, 2020, 9:24am UTC](https://support.prodi.gy/t/convert-gensim-fasttext-to-spacy-readable-word2vec-format-for-terms-teach-recipe/3386 "2020-09-10T09:24:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DGMS90](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/dgms90/32/3133_2.png) [@DGMS90](https://support.prodi.gy/u/DGMS90)\
**Post date:** [September 10, 2020, 9:24am UTC](https://support.prodi.gy/t/convert-gensim-fasttext-to-spacy-readable-word2vec-format-for-terms-teach-recipe/3386/1 "2020-09-10T09:24:03Z")

</div>

Hey,

I'm trying to work out how to convert my custom Gensim FastText model into a spaCy-readable Word2Vec format for use in Prodigy. I've previously done this for a Gensim Doc2Vec model, however I'm not finding anything on how to achieve this for Gensim's FastText model.

Has anyone done this before?

Thanks in advance!

Darren

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 10, 2020, 1:56pm UTC](https://support.prodi.gy/t/convert-gensim-fasttext-to-spacy-readable-word2vec-format-for-terms-teach-recipe/3386/2 "2020-09-10T13:56:57Z")

</div>

Hi! You should be able to use the `init-model command for this. See the section on converting vectors here:

> **[Word Vectors and Semantic Similarity · spaCy Usage Documentation](https://spacy.io/usage/vectors-similarity/)**
>
> spaCy is a free open-source library for Natural Language Processing in Python. It features NER, POS tagging, dependency parsing, word vectors and more.

---

<div class="post-metadata">

**Author:** ![DGMS90](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/dgms90/32/3133_2.png) [@DGMS90](https://support.prodi.gy/u/DGMS90)\
**Post date:** [September 10, 2020, 2:51pm UTC](https://support.prodi.gy/t/convert-gensim-fasttext-to-spacy-readable-word2vec-format-for-terms-teach-recipe/3386/3 "2020-09-10T14:51:37Z")

</div>

Hi Ines,

Thanks for the response.

The init-model documentation mentions requiring a .txt, .zip or .gzip.zip file to be able to run. However, Gensim's models are saved to .pkl and .npy files.

I considered creating a simple .txt file by iterating through my model's entire vocab and saving on each line TOKEN VECTOR VALUE1 VALUE2...... VALUEN, however it's unclear whether the vectors in the text file should begin with the vector values themseleves or have a bracket to indicate the start of a list.

Do you know which is the case?

Thanks,

Darren

---

<div class="post-metadata">

**Author:** ![DGMS90](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/dgms90/32/3133_2.png) [@DGMS90](https://support.prodi.gy/u/DGMS90)\
**Post date:** [September 11, 2020, 6:03am UTC](https://support.prodi.gy/t/convert-gensim-fasttext-to-spacy-readable-word2vec-format-for-terms-teach-recipe/3386/4 "2020-09-11T06:03:37Z")

</div>

Found a solution for formatting the .txt file.

TLDR: first line of the text file should contain a string of "{} {}".format(VOCAB\_SIZE, NDIMS).

Sources for solution:

- [How to use two .txt files one with vectors the other with words](https://support.prodi.gy/t/how-to-use-two-txt-files-one-with-vectors-the-other-with-words/565/4)
- [https://stackoverflow.com/questions/27324292/convert-word2vec-bin-file-to-text/29251943#29251943](https://stackoverflow.com/questions/27324292/convert-word2vec-bin-file-to-text/29251943#29251943)
- [https://github.com/explosion/spaCy/issues/2298#issuecomment-387091526](https://github.com/explosion/spaCy/issues/2298#issuecomment-387091526)

Thanks for your help Ines!

Darren

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 11, 2020, 10:11am UTC](https://support.prodi.gy/t/convert-gensim-fasttext-to-spacy-readable-word2vec-format-for-terms-teach-recipe/3386/5 "2020-09-11T10:11:16Z")

</div>

Thanks for updating and glad you got it working! 😃
