From d6a9242df323711660fce347c8428adac5409044 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 13 Dec 2023 13:54:49 +0000 Subject: [PATCH] adds test file for gpt2 --- tests/test_gpt2.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/test_gpt2.py diff --git a/tests/test_gpt2.py b/tests/test_gpt2.py new file mode 100644 index 000000000..c2cdfed58 --- /dev/null +++ b/tests/test_gpt2.py @@ -0,0 +1,9 @@ +from transformers import set_seed +from transformers import AutoModelForCausalLM, pipeline, AutoTokenizer + +model = AutoModelForCausalLM.from_pretrained("gpt2", cache_dir="models") +tokenizer = AutoTokenizer.from_pretrained("gpt2", cache_dir="models") +generator = pipeline('text-generation', model=model, tokenizer=tokenizer) + +set_seed(42) +print(generator("Hello, I'm a language model,", max_length=30, num_return_sequences=5)) \ No newline at end of file