CoolFace
Modelpublic

rodrigoramosrs/qwen3-4b-dotnet-specialist

sourceHugging Facecc-by-4.0updated 10mo agoView on Hugging Face
5likes242downloads
Model Card

๐Ÿง  qwen3-4b-dotnet-specialist

Fine-tuned model for technical reasoning and .NET documentation understanding

![Model Type]() ![Framework]() ![Dataset](https://huggingface.co/datasets/rodrigoramosrs/dotnet) ![License]()


๐Ÿ“˜ Overview

qwen3-4b-dotnet-specialist is a fine-tuned variant of Qwen 3 (4B parameters), specialized in understanding and generating accurate, structured, and deeply technical content related to the .NET ecosystem, including C#, ASP.NET Core, EF Core, CLI tools, documentation standards, and advanced runtime concepts.

This model was trained with a highly curated dataset of 70,000 question-answer pairs, derived from the official Microsoft documentation repository (dotnet/docs).


โ˜€๏ธ A Sustainable Experiment in AI Engineering

This project was built under a guiding principle:

โ€œGood science is not made of answers, but of the right questions.โ€

Every question in the dataset was algorithmically generated to test specific technical reasoning paths, and each answer was produced through a Retrieval-Augmented Generation (RAG) process โ€” retrieving context from the entire documentation dataset rather than from the paragraph that originated the question.

That design choice produced richer, contextually consistent, and cross-referenced answers โ€” making this model particularly strong in documentation synthesis, reasoning across APIs, and multi-version comparison tasks.

The entire curation, training, and evaluation process was powered using solar energy, highlighting that research-grade AI can be done locally, sustainably, and accessibly.


๐Ÿงฉ Dataset

๐Ÿ“ฆ Dataset used: **rodrigoramosrs/dotnet**

  • โ€”Source: Extracted and processed from `github.com/dotnet/docs`
  • โ€”Original size: ~300 MB of unstructured text
  • โ€”Post-curation size: ~60 MB
  • โ€”Format: JSONL with instruction, input, and output keys
  • โ€”Samples: ~70,000 Q&A pairs
  • โ€”Language: English
  • โ€”Domain: .NET / C# / Microsoft Docs structure

Each entry follows this structure:

json
{
  "instruction": "Explain how to organize tutorials in the .NET documentation portal.",
  "input": "",
  "output": "Detailed, step-by-step answer using the DocFX structure and YAML front-matter conventions."
}

โš™๏ธ Training

  • โ€”Base model: Qwen3-4B (Instruct variant)
  • โ€”Training method: LoRA fine-tuning
  • โ€”Context length: -
  • โ€”Batch size: 8
  • โ€”Precision: bfloat16
  • โ€”Epochs: 6.0
  • โ€”Optimizer: AdamW (8-bit)
  • โ€”Scheduler: Cosine decay with warmup
  • โ€”Learning Rate: 2e-4
  • โ€”Warmup Ratio: 0.7
  • โ€”Gradient Accumulation Steps: 6
  • โ€”Infrastructure: Local GPU (RTX 5080)
  • โ€”Power source: Off-grid solar system

๐Ÿงฎ Data Pipeline

  1. 1.Extraction โ€“ Crawled markdown files from `dotnet/docs`
  2. 2.Cleaning โ€“ Removed metadata, HTML, and outdated versions
  3. 3.Segmentation โ€“ Split long sections into atomic topics
  4. 4.Question Generation โ€“ Built synthetic instructions using a tuned model focused on documentation comprehension
  5. 5.Answer Generation (RAG) โ€“ Retrieved context from the entire dataset before generating final answers
  6. 6.Ranking & Filtering โ€“ Applied cross-encoder ranking and manual curation to ensure quality
  7. 7.Finalization โ€“ Consolidated into clean, versioned JSONL format

๐Ÿ“Š Training Configuration

python
Config:
trainer = SFTTrainer(
    model=model,
    train_dataset=train_ds,
    tokenizer=tokenizer,
    formatting_func=formatting_func,
    args=SFTConfig(
        per_device_train_batch_size=8,
        gradient_accumulation_steps=6,
        num_train_epochs=6.0,
        learning_rate=2e-4,
        lr_scheduler_type="cosine",
        warmup_ratio=0.7,
        logging_steps=10,
        save_strategy="steps",
        save_steps=200,
        eval_steps=200,
        output_dir=output_dir,
        push_to_hub=False,   # ๐Ÿšซ impede upload automรกtico
        hub_model_id=None,   # ๐Ÿšซ nรฃo referencia repositรณrio remoto
        bf16=True,
        gradient_checkpointing=True,
        optim="adamw_8bit",
        weight_decay=0.001,
        max_grad_norm=1.0,
        dataloader_pin_memory=False,
        dataloader_num_workers=4,
        report_to=None,
        ddp_find_unused_parameters=True,   # True ajuda em multi-GPU,
    ),
    eval_dataset=eval_ds,  # โœ… Inclui o dataset de avaliaรงรฃo (opcional, mas recomendado)
)

๐Ÿ“ˆ Training Results

  • โ€”Final Loss: 0.742800
  • โ€”Training Steps: 3930
  • โ€”Evaluation Metrics:
  • โ€”Perplexity: Good
  • โ€”Factual Accuracy (manual): ~High
  • โ€”Response Consistency: High
  • โ€”Formatting Accuracy: High

๐Ÿง  Intended Use

The model excels at:

  • โ€”Explaining .NET concepts, frameworks, and internal mechanics
  • โ€”Answering developer documentation questions
  • โ€”Summarizing and rewriting technical guides
  • โ€”Generating structured technical explanations
  • โ€”Acting as a documentation assistant for software engineers

๐Ÿšซ Limitations

  • โ€”Limited to .NET and related ecosystems โ€” not designed for general-purpose conversation.
  • โ€”May occasionally produce overly detailed explanations when prompted ambiguously.
  • โ€”Not a replacement for Microsoftโ€™s official documentation โ€” rather a complementary reasoning model.

๐Ÿ’ฌ Example Usage

python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_name = "rodrigoramosrs/qwen3-4b-dotnet-specialist"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16).eval()

prompt = """Explain how to publish an ASP.NET Core app using the .NET CLI."""

inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=600, temperature=0.3, top_p=0.9)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))

๐Ÿ”– License & Attribution


๐ŸŒ Closing Note

This project is a proof that precision and sustainability can coexist in AI research. It demonstrates that with the right questions, good data, and discipline, one person โ€” powered by sunlight โ€” can build a specialized model that truly understands a complex technical domain.

Built locally. Trained on clean data. Powered by the sun. โ˜€๏ธ

Model: `rodrigoramosrs/qwen3-4b-dotnet-specialist` Dataset: `rodrigoramosrs/dotnet`