Adapting LLMs to Hebrew: Unveiling DictaLM 2.0 with Enhanced Vocabulary and Instruction Capabilities

The DictaLM-2.0-Instruct Large Language Model (LLM) is an instruct fine-tuned version of the DictaLM-2.0 generative model using a variety of conversation datasets.

For full details of this model please read our release blog post or the technical report.

This is the instruct-tuned full-precision model designed for chat. You can try the model out on a live demo here.

You can view and access the full collection of base/instruct unquantized/quantized versions of DictaLM-2.0 here.

Instruction format

In order to leverage instruction fine-tuning, your prompt should be surrounded by [INST] and [/INST] tokens. The very first instruction should begin with a begin of sentence id. The next instructions should not. The assistant generation will be ended by the end-of-sentence token id.

E.g.

text = """<s>[INST] ืื™ื–ื” ืจื•ื˜ื‘ ืื”ื•ื‘ ืขืœื™ืš? [/INST]
ื˜ื•ื‘, ืื ื™ ื“ื™ ืžื—ื‘ื‘ ื›ืžื” ื˜ื™ืคื•ืช ืžื™ืฅ ืœื™ืžื•ืŸ ืกื—ื•ื˜ ื˜ืจื™. ื–ื” ืžื•ืกื™ืฃ ื‘ื“ื™ื•ืง ืืช ื”ื›ืžื•ืช ื”ื ื›ื•ื ื” ืฉืœ ื˜ืขื ื—ืžืฆืžืฅ ืœื›ืœ ืžื” ืฉืื ื™ ืžื‘ืฉืœ ื‘ืžื˜ื‘ื—!</s>[INST] ื”ืื ื™ืฉ ืœืš ืžืชื›ื•ื ื™ื ืœืžื™ื•ื ื–? [/INST]"

This format is available as a chat template via the apply_chat_template() method:

Example Code

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

device = "cuda" # the device to load the model onto

model = AutoModelForCausalLM.from_pretrained("dicta-il/dictalm2.0-instruct", torch_dtype=torch.bfloat16, device_map=device)
tokenizer = AutoTokenizer.from_pretrained("dicta-il/dictalm2.0-instruct")

messages = [
    {"role": "user", "content": "ืื™ื–ื” ืจื•ื˜ื‘ ืื”ื•ื‘ ืขืœื™ืš?"},
    {"role": "assistant", "content": "ื˜ื•ื‘, ืื ื™ ื“ื™ ืžื—ื‘ื‘ ื›ืžื” ื˜ื™ืคื•ืช ืžื™ืฅ ืœื™ืžื•ืŸ ืกื—ื•ื˜ ื˜ืจื™. ื–ื” ืžื•ืกื™ืฃ ื‘ื“ื™ื•ืง ืืช ื”ื›ืžื•ืช ื”ื ื›ื•ื ื” ืฉืœ ื˜ืขื ื—ืžืฆืžืฅ ืœื›ืœ ืžื” ืฉืื ื™ ืžื‘ืฉืœ ื‘ืžื˜ื‘ื—!"},
    {"role": "user", "content": "ื”ืื ื™ืฉ ืœืš ืžืชื›ื•ื ื™ื ืœืžื™ื•ื ื–?"}
]

encoded = tokenizer.apply_chat_template(messages, return_tensors="pt").to(device)

generated_ids = model.generate(encoded, max_new_tokens=50, do_sample=True)
decoded = tokenizer.batch_decode(generated_ids)
print(decoded[0])
# <s> [INST] ืื™ื–ื” ืจื•ื˜ื‘ ืื”ื•ื‘ ืขืœื™ืš? [/INST]
# ื˜ื•ื‘, ืื ื™ ื“ื™ ืžื—ื‘ื‘ ื›ืžื” ื˜ื™ืคื•ืช ืžื™ืฅ ืœื™ืžื•ืŸ ืกื—ื•ื˜ ื˜ืจื™. ื–ื” ืžื•ืกื™ืฃ ื‘ื“ื™ื•ืง ืืช ื”ื›ืžื•ืช ื”ื ื›ื•ื ื” ืฉืœ ื˜ืขื ื—ืžืฆืžืฅ ืœื›ืœ ืžื” ืฉืื ื™ ืžื‘ืฉืœ ื‘ืžื˜ื‘ื—!</s>  [INST] ื”ืื ื™ืฉ ืœืš ืžืชื›ื•ื ื™ื ืœืžื™ื•ื ื–? [/INST]
# ื‘ื˜ื—, ื”ื ื” ืžืชื›ื•ืŸ ื‘ืกื™ืกื™ ื•ืงืœ ืœื”ื›ื ืช ืžื™ื•ื ื– ื‘ื™ืชื™!
# 
# ืžืจื›ื™ื‘ื™ื:
# - 2 ื—ืœืžื•ื ื™ื ื’ื“ื•ืœื™ื
# - 1 ื›ืฃ ื—ื•ืžืฅ ื™ื™ืŸ ืœื‘ืŸ
# (it stopped early because we set max_new_tokens=50)

Model Architecture

DictaLM-2.0-Instruct follows the Zephyr-7B-beta recipe for fine-tuning an instruct model, with an extended instruct dataset for Hebrew.

Limitations

The DictaLM 2.0 Instruct model is a demonstration that the base model can be fine-tuned to achieve compelling performance. It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.

Citation

If you use this model, please cite:

@misc{shmidman2024adaptingllmshebrewunveiling,
      title={Adapting LLMs to Hebrew: Unveiling DictaLM 2.0 with Enhanced Vocabulary and Instruction Capabilities}, 
      author={Shaltiel Shmidman and Avi Shmidman and Amir DN Cohen and Moshe Koppel},
      year={2024},
      eprint={2407.07080},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2407.07080}, 
}
Downloads last month
50,378
Safetensors
Model size
7.25B params
Tensor type
BF16
ยท
Inference API
Input a message to start chatting with dicta-il/dictalm2.0-instruct.

Model tree for dicta-il/dictalm2.0-instruct

Finetuned
(4)
this model
Finetunes
5 models
Quantizations
5 models

Spaces using dicta-il/dictalm2.0-instruct 7

Collection including dicta-il/dictalm2.0-instruct