CBT-based panic-disorder reframing dialogue framed as task-oriented dialogue state tracking.
A T5 model predicts belief-state slots sequentially in an order derived from Ellis's ABC model, feeding each prediction into the prompt for the next slot.
common.py— shared prompt constants and utilitiesrun_language_modeling.py— training (--do_train) / evaluation (--do_eval)run_generate.py— inference: sequential slot generation from a trained checkpoint
event → thought → symptoms → cognitive distortion → client cognitive distortion → system response
Each step's prompt:
task: {dialogue state | system response} || context: {C_t} || question: {slot question}
From the second slot on, previously predicted values (except "Not mentioned") are appended as natural-language descriptions. Use --random_shuffled / --reverse for ablations on slot order.
pip install torch transformers pandas numpy tqdm tensorboard(--fp16 requires apex)
Train + eval
python run_language_modeling.py \
--train_src_file data/train.csv --eval_src_file data/dev.csv \
--output_dir outputs/s3-t5-base \
--model_type t5 --model_name_or_path t5-base \
--do_train --do_eval \
--per_gpu_train_batch_size 4 --num_train_epochs 10 \
--learning_rate 5e-5 --alpha 0.7 --gamma 1.0Eval only
python run_language_modeling.py \
--eval_src_file data/test.csv --output_dir outputs/s3-t5-base \
--model_type t5 --model_name_or_path outputs/s3-t5-base --do_evalGenerate
python run_generate.py \
--model_name_or_path outputs/s3-t5-base \
--prompts_from_file data/test.csv \
--path_output predictions/test_result.csv \
--length 100| arg | description |
|---|---|
--alpha |
weight of aux (yes/no) loss (default 0.7) |
--gamma |
weight of system-response loss vs. DST loss (default 1.0) |
--block_size |
max tokenized length (defaults to model's model_max_length) |
--random_shuffled |
use a fixed alternate slot order |
--reverse |
reverse slot order |
--should_continue |
resume from latest checkpoint in output_dir |
--save_total_limit |
cap number of saved checkpoints |