Views
No views yet
| Model | #params | Model file (pt) | Arch. | Training /Validation data (text) |
|---|---|---|---|---|
| gpt2-azerbaijani-smallv0 | 124M | 652 | GPT-2 small | Azerbaijani Wikipedia (110k articles / 19k articles) |
1import torch
2from transformers import GPT2LMHeadModel, AutoTokenizer, AutoModelWithLMHead
3
4tokenizer = AutoTokenizer.from_pretrained("nijatzeynalov/gpt2-azerbaijani-small")
5tokenizer.model_max_length=1024
6
7model_state_dict = torch.load('GPT2_pt_3epoch_lr2e-3.pth', map_location=torch.device('cpu'))
8model = GPT2LMHeadModel.from_pretrained('gpt2', state_dict=model_state_dict)
9
10model.eval()
11
12text = "Your prompt here"
13inputs = tokenizer(text, return_tensors="pt")
14
15sample_outputs = model.generate(inputs.input_ids,
16 pad_token_id=50256,
17 do_sample=True,
18 max_length=20,
19 top_k=10,
20 num_return_sequences=1)
21
22# generated sequence
23for i, sample_output in enumerate(sample_outputs):
24 print(">> Generated text {}\n\n{}".format(i+1, tokenizer.decode(sample_output.tolist())))Because large-scale language models like GPT-2 do not distinguish fact from fiction, we don’t support use-cases that require the generated text to be true. Additionally, language models like GPT-2 reflect the biases inherent to the systems they were trained on, so we do not recommend that they be deployed into systems that interact with humans > unless the deployers first carry out a study of biases relevant to the intended use-case. We found no statistically significant difference in gender, race, and religious bias probes between 774M and 1.5B, implying all versions of GPT-2 should be approached with similar levels of caution around use cases that are sensitive to biases around human attributes.