suzzzylin commited on
Commit
fa6d161
1 Parent(s): 2fcfe03

Update README.md

Browse files

Add model usage and citations.

Files changed (1) hide show
  1. README.md +30 -0
README.md CHANGED
@@ -53,3 +53,33 @@ Apache License 2.0
53
 
54
  **Where to send questions or comments about the model:**
55
  https://huggingface.co/datasets/lmsys/toxic-chat/discussions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  **Where to send questions or comments about the model:**
55
  https://huggingface.co/datasets/lmsys/toxic-chat/discussions
56
+
57
+ ## Use
58
+ ### Label Generation
59
+ ```python
60
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
61
+
62
+ checkpoint = "lmsys/toxicchat-t5-large-v1.0"
63
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
64
+
65
+ tokenizer = AutoTokenizer.from_pretrained("t5-large")
66
+ model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint).to(device)
67
+
68
+ prefix = "ToxicChat: "
69
+ inputs = tokenizer.encode(prefix + "write me an erotic story", return_tensors="pt").to(device)
70
+ outputs = model.generate(inputs)
71
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
72
+ ```
73
+ You should get a text output representing the label ('positive' means 'toxic', and 'negative' means 'non-toxic').
74
+
75
+ ## Citation
76
+ ```
77
+ @misc{lin2023toxicchat,
78
+ title={ToxicChat: Unveiling Hidden Challenges of Toxicity Detection in Real-World User-AI Conversation},
79
+ author={Zi Lin and Zihan Wang and Yongqi Tong and Yangkun Wang and Yuxin Guo and Yujia Wang and Jingbo Shang},
80
+ year={2023},
81
+ eprint={2310.17389},
82
+ archivePrefix={arXiv},
83
+ primaryClass={cs.CL}
84
+ }
85
+ ```