CoolFace
Modelpublic

TurkishCodeMan/Nanbeige4.1-3B-Gmail-Tool-Use

sourceHugging Faceapache-2.0updated 7mo agoView on Hugging Face
2likes7downloads
Model Card

Nanbeige4.1-3B โ€” Gmail Tool-Use (SFT + DPO)

Fine-tuned version of Nanbeige/Nanbeige4.1-3B for Gmail tool-calling tasks using a two-stage training pipeline.

<div align="center"> <img src="https://images.hdqwalls.com/wallpapers/king-glory-anime-boy-4k-ka.jpg" width="800" alt="Nanbeige Gmail Agent Chains" style="border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.2);"> <br><br> <h1>๐Ÿ“ง Nanbeige-4.1-3B Gmail Tool Use Agent</h1> <p><i>A hyper-aligned 3B parameter agent matching GPT-4o-mini performance inside LangGraph.</i></p> </div>

<br>

Training datasets: TurkishCodeMan/Nanbeige4.1-3B-Gmail-Tool-Use-Datasets

Training Pipeline

Stage 1 โ€” Supervised Fine-Tuning (SFT)

  • โ€”Dataset: 740 multi-turn Gmail agent traces (sft/traces_chatml_clean.jsonl)
  • โ€”Format: ChatML with tool_calls (OpenAI function-calling schema)
  • โ€”Method: LoRA r=16, ฮฑ=32, 7 target modules
  • โ€”Result: loss 0.8464 โ†’ 0.1888 ยท PPL 2.33 โ†’ 1.21

Stage 2 โ€” Direct Preference Optimization (DPO)

  • โ€”Dataset: 3223 preference pairs (dpo/dpo_dataset.jsonl) โ€” 3 rejection strategies:
  • โ€”wrong_tool โ€” incorrect tool selected (~34%)
  • โ€”missing_args โ€” required arguments omitted (~32%)
  • โ€”bad_answer โ€” poor final response (~34%)
  • โ€”Method: DPO ฮฒ=0.1, sigmoid loss, LoRA r=16, ref_model=None (PEFT implicit ref)
  • โ€”Result: val_loss=0.000765 ยท reward accuracy=100% ยท normalized margin=+0.52

Supported Tools

ToolDescription
search_emailsSearch Gmail inbox with filters
read_emailRead full email content by ID
send_emailSend a new email
draft_emailCreate a draft
modify_emailAdd/remove labels, mark read/unread
download_attachmentDownload email attachment

Usage

python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model = AutoModelForCausalLM.from_pretrained(
    "TurkishCodeMan/Nanbeige4.1-3B-Gmail-Tool-Use",
    torch_dtype=torch.bfloat16,
    trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(
    "TurkishCodeMan/Nanbeige4.1-3B-Gmail-Tool-Use",
    trust_remote_code=True,
)

Training Details

ParameterValue
Base modelNanbeige/Nanbeige4.1-3B
SFT LoRA rank16
DPO LoRA rank16
DPO ฮฒ0.1
Max length2682 tokens
GPU1ร— RTX 4090 24GB
FrameworkTRL 0.22 ยท Transformers 4.57 ยท PEFT 0.18