BERTweet
1.0.0
transformers 와 함께 Bertweet 사용fairseq 와 함께 Bertweet 사용Bertweet는 영어 트윗을 위해 미리 훈련 된 최초의 공개 대규모 언어 모델입니다. Bertweet는 Roberta 사전 훈련 절차를 기반으로 교육을받습니다. Bertweet를 사전 트레인하는 데 사용되는 코퍼스는 850m 영어 트윗 (16B 단어 토큰 ~ 80GB)으로 구성되며, 2012 년 1 월 1 일부터 2019 년 8 월 8 일까지 845m 트윗과 Covid-19 Pandemic과 관련된 5m 트윗이 포함되어 있습니다. Bertweet의 일반적인 아키텍처 및 실험 결과는 다음과 같습니다.
@inproceedings{bertweet,
title = {{BERTweet: A pre-trained language model for English Tweets}},
author = {Dat Quoc Nguyen and Thanh Vu and Anh Tuan Nguyen},
booktitle = {Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations},
pages = {9--14},
year = {2020}
}
Bertweet가 게시 된 결과를 생성하는 데 도움이되거나 다른 소프트웨어에 통합되는 데 사용되는 경우 논문을 인용하십시오 .




transformers 와 함께 Bertweet 사용pip install transformers transformers 설치하거나 소스에서 변압기를 설치하여 transformers 설치하십시오.transformers 브랜치로 병합했습니다. 이 풀트 요청에서 언급 한 바와 같이 Bertweet에 대한 빠른 토큰 화기 병합 과정은 논의 중입니다. 사용자가 빠른 토큰 화기를 사용하려면 사용자가 다음과 같이 transformers 설치할 수 있습니다. git clone --single-branch --branch fast_tokenizers_BARTpho_PhoBERT_BERTweet https://github.com/datquocnguyen/transformers.git
cd transformers
pip3 install -e .
pip3 install tokenizers 설치 tokenizers 사용하여 토큰 화제를 설치하십시오| 모델 | #Params | 아치. | 최대 길이 | 사전 훈련 데이터 |
|---|---|---|---|---|
vinai/bertweet-base | 135m | 베이스 | 128 | 850m 영어 트윗 (케이스) |
vinai/bertweet-covid19-base-cased | 135m | 베이스 | 128 | 23m Covid-19 영어 트윗 (케이스) |
vinai/bertweet-covid19-base-uncased | 135m | 베이스 | 128 | 23m Covid-19 영어 트윗 (기반) |
vinai/bertweet-large | 355m | 크기가 큰 | 512 | 873m 영어 트윗 (케이스) |
vinai/bertweet-covid19-base-cased 및 vinai/bertweet-covid19-base-uncased 23m Covid-19 Englishets의 코퍼스에서 사전 훈련 된 모델 vinai/bertweet-base 추가로 미리 훈련시킴으로써 발생합니다.vinai/bertweet-large 출시. import torch
from transformers import AutoModel , AutoTokenizer
bertweet = AutoModel . from_pretrained ( "vinai/bertweet-large" )
tokenizer = AutoTokenizer . from_pretrained ( "vinai/bertweet-large" )
# INPUT TWEET IS ALREADY NORMALIZED!
line = "DHEC confirms HTTPURL via @USER :crying_face:"
input_ids = torch . tensor ([ tokenizer . encode ( line )])
with torch . no_grad ():
features = bertweet ( input_ids ) # Models outputs are now tuples
## With TensorFlow 2.0+:
# from transformers import TFAutoModel
# bertweet = TFAutoModel.from_pretrained("vinai/bertweet-large") 영어 트윗의 사전 훈련 코퍼스에 BPE를 적용하기 전에 NLTK 툴킷에서 TweetTokenizer 사용 하여이 트윗을 토큰 화하고 감정 아이콘을 텍스트 문자열로 변환하기 위해 emoji 패키지를 사용했습니다 (여기, 각 아이콘은 Word Token이라고합니다). 또한 사용자 언급과 웹/URL 링크를 특수 토큰 @USER 및 HTTPURL 로 변환하여 트윗을 정규화했습니다. 따라서 Bertweet 기반 다운 스트림 애플리케이션에 대해 동일한 사전 처리 단계를 적용하는 것이 좋습니다.
원시 입력 트윗이 주어지면 동일한 사전 처리 출력을 얻으려면 사용자가 트윗을 사용하여 트윗을 사용할 수 있습니다.
pip3 install nltk emoji==0.6.0emoji 버전은 0.5.4 또는 0.6.0이어야합니다. 최신 emoji 버전은 최신 버전의 이모티콘 차트로 업데이트되었으므로 사전 훈련 트윗 코퍼스를 사전 처리하는 데 사용되는 것과 일치하지 않습니다. import torch
from transformers import AutoTokenizer
from TweetNormalizer import normalizeTweet
tokenizer = AutoTokenizer . from_pretrained ( "vinai/bertweet-large" )
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 ?" )
input_ids = torch . tensor ([ tokenizer . encode ( line )])fairseq 와 함께 Bertweet 사용여기에서 자세한 내용을 참조하십시오!
MIT License
Copyright (c) 2020-2021 VinAI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.