Exploring the magic and limitations of ChatGPT in generating Python code for acoustic design - Day 4
- INAcoustical

- May 21, 2023
- 4 min read
Day 4: Optimise angle of a reflector to maximise reflected energy to the audience
After setting the degree of each rotation and the number of rotations of the reflector, simply click on the Trigger component. It will calculate the projected energy at each angle and ultimately return the angle that reflects the most energy to the audience.
Since my Day 3 blog was published on LinkedIn on 25th April, it has garnered over 14,000 impressions and 169 reactions. As someone who is typically not very active on social media, I find the level of interest from the LinkedIn community quite surprising. It indicates that many professionals are keen on harnessing the newfound power that is now accessible to us, just as I am.
I would like to express my gratitude for the comments received. Regardless of their nature, they have provided me with valuable food for thought. Here are some reflections on the comments I have received.
Comment one: "I'm unable to get ChatGPT to add 1 dB + 1 dB successfully......I can’t imagine trying to debug an entire set of code."
This perspective stems from the human viewpoint. AI and humans approach problems differently. What may be simple for humans could be challenging for AI, and vice versa. I believe ChatGPT may have struggled with adding dB correctly due to a lack of training in this specific area. However, this does not imply that it cannot debug the programs it has received sufficient training in.
We can train ChatGPT through dialogues, but the knowledge it acquires in this manner is not retained permanently. When a new dialogue is initiated, all previous training is lost. This is because the chat windows in ChatGPT only provide short-term memory. For the GPT 3.5 engine, the short-term memory capacity is 4k tokens (equivalent to approximately 3k English words), whereas the GPT 4 engine has a larger capacity of 8k tokens. Even within the same chat, ChatGPT will forget any training received before the 3k words in GPT 3.5 and 6k words in GPT 4. To train ChatGPT permanently, techniques such as embeddings and machine learning are required.
Comment two: "ChatGPT confused sound pressure level with sound power level."
This error may be attributed to ChatGPT's lack of training in acoustics. It could also be a result of the default temperature setting in ChatGPT.
The ChatGPT temperature parameter, which ranges from 0 to 1, controls the degree of answer correctness. Higher values of this parameter lead to more random and surprising answers, while lower values generate the most probable outputs. The default value for ChatGPT is around 0.7. When a definitive answer is desired, setting the temperature to 0 is preferred. Additionally, lower temperature settings result in faster response times from ChatGPT. However, one cannot directly adjust the temperature of ChatGPT via the chat box, a ChatGPT API is required for the adjustment.
Comment three: "I have found if you just give it an open-ended question, it can struggle…"
I agree with this comment, emphasizing the importance of prompts. However, the errors in the Grasshopper Python codes created by ChatGPT for my use are largely unrelated to the prompts. The codes generated by ChatGPT often include detailed descriptions, making it easy to determine whether it understands the requirements or not. In general, I have found that ChatGPT exhibits a surprisingly good ability to comprehend prompts. The main challenge lies in its limited understanding of function syntax. ChatGPT's coding knowledge primarily comes from GitHut, and it seems there may be a lack of high-quality Grasshopper Python codes available there. Nonetheless, ChatGPT demonstrates excellent logical reasoning skills. For this reason, it is only a matter of time before it can generate high-quality code from prompts using natural language.
In their bestselling book "The Second Machine Age," published in 2014, authors Erik Brynjolfsson and Andrew McAfee predicted the exponential advancement of the Second Machine Age, powered by digital technologies like AI (the First Machine Age was powered by physical machine). The significance of exponential growth cannot be overstated. You may have heard the old story of the chessboard inventor who asked the king to place a single grain of rice on the first square, then double the amount on each subsequent square. By the time the chessboard was halfway filled, the required amount of grain surpassed the entire kingdom's possession! It has been nine years since the publication of the book, and we may be approaching the halfway mark on the chessboard! Contemplating this exponential trajectory fills me with awe, excitement, and a sense of uneasiness...
The Grasshopper Python component featured in the video at the beginning of this article can optimise the reflector angle to maximise energy directed toward a chosen audience plane. While I primarily wrote the code, ChatGPT played an instrumental but important role. Without its assistance, I am uncertain if I could have completed the task, as I taught myself Grasshopper and Python without any external support.



Comments