Albert Large V2
ALBERT Large v2是基於英語語料、採用掩碼語言建模(MLM)目標預訓練的Transformer模型,具有參數共享的特點。
下載量 6,841
發布時間 : 3/2/2022
模型概述
該模型是一個基於Transformer架構的自監督學習模型,主要用於自然語言處理任務,如文本分類、問答系統等。
模型特點
參數共享
ALBERT在Transformer中共享各層的參數,減少了內存佔用。
高效預訓練
通過掩碼語言建模和句子順序預測兩個目標進行預訓練,學習語言的深層表示。
版本改進
版本2相比版本1有更好的性能,得益於不同的丟棄率、額外的訓練數據和更長的訓練時間。
模型能力
文本特徵提取
掩碼語言建模
句子順序預測
下游任務微調
使用案例
自然語言處理
文本分類
使用ALBERT模型生成的特徵作為輸入來訓練標準分類器。
問答系統
在問答任務上進行微調,如SQuAD數據集。
在SQuAD2.0上達到84.9/81.8的F1/EM分數
🚀 ALBERT Large v2
ALBERT Large v2是一個基於英語語料庫,採用掩碼語言模型(MLM)目標進行預訓練的模型。它能學習到英語語言的內在表示,可用於提取對下游任務有用的特徵,在多個自然語言處理任務中表現出色。
🚀 快速開始
你可以直接使用該模型進行掩碼語言建模,也能將其微調用於下游任務。以下是使用該模型的簡單示例:
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='albert-large-v2')
>>> unmasker("Hello I'm a [MASK] model.")
[
{
"sequence":"[CLS] hello i'm a modeling model.[SEP]",
"score":0.05816134437918663,
"token":12807,
"token_str":"â–modeling"
},
{
"sequence":"[CLS] hello i'm a modelling model.[SEP]",
"score":0.03748830780386925,
"token":23089,
"token_str":"â–modelling"
},
{
"sequence":"[CLS] hello i'm a model model.[SEP]",
"score":0.033725276589393616,
"token":1061,
"token_str":"â–model"
},
{
"sequence":"[CLS] hello i'm a runway model.[SEP]",
"score":0.017313428223133087,
"token":8014,
"token_str":"â–runway"
},
{
"sequence":"[CLS] hello i'm a lingerie model.[SEP]",
"score":0.014405295252799988,
"token":29104,
"token_str":"â–lingerie"
}
]
✨ 主要特性
- 自監督預訓練:在大量英語數據上進行自監督學習,學習到英語語言的內在表示。
- 雙向表示學習:通過掩碼語言建模(MLM),模型能夠學習到句子的雙向表示。
- 參數共享:在Transformer層之間共享參數,減少了內存佔用。
- 版本改進:版本2在版本1的基礎上,調整了丟棄率、增加了訓練數據和訓練時長,在幾乎所有下游任務中都取得了更好的效果。
📦 安裝指南
文檔未提及安裝步驟,故跳過此章節。
💻 使用示例
基礎用法
以下是使用該模型獲取給定文本特徵的PyTorch代碼示例:
from transformers import AlbertTokenizer, AlbertModel
tokenizer = AlbertTokenizer.from_pretrained('albert-large-v2')
model = AlbertModel.from_pretrained("albert-large-v2")
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)
高級用法
以下是使用該模型獲取給定文本特徵的TensorFlow代碼示例:
from transformers import AlbertTokenizer, TFAlbertModel
tokenizer = AlbertTokenizer.from_pretrained('albert-large-v2')
model = TFAlbertModel.from_pretrained("albert-large-v2")
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='tf')
output = model(encoded_input)
📚 詳細文檔
預期用途與限制
你可以使用原始模型進行掩碼語言建模或下一句預測,但它主要用於下游任務的微調。該模型主要針對需要使用整個句子(可能經過掩碼處理)進行決策的任務進行微調,如序列分類、標記分類或問答任務。對於文本生成等任務,你應該考慮使用GPT2等模型。
侷限性和偏差
即使該模型使用的訓練數據可以被認為是相當中立的,但模型仍可能產生有偏差的預測。這種偏差也會影響該模型的所有微調版本。
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='albert-large-v2')
>>> unmasker("The man worked as a [MASK].")
[
{
"sequence":"[CLS] the man worked as a chauffeur.[SEP]",
"score":0.029577180743217468,
"token":28744,
"token_str":"â–chauffeur"
},
{
"sequence":"[CLS] the man worked as a janitor.[SEP]",
"score":0.028865724802017212,
"token":29477,
"token_str":"â–janitor"
},
{
"sequence":"[CLS] the man worked as a shoemaker.[SEP]",
"score":0.02581118606030941,
"token":29024,
"token_str":"â–shoemaker"
},
{
"sequence":"[CLS] the man worked as a blacksmith.[SEP]",
"score":0.01849772222340107,
"token":21238,
"token_str":"â–blacksmith"
},
{
"sequence":"[CLS] the man worked as a lawyer.[SEP]",
"score":0.01820771023631096,
"token":3672,
"token_str":"â–lawyer"
}
]
>>> unmasker("The woman worked as a [MASK].")
[
{
"sequence":"[CLS] the woman worked as a receptionist.[SEP]",
"score":0.04604868218302727,
"token":25331,
"token_str":"â–receptionist"
},
{
"sequence":"[CLS] the woman worked as a janitor.[SEP]",
"score":0.028220869600772858,
"token":29477,
"token_str":"â–janitor"
},
{
"sequence":"[CLS] the woman worked as a paramedic.[SEP]",
"score":0.0261906236410141,
"token":23386,
"token_str":"â–paramedic"
},
{
"sequence":"[CLS] the woman worked as a chauffeur.[SEP]",
"score":0.024797942489385605,
"token":28744,
"token_str":"â–chauffeur"
},
{
"sequence":"[CLS] the woman worked as a waitress.[SEP]",
"score":0.024124596267938614,
"token":13678,
"token_str":"â–waitress"
}
]
訓練數據
ALBERT模型在BookCorpus和英文維基百科(不包括列表、表格和標題)上進行了預訓練。BookCorpus包含11,038本未出版的書籍。
訓練過程
預處理
文本先進行小寫處理,然後使用SentencePiece進行分詞,詞彙表大小為30,000。模型的輸入形式如下:
[CLS] Sentence A [SEP] Sentence B [SEP]
訓練
ALBERT的訓練過程遵循BERT的設置。每個句子的掩碼處理細節如下:
- 15%的標記被掩碼。
- 在80%的情況下,被掩碼的標記被替換為
[MASK]
。 - 在10%的情況下,被掩碼的標記被替換為一個隨機標記。
- 在剩下10%的情況下,被掩碼的標記保持不變。
評估結果
在下游任務上進行微調時,ALBERT模型取得了以下結果:
平均值 | SQuAD1.1 | SQuAD2.0 | MNLI | SST-2 | RACE | |
---|---|---|---|---|---|---|
V2 | ||||||
ALBERT-base | 82.3 | 90.2/83.2 | 82.1/79.3 | 84.6 | 92.9 | 66.8 |
ALBERT-large | 85.7 | 91.8/85.2 | 84.9/81.8 | 86.5 | 94.9 | 75.2 |
ALBERT-xlarge | 87.9 | 92.9/86.4 | 87.9/84.1 | 87.9 | 95.4 | 80.7 |
ALBERT-xxlarge | 90.9 | 94.6/89.1 | 89.8/86.9 | 90.6 | 96.8 | 86.8 |
V1 | ||||||
ALBERT-base | 80.1 | 89.3/82.3 | 80.0/77.1 | 81.6 | 90.3 | 64.0 |
ALBERT-large | 82.4 | 90.6/83.9 | 82.3/79.4 | 83.5 | 91.7 | 68.5 |
ALBERT-xlarge | 85.5 | 92.5/86.1 | 86.1/83.1 | 86.4 | 92.4 | 74.8 |
ALBERT-xxlarge | 91.0 | 94.8/89.3 | 90.2/87.4 | 90.8 | 96.9 | 86.5 |
🔧 技術細節
ALBERT是一種基於Transformer架構的模型,它在Transformer層之間共享參數,從而減少了內存佔用。該模型使用掩碼語言建模(MLM)和句子順序預測(SOP)作為預訓練目標,學習英語語言的內在表示。
該模型具有以下配置:
- 24個重複層
- 128維嵌入維度
- 1024維隱藏維度
- 16個注意力頭
- 1700萬個參數
📄 許可證
本項目採用Apache-2.0許可證。
BibTeX引用和引用信息
@article{DBLP:journals/corr/abs-1909-11942,
author = {Zhenzhong Lan and
Mingda Chen and
Sebastian Goodman and
Kevin Gimpel and
Piyush Sharma and
Radu Soricut},
title = {{ALBERT:} {A} Lite {BERT} for Self-supervised Learning of Language
Representations},
journal = {CoRR},
volume = {abs/1909.11942},
year = {2019},
url = {http://arxiv.org/abs/1909.11942},
archivePrefix = {arXiv},
eprint = {1909.11942},
timestamp = {Fri, 27 Sep 2019 13:04:21 +0200},
biburl = {https://dblp.org/rec/journals/corr/abs-1909-11942.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
Phi 2 GGUF
其他
Phi-2是微軟開發的一個小型但強大的語言模型,具有27億參數,專注於高效推理和高質量文本生成。
大型語言模型 支持多種語言
P
TheBloke
41.5M
205
Roberta Large
MIT
基於掩碼語言建模目標預訓練的大型英語語言模型,採用改進的BERT訓練方法
大型語言模型 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基礎模型的蒸餾版本,在保持相近性能的同時更輕量高效,適用於序列分類、標記分類等自然語言處理任務。
大型語言模型 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一個多語言大語言模型,針對多語言對話用例進行了優化,在常見的行業基準測試中表現優異。
大型語言模型 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基於100種語言的2.5TB過濾CommonCrawl數據預訓練的多語言模型,採用掩碼語言建模目標進行訓練。
大型語言模型 支持多種語言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基於Transformer架構的英語預訓練模型,通過掩碼語言建模目標在海量文本上訓練,支持文本特徵提取和下游任務微調
大型語言模型 英語
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI發佈的開放預訓練Transformer語言模型套件,參數量從1.25億到1750億,旨在對標GPT-3系列性能,同時促進大規模語言模型的開放研究。
大型語言模型 英語
O
facebook
6.3M
198
1
基於transformers庫的預訓練模型,適用於多種NLP任務
大型語言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多語言大語言模型系列,包含8B、70B和405B參數規模,支持8種語言和代碼生成,優化了多語言對話場景。
大型語言模型
Transformers 支持多種語言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基礎版是由Google開發的文本到文本轉換Transformer模型,參數規模2.2億,支持多語言NLP任務。
大型語言模型 支持多種語言
T
google-t5
5.4M
702
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98