Albert Xxlarge V2
ALBERT XXLarge v2是基於掩碼語言建模目標預訓練的大型語言模型,採用參數共享的Transformer架構,具有12層重複結構和2.23億參數。
下載量 19.79k
發布時間 : 3/2/2022
模型概述
該模型是ALBERT系列中的最大版本,通過共享層參數減少內存佔用,在多項NLP任務中表現優異。主要用於文本特徵提取和下游任務微調。
模型特點
參數共享架構
通過共享所有Transformer層的參數,顯著減少模型內存佔用
雙目標預訓練
同時使用掩碼語言建模(MLM)和句子順序預測(SOP)進行預訓練
大規模預訓練數據
使用BookCorpus和英文維基百科進行訓練,覆蓋廣泛文本類型
版本改進
v2版本通過調整dropout率和延長訓練時間,性能優於v1版本
模型能力
文本特徵提取
掩碼語言預測
句子順序判斷
下游任務微調
使用案例
自然語言理解
文本分類
可用於情感分析、主題分類等任務
在SST-2情感分析任務中達到96.8%準確率
問答系統
用於構建開放域問答系統
在SQuAD2.0問答任務中達到89.8/86.9的EM/F1分數
語言模型研究
語言表示學習
研究參數共享架構對語言表示的影響
🚀 ALBERT XXLarge v2
ALBERT XXLarge v2 是一個基於英文語料庫,採用掩碼語言模型(MLM)目標進行預訓練的模型。它能夠學習英文語言的內部表示,可用於提取對下游任務有用的特徵。
🚀 快速開始
你可以直接使用此模型進行掩碼語言建模或下一句預測,但它主要用於在下游任務上進行微調。可訪問 模型中心 查找針對你感興趣任務的微調版本。
✨ 主要特性
- 雙向表示學習:通過掩碼語言建模(MLM),模型能夠學習句子的雙向表示。
- 句子順序預測:使用基於預測兩個連續文本片段順序的預訓練損失。
- 參數共享:在 Transformer 中共享層,減少內存佔用。
- 版本優化:版本 2 由於不同的丟棄率、額外的訓練數據和更長的訓練時間,在幾乎所有下游任務中都有更好的表現。
📦 安裝指南
文檔未提及安裝步驟,故跳過此章節。
💻 使用示例
基礎用法
你可以使用管道直接進行掩碼語言建模:
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='albert-xxlarge-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"
}
]
高級用法
以下是在 PyTorch 中使用此模型獲取給定文本特徵的方法:
from transformers import AlbertTokenizer, AlbertModel
tokenizer = AlbertTokenizer.from_pretrained('albert-xxlarge-v2')
model = AlbertModel.from_pretrained("albert-xxlarge-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-xxlarge-v2')
model = TFAlbertModel.from_pretrained("albert-xxlarge-v2")
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='tf')
output = model(encoded_input)
📚 詳細文檔
模型描述
ALBERT 是一個基於自監督方式在大量英文數據語料庫上進行預訓練的 Transformer 模型。它通過自動從文本中生成輸入和標籤的過程進行預訓練,主要有兩個目標:
- 掩碼語言建模(MLM):隨機掩蓋句子中 15% 的單詞,然後讓模型預測這些被掩蓋的單詞,從而學習句子的雙向表示。
- 句子順序預測(SOP):基於預測兩個連續文本片段的順序進行預訓練。
ALBERT 的特殊之處在於它在 Transformer 中共享層,所有層具有相同的權重,這使得內存佔用較小,但計算成本與具有相同隱藏層數的 BERT 架構相似。
此模型具有以下配置:
屬性 | 詳情 |
---|---|
層數 | 12 個重複層 |
嵌入維度 | 128 |
隱藏維度 | 4096 |
注意力頭數 | 64 |
參數數量 | 2.23 億 |
預期用途和侷限性
該模型主要用於需要使用整個句子(可能被掩碼)進行決策的任務,如序列分類、標記分類或問答。對於文本生成等任務,建議使用 GPT2 等模型。
侷限性和偏差
即使該模型使用的訓練數據相對中立,但它仍可能存在有偏差的預測。例如:
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='albert-xxlarge-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 和 英文維基百科(不包括列表、表格和標題)上進行預訓練。
訓練過程
預處理
文本先轉換為小寫,然後使用 SentencePiece 進行分詞,詞彙表大小為 30,000。模型的輸入形式如下:
[CLS] 句子 A [SEP] 句子 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 |
🔧 技術細節
文檔未提及技術實現細節,故跳過此章節。
📄 許可證
本項目採用 Apache - 2.0 許可證。

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