Recorded memory numbers above are GPU memory / VRAM measurements taken from the training run. The notebook did not record host system RAM.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3repo_id = "AyoubChLin/Qwen3.5-4B-saudi-dialect"
4
5tokenizer = AutoTokenizer.from_pretrained(repo_id)
6model = AutoModelForCausalLM.from_pretrained(
7 repo_id,
8 torch_dtype="auto",
9 device_map="auto",
10)
11
12messages = [
13 {"role": "system", "content": "أنت مساعد مفيد يتحدث باللهجة السعودية العامية."},
14 {"role": "user", "content": "كيف حالك اليوم؟"},
15]
16
17input_ids = tokenizer.apply_chat_template(
18 messages,
19 tokenize=True,
20 add_generation_prompt=True,
21 enable_thinking=False,
22 return_tensors="pt",
23).to(model.device)
24
25outputs = model.generate(
26 input_ids,
27 max_new_tokens=200,
28 temperature=0.7,
29 top_p=0.9,
30)
31
32print(tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True))
1%%capture
2import re, torch
3
4v = re.match(r"[\d]{1,}\.[\d]{1,}", str(torch.__version__)).group(0)
5xformers = "xformers==" + {
6 "2.10": "0.0.34",
7 "2.9": "0.0.33.post1",
8 "2.8": "0.0.32.post2",
9}.get(v, "0.0.34")
10
11!pip install sentencepiece protobuf "datasets>=2.18.0" "huggingface_hub>=0.34.0" hf_transfer wandb
12!pip install --no-deps unsloth_zoo bitsandbytes accelerate {xformers} peft trl triton unsloth
13!pip install -q "transformers>=5.0.0"
14!pip install -q --no-deps "trl>=0.15.0"
1from unsloth import FastLanguageModel
2
3repo_id = "AyoubChLin/Qwen3.5-4B-saudi-dialect"
4max_seq_length = 4096
5
6model, tokenizer = FastLanguageModel.from_pretrained(
7 model_name=repo_id,
8 max_seq_length=max_seq_length,
9 load_in_4bit=False, # this repo was pushed as merged_16bit
10)
11
12FastLanguageModel.for_inference(model)
13
14messages = [
15 {
16 "role": "system",
17 "content": [
18 {"type": "text", "text": "أنت مساعد مفيد يتحدث باللهجة السعودية العامية."}
19 ],
20 },
21 {
22 "role": "user",
23 "content": [
24 {"type": "text", "text": "كيف حالك اليوم؟"}
25 ],
26 },
27]
28
29input_ids = tokenizer.apply_chat_template(
30 messages,
31 tokenize=True,
32 add_generation_prompt=True,
33 enable_thinking=False,
34 return_tensors="pt",
35).to(model.device)
36
37output_ids = model.generate(
38 input_ids=input_ids,
39 max_new_tokens=200,
40 use_cache=True,
41 temperature=0.7,
42 top_p=0.9,
43)
44
45response = tokenizer.decode(
46 output_ids[0][input_ids.shape[-1]:],
47 skip_special_tokens=True,
48)
49print(response)