BM25 Explained

I already wrote a blog post about TF-IDF. I highly recommend reading it before this one. The goal of TF-IDF is to give us a matching score between two documents. Using this score, given a query and a bunch of documents, we can compute how well the query matches each document in our database and return the most relevant results. Here’s the gist of what TF-IDF does: It asks: how much do these two documents overlap on informative keywords? ...

July 3, 2026 · 12 min · Dariush

TF-IDF Explained

Search feels like magic until you build one yourself. Type in a few words, and somehow the right document floats to the top of the list. Under the hood, even the simplest version of this magic relies on an elegant, decades-old idea: TF-IDF. In this post, we’ll build a tiny search engine from scratch, using nothing but Python’s standard library, and use it to find the most relevant document for a query. ...

June 24, 2026 · 9 min · Dariush

JPEG Compression as a Differentiable PyTorch Module

Most autoencoders learn their representations from data. That’s powerful, but opaque — you can’t easily reason about what each latent dimension means, or guarantee invertibility. JPEG takes the opposite approach. Its encoding is a fixed, well-understood signal-processing pipeline. I’ve always found that contrast interesting, so I built dct-autoencoder — a PyTorch module that implements the core JPEG pipeline analytically, without any training. The motivation A question I kept running into doing computer vision work: why do we process images in RGB? ...

June 6, 2026 · 6 min · Dariush

Understanding Precision and Recall

Introduction When I first learned about precision and recall, I found them confusing — but later realized these metrics are actually very intuitive. They just need the right context to click. The best way to think about them is through the confusion matrix. Once you understand the confusion matrix, precision and recall become natural and easy to reason about. Confusion Matrix The figure below shows a confusion matrix for a binary classification task: ...

June 5, 2026 · 3 min · Dariush

Hello World

This is a place where I write things down. Mostly so I don’t forget them — but also because explaining something forces you to actually understand it. Topics will wander: machine learning, math, programming, systems, whatever I’m currently curious about. No strict theme. If something here is useful to you, great. If not, that’s fine too.

June 4, 2026 · 1 min · Dariush