Text Generation
Transformers
Safetensors
Chinese
llama
counseltraj
counseltrajlm
counseling
conversational
merged
text-generation-inference
Instructions to use UEC-InabaLab/Llama-3.1-8B-CounselTrajLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use UEC-InabaLab/Llama-3.1-8B-CounselTrajLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="UEC-InabaLab/Llama-3.1-8B-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/Llama-3.1-8B-CounselTrajLM") model = AutoModelForCausalLM.from_pretrained("UEC-InabaLab/Llama-3.1-8B-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/Llama-3.1-8B-CounselTrajLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "UEC-InabaLab/Llama-3.1-8B-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/Llama-3.1-8B-CounselTrajLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/UEC-InabaLab/Llama-3.1-8B-CounselTrajLM
- SGLang
How to use UEC-InabaLab/Llama-3.1-8B-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/Llama-3.1-8B-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/Llama-3.1-8B-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/Llama-3.1-8B-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/Llama-3.1-8B-CounselTrajLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use UEC-InabaLab/Llama-3.1-8B-CounselTrajLM with Docker Model Runner:
docker model run hf.co/UEC-InabaLab/Llama-3.1-8B-CounselTrajLM
File size: 5,688 Bytes
e978c80 | 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | ---
license: llama3.1
language:
- zh
library_name: transformers
pipeline_tag: text-generation
base_model: meta-llama/Llama-3.1-8B-Instruct
base_model_relation: finetune
datasets:
- UEC-InabaLab/CounselTrajD
tags:
- llama
- counseltraj
- counseltrajlm
- counseling
- conversational
- merged
---
# Llama-3.1-8B-CounselTrajLM
**Built with Llama**
📄 **Paper:** [CounselTraj (arXiv:2611.24168)](https://arxiv.org/abs/2611.24168)
Llama-3.1-8B-CounselTrajLM is the Llama 3.1 backbone version of CounselTrajLM,
fine-tuned on [CounselTrajD](https://huggingface.co/datasets/UEC-InabaLab/CounselTrajD)
to generate the next Chinese counselor response from dialogue history. Its base
checkpoint is [meta-llama/Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct).
The repository contains the **complete merged BF16 model**, in nine safetensors
shards totaling approximately **16.1 GB**, together with its tokenizer, chat
template, inference script, and checksums. It loads directly with Transformers.
The project, construction pipeline, and other model versions are available on
[GitHub](https://github.com/UEC-InabaLab/CounselTraj).
## License and attribution
This model is distributed under the **Llama 3.1 Community License Agreement**.
The original agreement is included in [LICENSE](LICENSE), and the Llama 3.1
Acceptable Use Policy is included in [USE_POLICY.md](USE_POLICY.md). The required
attribution is provided in [NOTICE](NOTICE). Use and redistribution are subject to
these terms.
## Training details
| Item | Value |
| --- | --- |
| Base model | meta-llama/Llama-3.1-8B-Instruct |
| Base revision | `0e9e39f249a16976918f6564b8830bc894c89659` |
| Training data | CounselTrajD; dialogue-disjoint 90/10 train/validation split |
| Training / validation examples | 425,679 / 47,528 next-response examples |
| Fine-tuning method | QLoRA; adapter merged into the unquantized BF16 base for release |
| LoRA rank / alpha / dropout | 32 / 64 / 0.05 |
| Learning rate | 0.0002 |
| Schedule / warmup ratio | Cosine / 0.06 |
| Epochs | 3; final-epoch export |
| Final optimizer step | 79,815 |
| Effective batch size | 16 |
| Maximum training sequence length | 2,048 tokens |
| Maximum history length | Last 1,800 characters |
| Release format | Complete merged BF16 safetensors |
Validation was used for monitoring. The released model is the final epoch.
See [training_summary.json](training_summary.json) for the recorded settings.
## Generate a reply
The repository is public. Download it and install the inference dependencies:
```bash
pip install huggingface_hub
python -c 'from huggingface_hub import snapshot_download; snapshot_download("UEC-InabaLab/Llama-3.1-8B-CounselTrajLM", local_dir="Llama-3.1-8B-CounselTrajLM")'
cd Llama-3.1-8B-CounselTrajLM
pip install -r requirements.txt
python generate_reply.py --model . --input-file examples/histories.jsonl
```
Or provide a history directly:
```bash
python generate_reply.py --model . --history 'client:最近工作压力很大,晚上总是睡不好。'
```
Input JSONL rows contain an optional `id` and a nonempty `history` string. Use
`client:` and `counselor:` speaker prefixes within the history. The script uses the
original counselor system instruction and training prompt format, retaining the
last 1,800 history characters. It outputs JSON with the generated `response`.
The three bundled histories are newly written synthetic examples.
After downloading the repository, it can also be used from Python:
```python
from generate_reply import load_model, generate_reply
tokenizer, model = load_model("UEC-InabaLab/Llama-3.1-8B-CounselTrajLM")
response = generate_reply(
tokenizer, model,
"client:最近工作压力很大,晚上总是睡不好。",
)
print(response)
```
The complete weights load in BF16, with additional memory required for inference.
A separate base-model download or PEFT adapter loading is not required.
The release was checked with Transformers 5.13.0, PyTorch 2.5.1,
Accelerate 1.13.0, and safetensors 0.8.0. The GPU generation checks and integrity
results are recorded in [validation.json](validation.json); file checksums are in
[SHA256SUMS](SHA256SUMS).
## Training data and references
CounselTrajD contains 10,964 synthetic Chinese counseling dialogues expanded from
three sources:
- SmileChat: Qiu et al. (2024), [SMILE](https://aclanthology.org/2024.findings-emnlp.34/).
- PsyDTCorpus: Xie et al. (2025), [PsyDT](https://aclanthology.org/2025.acl-long.55/).
- CPsyCounD: Zhang et al. (2024), [CPsyCoun](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. These data terms are separate from the
Llama 3.1 model license.
## Intended use and limitations
This model is intended for research on Chinese counseling dialogue generation,
subject to the Llama 3.1 license and Acceptable Use Policy. Its training data are
synthetic. Generated responses may be inaccurate, inappropriate, or unsafe, and
the model is not a substitute for professional mental health care.
## 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",
}
```
|