Views
No views yet
DictaLM-2.0 here.[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.text = """<s>[INST] איזה רוטב אהוב עליך? [/INST]
טוב, אני די מחבב כמה טיפות מיץ לימון סחוט טרי. זה מוסיף בדיוק את הכמות הנכונה של טעם חמצמץ לכל מה שאני מבשל במטבח!</s>[INST] האם יש לך מתכונים למיונז? [/INST]"apply_chat_template() method:1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4device = "cuda" # the device to load the model onto
5
6model = AutoModelForCausalLM.from_pretrained("dicta-il/dictalm2.0-instruct", torch_dtype=torch.bfloat16, device_map=device)
7tokenizer = AutoTokenizer.from_pretrained("dicta-il/dictalm2.0-instruct")
8
9messages = [
10 {"role": "user", "content": "איזה רוטב אהוב עליך?"},
11 {"role": "assistant", "content": "טוב, אני די מחבב כמה טיפות מיץ לימון סחוט טרי. זה מוסיף בדיוק את הכמות הנכונה של טעם חמצמץ לכל מה שאני מבשל במטבח!"},
12 {"role": "user", "content": "האם יש לך מתכונים למיונז?"}
13]
14
15encoded = tokenizer.apply_chat_template(messages, return_tensors="pt").to(device)
16
17generated_ids = model.generate(encoded, max_new_tokens=50, do_sample=True)
18decoded = tokenizer.batch_decode(generated_ids)
19print(decoded[0])
20# <s> [INST] איזה רוטב אהוב עליך? [/INST]
21# טוב, אני די מחבב כמה טיפות מיץ לימון סחוט טרי. זה מוסיף בדיוק את הכמות הנכונה של טעם חמצמץ לכל מה שאני מבשל במטבח!</s> [INST] האם יש לך מתכונים למיונז? [/INST]
22# בטח, הנה מתכון בסיסי וקל להכנת מיונז ביתי!
23#
24# מרכיבים:
25# - 2 חלמונים גדולים
26# - 1 כף חומץ יין לבן
27# (it stopped early because we set max_new_tokens=50)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}