mlsanityData to 7 Oct 2026

Guiding Language Models of Code with Global Context using Monitors

arXiv 2306.10763 ↗First posted 19 Jun 2023cs.CL cs.AI cs.LGcited by 20

Not on the map. Why?

Abstract (arXiv)

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. We construct a repository-level dataset PragmaticCode for method-completion in Java and evaluate MGD on it. On models of varying parameter scale, by monitoring for type-consistent object dereferences, MGD consistently improves compilation rates and agreement with ground truth. Further, LMs with fewer parameters, when augmented with MGD, can outperform larger LMs. With MGD, SantaCoder-1.1B achieves better compilation rate and next-identifier match than the much larger text-davinci-003 model. We also conduct a generalizability study to evaluate the ability of MGD to generalize to multiple programming languages (Java, C# and Rust), coding scenarios (e.g., correct number of arguments to method calls), and to enforce richer semantic constraints (e.g., stateful API protocols). Our data and implementation are available at https://github.com/microsoft/monitors4codegen .

Key facts. Cited by 20 papers in the map (data through 7 Oct 2026). Builds on 34 of its 66 references that are in the map. First posted on arXiv 19 Jun 2023.

Builds on

34 of 66 references.

References · 34

  1. 2022Training language models to follow instructions with human feedbackcited by 15,712
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  3. 2021Program Synthesis with Large Language Modelscited by 3,509
  4. 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,898
  5. 2019The Curious Case of Neural Text Degenerationcited by 2,881
  6. 2018SentencePiece: A simple and language independent subword tokenizer and detokenizer for Neural Text Processingcited by 1,973
  7. 2022Competition-Level Code Generation with AlphaCodecited by 1,427
  8. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
  9. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
  10. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
  11. 2023StarCoder: may the source be with you!cited by 790
  12. 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 788
22 more
  1. 2022GPT-NeoX-20B: An Open-Source Autoregressive Language Modelcited by 711
  2. 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
  3. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
  4. 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 402
  5. 2021Unified Pre-training for Program Understanding and Generationcited by 361
  6. 2022A Systematic Evaluation of Large Language Models of Codecited by 360
  7. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
  8. 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
  9. 2022Efficient Training of Language Models to Fill in the Middlecited by 248
  10. 2023SantaCoder: don't reach for the stars!cited by 169
  11. 2022Synchromesh: Reliable code generation from pre-trained language modelscited by 156
  12. 2022DocPrompting: Generating Code by Retrieving the Docscited by 151
  13. 2020Enabling Language Models to Fill in the Blankscited by 121
  14. 2022Repository-Level Prompt Generation for Large Language Models of Codecited by 106
  15. 2022CoCoMIC: Code Completion By Jointly Modeling In-file and Cross-file Contextcited by 64
  16. 2018Generative Code Modeling with Graphscited by 59
  17. 2022When Language Model Meets Private Librarycited by 54
  18. 2020Big Code != Big Vocabulary: Open-Vocabulary Models for Source Codecited by 53
  19. 2023CoderEval: A Benchmark of Pragmatic Code Generation with Generative Pre-trained Modelscited by 28
  20. 2023Better Context Makes Better Code Language Models: A Case Study on Function Call Argument Completioncited by 14
  21. 2021Neural Program Generation Modulo Static Analysiscited by 13
  22. 2021Capturing Structural Locality in Non-parametric Language Modelscited by 8

Built on by

Cited by year

Citing papers per year: 2023: 3; 2024: 12; 2025: 5.

20 papers.

Sort:

By area:

  1. 2024SynCode: LLM Generation with Grammar Augmentationcited by 66
  2. 2023Unifying the Perspectives of NLP and Software Engineering: A Survey on Language Models for Codecited by 62
  3. 2024Agents in Software Engineering: Survey, Landscape, and Visioncited by 60
  4. 2024AgileCoder: Dynamic Collaborative Agents for Software Development based on Agile Methodologycited by 45
  5. 2025Uncertainty-Guided Chain-of-Thought for Code Generation with LLMscited by 30
  6. 2024IterGen: Iterative Semantic-aware Structured LLM Generation with Backtrackingcited by 28
  7. 2024Octopus: On-device language model for function calling of software APIscited by 26
  8. 2024NoFunEval: Funny How Code LMs Falter on Requirements Beyond Functional Correctnesscited by 23
  9. 2024M2rc-Eval: Massively Multilingual Repository-level Code Completion Evaluationcited by 21
  10. 2024RepoHyper: Search-Expand-Refine on Semantic Graphs for Repository-Level Code Completioncited by 15
  11. 2024Beyond Functional Correctness: Investigating Coding Style Inconsistencies in Large Language Modelscited by 15
  12. 2024VersiCode: Towards Version-controllable Code Generationcited by 14
8 more
  1. 2025Software Development Life Cycle Perspective: A Survey of Benchmarks for Code Large Language Models and Agentscited by 11
  2. 2024R2C2-Coder: Enhancing and Benchmarking Real-world Repository-level Code Completion Abilities of Code Large Language Modelscited by 9
  3. 2023Frustrated with Code Quality Issues? LLMs can Help!cited by 5
  4. 2025Enhancing Project-Specific Code Completion by Inferring Internal API Informationcited by 5
  5. 2025Benchmarking AI Models in Software Engineering: A Review, Search Tool, and Unified Approach for Elevating Benchmark Qualitycited by 3
  6. 2024Insights from Benchmarking Frontier Language Models on Web App Code Generationcited by 1
  7. 2023CodeScholar: Growing Idiomatic Code Examplescited by 0
  8. 2025Guided Decoding and Its Critical Role in Retrieval-Augmented Generationcited by 0