I wanted to learn OCaml and needed a problem small enough to finish. Cogitator indexes a codebase into chunks, splits identifiers the way programmers write them (getUserName becomes get, user, name), weights terms with TF-IDF and ranks chunks by cosine similarity. The output is a prompt with the most relevant code, ready to hand to a model.
It’s deliberately simple: no embeddings, no server, no dependencies worth mentioning. The write-up of how it works, and what OCaml turned out to be good at, is in TF-IDF in OCaml.