Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Quick example of language detection with fasttext small model (less than 1MB model)
# Public Domain CC0 license.
# Prepare with: pip install fasttext
# Tested with Python 3.9
import urllib.request
import fasttext
# Download small model (917KB)
# Other options:
urllib.request.urlretrieve('', 'model.ft')
# Predict language of "hello world"
m = fasttext.load_model('model.ft')
m.predict('hello world')
# Returns (('__label__en',), array([0.17635809]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment