Loading a Model and Processing a Doc
Run text through nlp() in one call.
Loading a Model and Processing a Doc is a free NLP Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the NLP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Install First
Before you load anything, you download a model once. The en_core_web_sm model is small, fast, and perfect for getting started.
python -m spacy download en_core_web_smLoad the Model
You bring spaCy to life with spacy.load. It reads the model from disk and hands you an nlp object ready to process text.
import spacy
nlp = spacy.load("en_core_web_sm")What nlp Is
That nlp object is your whole pipeline wrapped up. Calling it on text runs every stage: tokenizer, tagger, parser, and entity recognizer.
Process Some Text
To analyze a sentence, just call nlp() on a string. The result is a Doc, a rich container holding all the analysis.
doc = nlp("Apple is hiring in Berlin.")One Call Does It All
That single call already ran tokenizing, tagging, and parsing. The Doc now carries every result, so you never repeat the work.
Loop Over Tokens
A Doc behaves like a sequence, so you can loop through it. Each item you get back is a Token with its own attributes.
for token in doc:
print(token.text)Read Token Text
The raw word lives in token.text. It is exactly the surface string spaCy found while splitting your sentence.
Load Once, Reuse
Loading a model is slow, so do it once at startup. Then reuse the same nlp object for every document you process.
Process Many Docs
For lots of texts, use nlp.pipe. It batches them efficiently and is far faster than calling nlp() in a plain loop.
for doc in nlp.pipe(texts):
print(len(doc))Disable for Speed
Need only tokens? You can disable unused components when loading to skip work and run even faster.
nlp = spacy.load("en_core_web_sm", disable=["parser"])Blank Pipelines
You can also start from spacy.blank for a tokenizer-only pipeline. It is handy when you want to build everything yourself.
nlp = spacy.blank("en")Quick Check
What do you get back from calling nlp() on a string?
Recap
You install a model, load it once with spacy.load, then call nlp() to get a Doc. One call runs the whole pipeline and you reuse it everywhere. 🎯
Frequently asked questions
Is the “Loading a Model and Processing a Doc” lesson free?
Yes — the full text of “Loading a Model and Processing a Doc” is free to read here on the web, and the NLP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the NLP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Loading a Model and Processing a Doc”?
Run text through nlp() in one call. You practise NLP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start NLP Academy?
No prior experience is required. NLP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Loading a Model and Processing a Doc” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this NLP Academy lesson?
Yes. Every NLP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Why spaCy for Real Projects
- Loading a Model and Processing a Doc
- Tokens, Spans, and Doc Objects
- Customizing the Pipeline