-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPU CODE.txt
More file actions
34 lines (26 loc) · 792 Bytes
/
Copy pathGPU CODE.txt
File metadata and controls
34 lines (26 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
!pip install pytorch_lightning==1.8.6
!pip uninstall -y aitextgen
!pip install aitextgen==0.6.0
import os
os._exit(00)
# Install compatible versions of dependencies
!pip uninstall -y aitextgen
!pip install aitextgen==0.6.0
!pip install pytorch_lightning==1.8.6 transformers==4.42.4 torch==2.3.1
from aitextgen import aitextgen
# Initialize aitextgen with GPT-2 model
ai = aitextgen(tf_gpt2="124M", to_gpu=True)
# Train the model
ai.train("input.txt",
line_by_line=True,
from_cache=False,
num_steps=2000,
generate_every=100,
save_every=500,
save_gdrive=False,
learning_rate=1e-3,
fp16=False,
batch_size=1,
)
# Generate text with the trained model
ai.generate(10, prompt="What a wonderful day")