赞
踩
github链接:GitHub - karpathy/minGPT: A minimal PyTorch re-implementation of the OpenAI GPT (Generative Pretrained Transformer) training
搬运到CSDN资源链接:从零创建一个最简单的GPT,minGPTbyAndrejkarpathy资源-CSDN文库
pip install torch numpy transformers datasets tiktoken wandb tqdm
如果你不是深度学习领域的专业人士,只是想感受一下它的魔力并初步尝试,那么最快速的入门方式就是在莎士比亚的作品上训练一个字符级别的GPT模型。首先,我们需要将其下载为一个单独(1MB)的文件,并将原始文本转换为一串大的整数流。
python data/shakespeare_char/prepare.py
python train.py config/train_shakespeare_char.py --device=cpu --compile=False --eval_iters=20 --log_interval=1 --block_size=64 --batch_size=12 --n_layer=4 --n_head=4 --n_embd=128 --max_iters=2000 --lr_decay_iters=2000 --dropout=0.0
生成结果 by CPU
python sample.py --out_dir=out-shakespeare-char --device=cpu
结果大概长这样:
GLEORKEN VINGHARD III:
Whell's the couse, the came light gacks,
And the for mought you in Aut fries the not high shee
bot thou the sought bechive in that to doth groan you,
No relving thee post mose the wear
```
python train.py config/train_shakespeare_char.py
生成结果 by GPU
$ python sample.py --out_dir=out-shakespeare-char
结果大概长这样:
ANGELO:
And cowards it be strawn to my bed,
And thrust the gates of my threats,
Because he that ale away, and hang'd
An one with him.DUKE VINCENTIO:
I thank your eyes against it.DUKE VINCENTIO:
Then will answer him to save the malm:
And what have you tyrannous shall do this?DUKE VINCENTIO:
If you have done evils of all disposition
To end his power, the day of thrust for a common men
That I leave, to fight with over-liking
Hasting in a roseman.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。