Search code examples
python-3.xjupyter-notebookfast-ai

ModuleNotFoundError: No module named 'fastai.nlp'


I tried to import the following modules

from fastai.nlp import *
from fastai.model import Stepper

But, I get the following error

ModuleNotFoundError: No module named 'fastai.nlp'
ModuleNotFoundError: No module named 'fastai.model'

I have already install pip install fastai.

Thanks in advance for your help.


Solution

  • The fastai library does not contain modules called stepper or model. For NLP you use the fastai.text modules, not fastai.nlp. Here's a tutorial explaining how:

    https://docs.fast.ai/tutorial.text.html

    Where did you find code containing the two lines you're trying to run? It's not fastai v1 or v2 code. Perhaps it's from the part2 course where something like fastai was rewritten from scratch? https://course19.fast.ai/part2. If so, you'll need to use the notebooks from there.