This is a repo for listener model for the PhotoBook Referential Game with CLIPScores as Implicit Reference Chain
Project description
Listener Model for PhotoBook Game
This repo houses the official PyTorch implementation for the following paper
- Listener Model for the PhotoBook Referential Game with CLIPScores as Implicit Reference Chain
Shih-Lun Wu, Yi-Hui Chou, and Liangze Li
Annual Meeting of the Association of Computational Linguistics (ACL) 2023
[ArXiv]
Installation
conda create -n photobook python=3.8.10
conda activate photobook
pip install -r requirements.txt
python
>>> import nltk
>>> nltk.download('punkt')
Data Preprocessing
-
Read
../data/data_splits.jsonand save processed log data to../data/{split}_sections.picklecd preprocess python dialogue_segmentation.py
-
Generate CLIP score
-
Read
../data/{split}_sections.pickleand save data to../data/{split}_clean_sections.picklepython process_section.py
- Extract image features with Segformer
-
Save features at
../data/image_feats.pickle, the saved data is a dictionary (key: image path, value: hidden features)python process_image.py
Training and Inference
-
Edit hyperparams in
model/variables.py -
Training (with the best-performing configuration)
python3 train.py config_paper/EXPERIMENT_JSON exp/EXPERIMENT_NAME
-
To reproduce logged ablations, use different
EXPERIMENT_JSONfor each run.- Ours -
vlscore_all.json -
- VisAttn -
vlscore_visattn.json
- VisAttn -
-
- CLIPScore -
base_deberta.json
- CLIPScore -
-
- CLIPScore + VisAttn -
visattn.json
- CLIPScore + VisAttn -
-
- Dense learning signals -
vlscore_all.json(changeDLStoFalseinmodel/variables.py)
- Dense learning signals -
- Ours -
-
Tweak random seeds for optimal performance.
-
Inference
python3 inference.py exp/EXPERIMENT_NAME
Baseline Model Adapted from Takmaz et al., 2020
-
Model implementation is based on official PhotoBook repo
-
To run the Takmaz baseline
cd takmaz_baseline/ python3 train.py
-
To use reference chains extracted using CLIPScore
- set
REF_CHAIN_PATH = ref_chain_img_clipscore.pickleintakmaz_baseline/variables.py
- set
-
Note that different random seeds might be needed in
takmaz_baseline/variables.pyfor optimal results in different experiments.
Utterance-based Reference Chain Extraction
-
This part is largely inherited from official PhotoBook repo, except that we add the option to use CLIPScore as the scoring metric.
-
To reproduce the whole extraction and evaluation procedure described in (Takmaz et al., 2020), run these commands in
chain-extraction.python src/extract_segments.py out/all_segments.dict --stopwords --meteor --from_first_common --utterances_as_captions python src/make_chains.py out/all_segments.dict out/all_chains.json --score f1 python src/make_gold_chains.py out/gold_chains.json --from_first_common --first_reference_only python src/make_dataset.py out/all_chains.json out/gold_chains.json out/dataset python src/extract_segments.py out/eval_segments.dict --path_game_logs data/logs/test_logs.dict --stopwords --meteor --from_first_common --utterances_as_captions python src/eval_chains.py out/eval_segments.dict
-
To alternatively use CLIPScore as part of the scoring in extraction, just add the
--clipscoreoption when runningextract_segments.pyabove.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file photobook-full-listener-1.0.0.tar.gz.
File metadata
- Download URL: photobook-full-listener-1.0.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
679f0b7c55f7632830b3990e9e43a9f4c4fcc823456c279d66d1b797b8e3b8e6
|
|
| MD5 |
22ce54f3f2bb0484c6c933154f3aa64e
|
|
| BLAKE2b-256 |
f52b0207feeb1e0cac9b1becbd5bd245af5212d06de6c3329ae2ea0ce2376db5
|
File details
Details for the file photobook_full_listener-1.0.0-py3-none-any.whl.
File metadata
- Download URL: photobook_full_listener-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2dd54b91abac8afe63b4bfd05a07353d3a70847a508ba31bc53112ce70c3b32
|
|
| MD5 |
1db3d079f7b642d50a4056321348deec
|
|
| BLAKE2b-256 |
b2e2e5ec115ca759497bb1486916fc2cd9ff2603ddc8fd4b4f0af7b692a312d2
|