Update README.md
Browse files
README.md
CHANGED
|
@@ -15,14 +15,23 @@ library_name: transformers
|
|
| 15 |
- Intended use: content moderation research/demos; not for deployment without bias/fairness review.
|
| 16 |
- Limitations/risks: social bias, dataset age/domain mismatch; errors possible on slang/irony.
|
| 17 |
- How to use:
|
|
|
|
| 18 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
|
|
|
|
| 19 |
mid = "Yash22CSU192/davidson-roberta-hatespeech"
|
|
|
|
|
|
|
| 20 |
tok = AutoTokenizer.from_pretrained(mid)
|
| 21 |
mdl = AutoModelForSequenceClassification.from_pretrained(mid)
|
|
|
|
|
|
|
| 22 |
clf = pipeline("text-classification", model=mdl, tokenizer=tok, return_all_scores=True)
|
|
|
|
|
|
|
| 23 |
print(clf("Have a nice day."))
|
| 24 |
|
| 25 |
|
|
|
|
| 26 |
## Files
|
| 27 |
- model.safetensors, config.json, tokenizer.json, tokenizer_config.json, vocab.json, merges.txt, special_tokens_map.json
|
| 28 |
- training_args.bin (Trainer settings), metrics.json (evaluation summary)
|
|
|
|
| 15 |
- Intended use: content moderation research/demos; not for deployment without bias/fairness review.
|
| 16 |
- Limitations/risks: social bias, dataset age/domain mismatch; errors possible on slang/irony.
|
| 17 |
- How to use:
|
| 18 |
+
## Usage
|
| 19 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
|
| 20 |
+
|
| 21 |
mid = "Yash22CSU192/davidson-roberta-hatespeech"
|
| 22 |
+
|
| 23 |
+
# Load tokenizer and model
|
| 24 |
tok = AutoTokenizer.from_pretrained(mid)
|
| 25 |
mdl = AutoModelForSequenceClassification.from_pretrained(mid)
|
| 26 |
+
|
| 27 |
+
# Create a text-classification pipeline
|
| 28 |
clf = pipeline("text-classification", model=mdl, tokenizer=tok, return_all_scores=True)
|
| 29 |
+
|
| 30 |
+
# Test the classifier
|
| 31 |
print(clf("Have a nice day."))
|
| 32 |
|
| 33 |
|
| 34 |
+
|
| 35 |
## Files
|
| 36 |
- model.safetensors, config.json, tokenizer.json, tokenizer_config.json, vocab.json, merges.txt, special_tokens_map.json
|
| 37 |
- training_args.bin (Trainer settings), metrics.json (evaluation summary)
|