- The Vision, Debugged;
- Posts
- Can AI Fix Its Own Bugs? Meet OpenAI's CriticGPT
Can AI Fix Its Own Bugs? Meet OpenAI's CriticGPT
PLUS: Turn your ideas into a trending podcast with this killer prompt
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/3867b445-46a5-488b-8182-9acb0e48001d/Ep_25_Can_AI_Fix_Its_Own_Bugs_Meet_OpenAI_s_CriticGPT.png?t=1719929333)
Howdy fellas!
We've been on edge about AI lately, and Spark & Trouble are here to dig into the latest breakthrough: How AI is stepping up to fix its own mistakes, making our dev lives smoother. Ready to see how this game-changing tech plays out?
Here’s a sneak peek into today’s edition 👀
🕵️ Unveiling OpenAI’s CriticGPT: The AI that's revolutionizing Code Reviews
🎙️ An awesome prompt to turn your ideas into the next big podcast hit
🔮 3 AI Tools that you JUST cannot miss
Time to jump in!😄
PS: Got thoughts on our content? Share 'em through a quick survey at the end of every edition It helps us see how our product labs, insights & resources are landing, so we can make them even better.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ccc2aba0-7082-4e4a-b8e3-10274a932ed8/SectionBreak_BGRemoved-min.png?t=1710248949)
Hot off the Wires 🔥
We're eavesdropping on the smartest minds in research. 🤫 Don't miss out on what they're cooking up! In this section, we dissect some of the juiciest tech research that holds the key to what's next in tech.⚡
Remember this iconic tweet by world-renowned computer scientist Andrej Karpathy, when the earliest version of GitHub Copilot made the headlines?
Nice read on reverse engineering of GitHub Copilot 🪄. Copilot has dramatically accelerated my coding, it's hard to imagine going back to "manual coding". Still learning to use it but it already writes ~80% of my code, ~80% accuracy. I don't even really code, I prompt. & edit.
— Andrej Karpathy (@karpathy)
6:37 PM • Dec 30, 2022
This was a testament to the productivity gains software devs can achieve through AI tools like GitHub Copilot (check out our previous edition, where we dived deep into this).
While AI-powered code generation is revolutionizing how we write software, it's not without its pitfalls. Sure, it can churn out large blocks of code faster than you can say "Hello, World!", but it also serves up a hefty side of bugs that are trickier to find than a needle in a haystack.
Enter OpenAI with their latest brainchild: CriticGPT - an AI model designed to detect errors in code written by other AI models like their very own ChatGPT!
When we first saw the title of OpenAI's announcement blog, "Finding GPT-4's mistakes with GPT-4", we couldn't help but be reminded of this iconic dialogue from the Bollywood movie Dabangg 3:
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/4c883bff-887d-46a5-85ac-e43bf8913623/image.png?t=1719884450)
Salman Khan’s iconic dialogue from the movie Dabangg 3
(Translation: we'll beat you up, and we'll save you too)
It seems OpenAI has taken this philosophy to heart in the world of AI!😂
Forging the Fundamentals
Before we dive deeper into how CriticGPT is set to become the Sherlock Holmes of the coding world, let's break down some jargon:
Reinforcement Learning (RL): It’s a type of machine learning where an agent learns to make decisions by interacting with an environment, earning some sort of a reward based on the actions it takes. Idea here is to try & earn maximum rewards by optimizing the way the agent takes actions - very similar to how children learns its way to deal with stuff around them.
Reinforcement Learning from Human Feedback (RLHF): This is an RL technique where the reward signal comes from human evaluators. This technique has been garnering immense popularity of late, due to its successful use in LLMs like ChatGPT. Here’s a great read to understand the fundamentals of RLHF.
Adversarial Learning: These are techniques where we send specially engineered inputs to AI, where we know there’s a very high chance of incorrect outputs. Training AI systems with such examples helps them learn how to outsmart themselves & become really good at specific tasks. Check out this awesome lecture that discusses adversarial examples in deep learning.
Beam Search: A search algorithm to find the most likely sequence of choices by keeping a limited number of the best options at each step. It balances exploring new possibilities with focusing on the most promising paths, and is one of the key steps in decoding responses from LLMs. Here’s a fun tool to visualize how beam search works, with real examples.
So, what’s new?
Now, you might be thinking, "Wait a minute, we're using AI to catch mistakes made by... AI?" And you'd be right! It might take a while to wrap your head around this idea.
Recently, there have been efforts where LLMs were asked to evaluate their responses through "self-correction," which worked well only when given extra information. It's like asking a student to grade their own test - without the answer key, it's not very effective.
Other techniques, known as "scalable oversight," involve debates with humans or recursive reward modelling. These methods aim to enhance human judgment rather than improve the base model itself. Think of it as giving the teacher better tools to grade papers, instead of making the students smarter. However, these methods were primarily used in simpler scenarios like MCQ answering.
CriticGPT takes this idea and demonstrates how scalable oversight can help humans in a more realistic and complex setting: code review.
Code reviews are crucial for maintaining high-quality software, but reviewing AI-generated code presents unique challenges. How do you ensure thoroughness without getting bogged down in nitpicks? How do you catch subtle bugs that might slip past even human reviewers?
This is exactly where CriticGPT shines bright - researchers used a method similar to the RLHF used for ChatGPT but with some twists!
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/603d6147-77cb-4cd8-b949-c378d8f9d0c6/image.png?t=1719889774)
Example of CriticGPT finding bugs in code generated by ChatGPT (source: CriticGPT announcement)
Under the hood…
CriticGPT is built on the foundation of GPT-4 and trained using a variant of RLHF. Here, we’ll look at how it works its magic 🎩🪄
Training Data: The training data comprises pairs of questions (such as some coding tasks) & answers (the LLM’s response to the task, containing generated code). This data includes two types of examples:
Human-Inserted Bugs: Human contractors “tamper” the answers - they snuck subtle bugs into model-written code, then documented them just like a code review catch. These "adversarial" bugs were designed to be tricky for basic LLM critics, ensuring CriticGPT would be well-equipped to handle tough situations.
Human-Detected Bugs: Real-world bugs that were identified by humans from the training pipeline of ChatGPT were also included, providing CriticGPT with a taste of the unexpected errors it might encounter.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/9818152f-0431-4b29-b108-5c086024632a/image.png?t=1719888066)
Example of “tampering” of model-generated answers in the training data (source: CriticGPT paper)
CriticGPT Training Process:
Taking the question & answer as input, CriticGPT (before training) is asked to output structured critiques, highlighting portions of the code with issues, and commenting on them
Multiple critiques were sampled from this initial version of CriticGPT
Human evaluators compared and rated these critiques, giving scores based on various quality features, such as comprehensiveness, accuracy, and freedom from nitpicks, along with the ability to catch specific bugs (hello, human feedback!)
The framework used for comparison of LLM-generated critiques (source: CriticGPT paper)
These human ratings were used to train a reward model that assigns a score to each critique, reflecting its perceived quality
CriticGPT was then fine-tuned with the help of this reward model, optimizing its ability to generate awesome critiques. This was achieved using the Proximal Policy Optimization (PPO) algorithm and a clever new technique called Force Sampling Beam Search (FSBS).
Fun fact: For cases with human-introduced bugs, the evaluator checked if that specific bug was caught by the LLM critic or not (this is called “critique-bug inclusion”, or CBI)
What’s the Intrigue?
The probability of catching a bug increases with the number of claims that a critique makes. However, when an LLM is asked to point out a comprehensive & long list of bugs, it may often start hallucinating & nit-picking on unnecessary issues.
To tackle this challenge, a novel technique called Force Sampling Beam Search (FSBS) was introduced while fine-tuning CriticGPT.
FSBS makes CriticGPT generate critiques that highlight multiple erroneous snippets from a model-generated code answer using controlled sampling. These critiques are scored based on the original reward model and the number of highlights. The combined score is maximized to balance the tradeoff between being comprehensive (more highlights) and avoiding hallucinations & nitpicks (higher reward scores).
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/b0d79414-f784-4998-a727-9e7a1b236675/image.png?t=1719889152)
Using CriticGPT, the hallucinations & nitpicks are far less compared to ChatGPT across human-inserted & human-detected bugs (source: CriticGPT paper)
Why does this matter?
CriticGPT’s critiques often outperformed human critiques, catching more inserted bugs.
Putting things into perspective, if ChatGPT were pre-trained to match CriticGPT’s bug-catching ability, it would require 30x more compute
Moreover, CriticGPT also helps humans write more comprehensive critiques; those assisted by CriticGPT outperformed unassisted reviewers 60% of the time.
Now, let's talk about real-world applications. Companies in software development, cybersecurity, and financial technology can leverage this technology to ensure their code is robust and error-free. Imagine…
A fintech startup 💲 using CriticGPT to catch potential security vulnerabilities in their AI-generated code before deployment
A game development studio 🕹️ leveraging it to identify bugs in procedurally generated game levels
An e-commerce giant 🛒 integrating CriticGPT into their CI/CD pipelines, catching issues early and reducing costly downtime
The possibilities are endless!
While CriticGPT isn't perfect (it can still make mistakes), it's a significant step towards better evaluation of advanced AI systems. So, the next time you're knee-deep in a code review, remember – you might soon have an AI assistant helping you catch those elusive bugs.🔍
Key Takeaways
(Screenshot this!)
Adversarial Training: Creating challenging datasets with specifically engineered samples can significantly improve model performance in tricky scenarios
Balanced Optimization: Techniques like FSBS show the importance of balancing multiple objectives (e.g., comprehensiveness vs. precision)
Human-AI Collaboration: The best results often come from humans and AI working together, not competing
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ccc2aba0-7082-4e4a-b8e3-10274a932ed8/SectionBreak_BGRemoved-min.png?t=1710248949)
10x Your Workflow with AI 📈
Work smarter, not harder! In this section, you’ll find prompt templates 📜 & bleeding-edge AI tools ⚙️ to free up your time.
Fresh Prompt Alert!🚨
Ever dreamed of having a YouTube podcast that everyone's buzzing about? 🌟 Well, today's your lucky day! This week’s Fresh Prompt Alert is your ticket to becoming a podcasting sensation.
Picture this: you're diving deep into hot industry trends like AI, blockchain, and telehealth, chatting with experts who know their stuff. Ready to turn those ideas into a script that'll have your followers hooked?
Let's make it happen! 👇
Act as a renonwned influencer who has a massive following on their YouTube podcast channel.
Generate a script for a podcast episode discussing industry trends. Focus on topics like [mention some trending topics in your industry] and invite experts from [mention fields e.g. technology, finance, healthcare] to share their insights.
3 AI Tools You JUST Can't Miss 🤩
👩💻 Upsend - AI-powered mock coding interviews with personalized feedback
🛣️ GuideJar - Create interactive, easy-to-follow, AI-powered guides and demos
📢 FounderPal - AI marketing platform for Solopreneurs
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ccc2aba0-7082-4e4a-b8e3-10274a932ed8/SectionBreak_BGRemoved-min.png?t=1710248949)
Spark 'n' Trouble Shenanigans 😜
How long do you think it'll be before this becomes reality?? 😋
Codes without ChatGPT 😂🤔
— Ryan Els (@RyanEls4)
7:51 AM • Jun 13, 2024
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ccc2aba0-7082-4e4a-b8e3-10274a932ed8/SectionBreak_BGRemoved-min.png?t=1710248949)
Well, that’s a wrap! Until then, | ![]() |
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ccc2aba0-7082-4e4a-b8e3-10274a932ed8/SectionBreak_BGRemoved-min.png?t=1710248949)
Reply