logo
P
Prompt Master

Prompt 大师

掌握和 AI 对话的艺术

Alphabet person (TikZ)

iterative prompt example for visual concept

#TL;DR(中文)

  • 这是一个 “iterative prompting” 示例:目标是让模型生成
    code
    TikZ
    代码来表达一个视觉概念(字母拼成的人)。
  • 关键不是一次写完,而是:request → feedback → refinement,逐步逼近可用结果。
  • 落地建议:把反馈写得可操作(具体指出比例、对齐、相对位置),并保持每轮只改 1-2 个点。

#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(中文)

你可以把这个模式迁移到任何 “文本描述 → 可视化代码” 的任务里(比如

code
TikZ
、SVG、Mermaid):

  1. 第一轮:只描述主体结构(用哪些字母/形状组成哪些部位)
  2. 第二轮:基于编译结果给反馈(对齐、比例、位置关系)
  3. 第三轮:补充风格与细节(衣服、配件、颜色等)

#How to Iterate(中文)

高质量反馈通常具备 3 个要素:

  • 具体(哪一部分、什么问题)
  • 可量化(too long/too short 可以进一步给比例或坐标提示)
  • 不引入新需求(一次只改 1-2 个点)

你也可以加入一个固定的评估 checklist:

  • face 是否在 torso 上方且居中
  • arms 是否左右对称
  • leg spacing 是否合理且稳定

#Self-check rubric(中文)

  • 是否按 feedback 修正了对应问题?
  • 生成的 TikZ 是否可编译?
  • 结构是否模块化,便于继续迭代?

#Practice(中文)

练习:把 “alphabet person” 换成一个更复杂的概念(例如 “alphabet robot” 或 “alphabet animal”),保持 3 轮迭代:

  • Round 1:主体结构
  • Round 2:修正比例与对齐
  • Round 3:加细节与风格

#Prompt

Prompt iteration 1:

markdown
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:

markdown
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:

markdown
Please add a shirt and pants.

#Code / API

#OpenAI (Python)

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)

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

1v1免费职业咨询