We keep hearing how AI and Large Language Models will take all of our jobs. Back in 1980, when I first knew I wanted to be a computer programmer, I was told that the computers would program themselves soon, and I would be out of a job. It hasn’t happened yet, but the latest technology is certainly changing our job more than any time in the past. It is a very interesting time (in both a good and bad way) to be working in software. So what exactly does writing Delphi code with a Large Language Model assistant look like?
I’m only going to provide some basics, since this his changing so fast. I’ll also provide some very interesting historical background.
If you are completely new to LLM and GPT, know I may use those terms interchangeably, but technically a Generative Pre-trained Transformer (GPT) is a type of Large Language Model (LLM). These fall under the category of Generative Artificial Intelligence built out of Artificial Neural Networks that are trained on Natural Language Processing tasks. [Follow those Wikipedia links for more recently updated information.]
The idea of an artificial neural network has been around a long time, but it was only recently, thanks to the massive parallel nature of modern GPUs that they have become practical. Essentially they are a mathematical model based on the neural network in a biological brain that is trained on massive amounts of input data. This results in the internal structure of the neural network being a “black box” where the behavior is a result of the training, and not directly specified through normal code. While they are trained on massive amounts of data, they do not store the data they were trained on. Instead they retain the patterns of the data, allowing them to generate new text that matches the same pattern.
3Blue1Brown just published a fantastic video on GPTs specifically. If you aren’t familiar with 3Blue1Brown, it is an amazing math education YouTube channel by Grant Sanderson. He is one of the better educators I’ve encountered on these topics, and has over 170 videos, spanning multiple playlists. The GPT video is part of a course on Neural Networks.
Someone I hear very few people talking about when it comes to Large Language Models is Claude Shannon. I’m not sure where I first learned about Mr. Shannon, but I assumed he was one of those people like Charles Babbage, Ada Lovelace, Blaise Pascal, Margaret Hamilton, George Boole, Hedy Lamarr, Alan Turing, & Grace Hopper that everyone knew about (I included links for a reason, go read about them). But surprisingly he seems to be less know. In 1950 he built Theseus, the first example of artificial intelligence, a device that learned by trial and error. He was also the father of Information Theory, laid the ground work for Boolean algebra to be used in the digital computing, and so much more. He is described as the 20th century engineer who contributed the most to 21st century technologies. His achievements are said to be on par with those of Albert Einstein and Sir Isaac Newton in their fields.
There is a fantastic documentary on Claude Shannon called Bit Player that I highly recommend. (I found a version of it with Brazilian Portuguese subtitles too.) Here is an older documentary, but I prefer Bit Player. I also just discovered a biography about him, A Mind at Play: How Claude Shannon Invented the Information Age, by Jimmy Soni, Rob Goodman, but I haven’t read it yet. I did listen to a great podcast with the authors.
Beyond all of that, the thing I find the most interesting and relevant to Large Language Models is his research into “word pairs.” The idea being that if you look at which word typically follows another word, you can simulate “intelligent” writing. Since he came up with this before the invention of digital computers, he would test his theory with a novel by looking for the next occurrence of a word, copying the word after it, and repeating the process until you end up with a crude sentence.
This is a very simplified version of what a Large Language Model does. So I thought it would be interesting to use a modern large language model to build a primitive small language model. If you take a look at the saved analysis data, you will see that it just contains a list of words and numbers, but doesn’t contain the original analyzed text.
As much as possible I used ChatGPT 4 to write the code. There were a few small edits I made on my own, and I built the sample app myself, but ChatGPT did most of the library code and all the unit tests. I’ve shared the history of my conversation with ChatGPT so you can see the process. It did really well this time.
I didn’t time it, but I believe this was faster than if I wrote all the code myself. Where a Large Language Model really shines is when you are working on something you are less familiar with, saving you from needing to consult the documentation all the time. This could be an algorithm you are unfamiliar with, an API you are new to, etc.
If you try using ChatGPT or a similar large language model to write code, here are a few things to watch out for:
There are free options to use Bing CoPilot, ChatGPT 3.5, Google Gemini, and others. If you haven’t already tried working with them, you really need to set aside some time to familiarize yourself. If you tried a while ago, try it again. Things are changing very fast right now, and while the AI may not directly take your job, if your co-workers learn to use these LLMs to be more productive, they may make you redundant.
Is all of this too much for you? Well you are in luck! GDK Software is completely focused on the rapidly evolving world of Delphi software development. Everything from updating your old Delphi 7 project, to implementing the latest machine learning features and functionality, we have you covered.
Contact
GDK Software UK
(+44) 20 3355 4470GDK Software USA
+1 (575) 733-5744