UEC-InabaLab/KokoroChat
Viewer • Updated • 6.59k • 167 • 2
Llama-3.1-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.
tokyotech-llm/Llama-3.1-Swallow-8B-Instruct-v0.3from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "UEC-InabaLab/Llama-3.1-KokoroChat-Low"
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
# Set pad_token_id
if tokenizer.pad_token_id is None:
tokenizer.pad_token = "[PAD]"
tokenizer.pad_token_id = tokenizer.convert_tokens_to_ids("[PAD]")
model.config.pad_token_id = tokenizer.pad_token_id
# Build dialogue input
messages = [
{"role": "system", "content": "心理カウンセリングの会話において、対話履歴を考慮し、カウンセラーとして適切に応答してください。"},
{"role": "user", "content": "最近、気分が落ち込んでやる気が出ません。"}
]
# Tokenize with chat template
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
attention_mask = inputs.ne(tokenizer.pad_token_id)
# Generate response
outputs = model.generate(
inputs,
attention_mask=attention_mask,
pad_token_id=tokenizer.pad_token_id,
max_new_tokens=256
)
# Extract only the newly generated tokens
response = outputs[0][inputs.shape[-1]:]
response_text = tokenizer.decode(response, skip_special_tokens=True)
# Print clean response
print(response_text)
Fine-tuning was performed using QLoRA with the following configuration:
q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_projr = 8lora_alpha = 16lora_dropout = 0.05adamw_8bit1001e-358If you use this model or dataset, please cite the following paper:
@inproceedings{qi2025kokorochat,
title = {KokoroChat: A Japanese Psychological Counseling Dialogue Dataset Collected via Role-Playing by Trained Counselors},
author = {Zhiyang Qi and Takumasa Kaneko and Keiko Takamizo and Mariko Ukiyo and Michimasa Inaba},
booktitle = {Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics},
year = {2025},
url = {https://github.com/UEC-InabaLab/KokoroChat}
}