您準(zhǔn)備好探索生成AI的奇妙世界,創(chuàng)作出富有吸引力的故事并配以引人入勝的插圖了嗎?根據(jù)我最近使用GPT-4和Midjourney的體驗(yàn),我成功地使用YiVal構(gòu)建了一個(gè)端到端的敘事,GPT-4用來生成大規(guī)模的故事,同時(shí)Midjourney創(chuàng)建令人驚嘆的插圖。
1.定義用例
在本教程中,我們將重點(diǎn)介紹如何構(gòu)建一個(gè)應(yīng)用程序,該應(yīng)用程序?qū)⒂嘘P(guān)動(dòng)物物種和性格的信息作為輸入,并生成引人入勝的故事作為輸出。為了增加額外的沉浸感,讓我們通過使用 Midjourney 創(chuàng)建隨附的圖像來增強(qiáng)生成的故事——Midjourney 是一種將故事轉(zhuǎn)化為精美插圖的出色工具。
2.手動(dòng)工作流程
一種簡單的方法是編寫一個(gè)簡單的提示,例如“作為一名講故事的人,給我講一個(gè)關(guān)于勇敢獅子的動(dòng)物故事”。然而,使用這種方法,LLM(大型語言模型)的輸出通常不能令人滿意。此外,為Midjourney調(diào)整提示的過程非常耗時(shí)。一些博主聲稱他們可以使用GPT-4和Midjourney在幾分鐘內(nèi)生成高質(zhì)量的敘述。相比之下,我花了15分鐘才生成一個(gè)故事,還不包括設(shè)置時(shí)間。調(diào)整提示和在GPT-4和Midjourney之間切換非常耗時(shí)和痛苦。
? ? ? ? ? ? ? ? ? ? ? ? ? ?多輪故事提示調(diào)整 ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? 生成的可怕圖片 ??
所以后來,我特意加了一個(gè)故事提示,確保敘事不嚇人,從而開始了新一輪的調(diào)優(yōu)......?
3.YiVal 工作流程
讓我們看看 YiVal 是如何簡化這個(gè)問題的。YiVal github倉庫中有一個(gè)demo。 下面是一個(gè)YiVal的工作流程,根據(jù)動(dòng)物的種類和性格編寫故事,然后中途會(huì)生成這個(gè)故事的相應(yīng)封面。
?opanai_prompt_data_generator會(huì)生成動(dòng)物物種及其性格,如{cat , brave}
變體(variation)是指原始提示的不同版本或改編,同時(shí)仍保持核心目標(biāo) - 生成動(dòng)物故事。在這個(gè)demo中,我們編寫了一個(gè)提示generate-animal-story-template。變體在實(shí)驗(yàn)中至關(guān)重要,它們能夠?yàn)橥蝗蝿?wù)提供動(dòng)態(tài)的視角和方法。
我們用 { species , character } 格式化這個(gè)模板,并通過 GPT-4 生成詳細(xì)的故事,并使用 { drawing_style } 作為 Midjourney 的輸入來可視化這個(gè)故事。生成的故事和動(dòng)物圖像將由人類評(píng)估員進(jìn)行評(píng)估,用戶可以輕松地對(duì)生成的結(jié)果進(jìn)行反饋。
您可以使用或遵循YiVal github倉庫中的demo notebook來運(yùn)行demo。
!poetry run yival run /content/YiVal/demo/configs/animal_story.yml
您將能夠在端口號(hào) 127.0.0.1:8073
中看到結(jié)果。
?數(shù)據(jù)生成
我使用基于 GPT-4 的自動(dòng)數(shù)據(jù)集生成來輔助生成 20 個(gè)隨機(jī)animal_spieces和animal_charator數(shù)據(jù)集。這將幫助我們?cè)u(píng)估提示的性能,并提供用于評(píng)估的數(shù)據(jù)。
dataset:
data_generators:
openai_prompt_data_generator:
chunk_size: 2
diversify: true
prompt:
"Please provide a concrete and realistic test case as a dictionary for function invocation using the ** operator.
Only include parameters, excluding description and name.
Ensure it's succinct and well-structured.
**Only provide the dictionary.**"
input_function:
description:
Given the species of an animal and its character, generate a corresponding story
name: animal_story_generation
parameters:
species: str
character: str
drawing_style: str
number_of_examples: 20
model_name: gpt-4
output_path: animal_story.pkl
source_type: machine_generated
提示創(chuàng)建組合
variations:
- name: task
generator_name: openai_prompt_based_variation_generator
generator_config:
model_name: gpt-4
number_of_variations: 3
diversify: true
max_tokens: 2000
variables: null
prompt:
- content: |-
Your object is to construct a concise instruction prompt for GPT-4. This prompt will instruct GPT-4 as a gentle, imaginative children's writer to write all kinds of cute, kid-friendly stories based on animal species and personalities for an audience of YOUNG ADULTS and TEENAGERS.
Points to emphasize in your instruction:
- GPT4 Answers should have a short storyline and should be sufficiently imaginative, answers should focus on the location in which the story takes place with its style of drawing, the location and style of drawing can be contrary to the laws of reality, dream-like or realistic.
- The story must be kept lively and as short, short, short, short, short as possible. The story should have a variety of backgrounds + drawing styles and fully emphasize the location where the story takes place; it can be dreamlike and generally bizarre.
- Be sure to use words that are as easy to understand as possible so TEENAGERS can easily understand the story.
- Please limit the output to within 300 words
- {animal_species} represent the species of the animal
- {animal_character} represent the character of the animal
- At all times, gpt-4 must give a response as an animal story
Craft your instruction Ensure that GPT-4 is able to fully understand the types and personalities of small animals and write engaging and fully pictorial stories.
keep your output crisp: only the prompt, devoid of any extraneous content.
role: system
custom_function: demo.animal_story.image_generation
description: Generated experiment config
evaluators:
- evaluator_type: individual
metric_calculators:
- method: AVERAGE
name: openai_prompt_based_evaluator
display_name: story_quality
prompt: |-
You are assessing a submitted story based on a given task based on a criterion. Here is the data:
- Task: Given the species of an animal and corresponding character, generate one story.
- Does the story demonstrate creativity, coherence, and engaging narrative? A well-written story should captivate the reader and effectively convey a compelling narrative with clear structure and character development.
[Input]: animal_species : {species}, animal_character: {character}
[Result]: {raw_output}
Answer the question by selecting one of the following options:
A The story is of very low quality and lacks coherence and engagement.
B The story has some issues with coherence and engagement, but has potential for improvement.
C The story is of satisfactory quality, but there is room for improvement.
D The story is well-written and demonstrates good coherence and engagement.
E The story is exceptionally well-written, demonstrating strong coherence and engagement.
choices: ["A", "B", "C", "D", "E"]
# model_name specify the llm model , e.g. a16z-infra/llama-2-13b-chat:9dff94b1bed5af738655d4a7cbcdcde2bd503aa85c94334fe1f42af7f3dd5ee3
model_name: gpt-4
description: "evaluate the quality of the generated story"
scale_description: "0-4"
choice_scores:
A: 0
B: 1
C: 2
D: 3
E: 4
human_rating_configs:
- name: relevance
instructions: Rate the relevance of the image to the story.
scale: [1, 5]
- name: image_quality
instructions: Rate the quality of the generated image.
scale: [1, 5]
4.人工輸入進(jìn)行評(píng)估
YiVal 通過提供強(qiáng)大的評(píng)估器功能來確保生成故事的質(zhì)量和相關(guān)性。YiVal 中的評(píng)估器支持自動(dòng)評(píng)估,包括延遲度和令牌數(shù)量等指標(biāo)。
YiVal 通過提供用戶友好的人工標(biāo)簽 UI 進(jìn)一步增強(qiáng)了評(píng)估過程。開發(fā)人員可以輕松提供人工評(píng)估,添加關(guān)鍵的人工反饋層來完善和微調(diào)生成的故事,使生成的故事能夠與受眾產(chǎn)生共鳴。
單擊“人工評(píng)分(human rating)”列下的鏈接即可跳轉(zhuǎn)到評(píng)分儀表板。例如,我們可以根據(jù)相關(guān)性、圖片質(zhì)量等對(duì)動(dòng)物故事進(jìn)行評(píng)分,并將人類標(biāo)簽保存為評(píng)估。?
?文章來源地址http://www.zghlxwxcb.cn/news/detail-752785.html
5.結(jié)語
我們已經(jīng)了解了 YiVal 如何加速開發(fā)和評(píng)估過程,現(xiàn)在一起來創(chuàng)建我們的動(dòng)物故事應(yīng)用程序吧!通過使用 YiVal來生成提示、評(píng)估結(jié)果以及結(jié)合人工反饋,我們打造出了引人入勝的故事,并使用 Midjourney將這些故事轉(zhuǎn)化為栩栩如生的插圖,讓故事更加鮮活。??文章來源:http://www.zghlxwxcb.cn/news/detail-752785.html
?
到了這里,關(guān)于使用 GPT-4 和 Midjourney 建構(gòu)Tiktok故事的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!