Views
No views yet
nvidia/Llama-3_3-Nemotron-Super-49B-v1, modified to use a custom attention mechanism defined by the l_mul_attention function from the lmul library.DeciLM (decilm)forward method of the DeciAttention module has been replaced (monkey-patched) with a custom implementation that utilizes the l_mul_attention logic. Note that in some blocks of the original model, the attention layer is skipped entirely; those blocks are unaffected by this modification.l_mul_attention function implements a novel approach to calculating attention scores, and this model serves as a test case for evaluating its performance, efficiency, and impact on reasoning and generation tasks compared to the standard attention implementation.transformers library pipeline. Because the base model uses a custom architecture, you must use trust_remote_code=True when loading it.1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4# Make sure to log in with your Hugging Face token if the model is private
5# from huggingface_hub import login
6# login("your-hf-token")
7
8model_id = "YOUR_HF_USERNAME/Llama-3_3-Nemotron-Super-49B-v1-LMUL" # Replace with your HF username
9device = "cuda" if torch.cuda.is_available() else "cpu"
10
11tokenizer = AutoTokenizer.from_pretrained(model_id)
12model = AutoModelForCausalLM.from_pretrained(
13 model_id,
14 torch_dtype=torch.bfloat16,
15 device_map="auto",
16 trust_remote_code=True # Important! Required by the base model
17)
18
19# The base model uses a system prompt to control reasoning
20thinking = "on" # or "off"
21messages = [
22 {"role": "system", "content": f"detailed thinking {thinking}"},
23 {"role": "user", "content": "What is the airspeed velocity of an unladen swallow?"}
24]
25
26# Note: The original model's tokenizer does not have a chat template.
27# You must apply it manually or use the pipeline as shown in the original model card.
28# For simplicity, we'll format the prompt manually here.
29prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
30model_inputs = tokenizer([prompt], return_tensors="pt").to(model.device)
31
32generated_ids = model.generate(
33 **model_inputs,
34 max_new_tokens=512,
35 temperature=0.6,
36 top_p=0.95
37)
38response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
39
40print(response)nvidia-open-model-license, which is the same license as the base model, nvidia/Llama-3_3-Nemotron-Super-49B-v1. By using this model, you agree to the terms of the original license. It is your responsibility to ensure compliance with all applicable licenses and regulations. The model is also built upon Meta Llama 3, and its use is subject to the Llama 3.3 Community License Agreement.