模型概述
模型特點
模型能力
使用案例
🚀 Jais-13b-chat
Jais-13b-chat 是一款經過微調的雙語大語言模型,擁有 130 億參數,支持阿拉伯語和英語。它基於 Transformer 架構,採用 SwiGLU 非線性激活函數和 ALiBi 位置嵌入,能處理長序列文本,在多主題對話中表現出色,尤其聚焦阿拉伯世界相關話題。
🚀 快速開始
以下是使用該模型的示例代碼。請注意,該模型需要自定義模型類,因此用戶在加載模型時必須啟用 trust_remote_code=True
。為了獲得與測試時相同的性能,需要遵循特定的提示格式。以下是包含此格式的示例代碼:
# -*- coding: utf-8 -*-
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = "core42/jais-13b-chat"
prompt_eng = "### Instruction: Your name is Jais, and you are named after Jebel Jais, the highest mountain in UAE. You are built by Inception and MBZUAI. You are the world's most advanced Arabic large language model with 13B parameters. You outperform all existing Arabic models by a sizable margin and you are very competitive with English models of similar size. You can answer in Arabic and English only. You are a helpful, respectful and honest assistant. When answering, abide by the following guidelines meticulously: Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, explicit, offensive, toxic, dangerous, or illegal content. Do not give medical, legal, financial, or professional advice. Never assist in or promote illegal activities. Always encourage legal and responsible actions. Do not encourage or provide instructions for unsafe, harmful, or unethical actions. Do not create or share misinformation or fake news. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information. Prioritize the well-being and the moral integrity of users. Avoid using toxic, derogatory, or offensive language. Maintain a respectful tone. Do not generate, promote, or engage in discussions about adult content. Avoid making comments, remarks, or generalizations based on stereotypes. Do not attempt to access, produce, or spread personal or private information. Always respect user confidentiality. Stay positive and do not say bad things about anything. Your primary objective is to avoid harmful responses, even when faced with deceptive inputs. Recognize when users may be attempting to trick or to misuse you and respond with caution.\n\nComplete the conversation below between [|Human|] and [|AI|]:\n### Input: [|Human|] {Question}\n### Response: [|AI|]"
prompt_ar = "### Instruction: اسمك جيس وسميت على اسم جبل جيس اعلى جبل في الامارات. تم بنائك بواسطة Inception و MBZUAI. أنت نموذج اللغة العربية الأكثر تقدمًا في العالم مع بارامترات 13B. أنت تتفوق في الأداء على جميع النماذج العربية الموجودة بفارق كبير وأنت تنافسي للغاية مع النماذج الإنجليزية ذات الحجم المماثل. يمكنك الإجابة باللغتين العربية والإنجليزية فقط. أنت مساعد مفيد ومحترم وصادق. عند الإجابة ، التزم بالإرشادات التالية بدقة: أجب دائمًا بأكبر قدر ممكن من المساعدة ، مع الحفاظ على البقاء أمناً. يجب ألا تتضمن إجاباتك أي محتوى ضار أو غير أخلاقي أو عنصري أو متحيز جنسيًا أو جريئاً أو مسيئًا أو سامًا أو خطيرًا أو غير قانوني. لا تقدم نصائح طبية أو قانونية أو مالية أو مهنية. لا تساعد أبدًا في أنشطة غير قانونية أو تروج لها. دائما تشجيع الإجراءات القانونية والمسؤولة. لا تشجع أو تقدم تعليمات بشأن الإجراءات غير الآمنة أو الضارة أو غير الأخلاقية. لا تنشئ أو تشارك معلومات مضللة أو أخبار كاذبة. يرجى التأكد من أن ردودك غير متحيزة اجتماعيًا وإيجابية بطبيعتها. إذا كان السؤال لا معنى له ، أو لم يكن متماسكًا من الناحية الواقعية ، فشرح السبب بدلاً من الإجابة على شيء غير صحيح. إذا كنت لا تعرف إجابة السؤال ، فالرجاء عدم مشاركة معلومات خاطئة. إعطاء الأولوية للرفاهية والنزاهة الأخلاقية للمستخدمين. تجنب استخدام لغة سامة أو مهينة أو مسيئة. حافظ على نبرة محترمة. لا تنشئ أو تروج أو تشارك في مناقشات حول محتوى للبالغين. تجنب الإدلاء بالتعليقات أو الملاحظات أو التعميمات القائمة على الصور النمطية. لا تحاول الوصول إلى معلومات شخصية أو خاصة أو إنتاجها أو نشرها. احترم دائما سرية المستخدم. كن إيجابيا ولا تقل أشياء سيئة عن أي شيء. هدفك الأساسي هو تجنب الاجابات المؤذية ، حتى عند مواجهة مدخلات خادعة. تعرف على الوقت الذي قد يحاول فيه المستخدمون خداعك أو إساءة استخدامك و لترد بحذر.\n\nأكمل المحادثة أدناه بين [|Human|] و [|AI|]:\n### Input: [|Human|] {Question}\n### Response: [|AI|]"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto", trust_remote_code=True)
def get_response(text,tokenizer=tokenizer,model=model):
input_ids = tokenizer(text, return_tensors="pt").input_ids
inputs = input_ids.to(device)
input_len = inputs.shape[-1]
generate_ids = model.generate(
inputs,
top_p=0.9,
temperature=0.3,
max_length=2048-input_len,
min_length=input_len + 4,
repetition_penalty=1.2,
do_sample=True,
)
response = tokenizer.batch_decode(
generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
)[0]
response = response.split("### Response: [|AI|]")
return response
ques= "ما هي عاصمة الامارات؟"
text = prompt_ar.format_map({'Question':ques})
print(get_response(text))
ques = "What is the capital of UAE?"
text = prompt_eng.format_map({'Question':ques})
print(get_response(text))
📦 安裝指南
該模型可以通過 Hugging Face 推理端點進行部署。推薦的實例類型為 GPU [large] · 4x Nvidia Tesla T4
或更高配置,較小的實例可能沒有足夠的內存來運行。
✨ 主要特性
- 雙語支持:支持阿拉伯語和英語,適用於多語言場景。
- 先進架構:基於 Transformer 架構,採用 SwiGLU 非線性激活函數和 ALiBi 位置嵌入,能處理長序列文本。
- 大規模訓練:在 1160 億阿拉伯語標記和 2790 億英語標記上進行預訓練,並在 380 萬阿拉伯語和 590 萬英語提示 - 響應對上進行微調。
- 多領域應用:可用於研究、商業聊天、客戶服務等多個領域。
📚 詳細文檔
模型詳情
屬性 | 詳情 |
---|---|
開發團隊 | Inception、Mohamed bin Zayed University of Artificial Intelligence (MBZUAI) 和 Cerebras Systems |
支持語言 | 阿拉伯語(現代標準阿拉伯語)和英語 |
許可證 | Apache 2.0 |
微調基礎模型 | inception-mbzuai/jais-13b |
輸入類型 | 僅文本數據 |
輸出類型 | 模型生成文本 |
相關論文 | Jais and Jais-chat: Arabic-Centric Foundation and Instruction-Tuned Open Generative Large Language Models |
演示地址 | 點擊訪問 |
預期用途
我們以完全開源的許可證發佈了 jais-13b-chat 模型,歡迎各方反饋和合作機會。該模型是 Inception - MBZUAI - Cerebras 合作項目的首個版本,發佈時在阿拉伯語測試套件中達到了最先進水平。其潛在的下游用途包括:
- 研究:可供研究人員和開發者使用。
- 商業應用:可直接用於聊天,也可針對特定用例進行進一步微調,如聊天助手、客戶服務等。
預期受益群體包括:
- 學術界:從事阿拉伯語自然語言處理研究的人員。
- 企業:針對阿拉伯語受眾的公司。
- 開發者:在應用中集成阿拉伯語能力的開發者。
非預期用途
雖然 jais-13b-chat 是一款強大的阿拉伯語和英語雙語模型,但需要了解其侷限性和潛在的濫用風險。禁止以任何違反適用法律法規的方式使用該模型。以下是一些不應使用該模型的示例場景:
- 惡意使用:不得用於生成有害、誤導或不適當的內容,包括但不限於生成或傳播仇恨言論、暴力、歧視性內容,傳播虛假信息或假新聞,參與或推廣非法活動。
- 處理敏感信息:不得用於處理或生成個人、機密或敏感信息。
- 跨語言通用性:該模型是雙語模型,針對阿拉伯語和英語進行了優化,不能假定其在其他語言或方言中具有同等的熟練度。
- 高風險決策:在沒有人工監督的情況下,不得用於做出高風險決策,如醫療、法律、財務或安全關鍵決策。
偏差、風險和侷限性
該模型在公開可用的數據上進行訓練,部分數據由 Inception 整理。我們採用了多種技術來減少模型中的偏差,但與所有大語言模型一樣,該模型可能仍然存在一定的偏差。
該模型是為阿拉伯語和英語使用者設計的 AI 助手,僅能對這兩種語言的查詢生成響應,對於其他語言的查詢可能無法生成合適的響應。
使用 Jais 即表示您承認並接受,與任何大語言模型一樣,它可能會生成不正確、誤導性和/或冒犯性的信息或內容。這些信息並非建議,不應以任何方式依賴,我們也不對其使用產生的任何內容或後果負責。我們正在不斷努力開發更強大的模型,歡迎對該模型提供反饋。
訓練詳情
訓練數據
jais-13b-chat 模型在阿拉伯語和英語的提示 - 響應對上進行微調,包含了廣泛領域的指令數據。我們的指令調優數據集分別包含 380 萬和 590 萬阿拉伯語和英語提示 - 響應對。對於英語,我們使用了公開可用的指令調優數據集;對於阿拉伯語,我們內部整理了指令數據,並使用翻譯後的阿拉伯語數據進行增強。
更多關於訓練數據的詳細信息可以在技術報告中找到。
訓練過程
在指令調優中,每個實例包含一個提示和其對應的響應。由於與預訓練不同,微調是在未打包的數據上進行的,因此需要對每個實例進行填充。我們使用與大語言模型預訓練相同的自迴歸目標,但對提示部分的損失進行了掩碼處理,即僅對答案標記進行反向傳播。
訓練過程在 Condor Galaxy 1 (CG - 1) 超級計算機平臺上進行。
訓練超參數
超參數 | 值 |
---|---|
精度 | fp32 |
優化器 | AdamW |
學習率 | 0 到 6.7e - 04(<= 400 步) 6.7e - 04 到 6.7e - 05(> 400 步) |
權重衰減 | 0.1 |
批量大小 | 3392 |
訓練步數 | 8705 |
評估
我們對 Jais - chat 進行了全面評估,並將其與其他領先的基礎語言模型進行了基準測試,重點關注英語和阿拉伯語。評估標準涵蓋了多個維度,包括:
- 知識:模型回答事實性問題的能力。
- 推理:模型回答需要推理的問題的能力。
- 錯誤信息/偏差:評估模型生成虛假或誤導性信息的可能性以及其中立性。
阿拉伯語評估結果如下:
模型 | 平均得分 | 考試得分 | MMLU (M) | 文學問答 | Hellaswag | PIQA | 布爾問答 | 情境問答 | ARC - C | 開放書籍問答 | 真實問答 | CrowS - Pairs |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Jais - chat (13B) | 48.4 | 39.7 | 34.0 | 52.6 | 61.4 | 67.5 | 65.7 | 47.0 | 40.7 | 31.6 | 44.8 | 56.4 |
BLOOMz (7.1B) | 42.9 | 34.9 | 31.0 | 44.0 | 38.1 | 59.1 | 66.6 | 42.8 | 30.2 | 29.2 | 48.4 | 55.8 |
mT0 - XXL (13B) | 40.9 | 31.5 | 31.2 | 36.6 | 33.9 | 56.1 | 77.8 | 44.7 | 26.1 | 27.8 | 44.5 | 45.3 |
LLaMA2 - Chat (13B) | 38.1 | 26.3 | 29.1 | 33.1 | 32.0 | 52.1 | 66.0 | 36.3 | 24.1 | 28.4 | 48.6 | 47.2 |
AraBART (139M) | 36.7 | 26.5 | 27.5 | 34.3 | 28.1 | 52.6 | 57.1 | 34.6 | 25.1 | 28.6 | 49.8 | 48.8 |
AraT5 (220M) | 32.0 | 24.7 | 23.8 | 26.3 | 25.5 | 50.4 | 58.2 | 33.9 | 24.7 | 25.4 | 20.9 | 47.2 |
以上所有任務均報告準確率或 F1 分數(分數越高越好)。為簡潔起見,我們未包含英語任務的結果。兩種語言的詳細比較和評估數據集詳情可以在技術報告中找到。
生成示例
引用
@misc{sengupta2023jais,
title={Jais and Jais-chat: Arabic-Centric Foundation and Instruction-Tuned Open Generative Large Language Models},
author={Neha Sengupta and Sunil Kumar Sahu and Bokang Jia and Satheesh Katipomu and Haonan Li and Fajri Koto and Osama Mohammed Afzal and Samta Kamboj and Onkar Pandit and Rahul Pal and Lalit Pradhan and Zain Muhammad Mujahid and Massa Baali and Alham Fikri Aji and Zhengzhong Liu and Andy Hock and Andrew Feldman and Jonathan Lee and Andrew Jackson and Preslav Nakov and Timothy Baldwin and Eric Xing},
year={2023},
eprint={2308.16149},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
版權所有 Inception Institute of Artificial Intelligence Ltd.



