logo
P
Prompt Master

Prompt 大师

掌握和 AI 对话的艺术

Alphabet Person (TikZ)

Iterative prompt example for a visual concept

TL;DR

  • This is an "iterative prompting" example: the goal is to have the model generate TikZ code representing a visual concept (a person made of alphabet letters).
  • The key isn't getting it right in one shot -- it's: request → feedback → refinement, gradually converging on a usable result.
  • Production tip: make feedback actionable (specifically call out proportions, alignment, relative positions), and keep each round to just 1-2 changes.

Background

The following prompt explores a challenging multimodal-ish task: generating TikZ code for a visual concept using text-only reasoning. The key is iterative prompting: request → feedback → refinement.

Note: this task asks the model to generate TikZ code, which you then compile manually.

How to Apply

You can migrate this pattern to any "text description → visual code" task (like TikZ, SVG, Mermaid):

  1. Round 1: Describe the main structure only (which letters/shapes form which body parts)
  2. Round 2: Give feedback based on the compiled result (alignment, proportions, position relationships)
  3. Round 3: Add style and details (clothing, accessories, colors, etc.)

How to Iterate

High-quality feedback usually has 3 properties:

  • Specific (which part, what problem)
  • Quantifiable ("too long/too short" can be refined with proportion or coordinate hints)
  • Doesn't introduce new requirements (only change 1-2 things per round)

You can also add a fixed evaluation checklist:

  • Is the face above the torso and centered?
  • Are the arms symmetrical left-right?
  • Is the leg spacing reasonable and stable?

Self-check Rubric

  • Did it fix the issues from the feedback?
  • Is the generated TikZ compilable?
  • Is the structure modular enough for continued iteration?

Practice

Exercise: replace "alphabet person" with a more complex concept (e.g., "alphabet robot" or "alphabet animal"), keeping the 3-round iteration:

  • Round 1: Main structure
  • Round 2: Fix proportions and alignment
  • Round 3: Add details and style

Prompt

Prompt iteration 1:

Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.

Prompt iteration 2:

The torso is a bit too long, the arms are too short and it looks like the right arm is carrying the face instead of the face being right above the torso. Could you correct this please?

Prompt iteration 3:

Please add a shirt and pants.

Code / API

OpenAI (Python)

from openai import OpenAI

client = OpenAI()

response = client.chat.completions.create(
    model="gpt-4",
    messages=[
        {
            "role": "user",
            "content": "Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.",
        }
    ],
    temperature=1,
    max_tokens=1000,
    top_p=1,
    frequency_penalty=0,
    presence_penalty=0,
)

Fireworks (Python)

import fireworks.client

fireworks.client.api_key = "<FIREWORKS_API_KEY>"

completion = fireworks.client.ChatCompletion.create(
    model="accounts/fireworks/models/mixtral-8x7b-instruct",
    messages=[
        {
            "role": "user",
            "content": "Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.",
        }
    ],
    stop=["<|im_start|>", "<|im_end|>", "<|endoftext|>"],
    stream=True,
    n=1,
    top_p=1,
    top_k=40,
    presence_penalty=0,
    frequency_penalty=0,
    prompt_truncate_len=1024,
    context_length_exceeded_behavior="truncate",
    temperature=0.9,
    max_tokens=4000,
)

Reference