Update README.md
Browse files
README.md
CHANGED
@@ -62,3 +62,56 @@ The following hyperparameters were used during training:
|
|
62 |
- Pytorch 2.3.1+cu121
|
63 |
- Datasets 2.20.0
|
64 |
- Tokenizers 0.19.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
- Pytorch 2.3.1+cu121
|
63 |
- Datasets 2.20.0
|
64 |
- Tokenizers 0.19.1
|
65 |
+
|
66 |
+
### How to use
|
67 |
+
|
68 |
+
You can use this model directly with a pipeline for masked language modeling:
|
69 |
+
|
70 |
+
```python
|
71 |
+
>>> from transformers import pipeline
|
72 |
+
>>> unmasker = pipeline('fill-mask', model='bert-base-cased')
|
73 |
+
>>> unmasker("Hello I'm a [MASK] model.")
|
74 |
+
|
75 |
+
[{'sequence': "[CLS] Hello I'm a fashion model. [SEP]",
|
76 |
+
'score': 0.09019174426794052,
|
77 |
+
'token': 4633,
|
78 |
+
'token_str': 'fashion'},
|
79 |
+
{'sequence': "[CLS] Hello I'm a new model. [SEP]",
|
80 |
+
'score': 0.06349995732307434,
|
81 |
+
'token': 1207,
|
82 |
+
'token_str': 'new'},
|
83 |
+
{'sequence': "[CLS] Hello I'm a male model. [SEP]",
|
84 |
+
'score': 0.06228214129805565,
|
85 |
+
'token': 2581,
|
86 |
+
'token_str': 'male'},
|
87 |
+
{'sequence': "[CLS] Hello I'm a professional model. [SEP]",
|
88 |
+
'score': 0.0441727414727211,
|
89 |
+
'token': 1848,
|
90 |
+
'token_str': 'professional'},
|
91 |
+
{'sequence': "[CLS] Hello I'm a super model. [SEP]",
|
92 |
+
'score': 0.03326151892542839,
|
93 |
+
'token': 7688,
|
94 |
+
'token_str': 'super'}]
|
95 |
+
```
|
96 |
+
|
97 |
+
Here is how to use this model to get the features of a given text in PyTorch:
|
98 |
+
|
99 |
+
```python
|
100 |
+
from transformers import BertTokenizer, BertModel
|
101 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-cased')
|
102 |
+
model = BertModel.from_pretrained("bert-base-cased")
|
103 |
+
text = "Replace me by any text you'd like."
|
104 |
+
encoded_input = tokenizer(text, return_tensors='pt')
|
105 |
+
output = model(**encoded_input)
|
106 |
+
```
|
107 |
+
|
108 |
+
and in TensorFlow:
|
109 |
+
|
110 |
+
```python
|
111 |
+
from transformers import BertTokenizer, TFBertModel
|
112 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-cased')
|
113 |
+
model = TFBertModel.from_pretrained("bert-base-cased")
|
114 |
+
text = "Replace me by any text you'd like."
|
115 |
+
encoded_input = tokenizer(text, return_tensors='tf')
|
116 |
+
output = model(encoded_input)
|
117 |
+
```
|