Views
No views yet
DictaLM-2.0 here.1from transformers import pipeline
2import torch
3
4# This loads the model onto the GPU in bfloat16 precision
5model = pipeline('text-generation', 'dicta-il/dictalm2.0', torch_dtype=torch.bfloat16, device_map='cuda')
6
7# Sample few shot examples
8prompt = """
9עבר: הלכתי
10עתיד: אלך
11
12עבר: שמרתי
13עתיד: אשמור
14
15עבר: שמעתי
16עתיד: אשמע
17
18עבר: הבנתי
19עתיד:
20"""
21
22print(model(prompt.strip(), do_sample=False, max_new_tokens=8, stop_sequence='\n'))
23# [{'generated_text': 'עבר: הלכתי\nעתיד: אלך\n\nעבר: שמרתי\nעתיד: אשמור\n\nעבר: שמעתי\nעתיד: אשמע\n\nעבר: הבנתי\nעתיד: אבין\n\n'}]GPTQ and AWQ methods available for use: DictaLM-2.0-AWQ and DictaLM-2.0-GPTQ.bitsandbytes package, requiring :1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model = AutoModelForCausalLM.from_pretrained('dicta-il/dictalm2.0', torch_dtype=torch.bfloat16, device_map='cuda', load_in_4bit=True)
5tokenizer = AutoTokenizer.from_pretrained('dicta-il/dictalm2.0')
6
7prompt = """
8עבר: הלכתי
9עתיד: אלך
10
11עבר: שמרתי
12עתיד: אשמור
13
14עבר: שמעתי
15עתיד: אשמע
16
17עבר: הבנתי
18עתיד:
19"""
20
21encoded = tokenizer(prompt.strip(), return_tensors='pt').to(model.device)
22print(tokenizer.batch_decode(model.generate(**encoded, do_sample=False, max_new_tokens=4)))
23# ['<s> עבר: הלכתי\nעתיד: אלך\n\nעבר: שמרתי\nעתיד: אשמור\n\nעבר: שמעתי\nעתיד: אשמע\n\nעבר: הבנתי\nעתיד: אבין\n\n']1@misc{shmidman2024adaptingllmshebrewunveiling,
2 title={Adapting LLMs to Hebrew: Unveiling DictaLM 2.0 with Enhanced Vocabulary and Instruction Capabilities},
3 author={Shaltiel Shmidman and Avi Shmidman and Amir DN Cohen and Moshe Koppel},
4 year={2024},
5 eprint={2407.07080},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2407.07080},
9}