https://github.com/tf63/transformer-study
transformer勉強会の実装
https://github.com/tf63/transformer-study
Last synced: 2 months ago
JSON representation
transformer勉強会の実装
- Host: GitHub
- URL: https://github.com/tf63/transformer-study
- Owner: tf63
- Created: 2024-04-30T08:59:20.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-23T05:17:07.000Z (about 1 year ago)
- Last Synced: 2025-02-04T15:48:15.241Z (4 months ago)
- Language: Python
- Homepage:
- Size: 18.6 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Transformer勉強会 実装
解説記事
- https://qiita.com/tf63/items/788eeecd458acfa78c83### 動作確認
**.envの作成**
- [Weights & Biases](https://www.wandb.jp/) のアカウントを作成する
- サインインし **User Setting > Danger zone > API keys** からAPIキーを取得する
- `.env.example`をコピーし`.env`という名前のファイルを作成する
- `.env`に取得したAPIキーを書く (**APIキーは公開しない..envはgit管理から外しているので大丈夫**)
```
WANDB_API_KEY=""
```**環境構築**
```
bash cmd/docker.sh build
bash cmd/docker.sh shell
```**学習**
```
bash cmd/train.sh
```あるいは
```
python3 train.py \
--accelerator gpu \
--devices 1 \
--batch_size 256 \
--num_datas 50000 \
--max_epochs 10 \
--lr 0.0001 \
--num_heads 8 \
--dim 512
```もしかしたら初回は`wandb login`する必要があるかもしれない
**推論**
```
python3 inference.py
```### dependency
```
torch==2.0.0
pytorch-lightning==2.2.3
wandb==0.16.6
click==8.1.7
jupyter==1.0.0
ipykernel==6.29.4
```### 参考リンク
torch.nn.module.transformer の内部実装
- https://github.com/pytorch/pytorch/blob/main/torch/nn/modules/transformer.pypytorch lightning公式
- https://pytorch-lightning.readthedocs.io/en/2.2.3/common/lightning_module.htmlhuggingface/transformers
- https://github.com/huggingface/transformersmodel.pyの参考
- https://qiita.com/gensal/items/e1c4a34dbfd0d7449099デモ用プロジェクトの参考
- https://github.com/i14kwmr/practice-transformer/tree/main