Instructions to use liamcripwell/ctrl44-clf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use liamcripwell/ctrl44-clf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="liamcripwell/ctrl44-clf")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("liamcripwell/ctrl44-clf") model = AutoModelForSequenceClassification.from_pretrained("liamcripwell/ctrl44-clf", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| language: en | |
| # CTRL44 Classification model | |
| This is a pretrained version of the 4-class simplification operation classifier presented in the NAACL 2022 paper "Controllable Sentence Simplification via Operation Classification". It was trained on the IRSD classification dataset. | |
| Predictions from this model can be used for input into the [simplification model](https://huggingface.co/liamcripwell/ctrl44-simp) to reproduce pipeline results seen in the paper. | |
| ## How to use | |
| Here is how to use this model in PyTorch: | |
| ```python | |
| from transformers import RobertaForSequenceClassification, AutoTokenizer | |
| model = RobertaForSequenceClassification.from_pretrained("liamcripwell/ctrl44-clf") | |
| tokenizer = AutoTokenizer.from_pretrained("liamcripwell/ctrl44-clf") | |
| text = "Barack Hussein Obama II is an American politician who served as the 44th president of the United States from 2009 to 2017." | |
| inputs = tokenizer(text, return_tensors="pt") | |
| with torch.no_grad(): | |
| logits = model(**inputs).logits | |
| predicted_class_id = logits.argmax().item() | |
| predicted_class_name = model.config.id2label[predicted_class_id] | |
| ``` |