Programmers can use large language models (LLMs) to generate computer code faster, but this is only beneficial if the code conforms to programming language rules and runs without errors. Existing methods to ensure LLM-generated code follows language rules often distort the model’s intended meaning or are too slow for complex tasks. Researchers at MIT and other institutions have developed a new approach that automatically guides an LLM to produce error-free, rule-compliant text—such as code in a specific programming language. Their method probabilistically allocates more effort to outputs most likely to be valid and accurate, discarding less promising ones early, thereby improving computational efficiency. Thanks to these efficiency gains, the researchers’ architecture allowed smaller LLMs to outperform much larger models in generating accurate, well-structured outputs across real-world applications like molecular biology and robotics. In the future, this approach could empower nonexperts to control AI-generated content; for example, businesspeople could write complex SQL database queries simply by using natural language prompts. João Loula, an MIT graduate student and co-lead author, notes, “This work has implications beyond research. It could improve programming assistants, AI-driven data analysis, and scientific discovery tools by ensuring AI outputs remain useful and correct. ” The international team also includes co-lead authors Benjamin LeBrun (Mila), Li Du (Johns Hopkins), and co-senior authors Vikash Mansinghka (MIT), Alexander K. Lew (Yale), Tim Vieira (ETH Zurich), and Timothy J. O’Donnell (McGill/Mila), among others. Their research will be presented at the International Conference on Learning Representations. **Enforcing Structure and Meaning** A common method to control structured text generation involves checking the entire output (e. g. , code) for validity; if it fails, the user must restart, increasing computational costs.
Alternatively, one can verify the output incrementally, but fixing it step-by-step risks drifting away from the original intent, harming accuracy. “It is easier to enforce structure than meaning, ” Loula explains. “We can quickly check if output follows a programming language, but verifying meaning requires executing the code. Our work addresses handling both types of information. ” The researchers embed expert knowledge into the LLM to steer it toward outputs that likely satisfy structural constraints and reflect intended meaning. “We aren’t training the LLM anew but engineering expert knowledge combined with the LLM’s existing knowledge, ” says Mansinghka, contrasting their method with traditional deep learning scaling approaches. They use sequential Monte Carlo techniques, allowing multiple parallel generations by the LLM to compete. Outputs receive weights quantifying likelihood of structural and semantic correctness; the model focuses on higher-weighted outputs, discarding others incrementally. Essentially, the LLM works with an expert overseeing its choices to maintain alignment with user-specified structure and meaning, guided by user-defined verification procedures. “We’ve developed the mathematics so that for any constraints, you get proper weighting, ensuring the final outputs are correct, ” Loula adds. **Boosting Small Models** Testing the framework on tasks including Python coding, SQL query generation, molecular structure design, and robot planning, the method proved more accurate and computationally efficient than existing techniques. For example, a small open-source Python model outperformed a commercial model more than twice its size. “We’re excited to help small models punch above their weight, ” Loula remarks. Looking ahead, the researchers aim to control larger segments of generated text instead of small pieces and integrate learning so models improve accuracy through this guided output control. Their approach has potential to assist non-technical users, combining with automated data modeling and querying generative database models. Mansinghka envisions machine-assisted data analysis where users dialogue with software that precisely models data meaning and user queries. O’Donnell adds, “Mapping words to distributions over grounded meanings in narrow symbolic domains is a small but important step toward addressing deeper linguistic and cognitive science challenges about how machines communicate about the world. ” This research is supported in part by the Canada CIFAR AI Chairs Program, MIT Quest for Intelligence, and Convergent Research.
MIT Researchers Develop Efficient Method for Error-Free Code Generation Using Large Language Models
The landscape of video content creation is experiencing a profound transformation with the rise of AI-powered editing tools.
AI Company has strategically acquired a promising robotics startup specializing in industrial automation, aiming to enhance its technological capabilities and expand market reach.
At the Lithium Battery Recycling Forum during the 10th CLNB New Energy Industry Chain Expo 2025, hosted by SMM Information & Technology Co., Ltd.
Apple’s iPhone sales surged to a new quarterly high during the holiday season, despite setbacks in artificial intelligence that led the tech pioneer to seek assistance from Google.
Google has just provided marketers with their 2026 playbook.
Artificial intelligence (AI) is profoundly transforming digital marketing, especially by reshaping how search engine optimization (SEO) is approached and executed.
As we enter 2026, artificial intelligence (AI) is profoundly transforming search engine optimization (SEO), revolutionizing how marketers create, distribute, and evaluate content.
Launch your AI-powered team to automate Marketing, Sales & Growth
and get clients on autopilot — from social media and search engines. No ads needed
Begin getting your first leads today