AI coder competence is still a huge wildcard

Julian Harris
TheAIEngineer
Published in
4 min readDec 19, 2023

The role of software engineers is changing significantly. We now have a bunch of interns / copilots / tutors to help accelerate our work.

HOWEVER: how much an AI coder will help hugely depends on many factors. Sometimes it magically hits the bulls-eye. But what do you do when it doesn’t?

For example: a glyph-based word cloud

Today (while on the bus) I had a few minutes so I was curious whether I could get an AI coder to create one of those cool word clouds where text wraps beautifully around all the characters (or glyphs).

This was my goal. I didn’t meet it yet — this was done by wordart.com

Session 1

Here was my prompt (view full conversation)

Word cloud component: Create an HTML component that
Accepts a list of words and number of occurrences, and
Creates an svg word cloud taking up the full space of its parent container, where the words are tightly clustered together.
Each word’s size dictated by the frequency.
To cluster the words together please take into account all the white space around and in the letters. So if there’s space words might fit inside individual glyphs of much bigger words.

It immediately provided a solution just using bounding rectangles like Jason Davies’ one, which is wrong, as it only uses bounding rectangles. It knew it was wrong, because the response included this:

“Note that this is a basic implementation and may need significant enhancements to meet all your requirements, especially the advanced white space handling within glyphs”

What then followed was an AI that really, really didn’t want to do it, because it was basically too hard.

Me: Please revise to use advanced clustering and custom algorithm development if necessary.

It still refused saying:

“creating an optimal word cloud fitting words into the white spaces of other words is a complex problem and might require significant additional development or the use of specialized text layout libraries”

So I changed tack. In the past I’ve encountered a “shoulders of giants” problem where an AI code won’t necessarily start off with the right building blocks. So I started another session, this time trying to do this.

Session 2: finding the right starting point

View full conversation

Me: Sota word cloud functions cluster words that take into account glyph shape. Eg it will fit words inside letters if there is space, or inside concave parts of a glyph. These approaches are much more advanced than simple bounding box checks. Help me understand which JavaScript libraries would be best to use to achieve this effect.

It listed d3-cloud and wordcloud2.js. Ok!

ChatGPT: “Both of these libraries provide a range of customization options and are well-suited for projects that require more advanced word cloud layouts, including those that consider the shape of glyphs.”

Ok! Looking good!

Me: What’s the simplest first step to creating a demo using d3-cloud demonstrating a word cloud taking into account glyph shape?

Things were progressing but the caveat at the end was… disappointing given the promises made earlier:

ChatGPT: Remember, d3-cloud doesn’t natively account for the actual shape of the glyphs; it places words based on bounding boxes

🤦‍♂️

Ok. Back to finding new shoulders to stand on. New starting points. Can I bring them together?

Me: Is there a utility library in JavaScript that can retrieve glyph shape data?

Yes! It went on to say sure there is Fontkit and opentype.js.

ChatGPT: Either of these libraries could be integrated with a word cloud generation library like d3-cloud to achieve a layout that considers glyph shapes

Ok, very promising. I know have two shoulders to stand on: d3-cloud, and fontkit.

How did that go?

After some task breakdowns and code stubs, we arrived at this:

Integrating this with d3-cloud for glyph-aware word cloud layout is an advanced task and might require additional tools or libraries for handling SVG paths and collision detection.

It’s become clear that modifying d3-cloud to support glyphs is not something ChatGPT can do without a lot of guidance and prompting: the knowledge gap is too broad in this specific case and you get stuck in the mud trying to decompose the problem into pieces it can understand. Accepting also that it still does make stuff up so it might just not work at all. This can take quite some time.

Human engineers will be the glue to bring AI coding pieces together for quite some time.

This is the approach I’m seeing to be quite effective:

  1. Ask for a solution

2. If it can’t deal with it, it’s likely the scope is too broad, so decompose it into smaller pieces, ask again, then bring the pieces together.

Questions human software engineers need to answer:

  • Is the solution using the right starting points?
  • If the scope is too broad how do you decompose it into pieces the AI coders can handle?
  • How do you bring the pieces together?

PS this is what good tech leads do with existing teams 😉

--

--

Julian Harris
TheAIEngineer

Ex-Google Technical Product guy specialising in generative AI (NLP, chatbots, audio, etc). Passionate about the climate crisis.