Keras 3 API 文件 / KerasNLP / KerasNLP 模型

KerasNLP 模型

KerasNLP 包含熱門模型架構的端到端實現。這些模型可以通过两种方式創建

  • 通過 from_preset() 構造函數,它會實例化一個具有預先訓練好的配置、詞彙表和(可選)權重的物件。
  • 通過用戶控制的自定义配置。

下面,我們列出了函式庫中可用的所有預設值。有關更詳細的使用方法,請瀏覽特定類別的說明文件。有關我們 API 的詳細介紹,請參閱入門指南

預設值

以下預設名稱對應於預訓練模型的配置和權重。任何任務、預處理器、骨幹或分詞器 from_preset() 都可以用於從保存的預設值創建模型。

backbone = keras_nlp.models.Backbone.from_preset("bert_base_en")
tokenizer = keras_nlp.models.Tokenizer.from_preset("bert_base_en")
classifier = keras_nlp.models.TextClassifier.from_preset("bert_base_en", num_classes=2)
preprocessor = keras_nlp.models.TextClassifierPreprocessor.from_preset("bert_base_en")
預設名稱 模型 參數 說明
albert_base_en_uncased ALBERT 11.68M 12 層 ALBERT 模型,所有輸入都小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡
albert_large_en_uncased ALBERT 17.68M 24 層 ALBERT 模型,所有輸入都小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡
albert_extra_large_en_uncased ALBERT 58.72M 24 層 ALBERT 模型,所有輸入都小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡
albert_extra_extra_large_en_uncased ALBERT 222.60M 12 層 ALBERT 模型,所有輸入都小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡
bart_base_en BART 139.42M 6 層 BART 模型,保留大小寫。在 BookCorpus、英文維基百科和 CommonCrawl 上訓練。模型卡
bart_large_en BART 406.29M 12 層 BART 模型,保留大小寫。在 BookCorpus、英文維基百科和 CommonCrawl 上訓練。模型卡
bart_large_en_cnn BART 406.29M 在 CNN+DM 摘要數據集上微調的 bart_large_en 骨幹模型。模型卡片
bert_tiny_en_uncased BERT 4.39M 2 層 BERT 模型,所有輸入均為小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡片
bert_small_en_uncased BERT 28.76M 4 層 BERT 模型,所有輸入均為小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡片
bert_medium_en_uncased BERT 41.37M 8 層 BERT 模型,所有輸入均為小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡片
bert_base_en_uncased BERT 109.48M 12 層 BERT 模型,所有輸入均為小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡片
bert_base_en BERT 108.31M 12 層 BERT 模型,保留大小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡片
bert_base_zh BERT 102.27M 12 層 BERT 模型。在中文維基百科上訓練。模型卡片
bert_base_multi BERT 177.85M 12 層 BERT 模型,保留大小寫。在 104 種語言的維基百科上訓練模型卡片
bert_large_en_uncased BERT 335.14M 24 層 BERT 模型,所有輸入均為小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡片
bert_large_en BERT 333.58M 24 層 BERT 模型,保留大小寫。在英文維基百科 + BooksCorpus 上訓練。模型卡片
bert_tiny_en_uncased_sst2 BERT 4.39M 在 SST-2 情感分析數據集上微調的 bert_tiny_en_uncased 骨幹模型。模型卡片
bloom_560m_multi BLOOM 559.21M 具有 1024 個隱藏維度的 24 層 Bloom 模型。在 45 種自然語言和 12 種程式語言上訓練。模型卡片
bloom_1.1b_multi BLOOM 1.07B 具有 1536 個隱藏維度的 24 層 Bloom 模型。在 45 種自然語言和 12 種程式語言上訓練。模型卡片
bloom_1.7b_multi BLOOM 1.72B 具有 2048 個隱藏維度的 24 層 Bloom 模型。在 45 種自然語言和 12 種程式語言上訓練。模型卡片
bloom_3b_multi BLOOM 3.00B 具有 2560 個隱藏維度的 30 層 Bloom 模型。在 45 種自然語言和 12 種程式語言上訓練。模型卡片
bloomz_560m_multi BLOOMZ 559.21M 具有 1024 個隱藏維度的 24 層 Bloom 模型。在跨語言任務混合 (xP3) 數據集上微調。模型卡片
bloomz_1.1b_multi BLOOMZ 1.07B 具有 1536 個隱藏維度的 24 層 Bloom 模型。在跨語言任務混合 (xP3) 數據集上微調。模型卡片
bloomz_1.7b_multi BLOOMZ 1.72B 具有 2048 個隱藏維度的 24 層 Bloom 模型。在跨語言任務混合 (xP3) 數據集上微調。模型卡片
bloomz_3b_multi BLOOMZ 3.00B 具有 2560 個隱藏維度的 30 層 Bloom 模型。在跨語言任務混合 (xP3) 數據集上微調。模型卡片
deberta_v3_extra_small_en DeBERTaV3 70.68M 12 層 DeBERTaV3 模型,保留大小寫。在英文維基百科、BookCorpus 和 OpenWebText 上訓練。模型卡片
deberta_v3_small_en DeBERTaV3 141.30M 6 層 DeBERTaV3 模型,保留大小寫。 根據英文維基百科、BookCorpus 和 OpenWebText 訓練。 模型說明
deberta_v3_base_en DeBERTaV3 183.83M 12 層 DeBERTaV3 模型,保留大小寫。 根據英文維基百科、BookCorpus 和 OpenWebText 訓練。 模型說明
deberta_v3_large_en DeBERTaV3 434.01M 24 層 DeBERTaV3 模型,保留大小寫。 根據英文維基百科、BookCorpus 和 OpenWebText 訓練。 模型說明
deberta_v3_base_multi DeBERTaV3 278.22M 12 層 DeBERTaV3 模型,保留大小寫。 根據 2.5TB 多語言 CC100 資料集訓練。 模型說明
distil_bert_base_en_uncased DistilBERT 66.36M 6 層 DistilBERT 模型,所有輸入皆為小寫。 根據英文維基百科和 BooksCorpus 訓練,並以 BERT 作為教師模型。 模型說明
distil_bert_base_en DistilBERT 65.19M 6 層 DistilBERT 模型,保留大小寫。 根據英文維基百科和 BooksCorpus 訓練,並以 BERT 作為教師模型。 模型說明
distil_bert_base_multi DistilBERT 134.73M 6 層 DistilBERT 模型,保留大小寫。 根據 104 種語言的維基百科訓練。 模型說明
electra_small_discriminator_uncased_en ELECTRA 13.55M 12 層小型 ELECTRA 鑑別器模型。 所有輸入皆為小寫。 根據英文維基百科和 BooksCorpus 訓練。 模型說明
electra_small_generator_uncased_en ELECTRA 13.55M 12 層小型 ELECTRA 生成器模型。 所有輸入皆為小寫。 根據英文維基百科和 BooksCorpus 訓練。 模型說明
electra_base_discriminator_uncased_en ELECTRA 109.48M 12 層基本 ELECTRA 鑑別器模型。 所有輸入皆為小寫。 根據英文維基百科和 BooksCorpus 訓練。 模型說明
electra_base_generator_uncased_en ELECTRA 33.58M 12 層基本 ELECTRA 生成器模型。 所有輸入皆為小寫。 根據英文維基百科和 BooksCorpus 訓練。 模型說明
electra_large_discriminator_uncased_en ELECTRA 335.14M 24 層大型 ELECTRA 鑑別器模型。 所有輸入皆為小寫。 根據英文維基百科和 BooksCorpus 訓練。 模型說明
electra_large_generator_uncased_en ELECTRA 51.07M 24 層大型 ELECTRA 生成器模型。 所有輸入皆為小寫。 根據英文維基百科和 BooksCorpus 訓練。 模型說明
f_net_base_en FNet 82.86M 12 層 FNet 模型,保留大小寫。 根據 C4 資料集訓練。 模型說明
f_net_large_en FNet 236.95M 24 層 FNet 模型,保留大小寫。 根據 C4 資料集訓練。 模型說明
falcon_refinedweb_1b_en Falcon 1.31B 24 層 Falcon 模型(Falcon 具有 10 億個參數),根據 3500 億個 RefinedWeb 資料集的詞彙訓練。 模型說明
gemma_2b_en Gemma 2.51B 20 億個參數、18 層的基本 Gemma 模型。 模型說明
gemma_instruct_2b_en Gemma 2.51B 20 億個參數、18 層,經過指令微調的 Gemma 模型。 模型說明
gemma_1.1_instruct_2b_en Gemma 2.51B 20 億個參數、18 層,經過指令微調的 Gemma 模型。 1.1 版更新提升了模型品質。 模型說明
code_gemma_1.1_2b_en Gemma 2.51B 20 億個參數、18 層的 CodeGemma 模型。 這個模型已經過填空任務訓練,可用於程式碼完成。 1.1 版更新提升了模型品質。 模型說明
code_gemma_2b_en Gemma 2.51B 20 億個參數、18 層的 CodeGemma 模型。 這個模型已經過填空任務訓練,可用於程式碼完成。 模型說明
gemma_7b_en Gemma 8.54B 70 億個參數、28 層的基本 Gemma 模型。 模型說明
gemma_instruct_7b_en Gemma 8.54B 70 億參數、28 層、指令微調的 Gemma 模型。模型卡
gemma_1.1_instruct_7b_en Gemma 8.54B 70 億參數、28 層、指令微調的 Gemma 模型。1.1 版更新提升了模型品質。模型卡
code_gemma_7b_en Gemma 8.54B 70 億參數、28 層、CodeGemma 模型。此模型已針對程式碼完成的填空任務進行訓練。模型卡
code_gemma_instruct_7b_en Gemma 8.54B 70 億參數、28 層、指令微調的 CodeGemma 模型。此模型已針對與程式碼相關的聊天用例進行訓練。模型卡
code_gemma_1.1_instruct_7b_en Gemma 8.54B 70 億參數、28 層、指令微調的 CodeGemma 模型。此模型已針對與程式碼相關的聊天用例進行訓練。1.1 版更新提升了模型品質。模型卡
gemma2_2b_en Gemma 2.61B 20 億參數、26 層、基礎 Gemma 模型。模型卡
gemma2_instruct_2b_en Gemma 2.61B 20 億參數、26 層、指令微調的 Gemma 模型。模型卡
gemma2_9b_en Gemma 9.24B 90 億參數、42 層、基礎 Gemma 模型。模型卡
gemma2_instruct_9b_en Gemma 9.24B 90 億參數、42 層、指令微調的 Gemma 模型。模型卡
gemma2_27b_en Gemma 27.23B 270 億參數、42 層、基礎 Gemma 模型。模型卡
gemma2_instruct_27b_en Gemma 27.23B 270 億參數、42 層、指令微調的 Gemma 模型。模型卡
shieldgemma_2b_en Gemma 2.61B 20 億參數、26 層、ShieldGemma 模型。模型卡
shieldgemma_9b_en Gemma 9.24B 90 億參數、42 層、ShieldGemma 模型。模型卡
shieldgemma_27b_en Gemma 27.23B 270 億參數、42 層、ShieldGemma 模型。模型卡
gpt2_base_en GPT-2 124.44M 12 層 GPT-2 模型,保留大小寫。使用 WebText 進行訓練。模型卡
gpt2_medium_en GPT-2 354.82M 24 層 GPT-2 模型,保留大小寫。使用 WebText 進行訓練。模型卡
gpt2_large_en GPT-2 774.03M 36 層 GPT-2 模型,保留大小寫。使用 WebText 進行訓練。模型卡
gpt2_extra_large_en GPT-2 1.56B 48 層 GPT-2 模型,保留大小寫。使用 WebText 進行訓練。模型卡
gpt2_base_en_cnn_dailymail GPT-2 124.44M 12 層 GPT-2 模型,保留大小寫。使用 CNN/DailyMail 摘要資料集進行微調。
llama3_8b_en LLaMA 3 8.03B 80 億參數、32 層、基礎 LLaMA 3 模型。模型卡
llama3_8b_en_int8 LLaMA 3 8.03B 80 億參數、32 層、基礎 LLaMA 3 模型,其激活和權重量化為 int8。模型卡
llama3_instruct_8b_en LLaMA 3 8.03B 80 億參數、32 層、指令微調的 LLaMA 3 模型。模型卡
llama3_instruct_8b_en_int8 LLaMA 3 8.03B 80 億參數、32 層、指令微調的 LLaMA 3 模型,其激活和權重量化為 int8。模型卡
llama2_7b_en LLaMA 2 6.74B 70 億參數、32 層、基礎 LLaMA 2 模型。模型卡
llama2_7b_en_int8 LLaMA 2 6.74B 70 億參數、32 層、基礎 LLaMA 2 模型,其激活和權重量化為 int8。模型卡
llama2_instruct_7b_en LLaMA 2 6.74B 70 億參數、32 層、指令微調的 LLaMA 2 模型。模型卡
llama2_instruct_7b_en_int8 LLaMA 2 6.74B 70 億參數、32 層、經過指令微調的 LLaMA 2 模型,其激活函數和權重量化為 int8 格式。模型說明卡
vicuna_1.5_7b_en Vicuna 6.74B 70 億參數、32 層、經過指令微調的 Vicuna v1.5 模型。模型說明卡
mistral_7b_en Mistral 72.4 億 Mistral 7B 基礎模型模型說明卡
mistral_instruct_7b_en Mistral 72.4 億 Mistral 7B 指令模型模型說明卡
mistral_0.2_instruct_7b_en Mistral 72.4 億 Mistral 7B 指令模型 0.2 版模型說明卡
opt_125m_en OPT 1.2524 億 12 層 OPT 模型,保留大小寫。 訓練資料集為 BookCorpus、CommonCrawl、Pile 和 PushShift.io 語料庫。模型說明卡
opt_1.3b_en OPT 13.2 億 24 層 OPT 模型,保留大小寫。 訓練資料集為 BookCorpus、CommonCrawl、Pile 和 PushShift.io 語料庫。模型說明卡
opt_2.7b_en OPT 27 億 32 層 OPT 模型,保留大小寫。 訓練資料集為 BookCorpus、CommonCrawl、Pile 和 PushShift.io 語料庫。模型說明卡
opt_6.7b_en OPT 67 億 32 層 OPT 模型,保留大小寫。 訓練資料集為 BookCorpus、CommonCrawl、Pile 和 PushShift.io 語料庫。模型說明卡
pali_gemma_3b_mix_224 PaliGemma 29.2 億 圖像大小 224,混合微調,文字序列長度為 256模型說明卡
pali_gemma_3b_mix_448 PaliGemma 29.2 億 圖像大小 448,混合微調,文字序列長度為 512模型說明卡
pali_gemma_3b_224 PaliGemma 29.2 億 圖像大小 224,預先訓練,文字序列長度為 128模型說明卡
pali_gemma_3b_448 PaliGemma 29.2 億 圖像大小 448,預先訓練,文字序列長度為 512模型說明卡
pali_gemma_3b_896 PaliGemma 29.3 億 圖像大小 896,預先訓練,文字序列長度為 512模型說明卡
phi3_mini_4k_instruct_en Phi-3 38.2 億 38 億參數、32 層、上下文長度 4k 的 Phi-3 模型。該模型使用 Phi-3 資料集進行訓練。此資料集包含合成資料和過濾後的公開網站資料,重點放在高品質和推理密集的特性。模型說明卡
phi3_mini_128k_instruct_en Phi-3 38.2 億 38 億參數、32 層、上下文長度 128k 的 Phi-3 模型。該模型使用 Phi-3 資料集進行訓練。此資料集包含合成資料和過濾後的公開網站資料,重點放在高品質和推理密集的特性。模型說明卡
roberta_base_en RoBERTa 1.2405 億 12 層 RoBERTa 模型,保留大小寫。訓練資料集為英文維基百科、BooksCorpus、CommonCrawl 和 OpenWebText。模型說明卡
roberta_large_en RoBERTa 3.5431 億 24 層 RoBERTa 模型,保留大小寫。訓練資料集為英文維基百科、BooksCorpus、CommonCrawl 和 OpenWebText。模型說明卡
t5_small_multi T5 0 8 層 T5 模型。訓練資料集為 Colossal Clean Crawled Corpus (C4)。模型說明卡
t5_base_multi T5 0 12 層 T5 模型。訓練資料集為 Colossal Clean Crawled Corpus (C4)。模型說明卡
t5_large_multi T5 0 24 層 T5 模型。訓練資料集為 Colossal Clean Crawled Corpus (C4)。模型說明卡
flan_small_multi T5 0 8 層 T5 模型。訓練資料集為 Colossal Clean Crawled Corpus (C4)。模型說明卡
flan_base_multi T5 0 12 層 T5 模型。訓練資料集為 Colossal Clean Crawled Corpus (C4)。模型說明卡
flan_large_multi T5 0 24 層 T5 模型。訓練資料集為 Colossal Clean Crawled Corpus (C4)。模型說明卡
whisper_tiny_en Whisper 3718 萬 4 層 Whisper 模型。 根據 438,000 小時的標記英語語音數據訓練而成。 模型卡
whisper_base_en Whisper 124.44M 6 層 Whisper 模型。 根據 438,000 小時的標記英語語音數據訓練而成。 模型卡
whisper_small_en Whisper 241.73M 12 層 Whisper 模型。 根據 438,000 小時的標記英語語音數據訓練而成。 模型卡
whisper_medium_en Whisper 763.86M 24 層 Whisper 模型。 根據 438,000 小時的標記英語語音數據訓練而成。 模型卡
whisper_tiny_multi Whisper 37.76M 4 層 Whisper 模型。 根據 680,000 小時的標記多語言語音數據訓練而成。 模型卡
whisper_base_multi Whisper 72.59M 6 層 Whisper 模型。 根據 680,000 小時的標記多語言語音數據訓練而成。 模型卡
whisper_small_multi Whisper 241.73M 12 層 Whisper 模型。 根據 680,000 小時的標記多語言語音數據訓練而成。 模型卡
whisper_medium_multi Whisper 763.86M 24 層 Whisper 模型。 根據 680,000 小時的標記多語言語音數據訓練而成。 模型卡
whisper_large_multi Whisper 1.54B 32 層 Whisper 模型。 根據 680,000 小時的標記多語言語音數據訓練而成。 模型卡
whisper_large_multi_v2 Whisper 1.54B 32 層 Whisper 模型。 針對 680,000 小時的標記多語言語音數據訓練 2.5 個時期。 whisper_large_multi 的改進版本。 模型卡
xlm_roberta_base_multi XLM-RoBERTa 277.45M 12 層 XLM-RoBERTa 模型,保留大小寫。 根據 100 種語言的 CommonCrawl 訓練而成。 模型卡
xlm_roberta_large_multi XLM-RoBERTa 558.84M 24 層 XLM-RoBERTa 模型,保留大小寫。 根據 100 種語言的 CommonCrawl 訓練而成。 模型卡

注意:提供的連結將會導向模型卡,如果作者未提供模型卡,則會導向官方 README。

API 文件

Albert

Bart

Bert

Bloom

DebertaV3

DistilBert

Gemma

Electra

Falcon

FNet

GPT2

Llama

Llama3

Mistral

OPT

PaliGemma

Phi3

Roberta

XLMRoberta