$cat ~/posts/aprendendo-nlp-sem-dsa

bilingual · en / pt

← /blog

learning NLP without a solid DSA foundation (and paying for it)


I picked NLP as the first serious topic in my AI Engineering track. It made sense: I was already going to use spaCy at work, I had an NLP course running on Udemy alongside the official documentation tutorial, and the subject connected directly to what I needed to deliver. The problem showed up a bit later, when I noticed I was getting to the right output without understanding why it worked that way.

the symptom

At first, everything seemed fine. doc = nlp(text), iterate over the tokens, grab .pos_, .dep_, .ent_type_, build the logic on top of that. The course kept moving, the exercises kept passing, the code kept running. But when it came to real token manipulation: filtering, regrouping, walking the dependency tree, optimizing a scan that needed to run over real volumes of text, I got stuck. Not because I didn't understand NLP. Because I didn't understand data structures.

That's when it clicked: a spaCy Doc is an optimized data structure. Tokens live as views over a contiguous buffer of numeric data (the Vocab and its string hashes), and each Token is essentially an index into that structure. Manipulating it efficiently is, in practice, the same kind of reasoning as manipulating an array in pure DSA: understanding access cost, slicing cost, when you're copying data versus just pointing at it, when an iteration is O(n) and when it turns into O(n²) because you didn't notice you'd stuffed a linear search inside a loop.

I just never had that solidified. And the reason is pretty direct: my college never delivered a decent DSA foundation. I took the course, got the grade, moved on, but the real content of "how to think about complexity, structures, and trade-offs" never stuck.

DSA and NLP in parallel

The solution I landed on wasn't pausing NLP to "come back later with a better foundation." That would push the practical application into an uncertain future, and I already had deliverables at work. Instead, I started studying both things in parallel, on purpose:

  • NLP/spaCy keeps moving: course, documentation, direct application in the project.
  • DSA came in as its own track, studied in parallel, specifically to support what spaCy demands in practice: understanding how a sequence of tokens behaves as a data structure, what it means to manipulate a Span, why slicing a Doc is different from slicing a plain Python list, and how to think about complexity when the input is real text, not a toy array from an intro course.

On that front, Augusto Galego's DSA course has been the piece helping the most so far. It's the material that's actually filling the hole college left, not just teaching data structures in the abstract, but in a way I can pull straight into the reasoning I use on spaCy.

That means studying both subjects with the other in mind the whole time. Every time a DSA concept comes up (arrays, pointers, sliding windows, searches), I immediately try to map it to some real operation I do on spaCy tokens. And every time I hit a wall manipulating tokens, that's the signal for which DSA gap I need to close first.

why this matters

You can use a library like spaCy without understanding any of this: it's built to be that way, high-level enough to work like that. The problem is that without this foundation, you're at the mercy of whatever the library already solved for you. The moment the real application asks for something outside the documentation's happy path: a pattern extraction that needs to be efficient at volume, a span manipulation that isn't trivial, a decision between rebuilding a structure or navigating in place, the lack of DSA turns into a pretty low ceiling, pretty fast.

And that's especially true when the context is applied, not academic. It's about a pipeline that processes real documents, at real volume, within a real sprint deadline.

where that leaves me now

I'm still in this uncomfortable middle ground: solid enough in NLP to be productive, but rebuilding underneath the structure that should have come first. The DSA track runs alongside work, and the measure of progress is internalizing the structure-and-complexity reasoning that should have been the foundation before any AI work at all.

If this phase is making anything clear, it's that "learning AI" without this foundation is personal technical debt, and it charges interest exactly when you most need the code to actually work well: in production, on real data.

One good thing already coming out of this: I'm starting a DSA club at work with an Android specialist from my department who's become a friend along the way. He feels the same gap I do, just on the Android side, and studying this as a group has a better shot at actually sticking than studying alone.