News

ChatGPT 10-01-2023

Hello fellow programmers and tech enthusiasts! Have you ever wished that you had a magical tool that could understand your programming language and help you write code faster and more efficiently? Well, allow me to introduce you to GPT-3, the latest and greatest chatbot in the world of programming. With its advanced artificial intelligence, GPT-3 can understand and respond to your programming queries, making it an indispensable asset for any programmer. In this essay, we will explore the usefulness of GPT-3 in the field of programming and how it can help us code like never before. So, grab a cup of your favourite programming fuel (coffee, energy drinks, or whatever keeps you going) and let's dive in!

The first thing we are going to cover is GPT-3’s excellent natural language processing. ChatGPT is fantastically competent at producing text that is hard to distinguish from human writing, and if you don’t believe me take a look at the introduction of this article as this was written entirely by GPT-3 and generated from the prompt “can you write a slightly humorously worded introduction for an essay on GPT3 chat and its usefulness in programming?”. However, our discussion of GPT-3 will be focused on its ability to write code, although, we are still going to discuss natural language processing as it plays a more crucial role in GPT's ability to write code than you might think.

There are two ways in which natural language processing is extremely important to enable GPT-3’s coding abilities. The first is its ability to understand the function of the code that it writes and then describe the function of the code through comments. The comments that GPT produces are consistently succinct and informative. This is demonstrated in the third example "Code Commenting".

The other way in which natural language processing is very important is in enabling GPT-3 to understand specifically what we are asking it to do. When we give it a prompt to write some code ChatGPT is very good at understanding what we want the code to do and in what form we want it. In the following examples of GPT's Work, the first example “Sine wave” shows a very good example of GPT's ability to understand a prompt and produce a product in the correct form.

Interesting examples

Sine Wave

This example is an interactive sine wave with a user-adjustable wavelength. The code used to display it was generated by ChatGPT with 2 consecutive prompts. The first prompt: “can you write some code to produce an animated sine wave that can be embedded into a web page?”. This generated a fixed sine wave on the page and the next prompt: “can you make it so that the user can change the wavelength with a slider?” added the code required to allow the viewer to alter the wavelength.

This demonstrates that ChatGPT understands what we want, a sine wave that is adjustable and also understands how we want it formatted, which in this example is embedded into an HTML web page.

Wavelength:

ChatGPT has been trained on vast quantities of information from all over the internet. Thus, the AI can draw on niche programs or libraries for resources to solve a problem. An example of this was when one of our employees needed to render a cube whose rotation could be set using Euler angles from an IMU. ChatGPT was able to produce a working piece of code to display this in a web browser window using a Python library he had never heard of called “vpython”. This condensed a task that might have taken a few days to research an appropriate solution to and made it take only a few hours to understand and implement.

Cube

Code Commenting

The code below is a basic program to fit a line to some randomly generated points that conform to a first-order polynomial with some added noise. In this example, we will feed it into ChatGPT and ask it to comment the code on each line and describe what the code doing.

The comments that ChatGPT has produced, in our opinion, give good succinct descriptions of what each line is doing.

Chat GPT has also demonstrated its ability to produce comments of this quality for far longer and more complex programs.

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-10, 10, num=50)
y = 2 * x + 1 + np.random.normal(size=50)

coeffs = np.polyfit(x, y, deg=1)

plt.scatter(x, y)
lt.plot(x, np.polyval(coeffs, x), 'r-')

plt.show()

Write a haiku on xor

Binary values switch
XOR gate, the ultimate switch
On or off, never both.

Write a haiku on stm32

STM32 microchip
Powerful processing within
Small, but mighty force.

Haikus

Finally, for our last example, what's the point of new technology if you can't have a little fun with it. Jeff our manager got ChatGPT to write out a few topical Haikus, a couple of examples of which are shown on the right.

The general consensus from our team? "Not bad".

ChatGPT's Imperfections

ChatGPT is an immensely powerful and versatile tool. However, it does have some notable issues. First and foremost, ChatGPT will sometimes generate false information and mislead.

An example of this is, should the Ai generate a piece of code which has an issue or produces an unexpected result, the AI will often be able to fix the issue if you point it out. However, it will sometimes say that it has fixed the issue, but in actuality changed nothing or something unrelated to the problem. Another example of this is if you ask it to write about something factual, it may include some correct information but also some falsehoods.

Although these misbehaviours are worrying in a tool, they are very much in the crosshairs of the team at OpenAI, GPT's developers, as they seek to add protections to the AI to prevent it from lying or exhibiting other undesirable behaviours.

To close out this section why don't we ask the AI what it thinks its shortcomings are? As they say, introspection is the cornerstone of growth.

As an AI, I do not have the ability to experience or possess emotions, so I may lack empathy and understanding of human emotions. I also may not always have access to the most up-to-date information, and my responses may be limited by the programming and data I have been given. Additionally, I may not always be able to understand or interpret human language or context as well as a human can.

Conclusions and looking to the future of AI

As time goes on AI is proving itself to be more and more capable and competent and at the moment this trend shows no sign of slowing down. Even the tool discussed in this article ChatGPT will soon become outdated as the GPT-3 model, the model currently used to run ChatGPT, will soon be replaced by its successor GPT-4 which is sure to bring improvements and uplifts in capability across the board. This constant improvement will likely see AI working its way into more and more applications where they shall be able to provide more useful aid.

AI does have its issues, as discussed in the previous section. However, despite these issues, ChatGPT and other similar programs seem poised to be a potent tool in the arsenal of programmers and other tech professionals. Its wider use and refinement may allow us to focus on solving problems in our work while spending less time on small routine tasks as well as providing novel ideas on how to solve issues that we come across.