Code and data for the intention graph construction pipeline and the recommendation experiments from the paper "Intention Knowledge Graph Construction for User Intention Relation Modeling" (arXiv:2412.11500), accepted by EACL 2026.
If you use this code or data, please cite:
@misc{bai2025intentionknowledgegraphconstruction,
title={Intention Knowledge Graph Construction for User Intention Relation Modeling},
author={Jiaxin Bai and Zhaobo Wang and Junfei Cheng and Dan Yu and Zerui Huang and Weiqi Wang and Xin Liu and Chen Luo and Yanming Zhu and Bo Li and Yangqiu Song},
year={2025},
eprint={2412.11500},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2412.11500},
}
rec_model/: session-based recommendation experiments.generation_results/,annotation/,data_preprocess/: intention generation and annotation utilities.prompting.py,gpt35_prompting.py,gpt4_prompting.py: LLM prompting code.answer_process.py: post-processing to build intention graph outputs.
The intention graph is built by prompting LLMs to generate intentions and then post-processing the outputs into structured triples.
- Prompting for intentions:
prompting.pyis a minimal runner using Azure OpenAI (seeopenai.api_baseandopenai.api_key).- Example invocation in
prompting.pywrites JSONL togeneration_results/(one JSON object per line with the session, prompt, and LLM answer). gpt35_prompting.py/gpt4_prompting.pyare alternative entry points.
- Parsing and graph prep:
answer_process.pyparses the raw answers into a triple file and can create intermediate artifacts (e.g.,result_triple.txtand pickles for sessions).
The VERA-based relation scoring scripts live in discourse_model/.
Example (single split):
cd discourse_model
CUDA_VISIBLE_DEVICES=0 python vera_evaluation.py -s 0
Notes:
vera_evaluation.pyloads the VERA encoder fromliujch1998/vera-baseand expects a fine-tuned checkpoint at/data/jbai/cjf/Vera/vera_best_model.pth. Update that path if needed.- The input intention list is read from
data_preprocess/generation_results/gpt-35-turbo_answer_<split>_intentions.json. - Convenience scripts
vera_sampling_*.shrun different splits.
- The default dataset is
rec_model/data/m2.txt. - Full raw data files are available here: Google Drive folder.
- Format: one session per line as
user_id item_id_1 item_id_2 ... item_id_n(space-separated integers). rec_model/mat_m2_seqf.npzandrec_model/mat_m2.npzare sparse matrices used by the model code. Keep them inrec_model/when running experiments.
From the repo root:
cd rec_model
python main.py --data_dir ./data/ --data_name m2 --gpu_id 0
Key arguments in rec_model/main.py:
--max_seq_length: maximum session length (default: 20).--hidden_size,--num_hidden_layers,--num_attention_heads: SASRec size.--batch_size,--epochs,--lr: training hyperparameters.--no_cuda: force CPU if needed.
- Logs are written to
rec_model/logs_m2.txt. - Validation/test metrics are printed every epoch.
- Splits are random with ratio 0.8/0.1/0.1 by default in
rec_model/utils.py:get_user_seqs_split. - Training sessions are augmented by prefixing sequences of length >= 2.