Skip to content

Commit d68bf7a

Browse files
committed
doc: add generate.py usage
1 parent 89396d1 commit d68bf7a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

word_language_model/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Word-level Language Modeling using RNN and Transformer
22

3+
## Requirements
4+
5+
Just running the following command to get started. Actually we just need the torch.
6+
7+
```bash
8+
pip install -r requirements.txt
9+
```
10+
11+
## Usage
12+
313
This example trains a multi-layer RNN (Elman, GRU, or LSTM) or Transformer on a language modeling task. By default, the training script uses the Wikitext-2 dataset, provided.
414
The trained model can then be used by the generate script to generate new text.
515

@@ -54,3 +64,19 @@ python main.py --cuda --emsize 650 --nhid 650 --dropout 0.5 --epochs 40 --tied
5464
python main.py --cuda --emsize 1500 --nhid 1500 --dropout 0.65 --epochs 40
5565
python main.py --cuda --emsize 1500 --nhid 1500 --dropout 0.65 --epochs 40 --tied
5666
```
67+
68+
To generate samples from the default model checkpoint, just use the the `generate.py` script, which accepts the following arguments:
69+
70+
```bash
71+
optional arguments:
72+
-h, --help show this help message and exit
73+
--data DATA location of the data corpus
74+
--checkpoint MODEL model checkpoint to use
75+
--outf OUTPUT output file for generated text
76+
--words WORDS number of words to generate
77+
--seed SEED random seed
78+
--cuda use CUDA
79+
--mps enable GPU on macOS
80+
--temperature TEMP temperature - higher will increase diversity
81+
--log-interval N report interval
82+
```

0 commit comments

Comments
 (0)