Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New model implementation + linters + some life quality improvements #71

Open
wants to merge 82 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
cbf01de
error with inplace modification
Jan 26, 2023
8fa838e
implementation WIP
Jan 27, 2023
d39f516
WIP
Jan 27, 2023
5947ccb
WIP
Jan 27, 2023
939ac46
WIP
Jan 27, 2023
6ba65d3
WIP
Jan 27, 2023
8678509
WIP
Jan 27, 2023
2094278
WIP
Jan 27, 2023
dddd957
WIP
Jan 27, 2023
03570c8
fixemgan implementation for uncategorized type of data
Jan 27, 2023
16d10ea
cat fixem WIP
Jan 29, 2023
dc81448
oracle implementation WIP
Jan 29, 2023
7dda0c8
oracle implementation WIP
Jan 29, 2023
cf85084
oracle fixem implementation WIP
Jan 29, 2023
bde02b3
oracle fuxem implementation WIP
Jan 30, 2023
e5c8002
WIP
Jan 31, 2023
1d0dc9e
metrics WIP
Feb 1, 2023
b629ebc
WIP
Feb 1, 2023
0c75613
WIP
Feb 1, 2023
9e4eb03
new metrics WIP
Feb 2, 2023
4a1817c
fin text preprocessing, metrics WIP
Feb 3, 2023
b866269
metrics done
Feb 3, 2023
9004cda
metrics WIP
Feb 5, 2023
429712f
metrics WIP
Feb 5, 2023
ac63f67
consistent metrics WIP
Feb 5, 2023
9dd6de1
metrics clean WIP
Feb 6, 2023
1e3fcfb
seed everything
Feb 6, 2023
045675c
added new commands to get started in README
Feb 6, 2023
112517d
clean run files
Feb 6, 2023
58f3f78
logger used properly
Feb 6, 2023
fdfa125
fixing logger error
Feb 6, 2023
c958876
decresing ram usage
Feb 6, 2023
d5bad1c
ready for tests
Feb 6, 2023
73513c4
type and progress bar for evogan
Feb 6, 2023
5a16979
vectorizing texts batch vise
Feb 7, 2023
25e88ce
typos and intel to metrics
Feb 8, 2023
64747b5
decreased sample num to form 1000 to 100
Feb 8, 2023
38b7c0f
separating generators and discriminators
Feb 8, 2023
49cccfe
moved code references for generator and discriminator
Feb 8, 2023
825dd20
typo
Feb 8, 2023
3886132
deleted intel from metrics and created simgle small sample hyperparam
Feb 8, 2023
e133589
fixed README.md
Feb 22, 2023
84ea669
metric used BLEU 3 and sefl BLEU 3 and returned target and input to G…
Feb 22, 2023
bc099e3
try to fix issue with None, inf or 0 value in binomial
Feb 24, 2023
bbf7766
improoving metrics calculation
Feb 24, 2023
dd18778
metrics typos
Feb 24, 2023
d2b741d
metrics typos
Feb 24, 2023
27d2716
some prettyfying on metric print
Feb 24, 2023
cac3ec0
added weighted metrics to more representitive Overall score
Feb 25, 2023
f54c174
fixed data loader for list of tockens
Feb 28, 2023
12b8c28
fixed data loader for list of tockens
Feb 28, 2023
e433bf4
some tweaks with metirc
Mar 1, 2023
620dba1
addin wandb logger for metrics
Mar 2, 2023
f09a684
refacotoring metrics
Mar 3, 2023
7d87b0f
typo
Mar 3, 2023
3772f06
solving typos
Mar 3, 2023
9d122e2
solving error in oracle model
Mar 3, 2023
beac393
adding logging to oracle instructor
Mar 3, 2023
dfc7639
err in metrics
Mar 3, 2023
b252e22
workaround oracle generator
Mar 3, 2023
41bfc44
workaround oracle metrics
Mar 3, 2023
26071ab
cleaning for oracle metrics
Mar 4, 2023
27c29d7
adding sweep.yml for parameters selection
Apr 18, 2023
782a533
adding sweep.yml for parameters selection
Apr 18, 2023
c09da10
adding sweep.yml for parameters selection
Apr 18, 2023
542e8fc
adding sweep.yml for parameters selection
Apr 18, 2023
73edf15
adding sweep.yml for parameters selection
Apr 18, 2023
fca70b9
adding sweep.yml for parameters selection
Apr 18, 2023
cea83c0
adding sweep.yml for parameters selection
Apr 18, 2023
6d84e58
speeding up train process
Apr 18, 2023
d1e52f9
speeding up train process
Apr 18, 2023
ee55d29
deleted unnecessary requirement
Apr 20, 2023
3835b2c
deleted unnecessary requirement
Apr 20, 2023
ac2622b
adding new sweep parameters
Apr 20, 2023
734abc9
adding new sweep parameters
Apr 20, 2023
c5826b4
launching last sweep with smaller amount of parameters
Apr 27, 2023
61f242e
setting correct min max
Apr 27, 2023
f1149e9
correcting launch script
Apr 27, 2023
fca2696
generating sweep_id
Apr 27, 2023
b1ef1d5
Merge pull request #1 from salaxieb/fixem_implementation
salaxieb Jul 6, 2023
b9c2fa2
run black on whole repo
salaxieb Jul 6, 2023
0c41314
updated README
salaxieb Jul 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,8 @@ venv.bak/
/site

# mypy
.mypy_cache/
.mypy_cache/

# wandb logs
wandb/
**/.watchman-cookie-*
61 changes: 42 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ To install, run `pip install -r requirements.txt`. In case of CUDA problems, con

### General Text Generation

- **FixemGAN** - [FixemGAN: Continious Space Text GAN on Fixed Embeddings](https://medium.com/@salaxieb.ildar/text-gan-on-embeddings-debb9a006fff)
- **SeqGAN** - [SeqGAN: Sequence Generative Adversarial Nets with Policy Gradient](https://arxiv.org/abs/1609.05473)
- **LeakGAN** - [Long Text Generation via Adversarial Training with Leaked Information](https://arxiv.org/abs/1709.08624)
- **MaliGAN** - [Maximum-Likelihood Augmented Discrete Generative Adversarial Networks](https://arxiv.org/abs/1702.07983)
Expand All @@ -67,9 +68,20 @@ To install, run `pip install -r requirements.txt`. In case of CUDA problems, con
git clone https://github.com/williamSYSU/TextGAN-PyTorch.git
cd TextGAN-PyTorch
```
- Downlaod dataset and pretrained embeddings from kaggle dataset or manually:
```bash
kaggle datasets download -d salaxieb/texts-corpus-preprocessed
kaggle datasets download -d salaxieb/pretrained-embeddings

unzip ../texts-corpus-preprocessed.zip -d dataset
mkdir dataset/testdata
mv dataset/*_test.txt dataset/testdata/

- For real data experiments, all datasets (`Image COCO`, `EMNLP NEWs`, `Movie Review`, `Amazon Review`) can be downloaded from [here](https://drive.google.com/drive/folders/1XvT3GqbK1wh3XhTgqBLWUtH_mLzGnKZP?usp=sharing).
- Run with a specific model
mkdir pretrain
unzip ../pretrained-embeddings.zip -d pretrain/real_data
```

- Manually (`Image COCO`, `EMNLP NEWs`, `Movie Review`, `Amazon Review`) can be downloaded from [here](https://drive.google.com/drive/folders/1XvT3GqbK1wh3XhTgqBLWUtH_mLzGnKZP?usp=sharing).

```bash
cd run
Expand All @@ -86,13 +98,13 @@ python3 run_seqgan.py 0 0
For each model, the entire runing process is defined in `instructor/oracle_data/seqgan_instructor.py`. (Take SeqGAN in Synthetic data experiment for example). Some basic functions like `init_model()`and `optimize()` are defined in the base class `BasicInstructor` in `instructor.py`. If you want to add a new GAN-based text generation model, please create a new instructor under `instructor/oracle_data` and define the training process for the model.

2. **Visualization**

Use `utils/visualization.py` to visualize the log file, including model loss and metrics scores. Custom your log files in `log_file_list`, no more than `len(color_list)`. The log filename should exclude `.txt`.

3. **Logging**

The TextGAN-PyTorch use the `logging` module in Python to record the running process, like generator's loss and metric scores. For the convenience of visualization, there would be two same log file saved in `log/log_****_****.txt` and `save/**/log.txt` respectively. Furthermore, The code would automatically save the state dict of models and a batch-size of generator's samples in `./save/**/models` and `./save/**/samples` per log step, where `**` depends on your hyper-parameters.

4. **Running Signal**

You can easily control the training process with the class `Signal` (please refer to `utils/helpers.py`) based on dictionary file `run_signal.txt`.
Expand All @@ -105,13 +117,25 @@ python3 run_seqgan.py 0 0

## Implementation Details

### FixemGAN

- run file: [run_fixem.py](run/run_fixem.py)

- Instructors: [oracle_data](instructor/oracle_data/fixem_instructor.py), [real_data](instructor/real_data/fixem_instructor.py)

- Models: [generator](models/generators/FixemGAN_G.py), [discriminator](models/discriminators/FixemGAN_D.py)

- Structure (from [FixemGAM](https://www.com))

![model_fixem](./assets/model_fixem.png)

### SeqGAN

- run file: [run_seqgan.py](run/run_seqgan.py)

- Instructors: [oracle_data](instructor/oracle_data/seqgan_instructor.py), [real_data](instructor/real_data/seqgan_instructor.py)

- Models: [generator](models/SeqGAN_G.py), [discriminator](models/SeqGAN_D.py)
- Models: [generator](models/generators/SeqGAN_G.py), [discriminator](models/discriminators/SeqGAN_D.py)

- Structure (from [SeqGAN](https://arxiv.org/pdf/1609.05473.pdf))

Expand All @@ -123,7 +147,7 @@ python3 run_seqgan.py 0 0

- Instructors: [oracle_data](instructor/oracle_data/leakgan_instructor.py), [real_data](instructor/real_data/leakgan_instructor.py)

- Models: [generator](models/LeakGAN_G.py), [discriminator](models/LeakGAN_D.py)
- Models: [generator](models/generators/LeakGAN_G.py), [discriminator](models/discriminators/LeakGAN_D.py)

- Structure (from [LeakGAN](https://arxiv.org/pdf/1709.08624.pdf))

Expand All @@ -135,7 +159,7 @@ python3 run_seqgan.py 0 0

- Instructors: [oracle_data](instructor/oracle_data/maligan_instructor.py), [real_data](instructor/real_data/maligan_instructor.py)

- Models: [generator](models/MaliGAN_G.py), [discriminator](models/MaliGAN_D.py)
- Models: [generator](models/generators/MaliGAN_G.py), [discriminator](models/discriminators/MaliGAN_D.py)

- Structure (from my understanding)

Expand All @@ -147,7 +171,7 @@ python3 run_seqgan.py 0 0

- Instructors: [oracle_data](instructor/oracle_data/jsdgan_instructor.py), [real_data](instructor/real_data/jsdgan_instructor.py)

- Models: [generator](models/JSDGAN_G.py) (No discriminator)
- Models: [generator](models/generators/JSDGAN_G.py) (No discriminator)

- Structure (from my understanding)

Expand All @@ -159,39 +183,39 @@ python3 run_seqgan.py 0 0

- Instructors: [oracle_data](instructor/oracle_data/relgan_instructor.py), [real_data](instructor/real_data/relgan_instructor.py)

- Models: [generator](models/RelGAN_G.py), [discriminator](models/RelGAN_D.py)
- Models: [generator](models/generators/RelGAN_G.py), [discriminator](models/discriminators/RelGAN_D.py)

- Structure (from my understanding)

![model_relgan](assets/model_relgan.png)

### DPGAN

- run file: [run_dpgan.py](run/run_dpgan.py)

- Instructors: [oracle_data](instructor/oracle_data/dpgan_instructor.py), [real_data](instructor/real_data/dpgan_instructor.py)

- Models: [generator](models/DPGAN_G.py), [discriminator](models/DPGAN_D.py)
- Models: [generator](models/generators/DPGAN_G.py), [discriminator](models/discriminators/DPGAN_D.py)

- Structure (from [DPGAN](https://arxiv.org/abs/1802.01345))

![model_dpgan](assets/model_dpgan.png)

### DGSAN

- run file: [run_dgsan.py](run/run_dgsan.py)

- Instructors: [oracle_data](instructor/oracle_data/dgsan_instructor.py), [real_data](instructor/real_data/dgsan_instructor.py)

- Models: [generator](models/DGSAN_G.py), [discriminator](models/DGSAN_D.py)
- Models: [generator](models/generators/DGSAN_G.py), [discriminator](models/discriminators/DGSAN_D.py)

### CoT

- run file: [run_cot.py](run/run_cot.py)

- Instructors: [oracle_data](instructor/oracle_data/cot_instructor.py), [real_data](instructor/real_data/cot_instructor.py)

- Models: [generator](models/CoT_G.py), [discriminator](models/CoT_D.py)
- Models: [generator](models/generators/CoT_G.py), [discriminator](models/discriminators/CoT_D.py)

- Structure (from [CoT](https://arxiv.org/abs/1804.03782))

Expand All @@ -203,7 +227,7 @@ python3 run_seqgan.py 0 0

- Instructors: [oracle_data](instructor/oracle_data/sentigan_instructor.py), [real_data](instructor/real_data/sentigan_instructor.py)

- Models: [generator](models/SentiGAN_G.py), [discriminator](models/SentiGAN_D.py)
- Models: [generator](models/generators/SentiGAN_G.py), [discriminator](models/discriminators/SentiGAN_D.py)

- Structure (from [SentiGAN](https://www.ijcai.org/proceedings/2018/0618.pdf))

Expand All @@ -215,15 +239,14 @@ python3 run_seqgan.py 0 0

- Instructors: [oracle_data](instructor/oracle_data/catgan_instructor.py), [real_data](instructor/real_data/catgan_instructor.py)

- Models: [generator](models/CatGAN_G.py), [discriminator](models/CatGAN_D.py)
- Models: [generator](models/generators/CatGAN_G.py), [discriminator](models/discriminators/CatGAN_D.py)

- Structure (from [CatGAN](https://arxiv.org/abs/1911.06641))

![model_catgan](assets/model_catgan.png)



## Licence

**MIT lincense**

Binary file added assets/model_fixem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading