-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_generation.txt
More file actions
27 lines (18 loc) · 1014 Bytes
/
run_generation.txt
File metadata and controls
27 lines (18 loc) · 1014 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
Text Generation.
This script will use a pre-trained model (GPT-2 by default) to generate text based on a starting prompt you provide.
Prerequisites:
Make sure you have the necessary libraries installed:
Bash
pip install transformers torch
# Or: pip install transformers tensorflow
How to Run:
Save the code above into a file named run_generation.py.
Open your Ubuntu terminal.
Make sure your virtual environment (if used) is activated (source .venv/bin/activate).
Run the script:
Bash
python run_generation.py
What to Expect:
First Run: It will download the gpt2 model files (which are larger than the sentiment model, potentially >500MB) and cache them locally. This might take some time.
Generation: It will then use the loaded model to continue the text starting from your prompt ("Thinking about the beautiful weather...").
Output: It will print the complete text (prompt + generated continuation) up to the max_length specified. Since num_return_sequences is 1, it will print one possible completion.