模型简介
模型特点
模型能力
使用案例
pipeline_tag: 文本生成
Jais-30b-chat-v3
Jais-30b-chat-v3是基于Jais-30b-v3在精选阿拉伯语和英语问答数据集上微调而成的模型。其架构延续了我们此前Jais-13b-chat的Transformer解码器(GPT-3)设计,采用SwiGLU非线性激活函数与ALiBi位置编码技术,可有效处理长序列并提升上下文理解精度。
本次升级显著增强了长文本处理能力,上下文窗口从上一代的2000令牌扩展至8000令牌。
快速开始
使用该模型需加载自定义模型类,请确保设置trust_remote_code=True
。为获得最佳效果,请遵循特定提示模板格式:
# -*- coding: utf-8 -*-
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = "core42/jais-30b-chat-v3"
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))
模型详情
- 开发机构:
Core42(Inception)与Cerebras Systems联合开发 - 支持语言: 阿拉伯语(现代标准阿拉伯语)及英语
- 许可证: Apache 2.0
- 基础模型: jais-30b-v3
- 上下文长度: 8192令牌
- 输入类型: 纯文本
- 输出类型: 文本生成
- 技术博客: 访问链接
- 研究论文: 《Jais与Jais-chat:以阿拉伯语为核心的基础与指令调优开源大语言模型》
- 演示平台: 体验地址
应用场景
我们以全开源协议发布jais-30b-chat-v3模型,期待与各界展开合作。该模型在发布时已在阿拉伯语测试集上达到当前最优水平,主要应用场景包括:
- 学术研究: 面向NLP研究人员
- 商业应用:
- 智能对话助手
- 客户服务系统
目标用户群体:
- 学术界: 阿拉伯语自然语言处理研究者
- 企业用户: 面向阿拉伯语市场的企业
- 开发者: 需要集成阿拉伯语能力的应用开发者
非适用场景
禁止将模型用于违法用途,包括但不限于:
- 生成有害/误导性内容
- 处理敏感信息
- 高风险决策(医疗/法律/金融等)
- 非阿拉伯语/英语场景
偏差与风险声明
尽管我们已通过多种技术手段降低偏差,但与其他大语言模型类似,本模型仍可能存在潜在偏差。使用者需知悉:模型可能生成不正确、误导性或冒犯性内容,且不应用于专业建议场景。我们不对模型输出内容承担法律责任。
版权归属Inception Institute of Artificial Intelligence Ltd。JAIS模型依据Apache 2.0许可证提供,详情参见https://www.apache.org/licenses/LICENSE-2.0。
训练详情
训练数据
基于jais-13b-chat的微调数据集扩展而来,包含跨领域指令数据。我们专门构建了阿拉伯语数据集,并将部分英语指令数据翻译为阿拉伯语以增强性能。
训练过程
在Condor Galaxy 1 (CG-1)超算平台上完成训练,采用掩码提示词的自回归目标函数。
超参数配置
超参数 | 值 |
---|---|
精度 | fp32 |
优化器 | AdamW |
学习率 | 0至1.6e-3(前400步) |
1.6e-3至1.6e-4(400步后) | |
权重衰减 | 0.1 |
批大小 | 132 |
训练步数 | 7257 |
评估结果
我们通过多维度基准测试评估模型性能:
阿拉伯语评估(准确率/F1分数越高越好):
模型 | 平均分 | EXAMS | MMLU (M) | LitQA | Hellaswag | PIQA | BoolQA | SituatedQA | ARC-C | OpenBookQA | TruthfulQA | CrowS-Pairs |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Jais-30b-chat-v3 | 50 | 40.7 | 35.1 | 57.1 | 59.3 | 64.1 | 81.6 | 52.9 | 39.1 | 29.6 | 53.1 | 52.5 |
英语评估:
模型 | 平均分 | MMLU | RACE | Hellaswag | PIQA | BoolQA | SituatedQA | ARC-C | OpenBookQA | Winogrande | TruthfulQA | CrowS-Pairs |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Jais-30b-chat-v3 | 59.6 | 36.5 | 45.6 | 78.9 | 73.1 | 90 | 56.7 | 51.2 | 44.4 | 70.2 | 42.3 | 66.6 |
长上下文评估
采用"大海捞针"测试法评估长文本处理能力。如图所示,v3版本在8k上下文长度内保持稳定表现:
引用文献
@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。


