File size: 3,076 Bytes
21aaffb
 
 
 
 
 
 
9e94865
21aaffb
 
 
 
 
558d2f8
21aaffb
 
 
 
 
 
 
 
 
 
 
 
613b72c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21aaffb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
613b72c
21aaffb
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
language: "id"
license: "mit"
datasets:
- wikipedia
- id_newspapers_2018
widget:
- text: "ayahku sedang bekerja di sawah untuk [MASK] padi."
---

# Indonesian DistilBERT base model (uncased) 

## Model description
This model is a distilled version of the [Indonesian BERT base model](https://huggingface.co/cahya/bert-base-indonesian-1.5G).
This model is uncased.

This is one of several other language models that have been pre-trained with indonesian datasets. More detail about 
its usage on downstream tasks (text classification, text generation, etc) is available at [Transformer based Indonesian Language Models](https://github.com/cahya-wirawan/indonesian-language-models/tree/master/Transformers)

## Intended uses & limitations

### How to use
You can use this model directly with a pipeline for masked language modeling:
```python
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='cahya/distilbert-base-indonesian')
>>> unmasker("Ayahku sedang bekerja di sawah untuk [MASK] padi")

[
  {
    "sequence": "[CLS] ayahku sedang bekerja di sawah untuk menanam padi [SEP]",
    "score": 0.6853187084197998,
    "token": 12712,
    "token_str": "menanam"
  },
  {
    "sequence": "[CLS] ayahku sedang bekerja di sawah untuk bertani padi [SEP]",
    "score": 0.03739545866847038,
    "token": 15484,
    "token_str": "bertani"
  },
  {
    "sequence": "[CLS] ayahku sedang bekerja di sawah untuk memetik padi [SEP]",
    "score": 0.02742469497025013,
    "token": 30338,
    "token_str": "memetik"
  },
  {
    "sequence": "[CLS] ayahku sedang bekerja di sawah untuk penggilingan padi [SEP]",
    "score": 0.02214187942445278,
    "token": 28252,
    "token_str": "penggilingan"
  },
  {
    "sequence": "[CLS] ayahku sedang bekerja di sawah untuk tanam padi [SEP]",
    "score": 0.0185895636677742,
    "token": 11308,
    "token_str": "tanam"
  }
]

```
Here is how to use this model to get the features of a given text in PyTorch:
```python
from transformers import DistilBertTokenizer, DistilBertModel

model_name='cahya/distilbert-base-indonesian'
tokenizer = DistilBertTokenizer.from_pretrained(model_name)
model = DistilBertModel.from_pretrained(model_name)
text = "Silakan diganti dengan text apa saja."
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)
```
and in Tensorflow:
```python
from transformers import DistilBertTokenizer, TFDistilBertModel

model_name='cahya/distilbert-base-indonesian'
tokenizer = DistilBertTokenizer.from_pretrained(model_name)
model = TFDistilBertModel.from_pretrained(model_name)
text = "Silakan diganti dengan text apa saja."
encoded_input = tokenizer(text, return_tensors='tf')
output = model(encoded_input)
```

## Training data

This model was distiled with 522MB of indonesian Wikipedia and 1GB of
[indonesian newspapers](https://huggingface.co/datasets/id_newspapers_2018).
The texts are lowercased and tokenized using WordPiece and a vocabulary size of 32,000. The inputs of the model are 
then of the form:

```[CLS] Sentence A [SEP] Sentence B [SEP]```