← Questions

N-gram language model with fit and generate

0
RunwayCodingLast asked Jun 2026

A coding interview question asked in Runway's coding screen, last asked Jun 2026. It tests nlp, language models and ml coding.

Write an n-gram language model class. fit reads a text file, tokenizes it, counts n-grams and their (n − 1)-word contexts, and turns the counts into smoothed conditional probabilities. generate produces text by repeatedly sampling the…

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

What it tests

nlp · language models · ml coding

Your code and the AI tutor open when you unlock this question.