File size: 1,632 Bytes
1c78447
 
 
 
 
 
 
 
 
 
 
 
 
 
6684c8f
1c78447
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
---
language:
- da
pipeline_tag: text-generation
widget:
  - text: "### Bruger:\nAnders\n\n### Anmeldelse:\nUmuligt at komme igennem på telefonen.\n\n### Svar:\nKære Anders\n"
---

# What is this?

A fine-tuned GPT-2 model (medium version, ~354.8 M parameters) for generating responses to customer reviews in Danish.

# How to use

The model is based on the [gpt2-medium-danish model](https://huggingface.co/KennethTM/gpt2-medium-danish) and performs better than the smaller version ([gpt2-small-danish-review-response](https://huggingface.co/KennethTM/gpt2-small-danish-review-response)). Supervised fine-tuning is applied to adapt the model to generate responses to customer reviews in Danish. A prompting template is applied to the examples used for training (see the example below).

Test the model using the pipeline from the [🤗 Transformers](https://github.com/huggingface/transformers) library:

```python
from transformers import pipeline

generator = pipeline("text-generation", model = "KennethTM/gpt2-medium-danish-review-response")

def prompt_template(user, review):
    return f"### Bruger:\n{user}\n\n### Anmeldelse:\n{review}\n\n### Svar:\nKære {user}\n"

prompt = prompt_template(user = "Anders", review = "Umuligt at komme igennem på telefonen.")

text = generator(prompt)

print(text[0]["generated_text"])
```

Or load it using the Auto* classes:

```python
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("KennethTM/gpt2-medium-danish-review-response")
model = AutoModelForCausalLM.from_pretrained("KennethTM/gpt2-medium-danish-review-response")
```