ZhiyangQi97 commited on
Commit
544ca3c
·
verified ·
1 Parent(s): 48c49c4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +133 -3
README.md CHANGED
@@ -1,3 +1,133 @@
1
- ---
2
- license: cc-by-nc-nd-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: tokyotech-llm/Llama-3.1-Swallow-8B-Instruct-v0.3
3
+ license:
4
+ - llama3.1
5
+ - gemma
6
+ language:
7
+ - ja
8
+ - en
9
+ pipeline_tag: text-generation
10
+ tags:
11
+ - counseling
12
+ - dialogue-system
13
+ datasets:
14
+ - UEC-InabaLab/KokoroChat
15
+ ---
16
+
17
+ # 🧠 KokoroChat-Low: Japanese Counseling Dialogue Model
18
+
19
+ **KokoroChat-Low** is a large-scale Japanese language model fine-tuned on the **entire KokoroChat dataset**—a collection of over 6,000 psychological counseling dialogues conducted via **role-play between trained counselors**. The model is capable of generating **empathetic and context-aware responses** suitable for mental health-related conversational tasks.
20
+
21
+ ---
22
+
23
+ ## 💡 Overview
24
+
25
+ - ✅ Fine-tuned on **3,870 dialogues** with client feedback scores **below 70**
26
+ - ✅ Data collected through **text-based role-play** by trained counselors
27
+ - ✅ Covers a wide range of topics: depression, family, school, career, relationships, and more
28
+ - ✅ Base Model: [`tokyotech-llm/Llama-3.1-Swallow-8B-Instruct-v0.3`](https://huggingface.co/tokyotech-llm/Llama-3.1-Swallow-8B-Instruct-v0.3)
29
+
30
+ ---
31
+
32
+ ## ⚙️ Usage Example
33
+
34
+ ```python
35
+ from transformers import AutoModelForCausalLM, AutoTokenizer
36
+
37
+ model_id = "UEC-InabaLab/KokoroChat-Low"
38
+
39
+ # Load tokenizer and model
40
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
41
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
42
+
43
+ # Set pad_token_id
44
+ if tokenizer.pad_token_id is None:
45
+ tokenizer.pad_token = "[PAD]"
46
+ tokenizer.pad_token_id = tokenizer.convert_tokens_to_ids("[PAD]")
47
+
48
+ model.config.pad_token_id = tokenizer.pad_token_id
49
+
50
+ # Build dialogue input
51
+ messages = [
52
+ {"role": "system", "content": "心理カウンセリングの会話において、対話履歴を考慮し、カウンセラーとして適切に応答してください。"},
53
+ {"role": "user", "content": "最近、気分が落ち込んでやる気が出ません。"}
54
+ ]
55
+
56
+ # Tokenize with chat template
57
+ inputs = tokenizer.apply_chat_template(
58
+ messages,
59
+ add_generation_prompt=True,
60
+ return_tensors="pt"
61
+ ).to(model.device)
62
+
63
+ attention_mask = inputs.ne(tokenizer.pad_token_id)
64
+
65
+ # Generate response
66
+ outputs = model.generate(
67
+ inputs,
68
+ attention_mask=attention_mask,
69
+ pad_token_id=tokenizer.pad_token_id,
70
+ max_new_tokens=256
71
+ )
72
+
73
+ # Extract only the newly generated tokens
74
+ response = outputs[0][inputs.shape[-1]:]
75
+ response_text = tokenizer.decode(response, skip_special_tokens=True)
76
+
77
+ # Print clean response
78
+ print(response_text)
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 🛠️ Fine-Tuning Details
84
+
85
+ Fine-tuning was performed using **QLoRA** with the following configuration:
86
+
87
+ - **Quantization**: 4-bit NF4 with bfloat16 computation
88
+ - **LoRA target modules**: `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`
89
+ - **LoRA parameters**:
90
+ - `r = 8`
91
+ - `lora_alpha = 16`
92
+ - `lora_dropout = 0.05`
93
+
94
+ ### Dataset Split
95
+
96
+ - **Training Data**: 3,870 dialogues with feedback scores < 70
97
+ - **Train/Validation Split**: 90% train, 10% validation
98
+
99
+ ### Hyperparameter Settings
100
+
101
+ - **Optimizer**: `adamw_8bit`
102
+ - **Warm-up Steps**: `100`
103
+ - **Learning Rate**: `1e-3`
104
+ - **Epochs**: `5`
105
+ - **Batch Size**: `8`
106
+ - **Validation Frequency**: every 400 steps
107
+
108
+ ---
109
+
110
+ ## 📄 Citation
111
+
112
+ If you use this model or dataset, please cite the following paper:
113
+
114
+ ```bibtex
115
+ @inproceedings{qi2025kokorochat,
116
+ title = {KokoroChat: A Japanese Psychological Counseling Dialogue Dataset Collected via Role-Playing by Trained Counselors},
117
+ author = {Zhiyang Qi and Takumasa Kaneko and Keiko Takamizo and Mariko Ukiyo and Michimasa Inaba},
118
+ booktitle = {Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics},
119
+ year = {2025},
120
+ url = {https://github.com/UEC-InabaLab/KokoroChat}
121
+ }
122
+ ```
123
+ ---
124
+
125
+ ## 🔗 Related
126
+
127
+ - 📁 **Dataset**:
128
+ - [KokoroChat on Hugging Face Datasets](https://huggingface.co/datasets/UEC-InabaLab/KokoroChat)
129
+ - [KokoroChat on GitHub (UEC-InabaLab)](https://github.com/UEC-InabaLab/KokoroChat)
130
+ - 🤖 **Model Variants**:
131
+ - [KokoroChat-High](https://huggingface.co/UEC-InabaLab/KokoroChat-High): fine-tuned on **2,601 dialogues** with client feedback scores between **70 and 98**
132
+ - [KokoroChat-Full](https://huggingface.co/UEC-InabaLab/KokoroChat-Full): fine-tuned on **6,471 dialogues** with client feedback scores **≤ 98**
133
+ - 📄 **Paper**: [ACL 2025 Paper (PDF)](https://drive.google.com/file/d/1T6XgvZii8rZ1kKLgOUGqm3BMvqQAvxEM/view?usp=sharing)