--- language: - zh base_model: Qwen/Qwen3-8B base_model_relation: finetune library_name: peft pipeline_tag: text-generation tags: - qwen3 - lora - dialogue-act-planning - psychological-counseling --- # CounselTraj 📄 **Paper:** [arXiv:2611.24168](https://arxiv.org/abs/2611.24168) CounselTraj is a dialogue-act trajectory planner for synthesizing process-aware psychological counseling dialogues. Given a brief counseling dialogue, the planner produces an ordered trajectory of role-tagged acts such as `counselor:[OpenQuestion]` and `client:[SelfDisclosure]` for subsequent dialogue synthesis. This repository contains a **LoRA adapter for [Qwen/Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B)**, together with its tokenizer, the trajectory planning script, and aggregate dialogue-act priors. Loading the adapter also requires the Qwen3-8B base model. Its base model is distributed under Apache-2.0. Project and dataset: [UEC-InabaLab/CounselTraj](https://github.com/UEC-InabaLab/CounselTraj). ## Model details | Item | Value | | --- | --- | | Base model | Qwen/Qwen3-8B | | Adapter | LoRA, rank 8, alpha 16, dropout 0.05 | | Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj | | Adapter parameters | 21,823,488 | | Selected checkpoint | checkpoint-145, epoch 5 | | Selection criterion | Lowest recorded validation loss, 1.1678476334 | | Learning rate / warmup ratio | 0.0002 / 0.03 | | Planner | Content-conditioned v4 constrained decoding | | Default trajectory length budget | 64–92 dialogue acts | The released adapter is byte-identical to both the selected checkpoint and the saved final model. Training uses dialogue-act annotations of counseling dialogues; the bundled stage, transition, and global priors were aggregated from 1,010 annotated dialogues. ## Generate a trajectory Download the public model repository and install its dependencies: ```bash pip install huggingface_hub python -c 'from huggingface_hub import snapshot_download; snapshot_download("UEC-InabaLab/CounselTraj", local_dir="CounselTraj")' cd CounselTraj pip install -r requirements.txt python plan_trajectory.py --input-file examples/input.jsonl --limit 1 ``` The default inference path uses CUDA and bitsandbytes NF4 quantization. On a supported device with enough memory, `--no-4bit` loads the base model without 4-bit quantization. Input is UTF-8 JSONL with an `input` string containing the brief dialogue. Optional fields include `id`, `topic`, `topic_zh`, `source_dataset`, and `source_id`. The bundled example is a newly written synthetic illustration. The output JSONL contains the planned role-tagged trajectory in `output`, along with its length and tag counts. The original planner can append closing acts beyond its target length budget; count the acts in `output` when an exact realized length is needed. The planner combines adapter likelihoods with stage, transition, and global priors, content and phase scores, a repetition penalty, and a diversity bonus. Use `plan_trajectory.py` to run this decoding procedure. Loading the adapter alone provides the language-model component of the planner. The client candidate inventory contains 14 tags, including `Resistance` (rejection, reluctance, or resistance toward counselor interventions). This candidate was added after the initial release; newly planned trajectories can therefore differ from the original v4 outputs. The adapter weights are unchanged. ## Load the adapter in Python ```python import torch from peft import PeftModel from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig repo_id = "UEC-InabaLab/CounselTraj" tokenizer = AutoTokenizer.from_pretrained(repo_id) base = AutoModelForCausalLM.from_pretrained( "Qwen/Qwen3-8B", quantization_config=BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.bfloat16, ), device_map="auto", ) model = PeftModel.from_pretrained(base, repo_id) model.eval() ``` ## Files - `adapter_model.safetensors` and `adapter_config.json`: selected LoRA weights and configuration. - Tokenizer files: the saved tokenizer accompanying the adapter. - `plan_trajectory.py`: v4 planning algorithm, with portable local defaults. - `da_stats.json`: aggregate planning priors. - `examples/input.jsonl`: synthetic input example. - `model_details.json`: checkpoint selection and release details. - `validation.json`: release checks and a synthetic GPU inference check. - `SHA256SUMS`: file integrity checksums. The planner generates research planning labels. Its trajectories have not been validated as clinical treatment plans. ## 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", } ```