- Nile unwraps NaaS security features for enterprise customers
- Even Nvidia's CEO is obsessed with Google's NotebookLM AI tool
- Get these premium Sony Bravia home theater speakers for $500 off during Black Friday
- The best Black Friday soundbar and speaker deals: Save on Bose, Sonos, Beats, and more
- One of the best pool-cleaning robots I've tested is $450 off for Prime Day
How I used ChatGPT to scan 170k lines of code in seconds and save me hours of detective work
This is an article about using artificial intelligence (AI) as a tool and how to apply it to your unique, specialized needs. It provides some interesting lessons for everyone.
Also: I’ve tested dozens of AI chatbots since ChatGPT’s stunning debut. Here’s my top pick
You’ll learn you can use a tool like ChatGPT to solve complex problems quickly, so long as you have the right prompts and a hint of skepticism.
First, a brief 3d printing rabbit hole
Our context for this lesson is 3D printing. A special test in 3D printing called a 3DBenchy checks printer performance. It helps 3D printer users test speed and various print-quality measures. The Benchy takes most printers an hour or two to print out.
I recently tested a new printer that’s supposed to be faster than many others. On this printer, the Benchy took 42 minutes, while on other 3D printers in the Fab Lab, it took 60 to 70 minutes. But here’s the thing: the test version provided by the company that makes the printer took 16 minutes. That’s a heck of a difference.
3D printers are controlled with G-code, a program custom-generated by a tool called a slicer that controls how the printer moves its print head and print platform, heats up, and feeds and retracts molten filament.
Also: ChatGPT vs. Microsoft Copilot vs. Gemini: Which is the best AI chatbot?
The pre-sliced G-code provided by the factory for the printer I was testing resulted in a 16-minute print. The G-code I generated using the company’s slicer resulted in a 42-minute print. I wanted to know why.
Unfortunately, no one on the company’s support team could answer my question. Despite numerous tries, I couldn’t get an answer about what slicer settings to change to get the G-code I produced using their slicer to perform as well as the G-code generated using their slicer.
After many web searches and reading posts from frustrated Reddit posts, it was clear that other customers had the same problem. Here’s a machine capable of more than double the performance, yet none of us could reproduce that performance successfully.
Can AI help?
This is where ChatGPT comes into the picture. G-code consists of thousands of lines that look like this:
G1 X122.473 Y140.422 E4.23368 G1 X122.222 Y140.6 E4.24443 G0 F14400 X122.703 Y140.773 G1 F3600 X122.117 Y141.251 E4.27083 G1 X121.767 Y141.66 E4.28963 G1 X121.415 Y142.139 E4.31039 G1 X121.105 Y142.641 E4.33099
Together, both Benchy G-code files had 170,000+ lines of code. I didn’t intend to spend a Saturday afternoon sifting through that stuff manually. But I thought, perhaps, AI could help.
Also: How to use ChatGPT to digitize your handwritten notes for free
I had the G-code I generated using the slicer. I could also export and save the G-code provided by the factory. Using ChatGPT Plus, I fed both files into the AI.
I started by confirming ChatGPT could read the files. After I uploaded each file, I asked:
Can you read this?
ChatGPT confirmed, stating, “I can read the contents of the file. It appears to be a G-code file, typically used to control 3D printers.” That was a good start.
To ensure we were clear on which file was which, I gave ChatGPT some labels for the files:
Let’s call the first file uploaded “regular print” and the second file uploaded “fast print”. Okay?
The AI agreed, so then I told it:
Describe how the files differ.
Other than naming one of the files “fast print”, I gave ChatGPT no indication of what I was looking for. Even so, the bot identified that one print had higher print speeds, although the temperature settings were the same.
I then asked the AI:
Why is “fast print” so much faster?
It was at this point that ChatGPT started to annoy me. Instead of giving me details from the code I provided, it speculated. The AI used phrases containing “likely”, “may”, and “might” to describe why the print was faster.
Also: If these chatbots could talk: The most popular ways people are using AI tools
But I had given it G-code files that described exactly what the printer was doing, so I wanted an exact answer about what the printer was doing. As is often the case with ChatGPT, the conversation was a lot like talking to a brilliant grad student who is somewhat stubborn and uncooperative.
Why the right prompt makes all the difference
I finally landed on this prompt, which teased out workable answers:
The G-code provided in both files is the only thing that is different for these prints. Using solely the G-code provided as comparisons, what slicer settings would be different? Don’t speculate on what other settings might be. Base your analysis only on the code provided.
ChatGPT identified three key factors:
- The regular print G-code shows feed rates typically between 2400 mm/min and 3400 mm/min. The fast print G-code shows much higher feed rates, with some commands reaching up to 14400 mm/min. This rate is a significant increase in speed, directly contributing to the reduced print time.
- Compared to a layer height of 0.2 mm for the regular print, the fast print set layer height to 0.25 mm, reducing the number of layers needed to complete the print.
- The fast print G-code includes much more aggressive acceleration settings, allowing the printer to reach higher speeds quicker and maintain them, contributing to faster printing.
That result was interesting. However, I wanted to know whether the company hand-optimized the G-code or generated it directly in the slicer. So, I asked ChatGPT:
Can you tell if fast print has been hand-coded or was generated by a slicer? Perhaps look for inconsistent commands or non-standard comments.
The AI responded with three interesting considerations:
- The variations in G-code commands like changes in feed rates, switching between different movement commands, and alterations in other parameters are typical of slicer-generated code. These changes are designed to optimize the print process and are consistent with the behavior of a slicer.
- If the G-code were hand-coded, we would expect to see more irregular and unpredictable patterns, but these transitions follow a logical sequence, characteristic of a slicer’s optimization process.
- Therefore, the presence of these commands does not indicate hand-coding; rather, it supports the conclusion that this G-code was generated by a slicer.
What these results tell me is that it is probably possible for users to modify their slicer settings to get similar performance.
What have we learned?
We’ve learned that ChatGPT understands G-code. That’s unsurprising because, in my earliest tests, we learned that ChatGPT has a fairly good command of even the most obscure programming languages.
We also learned that ChatGPT can sift through and compare 170,000+ lines of machine instructions and reach actionable conclusions in seconds.
Also: How I test an AI chatbot’s coding ability – and you can, too
Finally, we learned we can use AIs like ChatGPT to explore complex problems from several angles. Not only did ChatGPT explain the vast speed difference between the two files, but it was also able to validate whether or not the factory-provided file had been hand-tweaked.
In conclusion, don’t accept what the AI tells you as absolute truth. Don’t make critical decisions based on its answers. And remember that you sometimes have to negotiate with the AI before it’s willing to give you helpful answers.
This test is yet another case where I’ve been able to turn to the AI and find an answer for a very me-specific question without coding in minutes.
If you have a question that requires a lot of text or numerical analysis, consider running it by ChatGPT or one of the other AIs. You might get a useful answer in minutes.
Also: Midjourney’s AI-image generator website is now officially open to everyone – for free
Writing this article about the problem took me a few hours. The actual analysis process, from start to finish, took me less than 10 minutes. That’s some serious productivity, right there.
You can follow my day-to-day project updates on social media. Be sure to subscribe to my weekly update newsletter, and follow me on Twitter/X at @DavidGewirtz, on Facebook at Facebook.com/DavidGewirtz, on Instagram at Instagram.com/DavidGewirtz, and on YouTube at YouTube.com/DavidGewirtzTV.