Update README.md
Browse files
README.md
CHANGED
|
@@ -27,57 +27,3 @@ For further information or requests, please go to [BERTweet's homepage](https://
|
|
| 27 |
<img width="275" alt="irony" src="https://user-images.githubusercontent.com/2412555/135724595-15f4f2c8-bbb6-4ee6-82a0-034769dec183.png" />
|
| 28 |
</p>
|
| 29 |
|
| 30 |
-
### <a name="models2"></a> Pre-trained models
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
Model | #params | Arch. | Pre-training data
|
| 34 |
-
---|---|---|---
|
| 35 |
-
`vinai/bertweet-base` | 135M | base | 850M English Tweets (cased)
|
| 36 |
-
`vinai/bertweet-covid19-base-cased` | 135M | base | 23M COVID-19 English Tweets (cased)
|
| 37 |
-
`vinai/bertweet-covid19-base-uncased` | 135M | base | 23M COVID-19 English Tweets (uncased)
|
| 38 |
-
`vinai/bertweet-large` | 355M | large | 873M English Tweets (cased)
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
### <a name="usage2"></a> Example usage
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
```python
|
| 45 |
-
import torch
|
| 46 |
-
from transformers import AutoModel, AutoTokenizer
|
| 47 |
-
|
| 48 |
-
bertweet = AutoModel.from_pretrained("vinai/bertweet-large")
|
| 49 |
-
tokenizer = AutoTokenizer.from_pretrained("vinai/bertweet-large")
|
| 50 |
-
|
| 51 |
-
# INPUT TWEET IS ALREADY NORMALIZED!
|
| 52 |
-
line = "SC has first two presumptive cases of coronavirus , DHEC confirms HTTPURL via @USER :cry:"
|
| 53 |
-
|
| 54 |
-
input_ids = torch.tensor([tokenizer.encode(line)])
|
| 55 |
-
|
| 56 |
-
with torch.no_grad():
|
| 57 |
-
features = bertweet(input_ids) # Models outputs are now tuples
|
| 58 |
-
|
| 59 |
-
## With TensorFlow 2.0+:
|
| 60 |
-
# from transformers import TFAutoModel
|
| 61 |
-
# bertweet = TFAutoModel.from_pretrained("vinai/bertweet-large")
|
| 62 |
-
```
|
| 63 |
-
|
| 64 |
-
### <a name="preprocess"></a> Normalize raw input Tweets
|
| 65 |
-
|
| 66 |
-
Before applying BPE to the pre-training corpus of English Tweets, we tokenized these Tweets using `TweetTokenizer` from the NLTK toolkit and used the `emoji` package to translate emotion icons into text strings (here, each icon is referred to as a word token). We also normalized the Tweets by converting user mentions and web/url links into special tokens `@USER` and `HTTPURL`, respectively. Thus it is recommended to also apply the same pre-processing step for BERTweet-based downstream applications w.r.t. the raw input Tweets.
|
| 67 |
-
|
| 68 |
-
For `vinai/bertweet-large`, given the raw input Tweets, to obtain the same pre-processing output, users could employ our [TweetNormalizer](https://github.com/VinAIResearch/BERTweet/blob/master/TweetNormalizer.py) module.
|
| 69 |
-
|
| 70 |
-
- Installation: `pip3 install nltk emoji==0.6.0`
|
| 71 |
-
- The `emoji` version must be either 0.5.4 or 0.6.0. Newer `emoji` versions have been updated to newer versions of the Emoji Charts, thus not consistent with the one used for pre-processing our pre-training Tweet corpus.
|
| 72 |
-
|
| 73 |
-
```python
|
| 74 |
-
import torch
|
| 75 |
-
from transformers import AutoTokenizer
|
| 76 |
-
from TweetNormalizer import normalizeTweet
|
| 77 |
-
|
| 78 |
-
tokenizer = AutoTokenizer.from_pretrained("vinai/bertweet-large")
|
| 79 |
-
|
| 80 |
-
line = normalizeTweet("DHEC confirms https://postandcourier.com/health/covid19/sc-has-first-two-presumptive-cases-of-coronavirus-dhec-confirms/article_bddfe4ae-5fd3-11ea-9ce4-5f495366cee6.html?utm_medium=social&utm_source=twitter&utm_campaign=user-share… via @postandcourier 😢")
|
| 81 |
-
|
| 82 |
-
input_ids = torch.tensor([tokenizer.encode(line)])
|
| 83 |
-
```
|
|
|
|
| 27 |
<img width="275" alt="irony" src="https://user-images.githubusercontent.com/2412555/135724595-15f4f2c8-bbb6-4ee6-82a0-034769dec183.png" />
|
| 28 |
</p>
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|