Views
No views yet
unsloth/Llama-3.3-70B-Instruct-bnb-4bit. It uses Meta’s Llama 3 chat format (<|begin_of_text|>…<|eot_id|>) and maintains the 128K long‑context setting (RoPE scaling with θ≈500k). Architecture hyperparameters are inherited from the Llama 3.x/70B family (80 layers, hidden size 8192, 64 attention heads, 8 KV heads; FFN dim ~28,672). (Hugging Face, Llama, ar5iv)<|begin_of_text|><|eot_id|> (recommended stop token for chat)<|finetune_right_pad_id|> (Unsloth convention to avoid EOS-as-PAD pitfalls) (Llama, GitHub)unsloth/Llama-3.3-70B-Instruct-bnb-4bit. (Hugging Face)meta-llama/Llama-3.3-70B-Instruct. (Hugging Face)unsloth/Llama-3.3-70B-Instruct-bnb-4bit. (Hugging Face)<|eot_id|>. (Hugging Face)<|eot_id|> or mis‑setting PAD to EOS can cause run‑on or truncated generations. Use the official template and a dedicated PAD (e.g., <|finetune_right_pad_id|>). (Llama, Hugging Face Forums, GitHub)Option A — Full merged model (if you pushed a full model repo)
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
3
4model_id = "vhdrostami/sciloop-neuro-motor-70b" # this fine-tune repo if weights are merged
5bnb = BitsAndBytesConfig(load_in_4bit=True,
6 bnb_4bit_quant_type="nf4",
7 bnb_4bit_use_double_quant=True,
8 bnb_4bit_compute_dtype=torch.bfloat16)
9
10tok = AutoTokenizer.from_pretrained(model_id, use_fast=True)
11model = AutoModelForCausalLM.from_pretrained(
12 model_id,
13 device_map="auto",
14 torch_dtype=torch.bfloat16,
15 quantization_config=bnb,
16 attn_implementation="flash_attention_2", # if available
17)
18
19messages = [
20 {"role": "system", "content": "You are a helpful assistant."},
21 {"role": "user", "content": "Summarize the attached report in 5 bullets."},
22]
23inputs = tok.apply_chat_template(messages, add_generation_prompt=True,
24 return_tensors="pt").to(model.device)
25eot_id = tok.convert_tokens_to_ids("<|eot_id|>")
26out = model.generate(inputs, max_new_tokens=512, eos_token_id=eot_id)
27print(tok.decode(out[0], skip_special_tokens=True))Option B — PEFT/LoRA adapters (if you’re sharing adapters only)
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
3from peft import PeftModel
4
5base = "unsloth/Llama-3.3-70B-Instruct-bnb-4bit"
6adapter = "YOUR-ORG/YOUR-ADAPTER"
7bnb = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4",
8 bnb_4bit_use_double_quant=True,
9 bnb_4bit_compute_dtype=torch.bfloat16)
10
11tok = AutoTokenizer.from_pretrained(base, use_fast=True)
12base_model = AutoModelForCausalLM.from_pretrained(
13 base, device_map="auto", torch_dtype=torch.bfloat16,
14 quantization_config=bnb, attn_implementation="flash_attention_2",
15)
16model = PeftModel.from_pretrained(base_model, adapter)<|eot_id|>. Keep PAD as a dedicated token (e.g., <|finetune_right_pad_id|>) rather than EOS. (Llama, GitHub)lm-eval or on HF Evaluation on the Hub; ensure the chat template is applied and stop at <|eot_id|> to avoid over‑generation bias. (GitHub)1@article{meta2024llama3,
2 title={The Llama 3 Herd of Models},
3 author={Meta AI},
4 journal={arXiv preprint arXiv:2407.21783},
5 year={2024}
6}1@article{dettmers2023qlora,
2 title={QLoRA: Efficient Finetuning of Quantized LLMs},
3 author={Dettmers, Tim and Pagnoni, Artidoro and Holtzman, Ari and Zettlemoyer, Luke},
4 journal={arXiv preprint arXiv:2305.14314},
5 year={2023}
6}config.json)config.json)architectures=["LlamaForCausalLM"], model_type="llama"num_hidden_layers=80, hidden_size=8192, num_attention_heads=64, num_key_value_heads=8, intermediate_size=28672, head_dim=128max_position_embeddings=131072 (≈128K), rope_theta=500000.0, rope_scaling={"type":"llama3","factor":8,...}bos_token_id=128000, eos_token_id=[128001,128008,128009], pad_token_id=128004quantization_config: load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True, bnb_4bit_compute_dtype="bfloat16"For correctness and best behavior, format prompts using the Llama 3 chat template and stop generation on<|eot_id|>. (Llama)