Prompt Hub - 圖像生成(Image Generation)

圖像生成 (Image Generation)

本段包含一組用於探索大型語言模型(LLMs)與多模態模型能力的提示集合。


目錄


用英文字母繪製一個人像

背景

以下提示旨在測試大型語言模型處理視覺概念的能力,儘管其訓練主要基於文字。這對 LLM 來說是一項具有挑戰性的任務,因此通常需要多次反覆試作。在下方範例中,使用者首先請求生成特定視覺內容,接著根據 LLM 的輸出提供回饋、修正與補充。後續的指示將根據 LLM 在任務中的進展而調整。
請注意,此任務要求生成 TikZ 程式碼,使用者需自行手動編譯該程式碼才能產生圖像。

提示詞

提示詞第 1 次迭代:

請產生 TikZ 程式碼,繪製一個由英文字母組成的人形圖案。
手臂與軀幹可以使用字母 Y,臉使用字母 O(請加上一些五官特徵),雙腿則可用字母 H 的腿部形狀來表示。你也可以自由添加其他細節。

提示詞第 2 次迭代:

軀幹看起來太長了,手臂太短,而且右手看起來像是在托著臉,而不是臉在軀幹正上方。請幫我修正這些問題。

提示詞第 3 次迭代:

請幫這個人加上襯衫與褲子。

程式

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
)
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
)

References

Image Generation


目錄:Prompt Hub - 提示詞匯集

上一篇:Prompt Hub - 使用大型語言模型進行資訊擷取 (Information Extraction with LLMs)
下一篇:Prompt Hub - 使用大型語言模型進行數學理解 (Mathematical Understanding with LLMs)