made usage example more copy friendly
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|