Views
No views yet
Qwen/Qwen3-1.7B-BaseMBZUAI/LaMini-instruction (we utilized half of the data)### Input:, use:prompt_format.py.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4MODEL_ID = "ericoh929/qwen3-1.7b-lamini-qlora-instruction-tuned"
5
6tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 MODEL_ID,
9 trust_remote_code=True,
10 device_map="auto",
11 torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
12)
13model.eval()
14
15instruction = "Answer the question concisely."
16inp = "If Tom has 3 apples and buys 4 more, how many apples does he have?"
17
18prompt = (
19 f"### Instruction:\n{instruction}\n\n"
20 f"### Input:\n{inp}\n\n"
21 f"### Response:\n"
22)
23
24inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
25
26with torch.inference_mode():
27 out = model.generate(
28 **inputs,
29 max_new_tokens=128,
30 do_sample=False,
31 pad_token_id=tokenizer.pad_token_id or tokenizer.eos_token_id,
32 eos_token_id=tokenizer.eos_token_id,
33 )
34
35# Decode only the generated continuation (recommended)
36gen_ids = out[0][inputs["input_ids"].shape[1]:]
37answer = tokenizer.decode(gen_ids, skip_special_tokens=True).strip()
38print(answer)• Single-turn instruction following
• General Q/A, short reasoning, summarization style tasks• Trained on a synthetic/large instruction dataset; outputs can contain hallucinations.
• Best results are achieved when using the training prompt format shown above.
• This is a 1.7B model; complex reasoning / long-context tasks may be limited.• Method: QLoRA (4-bit base during training) + LoRA adapters
• Merge: Loaded base model in fp16/bf16 and merged adapters with merge_and_unload()
• max_seq_len: 2048