benjamin commited on
Commit
03e4c20
·
1 Parent(s): 30c5976

made usage example more copy friendly

Browse files
Files changed (1) hide show
  1. README.md +11 -1
README.md CHANGED
@@ -30,7 +30,17 @@ See the script `evaluate.py` in the [GerPT2 Github repository](https://github.co
30
 
31
  ## Usage
32
 
33
- ![GerPT2 usage](https://user-images.githubusercontent.com/13353204/100330362-288d0b80-2fcf-11eb-82e7-ed71c7140a88.png)
 
 
 
 
 
 
 
 
 
 
34
 
35
  Also, two tricks might improve the generated text:
36
 
 
30
 
31
  ## Usage
32
 
33
+ ```python
34
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
35
+
36
+ tokenizer = AutoTokenizer.from_pretrained("benjamin/gerpt2")
37
+ model = AutoModelForCausalLM.from_pretrained("benjamin/gerpt2")
38
+
39
+ prompt = "<your prompt>"
40
+
41
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
42
+ print(pipe(prompt)[0]["generated_text"])
43
+ ```
44
 
45
  Also, two tricks might improve the generated text:
46