Bias CRS
1.0.0
apt-get update
apt-get install build-essential -y
Preparing enviroment:
(for torch 1.12.0)
Option 1:
pip install pyg-lib torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cu113.html
export LD_LIBRARY_PATH="/opt/conda/lib/:$LD_LIBRARY_PATH"
Option 2:
pip install torch==1.12.0+cu113 torchvision==0.13.0+cu113 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu113
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-geometric
pip install -r requirements.txt
For the case of "command 'x86_64-linux-gnu-gcc' failed with exit status 1":
apt-get install python3.x-dev
python run_bias_crs.py --config config/crs/tgredial/tgredial.yaml
實驗在 ReDial、KGSF、KBRD 和 TGReDial 模型上進行,並在 ReDIAL 和 TGReDIAL 資料集上進行評估。
合成對話的產生和準備首先由 data_aug 資料夾中的 [data_prep_gen_ .ipynb] 和 [gen_convert_ .ipynb] 實作(* 指資料集名稱)。
資料增強是在[bias_crs/data/dataloader/base.py]內的base.py中實現的,而透過popNudge對要增強的項目數量的更改可以從這裡更改。
每次執行的實驗結果都會保存在[data/bias/]目錄下,後面是以模型和資料集名稱命名的資料夾,標題為[bias_anlytic_data.csv]。
透過跨劇集流行度和麵向使用者意圖的流行度評分對推薦結果進行相應的分析,可以透過[分析]資料夾存取。
from scipy.stats.stats import pearsonr
def compute_pop_scores(pop_score_dict, items):
return [pop_score_dict[item] if item in pop_score_dict else 0.0 for item in items]
pop_scores = [compute_pop_scores(pop_score_dict, row['Prediction_items']) for _, row in data.iterrows()]
data['pop_scores'] = pop_scores
new_conv = True
cep_scores = []
for idx, row in data.iterrows():
# set the default value to the first episode
if new_conv:
new_conv = False
cep_scores.append(0.5)
else:
if idx+1 < len(data) and row['conv_id'] != data.at[idx+1, 'conv_id']:
new_conv=True
pearsonr_score = np.abs(pearsonr(row['pop_scores'], data.at[idx-1, 'pop_scores'])[0])
cep_scores.append(pearsonr_score)
data['cep_score'] = cep_scores
data['cep_pop_score'] = data['cep_score'] * data['pop_bias']
data['target_pop_score'] = data['target_item_index'].map(pop_score_dict)
data['UIOP'] = np.abs(data['pop_bias'] - data['target_pop_score'])
@inproceedings{
title={Improving Conversational Recommendation Systems via Bias Analysis and Language-Model-Enhanced Data Augmentation},
author={Xi Wang, Hossein A. Rahmani, Jiqun Liu, Emine Yilmaz}
booktitle={Proceedings of EMNLP 2023 (Findings)}
year={2023}
}
此儲存庫是基於CRSLab框架開發的[https://github.com/RUCAIBox/CRSLab]。感謝他們為實現該專案中模型的系統開發和評估做出的寶貴貢獻。