Minej commited on
Commit
6f4d00d
1 Parent(s): a8ad43c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -51
README.md CHANGED
@@ -6,6 +6,59 @@ library_name: transformers
6
  pipeline_tag: text-classification
7
  ---
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  ### Model Description
10
 
11
  Transfer Learning for Big Five Personality Prediction
@@ -80,26 +133,7 @@ To mitigate risks and limitations associated with personality prediction models,
80
 
81
  It is important to note that the above recommendations are general guidelines, and further context-specific recommendations should be developed based on the particular use case and ethical considerations.
82
 
83
- ## How to Get Started with the Model
84
-
85
- To use the model through Hosted inference API, follow the code snippet provided below:
86
-
87
- ```python
88
- from transformers import BertTokenizer, BertForSequenceClassification
89
-
90
- def personality_detection(text):
91
- tokenizer = BertTokenizer.from_pretrained("Minej/bert-base-personality")
92
- model = BertForSequenceClassification.from_pretrained("Minej/bert-base-personality")
93
-
94
- inputs = tokenizer(text, truncation=True, padding=True, return_tensors="pt")
95
- outputs = model(**inputs)
96
- predictions = outputs.logits.squeeze().detach().numpy()
97
-
98
- label_names = ['Extroversion', 'Neuroticism', 'Agreeableness', 'Conscientiousness', 'Openness']
99
- result = {label_names[i]: predictions[i] for i in range(len(label_names))}
100
-
101
- return result
102
- ```
103
 
104
  If you would like to download the model files and use them instead of the Hosted inference API, then you can follow the code snippet provided below:
105
 
@@ -174,38 +208,7 @@ You can call the personality_detection function with your input text to obtain t
174
  Please note that this code assumes you have already downloaded the necessary model files (config.json, pytorch_model.bin, special_tokens_map.json, tokenizer_config.json, vocab.txt
175
  ) and placed them in the current directory (indicated by "."). Adjust the paths and filenames accordingly if needed.
176
 
177
- #### Result Format
178
-
179
- The personality_detection function returns a dictionary containing the predicted personality traits based on the given input text.
180
-
181
- The dictionary contains the following personality traits with their corresponding predicted values:
182
-
183
- Extroversion: A value between 0 and 1 representing the predicted extroversion trait.
184
- Neuroticism: A value between 0 and 1 representing the predicted neuroticism trait.
185
- Agreeableness: A value between 0 and 1 representing the predicted agreeableness trait.
186
- Conscientiousness: A value between 0 and 1 representing the predicted conscientiousness trait.
187
- Openness: A value between 0 and 1 representing the predicted openness trait.
188
-
189
- ```python
190
- text_input = "I am feeling excited about the upcoming event."
191
- personality_prediction = personality_detection(text_input)
192
-
193
- print(personality_prediction)
194
- ```
195
- ###### Output:
196
- ```python
197
- {
198
- "Extroversion": 0.535,
199
- "Neuroticism": 0.576,
200
- "Agreeableness": 0.399,
201
- "Conscientiousness": 0.253,
202
- "Openness": 0.563
203
- }
204
- ```
205
-
206
- Note: The values in the example output are just placeholders and may not reflect the actual predictions.
207
 
208
- You can modify the example code and the result format to match your specific use case and desired output format.
209
 
210
  ## Citation
211
 
 
6
  pipeline_tag: text-classification
7
  ---
8
 
9
+ ## How to Get Started with the Model
10
+
11
+ To use the model through Hosted inference API, follow the code snippet provided below:
12
+
13
+ ```python
14
+ from transformers import BertTokenizer, BertForSequenceClassification
15
+
16
+ def personality_detection(text):
17
+ tokenizer = BertTokenizer.from_pretrained("Minej/bert-base-personality")
18
+ model = BertForSequenceClassification.from_pretrained("Minej/bert-base-personality")
19
+
20
+ inputs = tokenizer(text, truncation=True, padding=True, return_tensors="pt")
21
+ outputs = model(**inputs)
22
+ predictions = outputs.logits.squeeze().detach().numpy()
23
+
24
+ label_names = ['Extroversion', 'Neuroticism', 'Agreeableness', 'Conscientiousness', 'Openness']
25
+ result = {label_names[i]: predictions[i] for i in range(len(label_names))}
26
+
27
+ return result
28
+ ```
29
+
30
+ #### Result Format
31
+
32
+ The personality_detection function returns a dictionary containing the predicted personality traits based on the given input text.
33
+
34
+ The dictionary contains the following personality traits with their corresponding predicted values:
35
+
36
+ Extroversion: A value between 0 and 1 representing the predicted extroversion trait.
37
+ Neuroticism: A value between 0 and 1 representing the predicted neuroticism trait.
38
+ Agreeableness: A value between 0 and 1 representing the predicted agreeableness trait.
39
+ Conscientiousness: A value between 0 and 1 representing the predicted conscientiousness trait.
40
+ Openness: A value between 0 and 1 representing the predicted openness trait.
41
+
42
+ ```python
43
+ text_input = "I am feeling excited about the upcoming event."
44
+ personality_prediction = personality_detection(text_input)
45
+
46
+ print(personality_prediction)
47
+ ```
48
+ ###### Output:
49
+ ```python
50
+ {
51
+ "Extroversion": 0.535,
52
+ "Neuroticism": 0.576,
53
+ "Agreeableness": 0.399,
54
+ "Conscientiousness": 0.253,
55
+ "Openness": 0.563
56
+ }
57
+ ```
58
+ Note: The values in the example output are just placeholders and may not reflect the actual predictions.
59
+
60
+ You can modify the example code and the result format to match your specific use case and desired output format.
61
+
62
  ### Model Description
63
 
64
  Transfer Learning for Big Five Personality Prediction
 
133
 
134
  It is important to note that the above recommendations are general guidelines, and further context-specific recommendations should be developed based on the particular use case and ethical considerations.
135
 
136
+ ## How to Download the Model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  If you would like to download the model files and use them instead of the Hosted inference API, then you can follow the code snippet provided below:
139
 
 
208
  Please note that this code assumes you have already downloaded the necessary model files (config.json, pytorch_model.bin, special_tokens_map.json, tokenizer_config.json, vocab.txt
209
  ) and placed them in the current directory (indicated by "."). Adjust the paths and filenames accordingly if needed.
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
 
212
 
213
  ## Citation
214