Jais-30b-v1-8bit
This is a 30 billion parameter pre-trained bilingual large language model for both Arabic and English, trained on a dataset containing 126 billion Arabic tokens, 251 billion English, and 50 billion code tokens.
This model, similar to our previous model releases Jais-13b, is based on transformer-based decoder-only (GPT-3) architecture and uses SwiGLU non-linearity. It implements ALiBi position embeddings, enabling the model to extrapolate to long sequence lengths, providing improved context handling and model precision.
Getting started
Below is sample code to use the model. Note that the model requires a custom model class, so users must
enable trust_remote_code=True
while loading the model.
Also, note that this code is tested on transformers==4.32.0
.
# -*- coding: utf-8 -*-
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = "core42/jais-30b-v1"
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=200,
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]
return response
text= "عاصمة دولة الإمارات العربية المتحدة ه"
print(get_response(text))
text = "The capital of UAE is"
print(get_response(text))
Quantitized It needs 40GB at least of GPU memory
!pip install --upgrade accelerate torch transformers bitsandbytes scipy huggingface_hub
!pip install --upgrade pip jupyter jupyterlab-nvdashboard
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from accelerate import Accelerator
from huggingface_hub import login
login(token="")
# Initialize the Accelerator
accelerator = Accelerator()
model_path = "brainiac-origin/jais-chat-30b-8bit"
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 = torch.device('cuda:0')
model= AutoModelForCausalLM.from_pretrained(model_path,trust_remote_code=True,device_map="auto",token="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")
tokenizer = AutoTokenizer.from_pretrained(model_path)
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 Tesla?"
text = prompt_eng.format_map({'Question':ques})
print(get_response(text))
# Save the checkpoint
torch.save(model.state_dict(), "checkpoint.pt")
Model Details
- Developed by: Core42 (Inception), Cerebras Systems.
- Language(s) (NLP): Arabic and English
- License: Apache 2.0
- Input: Text only data.
- Output: Model generates text.
- Paper : Jais and Jais-chat: Arabic-Centric Foundation and Instruction-Tuned Open Generative Large Language Models
- Blog : Access here
- Demo : Access here
Intended Use
We release the Jais 30B model under a full open source license. We welcome all feedback and opportunities to collaborate.
This is the second release after Jais-13b from Core42, and at the time of release, achieved state of the art across a comprehensive Arabic test suite as noted in the evaluation section. Some potential downstream uses include:
- Research: This model can be used by researchers and developers.
- Commercial Use: It can be used as a base model to further fine-tune for specific use cases (similar to jais-13b-chat).
Some potential use cases include:
- Chat-assistants.
- Customer service.
Audiences that we hope will benefit from our model:
- Academics: For those researching Arabic natural language processing.
- Businesses: Companies targeting Arabic-speaking audiences.
- Developers: Those integrating Arabic language capabilities in apps.
Out-of-Scope Use
While Jais-30b is a powerful Arabic and English bilingual model, it's essential to understand its limitations and the potential of misuse. It is prohibited to use the model in any manner that violates applicable laws or regulations. The following are some example scenarios where the model should not be used.
Malicious Use: The model should not be used for generating harmful, misleading, or inappropriate content. This includes but is not limited to:
- Generating or promoting hate speech, violence, or discrimination.
- Spreading misinformation or fake news.
- Engaging in or promoting illegal activities.
Sensitive Information: The model should not be used to handle or generate personal, confidential, or sensitive information.
Generalization Across All Languages: Jais-30b is bilingual and optimized for Arabic and English, it should not be assumed to have equal proficiency in other languages or dialects.
High-Stakes Decisions: The model should not be used to make high-stakes decisions without human oversight. This includes medical, legal, financial, or safety-critical decisions.
Bias, Risks, and Limitations
The model is trained on publicly available data which was in part curated by Inception. We have employed different techniqes to reduce bias in the model. While efforts have been made to minimize biases, it is likely that the model, as with all LLM models, will exhibit some bias.
The model is trained as an AI assistant for Arabic and English speakers. The model is limited to produce responses for queries in these two languages and may not produce appropriate responses to other language queries.
By using Jais, you acknowledge and accept that, as with any large language model, it may generate incorrect, misleading and/or offensive information or content. The information is not intended as advice and should not be relied upon in any way, nor are we responsible for any of the content or consequences resulting from its use. We are continuously working to develop models with greater capabilities, and as such, welcome any feedback on the model
Training Details
Training Data
For the pre-training of Jais-30b, we used a diverse bilingual corpus sourced from the Web and other sources. We also used publicly available English and code datasets. To collect Arabic data, we use multiple sources including web pages, wikipedia articles, news articles, Arabic books, and social network content. We augment the volume of Arabic data by translating English to Arabic using an in-house machine translation system. We restrict this to high quality English resources such as English Wikipedia and English books. Our data acquisition strategy is similar to as mentioned in Jais-13b.
Training Procedure
Training was performed on the Condor Galaxy 1 (CG-1) supercomputer platform.
Training Hyperparameters
Hyperparameter | Value |
---|---|
Precision | fp32 |
Optimizer | AdamW |
Learning rate | 0 to 0.012 (<= 69 steps) |
0.012 to 0.005 (> 69 & < 70k steps) | |
0.005 to 0.0008 (>70k-79k) | |
Weight decay | 0.1 |
Batch size | 2640 |
Steps | 79k |
Evaluation
We conducted a comprehensive evaluation of Jais and benchmarked it against other leading base language models, focusing on both English and Arabic. The evaluation criteria spanned various dimensions, including:
- Knowledge: How well the model answers factual questions.
- Reasoning: The model's ability to answer questions requiring reasoning.
- Misinformation/Bias: Assessment of the model's susceptibility to generating false or misleading information, and its neutrality.
Arabic evaluation results:
Models | Avg | EXAMS | MMLU (M) | LitQA | Hellaswag | PIQA | BoolQA | SituatedQA | ARC-C | OpenBookQA | TruthfulQA | CrowS-Pairs |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Jais (30B) | 47.8 | 40 | 30.8 | 58.3 | 60.1 | 70 | 68.7 | 43.3 | 38.5 | 32.2 | 42.6 | 56.9 |
Jais (13B) | 46.5 | 40.4 | 30.0 | 58.3 | 57.7 | 67.6 | 62.6 | 42.5 | 35.8 | 32.4 | 41.1 | 58.4 |
acegpt-13b | 42.5 | 34.7 | 29.9 | 42.3 | 45.6 | 60.3 | 63.2 | 38.1 | 32.8 | 32.2 | 45.1 | 56.4 |
acegpt-7b | 42.4 | 35.4 | 29 | 46.3 | 43.8 | 60.4 | 63.4 | 37.2 | 31.1 | 32 | 45.3 | 55.4 |
BLOOM (7.1B) | 40.9 | 34.0 | 28.2 | 37.1 | 40.9 | 58.4 | 59.9 | 39.1 | 27.3 | 28.0 | 44.4 | 53.5 |
LLaMA (30B) | 38.8 | 27.9 | 28.5 | 32.6 | 35 | 52.7 | 63.7 | 34.9 | 25.7 | 28.6 | 47.2 | 49.8 |
LLaMA2 (13B) | 38.1 | 29.2 | 28.4 | 32.0 | 34.3 | 52.9 | 63.8 | 36.4 | 24.3 | 30.0 | 45.5 | 49.9 |
English evaluation results:
Models | Avg | MMLU | RACE | Hellaswag | PIQA | BoolQA | SituatedQA | ARC-C | OpenBookQA | Winogrande | TruthfulQA | CrowS-Pairs |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Jais (30B) | 56.2 | 34.5 | 39.8 | 75.1 | 79.5 | 74.3 | 49.9 | 45.9 | 41.2 | 68.4 | 36.5 | 73.3 |
Jais (13B) | 53.9 | 31.5 | 38.3 | 71.8 | 77.9 | 67.6 | 48.2 | 41.9 | 40.6 | 68.4 | 35.4 | 71.5 |
OPT-30b | 59.4 | 38.6 | 45.2 | 71.7 | 78.5 | 87.3 | 63.4 | 44.8 | 40.2 | 72.2 | 38.7 | 72.7 |
MPT-30b | 57.3 | 38.8 | 39.7 | 80 | 80.8 | 73.9 | 45.6 | 49.2 | 43.2 | 71.1 | 38.3 | 69.3 |
Llama-30b | 55.4 | 37 | 40.2 | 79.2 | 80.1 | 68.3 | 44 | 45.3 | 42 | 72.7 | 42.3 | 58.2 |
Falcon (40B) | 54.8 | 31.3 | 37.1 | 76.4 | 80.5 | 73.7 | 43.2 | 43.6 | 44.2 | 67.2 | 34.3 | 72.3 |
Citation
@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}
}
Copyright Inception Institute of Artificial Intelligence Ltd.
- Downloads last month
- 36