Ibraheem Wagih
All projects

Natural Language Processing

NLP from first principles

A single notebook covering four small language systems, built on the Stanford Sentiment Treebank and on literary texts.

  • PyTorch
  • TF-IDF
  • NER
  • n-grams
Context
UCL Natural Language Processing, individual coursework
Date
March 2026
Team
Individual
Stack
Python, NumPy, pandas, scikit-learn, PyTorch, Hugging Face Transformers

What it covers

Sentiment with logistic regression

Tokenisation, hand-built features and word embeddings, compared on the same task.

A neural sentiment classifier

An MLP in PyTorch with hyperparameter tuning, compared against zero-shot and few-shot classification by large language models.

Information retrieval

Preprocessing, named entity recognition, TF-IDF vectors and cosine similarity to retrieve documents from the Sherlock Holmes stories, with a two-dimensional projection of the document vectors.

Text generation

Unigram, bigram and longer n-gram language models, written without libraries.

Scatter plot of the Sherlock Holmes stories on the first two principal components, with the four novels well apart from the short stories.
PCA projection of the Sherlock Holmes stories. The four novels sit well apart from the short stories.
Word cloud of the most frequent words in Moby Dick.
Most frequent words in Moby Dick after cleaning.
Horizontal bar chart of the twenty most frequent bigrams in Moby Dick.
The twenty most frequent bigrams in the same text.