模型概述
模型特點
模型能力
使用案例
🚀 LAION LeoLM:語言增強型開放語言模型
LAION LeoLM 是首個基於 Llama - 2 和 Mistral 構建的、開放且可用於商業用途的德語基礎語言模型。該模型通過在大量德語語料庫(主要是特定地區文本)上持續預訓練,將 Llama - 2 的能力拓展到了德語領域。
得益於黑森州人工智能中心(HessianAI)新超級計算機“42”的計算資源支持,我們發佈了三個上下文長度為 8k 的基礎模型。其中,[LeoLM/leo - mistral - hessianai - 7b
](https://huggingface.co/LeoLM/leo - mistral - hessianai - 7b) 採用 Apache 2.0 許可證,[LeoLM/leo - hessianai - 7b
](https://huggingface.co/LeoLM/leo - hessianai - 7b) 和 [LeoLM/leo - hessianai - 13b
](https://huggingface.co/LeoLM/leo - hessianai - 13b) 採用 [Llama - 2 社區許可證](https://huggingface.co/meta - llama/Llama - 2 - 70b/raw/main/LICENSE.txt)(70b 版本也即將推出!👀)。我們希望此次發佈能為德語開源和商業大語言模型研究帶來新機遇,並加速其應用推廣。
更多詳情請閱讀我們的 [博客文章](https://laion.ai/blog/leo - lm/) 或論文(預印本即將發佈)。
本項目由 Björn Plüster 和 Christoph Schuhmann 與 LAION 和 HessianAI 合作完成。
🚀 快速開始
✨ 主要特性
- 語言能力拓展:將 Llama - 2 的能力拓展到德語領域,支持德語的文本生成任務。
- 多模型發佈:發佈了三個具有 8k 上下文長度的基礎模型,滿足不同場景需求。
- 商業可用:部分模型採用開放的商業許可證,便於商業應用。
📦 安裝指南
安裝直接依賴
pip install transformers torch sentencepiece
若要使用 flash - attention2 進行更快推理,需安裝以下依賴
pip install packaging ninja
pip install flash-attn
💻 使用示例
基礎用法
from transformers import pipeline
import torch
system_prompt = """Dies ist eine Unterhaltung zwischen einem intelligenten, hilfsbereitem KI-Assistenten und einem Nutzer.
Der Assistent gibt ausführliche, hilfreiche und ehrliche Antworten."""
prompt_format = "<|im_start|>system\n{system_prompt}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
prompt = "Erkläre mir wie die Fahrradwegesituation in Hamburg ist."
generator = pipeline(model="LeoLM/leo-mistral-hessianai-7b-chat", device="cuda", torch_dtype=torch.float16, use_flash_attention_2=True) # True for flash-attn2 else False
print(generator(prompt_format.format(system_prompt=system_prompt, prompt=prompt), do_sample=True, top_p=0.95, max_length=8192))
📚 詳細文檔
LeoLM Chat
LeoLM/leo - mistral - hessianai - 7b - chat
是基於基礎模型 LeoLM/leo - mistral - hessianai - 7b
構建的德語聊天模型,並在部分德語指令數據集上進行了微調。該模型在寫作、解釋和討論任務上表現出色,但在數學和高級推理方面存在一定挑戰。以下是其 MT - Bench - DE 評分:
{
"first_turn": 6.1,
"second_turn": 4.7,
"categories": {
"writing": 6.8,
"roleplay": 6.35,
"reasoning": 3.3,
"math": 2.75,
"coding": 4.4,
"extraction": 4.5,
"stem": 6.85,
"humanities": 8.25
},
"average": 5.4
}
模型詳情
屬性 | 詳情 |
---|---|
微調基礎模型 | [LeoLM/leo - mistral - hessianai - 7b](https://huggingface.co/LeoLM/leo - hessianai - 7b) |
模型類型 | 因果解碼器型Transformer語言模型 |
支持語言 | 英語和德語 |
演示 | 網頁演示即將推出! |
許可證 | [Apache 2.0](https://www.apache.org/licenses/LICENSE - 2.0.html) |
聯繫方式 | LAION Discord 或 Björn Plüster |
提示模板
提示對話模板(ChatML 格式):
"""
<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant
"""
模型輸入可以包含用戶和助手之間的多輪對話,例如:
<|im_start|>user
{prompt 1}<|im_end|>
<|im_start|>assistant
{reply 1}<|im_end|>
<|im_start|>user
{prompt 2}<|im_end|>
<|im_start|>assistant
(...)
🔧 技術細節
微調詳情
超參數 | 值 |
---|---|
訓練輪數 | 4 |
每輪樣本數 | 131214 |
全局批次大小 | 256 |
學習率 | 1e - 5 |
預熱步數 | 100 |
學習率調度器 | Cosine |
Adam 係數 | (0.9, 0.95) |
數據集詳情
## Stats for 'Subset of OpenAssistant/OASST-DE' (3534 samples (100.0%))
-----------------
Accepted: 3534/3534 (100.0%)
Accepted tokens: 2259302
Skipped: 0 (0.0%)
Min tokens per sample: 29
Max tokens per sample: 2484
Avg tokens per sample: 639.3044708545557
-----------------
## Stats for 'Subset of FreedomIntelligence/evol-instruct-deutsch' (57841 samples (100.0%))
-----------------
Accepted: 57841/57841 (100.0%)
Accepted tokens: 42958192
Skipped: 0 (0.0%)
Min tokens per sample: 33
Max tokens per sample: 5507
Avg tokens per sample: 742.6944900675991
-----------------
## Stats for 'Subset of FreedomIntelligence/alpaca-gpt4-deutsch' (48969 samples (100.0%))
-----------------
Accepted: 48969/48969 (100.0%)
Accepted tokens: 13372005
Skipped: 0 (0.0%)
Min tokens per sample: 19
Max tokens per sample: 1359
Avg tokens per sample: 273.07082031489307
-----------------
## Stats for 'Subset of LeoLM/OpenSchnabeltier' (21314 samples (100.0%))
-----------------
Accepted: 21314/21314 (100.0%)
Accepted tokens: 8134690
Skipped: 0 (0.0%)
Min tokens per sample: 25
Max tokens per sample: 1202
Avg tokens per sample: 381.65947264708643
-----------------
## Stats for 'Subset of LeoLM/German_Poems' (490 samples (100.0%))
-----------------
Accepted: 490/490 (100.0%)
Accepted tokens: 618642
Skipped: 0 (0.0%)
Min tokens per sample: 747
Max tokens per sample: 1678
Avg tokens per sample: 1262.534693877551
-----------------
## Stats for 'Subset of LeoLM/German_Songs' (392 samples (100.0%))
-----------------
Accepted: 392/392 (100.0%)
Accepted tokens: 187897
Skipped: 0 (0.0%)
Min tokens per sample: 231
Max tokens per sample: 826
Avg tokens per sample: 479.3290816326531
-----------------
## Stats for 'total' (132540 samples (100.0%))
-----------------
Accepted: 132540/132540 (100.0%)
Accepted tokens: 67530728
Skipped: 0 (0.0%)
Min tokens per sample: 19
Max tokens per sample: 5507
Avg tokens per sample: 509.51205673758864
-----------------
📄 許可證
本項目採用 [Apache 2.0](https://www.apache.org/licenses/LICENSE - 2.0.html) 許可證。
⚠️ 重要提示
LeoLM 已在英語和德語環境下進行了測試,但無法涵蓋所有場景。因此,與所有大語言模型一樣,LeoLM/leo - mistral - hessianai - 7b - chat
的輸出結果無法提前預測,模型在某些情況下可能會產生不準確、有偏差或其他令人反感的回覆。在部署 LeoLM/leo - mistral - hessianai - 7b - chat
的任何應用之前,開發者應針對具體應用進行安全測試和調優。
請參閱 Meta 的 [負責任使用指南](https://ai.meta.com/llama/responsible - use - guide/)。



