Views
No views yet
| Item | Detail |
|---|---|
| Parent model | zainkhanz/qwen3-4b-toxic-unsloth |
| Original base | Qwen/Qwen3-4B-Instruct-2507 |
| Quantization | bitsandbytes 4-bit NF4 + double quant |
| Parameters | ~4B |
| Training | Unsloth SFT then DPO, then quantize |
| Dataset | adamo1139/toxic-dpo-natural-v5 |
| Repo | Format |
|---|---|
| zainkhanz/qwen3-4b-toxic-unsloth | 16-bit merged |
| This repo | 4-bit NF4 |
| zainkhanz/qwen3-4b-toxic-unsloth-bnb-8bit | 8-bit |
1from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
2import torch
3
4model_id = "zainkhanz/qwen3-4b-toxic-unsloth-bnb-4bit"
5
6bnb = BitsAndBytesConfig(
7 load_in_4bit=True,
8 bnb_4bit_quant_type="nf4",
9 bnb_4bit_compute_dtype=torch.bfloat16,
10 bnb_4bit_use_double_quant=True,
11)
12
13tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
14model = AutoModelForCausalLM.from_pretrained(
15 model_id,
16 quantization_config=bnb,
17 device_map="auto",
18 trust_remote_code=True,
19)
20
21messages = [{"role": "user", "content": "Your question here."}]
22text = tokenizer.apply_chat_template(
23 messages,
24 tokenize=False,
25 add_generation_prompt=True,
26)
27inputs = tokenizer(text, return_tensors="pt").to(model.device)
28
29outputs = model.generate(
30 **inputs,
31 max_new_tokens=512,
32 temperature=0.7,
33 do_sample=True,
34 pad_token_id=tokenizer.eos_token_id,
35)
36print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))1@misc{zainkhanz_qwen3_4b_toxic_unsloth_bnb_4bit,
2 author = {zainkhanz},
3 title = {Qwen3-4B Toxic Unsloth (4-bit NF4 bitsandbytes)},
4 year = {2026},
5 publisher = {Hugging Face},
6 howpublished = {https://huggingface.co/zainkhanz/qwen3-4b-toxic-unsloth-bnb-4bit}
7}