My writer friends say Large Language Models (LLMs) like ChatGPT and Bard are overhyped and useless. Software developer friends say they’re a valuable tool, so much so that some pay out-of-pocket for ChatGPT Plus. They’re both correct: the writing they spew is pointless at best, pernicious at worst. … and coding with them has become an exciting part of my job as a data analyst.
Here I share a few concrete examples where they’ve shined for me at work and ruminate on why they’re good at coding but of limited use in writing. Compared to the general public, computer programmers are much more convinced of the potential of so-called Generative AI models. Perhaps these examples will help explain that difference.
Example 1: Finding a typo in my code
I was getting a generic error message from running this command, something whose Google results were not helpful. My prompt to Bard:
What’s the matter with this Python dict definition?
details = {
‘electrification_lvl’: decoded_vin.get(‘ElectrificationLevel’, None),
‘engine_kw’ = decoded_vin.get(‘EngineKW’, None),
‘fuel_type_primary’ = decoded_vin.get(‘FuelTypePrimary’, None),
‘fuel_type_secondary’ = decoded_vin.get(‘FuelTypeSecondary’, None),
‘battery_kwh’ = decoded_vin.get(‘BatteryKWh’, None)}
Bard told me I had a “significant issue”:
“You used an assignment operator (=) instead of a colon (:) to define the key-value pairs. This will cause a syntax error because assignment statements are not allowed within dictionary definitions.”
Yep! So trivial, but I wasn’t seeing it. It also suggested a styling change and, conveniently, gave me back the fixed code so that I could copy-paste it instead of correcting my typos. Here the LLM was able to work with my unique situation when StackOverflow and web searches were not helping. I like that the LLM can audit my code.
Example 2: Writing a SQL query
Today I started writing a query to check an assumption about my data. I could see that in translating my thoughts directly to code, I was getting long-winded, already on my third CTE (common table expression). There had to be a simpler way. I described my problem to Bard and it delivered.
My prompt:
I have a table in SQL Server called EV_VINs_Presence. It contains columns “vin”, “snapshot_date”, and “locale”. Every record that has a locale value of “Ann Arbor” should have a corresponding record with the same “vin” and “snapshot_date” but with the locale value of “State”.
Write a SQL Server query to return any records that do not have such a corresponding record.
Bard replied: