22 2 weeks ago

tools thinking
ollama run brnpistone/NVIDIA-Nemotron-3-Nano-30-AgentCoder-q5-k-m

Details

2 weeks ago

218d0710ab67 · 26GB ·

nemotron_h_moe
·
31.6B
·
Q5_K_M
{{- $lastUserIdx := -1 -}} {{- range $idx, $msg := .Messages -}} {{- if eq $msg.Role "user" }}{{ $la
{ "min_p": 0, "repeat_last_n": 256, "repeat_penalty": 1.15, "stop": [ "<|im_

Readme

🧠 NVIDIA-Nemotron-3-Nano-30B-A3B-AgentCoder

A Fine-Tuned Model for Enhanced Tool Calling, Code Generation, and Reasoning


Model Description

NVIDIA-Nemotron-3-Nano-30B-A3B-AgentCoder is a fine-tuned version of the NVIDIA Nemotron-3-Nano-30B-A3B hybrid Mamba-2 / Attention / MoE model, optimized for: - 🧮 Complex reasoning tasks - 🧰 Tool calling - 💻 Code generation

The model was post-trained with Direct Preference Optimization (DPO) on preference pairs collected from real conversations with my own agentic coding tool, to improve alignment, coherence, and reasoning accuracy on agentic workflows.

Highlights

  • Post-trained with DPO using chosen/rejected pairs harvested from real agentic sessions
  • Preference data reflects actual tool-calling traces, not synthetic prompts
  • LoRA adapters merged into the base weights — usable as a standard transformers checkpoint
  • Retains the base model’s thinking mode and 262K context window
  • Excellent balance between tool use, code generation, and reasoning

🚀 Direct Use

NVIDIA-Nemotron-3-Nano-30B-A3B-AgentCoder can be used directly for: - ✅ Tool calling in complex, multi-step agentic tasks - ✅ Code generation for Python, JS, and other languages - ✅ Multi-domain reasoning (math, logic, Q&A)

⚠️ Out-of-Scope Use

  • ❌ Highly sensitive or confidential data
  • ❌ Domains requiring expert-level specialization
  • ❌ Tasks where full explainability is mandatory

💻 Getting Started

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_name = "br1-pist/NVIDIA-Nemotron-3-Nano-30B-A3B-AgentCoder"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto",
    trust_remote_code=True
)
prompt = "Give me a short introduction to large language models."
messages = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(**model_inputs, max_new_tokens=1024)
output = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
print(output)

The chat template supports tool calling (pass tools=[...] to apply_chat_template) and thinking mode (enable_thinking=True / False, with truncate_history_thinking to drop reasoning traces from previous turns).


🧠 Training Details

Training Procedure

Phase 1 — Post-Training - Direct Preference Optimization (DPO)

The model underwent a DPO phase to enhance response alignment, reasoning robustness, and factual consistency on agentic tool-calling tasks. Training used LoRA adapters under FSDP full sharding, later merged into the base weights.

DPO objective - Beta: 0.1 (KL penalty strength) - Loss type: sigmoid - Max sequence length (prompt + completion): 5248 tokens (p95 of the dataset) - Attention implementation: kernels-community/flash-attn3

Optimization - Learning rate: 2.45e-6 - LR scheduler: cosine - Warmup steps: 4 - Epochs: 1 - Per-device train / eval batch size: 1 - Gradient accumulation: 2 (effective batch size 2 per device) - Max grad norm: 0.5 - Weight decay: 0.01 - Gradient checkpointing: enabled - Precision: bfloat16 (bf16: true, tf32: true) - Evaluation: every 10 steps - Checkpointing: every 10 steps (save_total_limit: 1)

LoRA configuration - Rank (r): 16 - Alpha: 32 - Dropout: 0.1 - Target modules: q_proj, k_proj, v_proj, o_proj, in_proj, out_proj (attention projections + Mamba-2 in/out projections) - Quantization: none (no 4-bit / MXFP4 — full bfloat16 base)

Distributed strategy (FSDP) - full_shard auto_wrap - Wrapped layer class: NemotronHBlock - reshard_after_forward: true (FSDP2) - CPU offload / CPU RAM-efficient loading: disabled

DPO Data
  • Chosen/rejected response pairs collected from real conversations with my agentic coding tool
  • Chosen samples: responses that produced correct tool calls, valid code, and coherent reasoning in the actual session
  • Rejected samples: failed or degraded turns from the same sessions (wrong/malformed tool calls, incoherent or verbose answers)

Objective - Encourage the model to prefer chosen completions - Improve clarity, correctness, and helpfulness - Reduce hallucinations, malformed tool calls, and verbosity


🖥️ Technical Specifications

Model Architecture

  • Model type: Causal language model — hybrid Mamba-2 / Attention / MoE (NemotronHForCausalLM)
  • Parameters: ~30B total, ~3B active per token (A3B)
  • Layers: 52 (MEMEM*EMEMEM*... — Mamba-2 M, self-attention *, MoE E)
  • Hidden size: 2688 · attention heads: 32 · KV heads: 2 (GQA)
  • MoE: 128 routed experts, top-6 routing + 1 shared expert
  • Vocabulary: 131,072 tokens
  • Context length: 262,144 tokens (~256K)
  • Precision: bfloat16
  • Thinking mode: Enabled

Compute Infrastructure

Hardware - GPU: NVIDIA H100 (80 GB VRAM) - System RAM: 2 TiB - Memory per vCPU: 10.67 GiB

Software - Python: 3.12 - Transformers: 5.13.1 - Libraries: peft, trl, torch, safetensors, accelerate, kernels, flash-attn3, tokenizers, psutil


🧾 Citation

BibTeX

@article{nemotron3-nano-30b-a3b-agentcoder,
  title={NVIDIA-Nemotron-3-Nano-30B-A3B-AgentCoder: A Fine-Tuned Model for Enhanced Tool Calling, Code Generation, and Reasoning},
  author={Bruno Pistone},
  year={2026},
  journal={Hugging Face Model Hub}
}

APA

Bruno Pistone. (2026). NVIDIA-Nemotron-3-Nano-30B-A3B-AgentCoder: A Fine-Tuned Model for Enhanced Tool Calling, Code Generation, and Reasoning. Hugging Face Model Hub. https://huggingface.co/br1-pist/NVIDIA-Nemotron-3-Nano-30B-A3B-AgentCoder


🧭 Recommendations

  • Tool use accuracy depends on task complexity
  • Code generation may occasionally produce minor syntax issues
  • Reasoning strongest in structured, logical, and mathematical contexts
  • DPO data comes from a single agentic tool, so preferences may reflect that tool’s conventions
  • Avoid using this model for confidential or safety-critical applications
  • Use of this model is subject to the NVIDIA Nemotron Open Model License

🧠 NVIDIA-Nemotron-3-Nano-30B-A3B-AgentCoder — created by Bruno Pistone
Enhanced reasoning, tool calling, and code generation — refined with DPO alignment