File size: 2,457 Bytes
51a8508
df185f2
51a8508
df185f2
 
 
 
 
 
 
 
 
 
 
 
51a8508
df185f2
51a8508
df185f2
51a8508
df185f2
51a8508
df185f2
51a8508
df185f2
 
 
 
 
 
51a8508
df185f2
51a8508
df185f2
51a8508
 
df185f2
 
 
51a8508
 
df185f2
 
 
51a8508
df185f2
51a8508
df185f2
51a8508
df185f2
 
51a8508
df185f2
 
 
 
51a8508
df185f2
51a8508
df185f2
 
 
 
51a8508
df185f2
51a8508
df185f2
51a8508
df185f2
 
 
51a8508
df185f2
 
 
 
51a8508
df185f2
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
base_model: viet-mistral/vinallama-2.7b-chat
library_name: peft
license: apache-2.0
language:
- vi
metrics:
- accuracy
- perplexity
pipeline_tag: text-generation
tags:
- code
- sft
- chat
- vietnamese
---
# Model Card for 522H0134-NguyenNhatHuy/Vinallama-2.7b-chat-SFT

This model is a fine-tuned version of **viet-mistral/vinallama-2.7b-chat** using **LoRA + PEFT**, targeting Vietnamese open-domain, instruction-following chat. It is aligned for **safe, helpful, and fluent conversations** in Vietnamese through supervised fine-tuning on high-quality prompt-response pairs.

---

## 🧠 Model Details

- **Base Model:** viet-mistral/vinallama-2.7b-chat
- **Model Type:** Causal Language Model (Chat)
- **Languages:** Vietnamese
- **License:** Apache 2.0
- **Fine-tuning Framework:** [PEFT](https://github.com/huggingface/peft) with LoRA
- **Training Dataset:** Custom Vietnamese SFT & DPO dataset (~10K SFT + 10K DPO + 1K test prompts)

---

## ✅ Intended Uses

### Direct Use
- Vietnamese open-domain dialogue
- Instruction-following tasks
- Educational or research-based QA

### Out-of-Scope Use
- Medical, legal, or financial advice
- Content moderation or safety-critical tasks
- English-centric prompts

---

## 🧪 Evaluation

### Test Data
The model was evaluated on a Vietnamese test set of **1,000 prompts** (60% safe / 40% adversarial) adapted from JailBreak, HarmBench, and OpenAssistant.

### Metrics
- **Helpfulness**
- **Toxicity (via Detoxify > 0.5)**
- **Appropriateness / Safety Rejection**

> Detoxify was used to filter harmful generations during evaluation.

### Summary
- 74% of generations were rated safe/aligned
- 86% rejection rate on highly toxic or adversarial prompts
- The model avoids unsafe completions better than its base model

---

## 🚀 How to Use the Model

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

# Load base model and LoRA adapter
tokenizer = AutoTokenizer.from_pretrained("viet-mistral/vinallama-2.7b-chat")
base_model = AutoModelForCausalLM.from_pretrained("viet-mistral/vinallama-2.7b-chat")
model = PeftModel.from_pretrained(base_model, "522H0134-NguyenNhatHuy/Vinallama-2.7b-chat-SFT")

# Chat example
prompt = "Xin chào, bạn có thể giúp tôi học tiếng Anh không?"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=150)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))