Update model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: lucid
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
tags:
|
| 5 |
+
- base
|
| 6 |
+
- bert
|
| 7 |
+
- lucid
|
| 8 |
+
datasets:
|
| 9 |
+
- wikipedia
|
| 10 |
+
- bookcorpus
|
| 11 |
+
pipeline_tag: feature-extraction
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# BERT-Small
|
| 15 |
+
|
| 16 |
+
> https://arxiv.org/abs/1810.04805
|
| 17 |
+
|
| 18 |
+
[Lucid](https://github.com/ChanLumerico/lucid) port of `transformers/google/bert_uncased_L-4_H-512_A-8`,
|
| 19 |
+
converted to Lucid-native safetensors.
|
| 20 |
+
|
| 21 |
+
## Available weights
|
| 22 |
+
|
| 23 |
+
| Tag | Params | GFLOPs | Size | Source |
|
| 24 |
+
|---|---|---|---|---|
|
| 25 |
+
| `WIKIPEDIA_BOOKSCORPUS` *(default)* | 28.8M | — | 109.73 MB | transformers |
|
| 26 |
+
|
| 27 |
+
## Usage
|
| 28 |
+
|
| 29 |
+
```python
|
| 30 |
+
import lucid
|
| 31 |
+
import lucid.models as models
|
| 32 |
+
from lucid.models.weights import BertSmallWeights
|
| 33 |
+
|
| 34 |
+
# default tag
|
| 35 |
+
model = models.bert_small(pretrained=True)
|
| 36 |
+
|
| 37 |
+
# explicit tag (enum or string)
|
| 38 |
+
model = models.bert_small(weights=BertSmallWeights.WIKIPEDIA_BOOKSCORPUS)
|
| 39 |
+
model = models.bert_small(pretrained="WIKIPEDIA_BOOKSCORPUS")
|
| 40 |
+
|
| 41 |
+
# feed token ids (tokenize with the matching lucid.utils.tokenizer)
|
| 42 |
+
input_ids = lucid.tensor([[101, 7592, 2088, 102]], dtype=lucid.int64)
|
| 43 |
+
out = model(input_ids)
|
| 44 |
+
hidden = out.last_hidden_state # (B, T, hidden_size)
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
## Conversion
|
| 48 |
+
|
| 49 |
+
Converted from `transformers/google/bert_uncased_L-4_H-512_A-8` via
|
| 50 |
+
`python -m tools.convert_weights bert_small --tag WIKIPEDIA_BOOKSCORPUS`.
|
| 51 |
+
Key mapping + numerical parity verified against the source.
|
| 52 |
+
|
| 53 |
+
## License
|
| 54 |
+
|
| 55 |
+
`apache-2.0` — inherited from the original weights.
|
| 56 |
+
|
| 57 |
+
## Citation
|
| 58 |
+
|
| 59 |
+
```
|
| 60 |
+
Devlin et al., "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding", NAACL 2019. Miniatures: Turc et al., "Well-Read Students Learn Better", 2019.
|
| 61 |
+
```
|