Monitor-Guided Decoding of Code LMs with Static Analysis of Repository Context Aditya Kanade Microsoft Research Microsoft Research Bangalore, India Shuvendu K. Lahiri Microsoft Research

Neural Information Processing Systems 

Language models of code (LMs) work well when the surrounding code provides sufficient context. This is not true when it becomes necessary to use types, functionality or APIs defined elsewhere in the repository or a linked library, especially those not seen during training. LMs suffer from limited awareness of such global context and end up hallucinating. Integrated development environments (IDEs) assist developers in understanding repository context using static analysis. We extend this assistance, enjoyed by developers, to LMs. We propose monitor-guided decoding (MGD) where a monitor uses static analysis to guide the decoding.