Entropic Thoughts

My Most Complicated Prompt So Far

My Most Complicated Prompt So Far

Let’s say we want to visualise a few grouped measurements in an article, and we need to use Unicode box drawing characters for it. We might draw it like so, for three groups:

   ┌──────────┐
   │o o      o│
   └──────────┘
┌─────┐
│o   o│
└─────┘
        ┌─┐
        │o│
        └─┘

After finishing the article, we proof-read it a week later and realise this is the wrong type of visualisation. What we really want is a stacked bar chart. The three groups above should instead look like

──────────────┬──────┬────┐
              │      │    │
──────────────┴──────┴────┘
──────┬─┐
      │ │
──────┴─┘
──────────┐
          │
──────────┘

We could transform all examples manually, but that would be annoying. It would also be relatively simple to write a Perl script for it, but we’d have to pay attention to edge cases, which is still a little mentally taxing.


We can try getting an llm to do it for us. I managed to get Claude 3.5 Sonnet to do it, after a few attempts. The result is not perfect, but good enough for my purpose. I wasn’t sure it was going to be able to do it at all.

Here’s the prompt, which is by far the most complicated prompting I have done to date – but that doesn’t say much, since I discovered how these models are useful just a couple of months ago:

I have some grouped measurements indicated by o, where their
numerical value correspond to the distance in from the left
margin. They are surrounded by a box, which for the purpose
of this task is meaningless.

I want to convert them into a cumulative (stacked) bar chart,
with the largest measurement at the bottom. Here's an example
of grouped measurements, and what I expect the output to look
like.

<example_input>
     ┌───────┐
     │o    oo│
     └───────┘
</example_input>

<example_output>
Measurements: 6, 11, 12
Sorted from largest to smallest: 12, 11, 6
Cumulative: 12, 23, 29
Corresponding visual representation:

────────────┬──────────┬─────┐
            │          │     │
────────────┴──────────┴─────┘
</example_output>


<example_input>
┌─┐
│o│
└─┘
</example_input>

<example_output>
Measurements: 1
Sorted from largest to smallest: 1
Cumulative: 1
Corresponding visual representation:

─┐
 │
─┘
</example_output>


<example_input>
             ┌─────────┐
             │o       o│
             └─────────┘
</example_input>

<example_output>
Measurements: 14, 22
Sorted from largest to smallest: 22, 14
Cumulative: 22, 36
Corresponding visual representation:

──────────────────────┬─────────────┐
                      │             │
──────────────────────┴─────────────┘
</example_output>

Here is the real input:

<input>
    ┌──────────┐
    │o o      o│
    └──────────┘
 ┌─────┐
 │o   o│
 └─────┘
         ┌─┐
         │o│
         └─┘
     ┌───────┐
     │o    oo│
     └───────┘
┌─┐
│o│
└─┘
             ┌─────────┐
             │o       o│
             └─────────┘
        ┌─┐
        │o│
        └─┘
   ┌───┐
   │o o│
   └───┘
</input>

For each of these, repeat the full process given in the examples.
Do it for one at a time, to avoid confusing them with each other.

At the end, please copy the visual representations and
concatenate them after each other in a <result> block.

This uses several tricks I have picked up over the past few weeks of using llm​s:

  1. Give a few examples of what you want, ideally with some variety and complications in them.
  2. Break the process down into steps (find out measurements, sort them, get a cumulative tally, then visualise.)
  3. Ask of it what you want at the end, rather than in the beginning.
  4. Ask it to work on one case at a time.
  5. Make sure it shows its work (since it does no thinking other than predicting tokens, it – much like myself – thinks by putting things on paper.)
  6. Tell it to summarise the main result at the end for convenient copy-pasting.

This seems to be more voodoo than science and it would be interesting to explore which things really work and which only seem to improve results, but that is beyond what I have time for at the moment.