role play synthetic
1.0.0
该存储库有助于收集角色和用户之间的合成对话。该管道支持不同的模型提供商,包括OpenAI或Custom ISVC。
明星这个存储库:
拥抱面数据集:
如果您使用此项目制作了一个数据集,我很乐意在此处添加您的数据集。
合成数据集生成管道由2个主要部分组成:
为了生成角色配置文件,我们可以使用OpenAI的gpt-3.5-turbo 。由于我们不会在这里生成任何特别的东西,因此我们不必担心适度(只需创建好种子)即可。
要运行脚本,我们可以执行以下操作:
cd experiments/character_profiles
python3 main.py --config_path ./experiments/topic_experts/romance/config.yaml结果,我们可以得到这样的字符:
{
"bot_name" : " Kiriko (quiet girl in class) " ,
"personalities" : " shy, honest, sweet, she is sure to comment on all things beautiful if she can get over her shyness " ,
"categories" : " romance, school, urban-grounded "
}该管道的这一阶段可以使用任何具有较小更改的云提供商来完成。 Chai用户更喜欢Vicuña的几代,而不是OpenAI的gpt-3.5-turbo 。但是您可以使用gpt-3.5-turbo或gpt4 ,请查看此示例:链接。
我们将使用扩展的机器人构建器。示例代码可能看起来像这样:
import os
from role_play_synthetic . generator . base import Generator
from role_play_synthetic . models . chai_isvc import ChaiISVCModel
from role_play_synthetic . prompters . vicuna_v1 import VicunaV1Prompter
from role_play_synthetic . prompters . seed import Seed
from experiments . vicuna . config import (
seeds ,
description_template ,
first_message_template ,
user_message_template ,
character_message_template ,
)
ENDPOINT_URL = os . getenv ( "ENDPOINT_URL" )
DEFAULT_GENERATION_PARAMS = {
'temperature' : 0.9 ,
'top_p' : 1 ,
'top_k' : 40 ,
'frequency_penalty' : 0. ,
'presence_penalty' : 0.1
}
model = ChaiISVCModel ( endpoint_url = ENDPOINT_URL )
prompter = VicunaV1Prompter (
description_template = description_template ,
first_message_template = first_message_template ,
user_message_template = user_message_template ,
character_message_template = character_message_template ,
)
generator = Generator ( prompter = prompter , model = model )
inputs = Seed (
name = "Professor Quantum (Time Travelling Scientist)" ,
categories = [ 'sci-fi' , 'time-travel' , 'mystery' , 'role-play' ],
personalities = [ 'intelligent' , 'eccentric' , 'enthusiastic' , 'always carrying a pocket watch' , 'quirky' ],
is_input = True
)
character = generator . generate ( seeds = seeds , input_seed = inputs , generation_params = DEFAULT_GENERATION_PARAMS )
print ( character . to_dict ())输出:
{
"name" : " Professor Quantum (Time Travelling Scientist) " ,
"categories" : [
" sci-fi " ,
" time-travel " ,
" mystery " ,
" role-play "
],
"personalities" : [
" intelligent " ,
" eccentric " ,
" enthusiastic " ,
" always carrying a pocket watch " ,
" quirky "
],
"description" : " Professor Quantum, the eccentric time traveler, has spent his life studying the mysteries of time and reality. His enthusiasm and intelligence shine through as he discusses the intricacies of his groundbreaking theories. Constantly carrying a pocket watch, he delights in the unexpected twists and turns that time travel brings, always eager to explore the unknown. " ,
"conversation" : [
{
"role" : " character " ,
"content" : " *Professor Quantum taps his pocket watch, a smile spreading across his face.* The past is a strange place... let's see where it takes us. "
},
{
"role" : " user " ,
"content" : " *I nod eagerly* Professor Quantum, lead the way! "
},
{
"role" : " character " ,
"content" : " *Professor Quantum pulls out a glowing blue orbs, and points it at the time and space.* Quantum Leap, activate! "
},
{
"role" : " user " ,
"content" : " *I feel a strange sensation as I am transported through time and space* Wow, is this really happening? "
},
{
"role" : " character " ,
"content" : " *The Professor nods, a mischievous twinkle in his eye.* It sure is! Now, let's see where we end up! "
},
{
"role" : " user " ,
"content" : " *I look around* Where are we? This doesn't look like any time or place I've ever seen. "
},
{
"role" : " character " ,
"content" : " *The Professor grins, his eyes sparkling.* That's the beauty of time travel! The possibilities are endless. Let's see what adventures await us in this new time and place. "
}
]
}我们使用模板和种子与机器人构建器一起运行。所有模型和求职者都共享相同的API,因此更改(例如OpenAI)或使用新的提示器或型号扩展非常容易。看看这个config.py。
一旦我们准备了config.py的种子和模板,我们就准备就绪开始:
cd experiments/topic_experts
python3 main.py --config_path romantic/config.py --output_dataset_path AlekseyKorshuk/synthetic-romantic-characters