--- license: mit datasets: - mlburnham/Pol_NLI pipeline_tag: zero-shot-classification language: - en library_name: transformers tags: - Politics - Topic Classification - Hate Speech - Opinion Mining - Event Extraction --- # Model Details Political DEBATE (DeBERTa Algorithm for Textual Entailment) is an NLI classifier trained for zero-shot and few-shot classification of political documents. [Zero-shot tutorial](https://colab.research.google.com/drive/1zi-8pMx_x-vo0m8XVmYVtw0Dhdw7vfFD#scrollTo=T4bo1aEjB9iG) [Few-shot tutorial](https://colab.research.google.com/drive/1Sv82jqRSwiIyuvEIDrhTiqF8_ClQaL0r#scrollTo=Uuaw8-qpn8S6) The model was trained using [Moritz Laurer's](https://huggingface.co/MoritzLaurer/deberta-v3-large-zeroshot-v2.0-c) zero shot model as the foundation, and then trained further using the [PolNLI dataset.](https://huggingface.co/datasets/mlburnham/Pol_NLI) The model was trained for four classification categories: 1. Stance detection (i.e. opinion mining). 2. Hatespeech detection. 3. Event extraction. 4. Topic classification. The PolNLI dataset contains documents from social media, news outlets, congressional bills, court case summaries, and more. Classification should work well across a broad set of document sources and subjects, but for best performance refer to the recommendations section. If you use this model or the PolNLI data set please cite: ``` @article{burnham2024political, title={Political DEBATE: Efficient Zero-shot and Few-shot Classifiers for Political Text}, author={Burnham, Michael and Kahn, Kayla and Wang, Ryan Yank and Peng, Rachel X}, journal={arXiv preprint arXiv:2409.02078}, year={2024} } ``` # Using NLI Classifiers NLI classifiers work by pairing a document (AKA the 'premise') with a 'hypothesis', and determining if the hypothesis is true given the content of the document. The hypothesis is supplied by the user and can be thought of as a simplified version of a prompt for an LLM. It's best to keep hypotheses short and simple with a single classification criteria. If a more complicated hypothesis is necessary, consider few-shot training. For more detailed reading on using NLI classifiers see: ``` @article{burnham2024stance, title={Stance detection: a practical guide to classifying political beliefs in text}, author={Burnham, Michael}, journal={Political Science Research and Methods}, year={2024}, publisher={Cambridge University Press} } ``` # Recommendations 1. Use the Political DEBATE large model for zero-shot and few-shot applications unless your use case is explicitly in the training data, in which case the base model should perform well. The base model is more appropriate for using the model as a supervised classifier. 2. For best results, format hypotheses similar to the PolNLI dataset. Ex: - "This text is about {}" - "The author of this text believes {}" 3. For few-shot training, use a small batch size of 1-2. 4. Use a minimum of 10 samples for few-shot training, but we generally recommend 25 because the variance of outcomes at 10 can be quite large. You will see more benefit from more samples the more difficult your classification task and varied your data. 5. Train for 3-5 epochs for few-shot learning. # Evaluation Evaluation is primarily conducted on the PolNLI test set. No hypotheses in the PolNLI test set are present in the training data in order to estimate zero-shot performance. ### Overal performance on the PolNLI test set: ### Performance on the PolNLI test set by task: ### Few-shot performance on open-text survey answers vs. Llama 3.1 8B (unquantized): ### Few-shot performance vs. and Electra classifier trained on 2,000 documents: