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

The DictaLM-2.0 Large Language Model (LLM) is a pretrained generative text model with 7 billion parameters trained to specialize in Hebrew text.

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

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

Example Code

from transformers import pipeline
import torch

# This loads the model onto the GPU in bfloat16 precision
model = pipeline('text-generation', 'dicta-il/dictalm2.0', torch_dtype=torch.bfloat16, device_map='cuda')

# Sample few shot examples
prompt = """
Χ’Χ‘Χ¨: Χ”ΧœΧ›ΧͺΧ™
Χ’ΧͺΧ™Χ“: אלך

Χ’Χ‘Χ¨: שמרΧͺΧ™
Χ’ΧͺΧ™Χ“: ΧΧ©ΧžΧ•Χ¨

Χ’Χ‘Χ¨: שמגΧͺΧ™
Χ’ΧͺΧ™Χ“: אשמג

Χ’Χ‘Χ¨: Χ”Χ‘Χ ΧͺΧ™
Χ’ΧͺΧ™Χ“:
"""

print(model(prompt.strip(), do_sample=False, max_new_tokens=8, stop_sequence='\n'))
# [{'generated_text': 'Χ’Χ‘Χ¨: Χ”ΧœΧ›ΧͺΧ™\nΧ’ΧͺΧ™Χ“: אלך\n\nΧ’Χ‘Χ¨: שמרΧͺΧ™\nΧ’ΧͺΧ™Χ“: ΧΧ©ΧžΧ•Χ¨\n\nΧ’Χ‘Χ¨: שמגΧͺΧ™\nΧ’ΧͺΧ™Χ“: אשמג\n\nΧ’Χ‘Χ¨: Χ”Χ‘Χ ΧͺΧ™\nΧ’ΧͺΧ™Χ“: ΧΧ‘Χ™ΧŸ\n\n'}]

Example Code - 4-Bit

There are already pre-quantized 4-bit models using the GPTQ and AWQ methods available for use: DictaLM-2.0-AWQ and DictaLM-2.0-GPTQ.

For dynamic quantization on the go, here is sample code which loads the model onto the GPU using the bitsandbytes package, requiring :

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model = AutoModelForCausalLM.from_pretrained('dicta-il/dictalm2.0', torch_dtype=torch.bfloat16, device_map='cuda', load_in_4bit=True)
tokenizer = AutoTokenizer.from_pretrained('dicta-il/dictalm2.0')

prompt = """
Χ’Χ‘Χ¨: Χ”ΧœΧ›ΧͺΧ™
Χ’ΧͺΧ™Χ“: אלך

Χ’Χ‘Χ¨: שמרΧͺΧ™
Χ’ΧͺΧ™Χ“: ΧΧ©ΧžΧ•Χ¨

Χ’Χ‘Χ¨: שמגΧͺΧ™
Χ’ΧͺΧ™Χ“: אשמג

Χ’Χ‘Χ¨: Χ”Χ‘Χ ΧͺΧ™
Χ’ΧͺΧ™Χ“:
"""

encoded = tokenizer(prompt.strip(), return_tensors='pt').to(model.device)
print(tokenizer.batch_decode(model.generate(**encoded, do_sample=False, max_new_tokens=4)))
# ['<s> Χ’Χ‘Χ¨: Χ”ΧœΧ›ΧͺΧ™\nΧ’ΧͺΧ™Χ“: אלך\n\nΧ’Χ‘Χ¨: שמרΧͺΧ™\nΧ’ΧͺΧ™Χ“: ΧΧ©ΧžΧ•Χ¨\n\nΧ’Χ‘Χ¨: שמגΧͺΧ™\nΧ’ΧͺΧ™Χ“: אשמג\n\nΧ’Χ‘Χ¨: Χ”Χ‘Χ ΧͺΧ™\nΧ’ΧͺΧ™Χ“: ΧΧ‘Χ™ΧŸ\n\n']

Model Architecture

DictaLM-2.0 is based on the Mistral-7B-v0.1 model with the following changes:

  • An extended tokenizer with 1,000 injected tokens specifically for Hebrew, increasing the compression rate from 5.78 tokens/word to 2.76 tokens/word.
  • Continued pretraining on over 190B tokens of naturally occuring text, 50% Hebrew and 50% English.

Notice

DictaLM 2.0 is a pretrained base model and therefore does not have any moderation mechanisms.

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
708
Safetensors
Model size
7B params
Tensor type
BF16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for dicta-il/dictalm2.0

Adapters
3 models
Finetunes
4 models
Quantizations
10 models

Spaces using dicta-il/dictalm2.0 4

Collection including dicta-il/dictalm2.0

Paper for dicta-il/dictalm2.0