traberph commited on
Commit
d095b8b
1 Parent(s): 336f4ff

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -34
README.md CHANGED
@@ -14,37 +14,3 @@ widget:
14
  ## Reddit post classification
15
 
16
  This model predicts the subreddit of a provided post
17
- The transformers library is required
18
- ```
19
- pip install 'transformers[torch]'
20
- ```
21
-
22
- ```py
23
- from transformers import pipeline
24
- pipe = pipeline('text-classification', model='traberph/RedBERT')
25
- pipe("Biden says US is at tipping point on gun control: We will ban assault weapons in this country")
26
- ```
27
-
28
- ## Class Labels
29
-
30
- To translate the labels back to subreddit names you need to download the `subreddits.json` file from this repo manually
31
-
32
- ```py
33
- import json
34
- s_count = 0
35
- s_data = []
36
- with open('subreddits.json', 'r') as file:
37
- s_data = json.load(file)
38
- s_count = len(s_data)
39
- labels = list(s_data.keys())
40
-
41
- def translate(d):
42
- d['label'] = s_data[ labels[ int( d['label'].split('_')[1]) ]]
43
- return d
44
- ```
45
-
46
- Now the class labels can be translated back to subreddits
47
-
48
- ```py
49
- list(map(translate, pipe("Biden says US is at tipping point on gun control: We will ban assault weapons in this country")))
50
- ```
 
14
  ## Reddit post classification
15
 
16
  This model predicts the subreddit of a provided post