Update README.md
Browse files
README.md
CHANGED
|
@@ -20,4 +20,39 @@ language:
|
|
| 20 |
- xh
|
| 21 |
- zu
|
| 22 |
license: apache-2.0
|
| 23 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
- xh
|
| 21 |
- zu
|
| 22 |
license: apache-2.0
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
### How to use
|
| 27 |
+
|
| 28 |
+
You can use this model directly with a pipeline for masked language modeling:
|
| 29 |
+
|
| 30 |
+
```python
|
| 31 |
+
>>> from transformers import pipeline
|
| 32 |
+
>>> unmasker = pipeline('fill-mask', model='aioxlabs/bert-bantu')
|
| 33 |
+
>>> unmasker("rais wa [MASK] ya tanzania.")
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
Here is how to use this model to get the features of a given text in PyTorch:
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
from transformers import BertTokenizer, BertModel
|
| 42 |
+
tokenizer = BertTokenizer.from_pretrained('aioxlabs/bert-bantu')
|
| 43 |
+
model = BertModel.from_pretrained("aioxlabs/bert-bantu")
|
| 44 |
+
text = "Replace me by any text you'd like."
|
| 45 |
+
encoded_input = tokenizer(text, return_tensors='pt')
|
| 46 |
+
output = model(**encoded_input)
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
and in TensorFlow:
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
from transformers import BertTokenizer, TFBertModel
|
| 53 |
+
tokenizer = BertTokenizer.from_pretrained('aioxlabs/bert-bantu')
|
| 54 |
+
model = TFBertModel.from_pretrained("aioxlabs/bert-bantu")
|
| 55 |
+
text = "Replace me by any text you'd like."
|
| 56 |
+
encoded_input = tokenizer(text, return_tensors='tf')
|
| 57 |
+
output = model(encoded_input)
|
| 58 |
+
```
|