Views
No views yet
1apt-get update
2apt-get install -y --no-install-recommends \
3 build-essential1transformers==4.56.2
2accelerate==1.11.0
3peft==0.18.0
4torch==2.10
5flash-attn @ https://github.com/mjun0812/flash-attention-prebuild-wheels/releases/download/v0.7.12/flash_attn-2.8.3+cu128torch2.10-cp312-cp312-linux_x86_64.whlhf auth login1from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig
2import torch
3
4model_id = "openchip-sw/Qwen3-4B-LayerBoost"
5
6device = "cuda" if torch.cuda.is_available() else "cpu"
7
8config = AutoConfig.from_pretrained(model_id)
9tokenizer = AutoTokenizer.from_pretrained(model_id)
10model = AutoModelForCausalLM.from_pretrained(
11 model_id,
12 trust_remote_code=True,
13)
14
15model.eval()
16model.to(device)
17
18prompt = "give me the list of European countrie accompanied with the capitals"
19
20eval_inputs = tokenizer(prompt, return_tensors="pt")
21eval_inputs = {k: v.to(device) for k, v in eval_inputs.items()}
22eval_tokens = model.generate(
23 **eval_inputs,
24 max_new_tokens=512,
25 do_sample=False,
26 use_cache=True,
27 return_dict_in_generate=True,
28)
29
30out_text = tokenizer.decode(eval_tokens.sequences[0], skip_special_tokens=True)
31print("Generated text:", out_text)