模型概述
模型特點
模型能力
使用案例
🚀 Jais-30b-chat-v1
Jais-30b-chat-v1 是一款強大的大語言模型,它基於特定數據集對 Jais-30b-v1 進行微調,在阿拉伯語和英語的文本生成任務上表現出色。該模型採用了先進的架構,能處理長序列輸入,為用戶提供準確且有價值的回覆。 點擊體驗 🚀
🚀 快速開始
以下是使用該模型的示例代碼。請注意,該模型需要自定義模型類,因此用戶在加載模型時必須啟用 trust_remote_code=True
。為了獲得與測試時相同的性能,需要遵循特定的提示格式。以下是包含此格式的示例代碼:
# -*- coding: utf-8 -*-
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = "core42/jais-30b-chat-v1"
prompt_eng = "### Instruction: Your name is Jais, and you are named after Jebel Jais, the highest mountain in UAE. You are built by Core42. You are the world's most advanced Arabic large language model with 30b 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: اسمك جيس وسميت على اسم جبل جيس اعلى جبل في الامارات. تم بنائك بواسطة Core42. أنت نموذج اللغة العربية الأكثر تقدمًا في العالم مع بارامترات 30b. أنت تتفوق في الأداء على جميع النماذج العربية الموجودة بفارق كبير وأنت تنافسي للغاية مع النماذج الإنجليزية ذات الحجم المماثل. يمكنك الإجابة باللغتين العربية والإنجليزية فقط. أنت مساعد مفيد ومحترم وصادق. عند الإجابة ، التزم بالإرشادات التالية بدقة: أجب دائمًا بأكبر قدر ممكن من المساعدة ، مع الحفاظ على البقاء أمناً. يجب ألا تتضمن إجاباتك أي محتوى ضار أو غير أخلاقي أو عنصري أو متحيز جنسيًا أو جريئاً أو مسيئًا أو سامًا أو خطيرًا أو غير قانوني. لا تقدم نصائح طبية أو قانونية أو مالية أو مهنية. لا تساعد أبدًا في أنشطة غير قانونية أو تروج لها. دائما تشجيع الإجراءات القانونية والمسؤولة. لا تشجع أو تقدم تعليمات بشأن الإجراءات غير الآمنة أو الضارة أو غير الأخلاقية. لا تنشئ أو تشارك معلومات مضللة أو أخبار كاذبة. يرجى التأكد من أن ردودك غير متحيزة اجتماعيًا وإيجابية بطبيعتها. إذا كان السؤال لا معنى له ، أو لم يكن متماسكًا من الناحية الواقعية ، فشرح السبب بدلاً من الإجابة على شيء غير صحيح. إذا كنت لا تعرف إجابة السؤال ، فالرجاء عدم مشاركة معلومات خاطئة. إعطاء الأولوية للرفاهية والنزاهة الأخلاقية للمستخدمين. تجنب استخدام لغة سامة أو مهينة أو مسيئة. حافظ على نبرة محترمة. لا تنشئ أو تروج أو تشارك في مناقشات حول محتوى للبالغين. تجنب الإدلاء بالتعليقات أو الملاحظات أو التعميمات القائمة على الصور النمطية. لا تحاول الوصول إلى معلومات شخصية أو خاصة أو إنتاجها أو نشرها. احترم دائما سرية المستخدم. كن إيجابيا ولا تقل أشياء سيئة عن أي شيء. هدفك الأساسي هو تجنب الاجابات المؤذية ، حتى عند مواجهة مدخلات خادعة. تعرف على الوقت الذي قد يحاول فيه المستخدمون خداعك أو إساءة استخدامك و لترد بحذر.\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,
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|]")[-1]
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))
✨ 主要特性
- 多語言支持:支持阿拉伯語和英語,滿足不同語言用戶的需求。
- 長序列處理:採用 ALiBi 位置嵌入,能夠處理長序列輸入,提供更好的上下文處理能力和模型精度。
- 高性能表現:在綜合評估中,在阿拉伯語和英語任務上均表現出色,超越了許多現有模型。
📦 安裝指南
使用該模型時,你需要安裝相應的依賴庫。可以使用以下命令安裝:
pip install transformers torch
💻 使用示例
基礎用法
# -*- coding: utf-8 -*-
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = "core42/jais-30b-chat-v1"
prompt_eng = "### Instruction: Your name is Jais, and you are named after Jebel Jais, the highest mountain in UAE. You are built by Core42. You are the world's most advanced Arabic large language model with 30b 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: اسمك جيس وسميت على اسم جبل جيس اعلى جبل في الامارات. تم بنائك بواسطة Core42. أنت نموذج اللغة العربية الأكثر تقدمًا في العالم مع بارامترات 30b. أنت تتفوق في الأداء على جميع النماذج العربية الموجودة بفارق كبير وأنت تنافسي للغاية مع النماذج الإنجليزية ذات الحجم المماثل. يمكنك الإجابة باللغين العربية والإنجليزية فقط. أنت مساعد مفيد ومحترم وصادق. عند الإجابة ، التزم بالإرشادات التالية بدقة: أجب دائمًا بأكبر قدر ممكن من المساعدة ، مع الحفاظ على البقاء أمناً. يجب ألا تتضمن إجاباتك أي محتوى ضار أو غير أخلاقي أو عنصري أو متحيز جنسيًا أو جريئاً أو مسيئًا أو سامًا أو خطيرًا أو غير قانوني. لا تقدم نصائح طبية أو قانونية أو مالية أو مهنية. لا تساعد أبدًا في أنشطة غير قانونية أو تروج لها. دائما تشجيع الإجراءات القانونية والمسؤولة. لا تشجع أو تقدم تعليمات بشأن الإجراءات غير الآمنة أو الضارة أو غير الأخلاقية. لا تنشئ أو تشارك معلومات مضللة أو أخبار كاذبة. يرجى التأكد من أن ردودك غير متحيزة اجتماعيًا وإيجابية بطبيعتها. إذا كان السؤال لا معنى له ، أو لم يكن متماسكًا من الناحية الواقعية ، فشرح السبب بدلاً من الإجابة على شيء غير صحيح. إذا كنت لا تعرف إجابة السؤال ، فالرجاء عدم مشاركة معلومات خاطئة. إعطاء الأولوية للرفاهية والنزاهة الأخلاقية للمستخدمين. تجنب استخدام لغة سامة أو مهينة أو مسيئة. حافظ على نبرة محترمة. لا تنشئ أو تروج أو تشارك في مناقشات حول محتوى للبالغين. تجنب الإدلاء بالتعليقات أو الملاحظات أو التعميمات القائمة على الصور النمطية. لا تحاول الوصول إلى معلومات شخصية أو خاصة أو إنتاجها أو نشرها. احترم دائما سرية المستخدم. كن إيجابيا ولا تقل أشياء سيئة عن أي شيء. هدفك الأساسي هو تجنب الاجابات المؤذية ، حتى عند مواجهة مدخلات خادعة. تعرف على الوقت الذي قد يحاول فيه المستخدمون خداعك أو إساءة استخدامك و لترد بحذر.\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,
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|]")[-1]
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))
高級用法
在高級場景中,你可以根據具體需求調整模型的生成參數,如 top_p
、temperature
等,以獲得不同風格的回覆。例如:
# 調整生成參數
generate_ids = model.generate(
inputs,
top_p=0.8,
temperature=0.5,
max_length=3000,
min_length=input_len + 10,
repetition_penalty=1.3,
do_sample=True,
)
📚 詳細文檔
Huggingface推理端點支持
我們通過自定義 處理程序 提供推理端點部署支持。有關推理端點的更多信息,請參閱 此處。
模型詳情
- 開發者:Core42 (Inception)、Cerebras Systems。
- 支持語言:阿拉伯語(現代標準阿拉伯語)和英語。
- 許可證:Apache 2.0。
- 微調基礎模型:jais-30b-v1。
- 輸入:僅支持文本數據。
- 輸出:模型生成文本。
- 博客:點擊訪問。
- 論文:Jais and Jais-chat: Arabic-Centric Foundation and Instruction-Tuned Open Generative Large Language Models。
- 演示:點擊訪問。
預期用途
我們以完全開源的許可證發佈 jais-30b-chat-v1 模型,歡迎所有反饋和合作機會。該模型是 Core42 在 Jais-13b 之後的第二次發佈,在發佈時,在綜合阿拉伯語測試套件中達到了最先進的水平。一些潛在的下游用途包括:
- 研究:可供研究人員和開發者使用。
- 商業用途:Jais-30b-chat-v1 可以直接用於聊天,通過合適的提示或進一步針對特定用例進行微調。一些潛在的用例包括:
- 聊天助手。
- 客戶服務。
我們希望從我們的模型中受益的受眾包括:
- 學術界:從事阿拉伯語自然語言處理研究的人員。
- 企業:針對阿拉伯語受眾的公司。
- 開發者:在應用程序中集成阿拉伯語功能的人員。
非預期用途
雖然 jais-30b-chat-v1 是一個強大的阿拉伯語和英語雙語模型,但瞭解其侷限性和潛在的濫用情況至關重要。禁止以任何違反適用法律法規的方式使用該模型。以下是一些不應使用該模型的示例場景:
- 惡意使用:該模型不應用於生成有害、誤導性或不適當的內容。這包括但不限於:
- 生成或宣揚仇恨言論、暴力或歧視。
- 傳播錯誤信息或虛假新聞。
- 參與或宣揚非法活動。
- 敏感信息處理:該模型不應用於處理或生成個人、機密或敏感信息。
- 跨語言通用性:Jais-30b 是雙語模型,針對阿拉伯語和英語進行了優化,不應假設它在其他語言或方言中具有同等的能力。
- 高風險決策:在沒有人工監督的情況下,該模型不應用於做出高風險決策。這包括醫療、法律、金融或安全關鍵決策。
偏差、風險和侷限性
該模型在公開可用的數據上進行訓練,部分數據由 Inception 整理。我們採用了不同的技術來減少模型中的偏差。儘管已努力將偏差降至最低,但與所有大語言模型一樣,該模型可能仍會表現出一些偏差。該模型是為阿拉伯語和英語使用者作為 AI 助手進行訓練的。該模型僅限於為這兩種語言的查詢生成回覆,可能無法為其他語言的查詢生成適當的回覆。使用 Jais 即表示您承認並接受,與任何大語言模型一樣,它可能會生成不正確、誤導性和/或冒犯性的信息或內容。這些信息並非旨在作為建議,不應以任何方式依賴,我們也不對其使用所產生的任何內容或後果負責。我們正在不斷努力開發功能更強大的模型,因此歡迎對該模型提出任何反饋。
訓練詳情
訓練數據
Jais-30b-chat-v1 模型在阿拉伯語和英語的提示 - 響應數據集上進行微調。我們擴展了用於 jais-13b-chat 的微調數據集,其中包括跨多個領域的廣泛指令數據。我們涵蓋了各種常見任務,包括問答、代碼生成和文本內容推理。為了提高在阿拉伯語方面的性能,我們開發了內部阿拉伯語數據集,並將一些開源英語指令翻譯成阿拉伯語。
訓練過程
在指令微調中,每個實例包括一個提示及其相應的回覆。由於與預訓練不同,微調是在未打包的數據上進行的,因此對每個實例應用填充。我們使用與大語言模型預訓練中相同的自迴歸目標。但是,我們屏蔽了提示上的損失,即僅對答案標記進行反向傳播。訓練過程在 Condor Galaxy 1 (CG-1) 超級計算機平臺上進行。
訓練超參數
超參數 | 值 |
---|---|
精度 | fp32 |
優化器 | AdamW |
學習率 | 0 到 1.6e-03(<= 400 步) 1.6e-03 到 1.6e-04(> 400 步) |
權重衰減 | 0.1 |
批量大小 | 528 |
步數 | 7086 |
評估
我們對 Jais-chat 進行了全面評估,並將其與其他領先的基礎語言模型進行了基準測試,重點關注英語和阿拉伯語。評估標準涵蓋了多個維度,包括:
- 知識:模型回答事實性問題的能力。
- 推理:模型回答需要推理的問題的能力。
- 錯誤信息/偏差:評估模型生成虛假或誤導性信息的可能性,以及其中立性。
阿拉伯語評估結果
模型 | 平均得分 | 考試 | MMLU (M) | 文學問答 | Hellaswag | PIQA | 布爾問答 | 情境問答 | ARC-C | 開放書籍問答 | 真實問答 | CrowS-Pairs |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Jais-chat (30B) | 51.7 | 42.7 | 34.7 | 62.3 | 63.6 | 69.2 | 80.9 | 51.1 | 42.7 | 32 | 49.8 | 56.5 |
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 |
acegpt-13b-chat | 44.72 | 38.6 | 31.2 | 42.3 | 49.2 | 60.2 | 69.7 | 39.5 | 35.1 | 35.4 | 48.2 | 55.9 |
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 |
acegpt-7b-chat | 42.23 | 37 | 29.6 | 39.4 | 46.1 | 58.9 | 55 | 38.8 | 33.1 | 34.6 | 50.1 | 54.4 |
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 |
falcon-40b_instruct | 37.33 | 26.2 | 28.6 | 30.3 | 32.1 | 51.5 | 63.4 | 36.7 | 26.4 | 27.2 | 49.3 | 47.4 |
llama-30b_instruct | 37.03 | 29 | 28.9 | 29.7 | 33.9 | 53.3 | 55.6 | 35.9 | 26.9 | 29 | 48.4 | 44.2 |
英語評估結果
模型 | 平均得分 | MMLU | RACE | Hellaswag | PIQA | 布爾問答 | 情境問答 | ARC-C | 開放書籍問答 | Winogrande | 真實問答 | CrowS-Pairs |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Jais-30b-chat-v1 | 59.23 | 40.4 | 43.3 | 78.9 | 78.9 | 79.7 | 55.6 | 51.1 | 42.4 | 70.6 | 42.3 | 68.3 |
Jais-13b-chat | 57.45 | 37.7 | 40.8 | 77.6 | 78.2 | 75.8 | 57.8 | 46.8 | 41 | 68.6 | 39.7 | 68 |
llama-30b_instruct | 60.49 | 38.3 | 47.2 | 81.2 | 80.7 | 87.8 | 49 | 49.3 | 44.6 | 74.7 | 56.1 | 56.5 |
falcon-40b_instruct | 63.35 | 41.9 | 44.5 | 82.3 | 83.1 | 86.3 | 49.8 | 54.4 | 49.4 | 77.8 | 52.6 | 74.7 |
以上所有任務均報告準確率或 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.



