Thursday, October 10, 2024

Playing with Large Language Models (LLMs)

Yesterday I participated in a hands-on lab to integrate large-language-model (LLM) technology to help generate complex SQL queries to look into our data. The lab only lasted an hour and I learned a lot during that time. It also highlighted one of the use cases for LLMs for more than just a toy to help write high-school papers.

When ChatGPT released, it garnered a lot of attention. While everyone seemed impressed, I didn't see a lot of people asking how the technology can be used for good. Automatic code generations seem to be one of those good uses that can really help us in our daily lives. Rather than spending countless hours writing thousands of lines of code to do something important, you can specify what you want and have created and the LLM will generate the code for you. That is what yesterday's lab explored.

For those that don't know SQL, it is a very simple and almost English-like language used to query databases. If you have a table that contains information about customers you can use something like this to query the database:

SELECT firsname, lastname, first_purchase_date FROM customers;

This will list out all customers' names and date when they made their first purchases. It is pretty simple, right? Well it gets complicated once you try to filter that data or include info from other tables in the database. While most of my queries are 25 lines or less, it is not uncommon for me to write 500-line ones. This is where an LLM can really help streamline my work.

In order to keep the lab under an hour, all the data and most of the code was created so I just needed to put it in the right place. I loaded the data into an online database server and downloaded the code to my laptop. The only modification I needed to do to the code was update the connection string to point to my online database. Then we ran through the code see how it worked.

The code included a file to describe the 3 tables in the lab and that turned out to be the secret sauce. I closely looked through the description file and realized that it would take about an hour per table to duplicate this file for the database I work with on a daily basis. When there are only 3 tables, this isn't a large effort. Unfortunately my database has thousands of tables and it would be a huge undertaking to use this technology in my environment.

I had hoped that the LLM would be able to look at my database tables and infer what information they contained. This is possible but unfortunately is not nearly as accurate as having a data expert provide this detail first.

I'm glad I attended the lab and I learned a lot. It also demystified what is going on with this particular LLM. While I hoped I could use the output of the lab to make it easier for non-data scientists to query the database, I did come away with a strong understanding of the underlying technology.

No comments:

Post a Comment