> Instruction-tuned model with LoRA can enforce structured output without losing general knowledge.

# KSS-Format Instruction-Tuned Model (LoRA)

## πŸ“Œ Model Description

This model is instruction-tuned to generate summaries in a structured format:

Subject:
Keywords:
Summary:

The goal of this project is to enforce output format while preserving the base model’s general knowledge and reasoning ability.

---

## 🎯 Key Features

- βœ… Structured summary generation (KSS-style format)
- βœ… Instruction-following behavior
- βœ… Knowledge preservation after fine-tuning
- βœ… Robust across both short and long inputs

---

## 🧠 Base Model

- Base model: Qwen3-4B
- Fine-tuning method: LoRA (Low-Rank Adaptation)

---

## πŸ—οΈ Training Details

### Dataset

- Total samples: 596
- Contrastive dataset:
  - Instruction data (format enforced)
  - Non-instruction data (free-form output)

### Data Sources

- GPT-generated summaries (short-form)
- Base model-generated summaries (long-form)
- CNN article dataset (961 samples used for label generation)

---

## βš™οΈ Training Setup

- Method: LoRA fine-tuning
- Objective:
  - Learn when to apply structured format
  - Avoid overfitting to instruction-only behavior

---

## πŸ“Š Evaluation

### 1. Format Adherence

- Evaluated on 50 samples
- Result:
  - High consistency in following required format

---

### 2. Knowledge Preservation (MMLU)

- Evaluation method: Logit-based scoring
- Samples: 20 per subject

| Model        | Score |
|--------------|------|
| Base Model   | 0.725 |
| Tuned Model  | 0.724 |

πŸ‘‰ No significant performance degradation observed

---

## πŸ’‘ Key Insight

Instruction tuning can enforce output structure **without degrading model knowledge**,  
when using a carefully designed LoRA fine tuning setup.

---

## πŸ§ͺ Example Usage
This model is finetuned on non-thinking mode. non-thinking mode is recommended
```python
from transformers import AutoTokenizer, AutoModelForCausalLM

#model calling
model_name = "Mindie/Qwen3-4b-kss-style-tuning"
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)

#generation
prompt = text
messages = [
    {"role": "user", "content": f'Use KSS style Summaries: {prompt}'}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=False # Switches between thinking and non-thinking modes. Default is True.
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

# conduct text completion
generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=200
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
content = tokenizer.decode(output_ids, skip_special_tokens=True).strip("\n")
print(content)

###Ouptut foramt
Subject:
Keywords:
Summary:


## πŸ”— Project Links

- GitHub Repository: https://github.com/byeongmin1/qwen3-4b-lora-instruction-tuning

## πŸ“– Training Details

This model was trained using a full pipeline including:
- data generation
- filtering
- instruction tuning (LoRA)
- Logit Evaluation (MMLU)

For full implementation details, please refer to the GitHub repository.
Downloads last month
1,460
Safetensors
Model size
4B params
Tensor type
BF16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Mindie/Qwen3-4b-kss-style-tuning

Finetuned
Qwen/Qwen3-4B
Finetuned
(576)
this model

Dataset used to train Mindie/Qwen3-4b-kss-style-tuning