Find the Most Likely Infill That Satisfies a Schema Automaton
Last updated: November 29, 2026
Quick Overview
Given a token template where some positions are fixed and others masked, per-position log-probabilities for masked slots, and a DFA describing valid outputs (for example a JSON shape), return the highest-probability filled sequence the DFA accepts, or report that none exists.
Inception
November 29, 20260
0
0 solved
Given a token template where some positions are fixed and others masked, per-position log-probabilities for masked slots, and a DFA describing valid outputs (for example a JSON shape), return the highest-probability filled sequence the DFA accepts, or report that none exists.
Inception highlights that diffusion LMs give finer control over output schemas, since the model sees the whole canvas at once. Engineers working on structured output need to combine model scores with grammar constraints exactly. The interviewer checks that the candidate turns this into a DP over positions and automaton states instead of greedy or brute-force search.
What the Interviewer Expects
- Recognize the product structure of positions times DFA states
- Treat fixed tokens as single options with zero log-probability
- Keep back-pointers to reconstruct the best sequence
- Detect infeasibility early when no state survives a position
- State complexity and why greedy per-position choice fails
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would this change if constraints are a context-free grammar instead of a DFA?
- Per-position scores assume independence; how would you use this inside an iterative denoiser?
- How would you return the top-k valid sequences?
- How do you handle a vocabulary of 100k tokens efficiently?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Positions 0..L-1; each is a fixed token or masked with a dict token -> log p. The DFA is a partial transition map (state, token) -> state, a start state and accepting states. Maximize the sum of l...
High-Level Design
This is Viterbi over the DFA. best[state] is the highest score of any valid prefix of length i ending in that state. For each position, expand each live state by each allowed token, keep the max per...
Submit Your Answer
Inception Machine Learning Engineer Interview Guide
Interview process, tips, and preparation timeline