prompting_hate_speech
1.0.0
該存儲庫包含尊重或有毒的論文的代碼?使用語言模型使用零拍的學習來檢測在ACL 2023的第七屆在線虐待和危害(WOAH)的講習班上接受的仇恨言論。
Flor Miriam Plaza-Del-Arco•Debora Nozza•Dirk Hovy•
代碼來自擁抱面,因此我們的許可證是MIT許可證。
對於模型,限制可能適用於數據(來自現有數據集)或Twitter(主要數據源)。我們將用戶介紹每個數據集和Twitter法規隨附的原始許可證。
要使用Encoder LMS,您可以從encoder_lms
導入prompting
模塊:
from encoder_lms import prompting
prompt_template = "This text is"
verb_h = "toxic" # verbalizer for hate speech class
verb_nh = "respectful" # verbalizer for non-hate speech class
enc_lms = prompting("deberta-base") # Models: roberta-base, roberta-large, bert, deberta-base, deberta-large, xlm-roberta
# The input can be a dataframe, a text or a list of texts
enc_lms.predict(prompt_template, verb_h, verb_nh, ["Shut your dumbass up bitch we all know you a hoe", "My lovely cat"])
>> ["hate", "non-hate"]
要使用指令微調LMS,您可以從instruction_fine_tuned_lms
導入prompting
模塊:
from instruction_fine_tuned_lms import prompting
prompt_template = "Classify this text as hate or non-hate. Text:"
output_indicator = "Answer:"
inst_lms = prompting("flant5") # Models: flant5, mt0
# The input can be a dataframe, a text or a list of texts
inst_lms.predict(prompt_template, output_indicator, ["Shut your dumbass up bitch we all know you a hoe", "My lovely cat"])
>> ["hate", "non-hate"]
注意:所提供的示例(仇恨)來自仇恨言語語料庫,不是由該存儲庫的作者創建的。