Text Generation
Transformers
Safetensors
Chinese
qwen3_5_text
qwen3_5
merged
psychological-counseling
counselor-response-generation
conversational
Instructions to use UEC-InabaLab/CounselTrajLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use UEC-InabaLab/CounselTrajLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="UEC-InabaLab/CounselTrajLM") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("UEC-InabaLab/CounselTrajLM") model = AutoModelForCausalLM.from_pretrained("UEC-InabaLab/CounselTrajLM", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use UEC-InabaLab/CounselTrajLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "UEC-InabaLab/CounselTrajLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "UEC-InabaLab/CounselTrajLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/UEC-InabaLab/CounselTrajLM
- SGLang
How to use UEC-InabaLab/CounselTrajLM with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "UEC-InabaLab/CounselTrajLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "UEC-InabaLab/CounselTrajLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "UEC-InabaLab/CounselTrajLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "UEC-InabaLab/CounselTrajLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use UEC-InabaLab/CounselTrajLM with Docker Model Runner:
docker model run hf.co/UEC-InabaLab/CounselTrajLM
|
Download README.md from UEC-InabaLab/CounselTrajLM: direct link, hf CLI and curl.
- Browser
- Download file 7.19 kB
-
https://huggingface.co/UEC-InabaLab/CounselTrajLM/resolve/main/README.md
- Command line
-
hf download hf://UEC-InabaLab/CounselTrajLM/README.md
-
curl -L -o README.md https://huggingface.co/UEC-InabaLab/CounselTrajLM/resolve/main/README.md
7.19 kB
| language: | |
| - zh | |
| base_model: Qwen/Qwen3.5-9B | |
| base_model_relation: finetune | |
| library_name: transformers | |
| license: apache-2.0 | |
| pipeline_tag: text-generation | |
| tags: | |
| - qwen3_5 | |
| - merged | |
| - psychological-counseling | |
| - counselor-response-generation | |
| # CounselTrajLM | |
| 📄 **Paper:** [arXiv:2611.24168](https://arxiv.org/abs/2611.24168) | |
| CounselTrajLM generates the next Chinese counselor response from a counseling | |
| dialogue history. It is fine-tuned on CounselTrajD and is the dialogue model used | |
| in the CounselTraj response-level and dialogue-level experiments. | |
| This release contains the **complete merged BF16 text language model**, its | |
| tokenizer, and a working inference script. It combines the previously released | |
| three-epoch LoRA adapter with the unquantized | |
| [Qwen/Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B) base at revision | |
| `c202236235762e1c871ad0ccb60c8ee5ba337b9a` and loads directly with Transformers. | |
| The model is released under Apache-2.0; see [LICENSE](LICENSE). | |
| Project, dataset, and evaluation prompts: | |
| [UEC-InabaLab/CounselTraj](https://github.com/UEC-InabaLab/CounselTraj). | |
| The separate [CounselTraj](https://huggingface.co/UEC-InabaLab/CounselTraj) | |
| model plans dialogue-act trajectories for data synthesis. | |
| ## Training details | |
| The following settings come from the saved training records for the released | |
| checkpoint. | |
| | Item | Value | | |
| | --- | --- | | |
| | Base model | Qwen/Qwen3.5-9B, text language-model component | | |
| | Release format | Complete merged BF16 text language model | | |
| | Fine-tuning | QLoRA, NF4 with double quantization and bfloat16 computation | | |
| | Adapter rank / alpha / dropout | 32 / 64 / 0.05 | | |
| | Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj | | |
| | Adapter parameters | 58,195,968 | | |
| | Dataset split | Dialogue-disjoint 90% training / 10% validation | | |
| | Training / validation examples | 425,679 / 47,528 next-response examples | | |
| | Training epochs | 3 | | |
| | Final optimizer step | 79,815 | | |
| | Learning rate / warmup ratio | 0.0002 / 0.06 | | |
| | Learning-rate schedule | Cosine | | |
| | Optimizer | paged_adamw_8bit | | |
| | Maximum training sequence length | 2,048 tokens | | |
| | Maximum history length | Last 1,800 characters | | |
| | Per-device training batch size / gradient accumulation | 2 / 1 | | |
| | Random seed | 20260704 | | |
| | Recorded final validation loss | 1.5481888056 | | |
| The merged model uses the final adapter saved after three epochs. Its SHA256 was | |
| verified against both the source final adapter and the previously published | |
| adapter. The trainer record contains no best-validation checkpoint selection. | |
| The [original adapter release](https://huggingface.co/UEC-InabaLab/CounselTrajLM/tree/341e9b198c985ee75c982a43376015d806b15522) | |
| remains available in the repository history. | |
| ## Training data and references | |
| [CounselTrajD](https://github.com/UEC-InabaLab/CounselTraj#counseltrajd) contains | |
| 10,964 synthetic Chinese counseling dialogues expanded from three sources: | |
| - SmileChat: Qiu et al. (2024), [SMILE: Single-turn to Multi-turn Inclusive Language Expansion via ChatGPT for Mental Health Support](https://aclanthology.org/2024.findings-emnlp.34/). | |
| - PsyDTCorpus: Xie et al. (2025), [PsyDT: Using LLMs to Construct the Digital Twin of Psychological Counselor with Personalized Counseling Style for Psychological Counseling](https://aclanthology.org/2025.acl-long.55/). | |
| - CPsyCounD: Zhang et al. (2024), [CPsyCoun: A Report-based Multi-turn Dialogue Reconstruction and Evaluation Framework for Chinese Psychological Counseling](https://aclanthology.org/2024.findings-acl.830/). | |
| See the project's [licensing scope](https://github.com/UEC-InabaLab/CounselTraj/blob/master/LICENSING.md) | |
| and [source notices](https://github.com/UEC-InabaLab/CounselTraj/blob/master/THIRD_PARTY_NOTICES.md) | |
| for the source-specific data terms. | |
| ## Generate a reply | |
| Download the public complete model and run the included example: | |
| ```bash | |
| pip install huggingface_hub | |
| python -c 'from huggingface_hub import snapshot_download; snapshot_download("UEC-InabaLab/CounselTrajLM", local_dir="CounselTrajLM")' | |
| cd CounselTrajLM | |
| pip install -r requirements.txt | |
| python generate_reply.py --model . --input-file examples/histories.jsonl | |
| ``` | |
| Or supply a history directly: | |
| ```bash | |
| python generate_reply.py --model . --history 'client:最近工作压力很大,晚上总是睡不好。' | |
| ``` | |
| The script uses the original counselor system prompt and user-history format, | |
| with `enable_thinking=False`. It loads the complete text language model in BF16, | |
| with additional memory required for the generation cache. A separate base-model | |
| download and the PEFT library are no longer required. | |
| The weights occupy approximately 17.9 GB. The exported model was reloaded on CUDA | |
| and checked on the three bundled synthetic histories. The merge comparison and | |
| file integrity results are recorded in [validation.json](validation.json). | |
| Input JSONL rows contain an optional `id` and a nonempty `history` string. The | |
| script outputs JSON with the generated `response`. The three bundled histories | |
| are newly written synthetic examples. | |
| ## Load in Python | |
| After downloading the repository and installing its requirements: | |
| ```python | |
| from generate_reply import load_model, generate_reply | |
| tokenizer, model = load_model("UEC-InabaLab/CounselTrajLM") | |
| response = generate_reply( | |
| tokenizer, | |
| model, | |
| "client:最近工作压力很大,晚上总是睡不好。", | |
| ) | |
| print(response) | |
| ``` | |
| ## Evaluation | |
| The response-level evaluation uses PsyDial-D101 from Qiu and Lan (2025), | |
| [PsyDial: A Large-scale Long-term Conversational Dataset for Mental Health Support](https://aclanthology.org/2025.acl-long.1049/). | |
| The dialogue-level evaluation uses client profiles from Pan et al. (2026), | |
| [PsychEval: A Multi-Session and Multi-Therapy Benchmark for High-Realism AI Psychological Counselor](https://arxiv.org/abs/2601.01802). | |
| The [evaluation documentation](https://github.com/UEC-InabaLab/CounselTraj/tree/master/evaluation) | |
| provides the prompts, dimensions, and research foundations. | |
| ## Files | |
| - `model-*.safetensors`, `model.safetensors.index.json`, and `config.json`: complete merged text language model. | |
| - `generation_config.json`: generation defaults. | |
| - `tokenizer.json`, `tokenizer_config.json`, and `chat_template.jinja`: saved tokenizer and chat template. | |
| - `generate_reply.py`: inference entry point. | |
| - `requirements.txt`: inference dependencies. | |
| - `model_details.json`: actual training settings and checkpoint provenance. | |
| - `examples/histories.jsonl`: synthetic example inputs. | |
| - `validation.json`: release integrity and generation checks. | |
| - `SHA256SUMS`: file checksums. | |
| - `LICENSE`: Apache-2.0 license. | |
| The model is intended for counseling dialogue research. Its generated responses | |
| have not been validated as clinical care or crisis support. | |
| ## Citation | |
| ```bibtex | |
| @inproceedings{qi-inaba-2027-counseltraj, | |
| title = "{CounselTraj}: Synthesizing Process-Aware Psychological Counseling Dialogues via Dialogue-Act Trajectory Planning", | |
| author = "Qi, Zhiyang and Inaba, Michimasa", | |
| booktitle = "Proceedings of the 20th Conference of the European Chapter of the Association for Computational Linguistics", | |
| year = "2027", | |
| url = "https://arxiv.org/abs/2611.24168", | |
| } | |
| ``` | |