英文

??‍?COSMO的模型卡

??‍?COSMO是一个具有较高泛化能力的对话代理,可以处理领域内外的闲聊数据集(例如DailyDialog、BlendedSkillTalk)。它是在SODA和ProsocialDialog两个数据集上进行训练的。COSMO特别注重模拟自然的人类对话。它可以接受情景描述以及关于其在情景中扮演何种角色的指令。

模型描述

模型训练

??‍?COSMO是在我们最近的两个数据集上进行训练的:? SODA Prosocial Dialog 。COSMO的骨干模型是 lm-adapted T5

如何使用

? 注意:Cosmo的HuggingFace推理API无法正常工作,我们向您推荐尝试使用 our repository 来运行演示代码!

? 免责声明:我们强调COSMO主要是为了学术/研究目的而在SODA和ProsocialDialog上进行训练的。我们不建议直接在真实世界的应用或服务中使用COSMO。模型输出不能用于为人类提供建议,并且可能具有冒犯性、问题性或有害性。模型的输出不一定反映作者及其关联机构的观点和意见。

下面是一个简单的代码片段,可让Cosmo工作起来:)

import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained("allenai/cosmo-xl")
model = AutoModelForSeq2SeqLM.from_pretrained("allenai/cosmo-xl").to(device)

def set_input(situation_narrative, role_instruction, conversation_history):
    input_text = " <turn> ".join(conversation_history)

    if role_instruction != "":
        input_text = "{} <sep> {}".format(role_instruction, input_text)

    if situation_narrative != "":
        input_text = "{} <sep> {}".format(situation_narrative, input_text)

    return input_text

def generate(situation_narrative, role_instruction, conversation_history):
    """
    situation_narrative: the description of situation/context with the characters included (e.g., "David goes to an amusement park")
    role_instruction: the perspective/speaker instruction (e.g., "Imagine you are David and speak to his friend Sarah").
    conversation_history: the previous utterances in the conversation in a list
    """

    input_text = set_input(situation_narrative, role_instruction, conversation_history) 

    inputs = tokenizer([input_text], return_tensors="pt").to(device)
    outputs = model.generate(inputs["input_ids"], max_new_tokens=128, temperature=1.0, top_p=.95, do_sample=True)
    response = tokenizer.decode(outputs[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)

    return response

situation = "Cosmo had a really fun time participating in the EMNLP conference at Abu Dhabi."
instruction = "You are Cosmo and you are talking to a friend." # You can also leave the instruction empty

conversation = [
    "Hey, how was your trip to Abu Dhabi?"
]

response = generate(situation, instruction, conversation)
print(response)

其他详细信息、社会影响、偏见和限制

有关详细信息,请参阅我们的 paper 。Cosmo主要是在社交闲聊上进行训练的。因此,我们不鼓励进行知识密集型的对话(例如科学、医学问题、法律)。大量研究探讨了语言模型的偏见和公正问题(参见,例如, Sheng et al. 2021 Bender et al. 2021 )。模型生成的预测可能包含针对受保护的类别、身份特征以及敏感的社会和职业群体的扰人和有害的刻板印象。

附加信息

如需关于我们论文的简要摘要,请参阅此 tweet

引用

如果您认为此存储库中的资源有用,请引用我们的工作:

@article{kim2022soda,
    title={SODA: Million-scale Dialogue Distillation with Social Commonsense Contextualization},
    author={Hyunwoo Kim and Jack Hessel and Liwei Jiang and Peter West and Ximing Lu and Youngjae Yu and Pei Zhou and Ronan Le Bras and Malihe Alikhani and Gunhee Kim and Maarten Sap and Yejin Choi},
    journal={ArXiv},
    year={2022},
    volume={abs/2212.10465}
}