Update README.md
Browse files
README.md
CHANGED
@@ -65,4 +65,18 @@ with torch.no_grad():
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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`
|
71 |
+
|
72 |
+
```python
|
73 |
+
import torch
|
74 |
+
from transformers import AutoTokenizer
|
75 |
+
from TweetNormalizer import normalizeTweet
|
76 |
+
|
77 |
+
tokenizer = AutoTokenizer.from_pretrained("vinai/bertweet-large")
|
78 |
+
|
79 |
+
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 😢")
|
80 |
+
|
81 |
+
input_ids = torch.tensor([tokenizer.encode(line)])
|
82 |
+
```
|