metadata
license: apache-2.0
datasets:
- webis/tldr-17
language:
- en
library_name: transformers
pipeline_tag: text-classification
widget:
- text: >-
Biden says US is at tipping point on gun control: We will ban assault
weapons in this country
example_title: classification
Reddit post classification
This model predicts the subreddit of a provided post
The transformers library is required
pip install 'transformers[torch]'
from transformers import pipeline
pipe = pipeline('text-classification', model='traberph/RedBERT')
pipe("Biden says US is at tipping point on gun control: We will ban assault weapons in this country")
Class Labels
To translate the labels back to subreddit names you need to download the subreddits.json
file from this repo manually
import json
s_count = 0
s_data = []
with open('subreddits.json', 'r') as file:
s_data = json.load(file)
s_count = len(s_data)
labels = list(s_data.keys())
def translate(d):
d['label'] = s_data[ labels[ int( d['label'].split('_')[1]) ]]
return d
Now the class labels can be translated back to subreddits
list(map(translate, pipe("Biden says US is at tipping point on gun control: We will ban assault weapons in this country")))