Kamran151199
commited on
Commit
·
ac5cabf
1
Parent(s):
14a6387
added model
Browse files- README.md +56 -0
- config.json +39 -0
- merges.txt +0 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tokenizer_config.json +1 -0
- vocab.json +0 -0
README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: de
|
| 3 |
+
|
| 4 |
+
widget:
|
| 5 |
+
- text: "In einer schockierenden Entdeckung fanden Wissenschaftler eine Herde Einhörner, die in einem abgelegenen, zuvor unerforschten Tal in den Anden lebten."
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# BPT2
|
| 9 |
+
|
| 10 |
+
See the [GPT2 model card](https://huggingface.co/gpt2) for considerations on limitations and bias. See the [GPT2 documentation](https://huggingface.co/transformers/model_doc/gpt2.html) for details on GPT2.
|
| 11 |
+
|
| 12 |
+
## Usage
|
| 13 |
+
|
| 14 |
+
```python
|
| 15 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 16 |
+
|
| 17 |
+
tokenizer = AutoTokenizer.from_pretrained("tursunali/bpt2")
|
| 18 |
+
model = AutoModelForCausalLM.from_pretrained("tursunali/bpt2")
|
| 19 |
+
|
| 20 |
+
prompt = "<your prompt>"
|
| 21 |
+
|
| 22 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 23 |
+
print(pipe(prompt)[0]["generated_text"])
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
Also, two tricks might improve the generated text:
|
| 27 |
+
|
| 28 |
+
```python
|
| 29 |
+
output = model.generate(
|
| 30 |
+
# during training an EOS token was used to mark the beginning of each text
|
| 31 |
+
# so it can help to insert it at the start
|
| 32 |
+
torch.tensor(
|
| 33 |
+
[tokenizer.eos_token_id] + tokenizer.encode(prompt)
|
| 34 |
+
).unsqueeze(0),
|
| 35 |
+
do_sample=True,
|
| 36 |
+
# try setting bad_words_ids=[[0]] to disallow generating an EOS token, without this the model is
|
| 37 |
+
# prone to ending generation early because a significant number of texts from the training corpus
|
| 38 |
+
# is quite short
|
| 39 |
+
bad_words_ids=[[0]],
|
| 40 |
+
max_length=max_length,
|
| 41 |
+
)[0]
|
| 42 |
+
print(tokenizer.decode(output))
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## Citing
|
| 46 |
+
|
| 47 |
+
Please cite BPT2 as follows:
|
| 48 |
+
|
| 49 |
+
```
|
| 50 |
+
@misc{Backpacker_Trail_German_large_2022,
|
| 51 |
+
author = {BackpackerTrail, Tursunali Kholdorov},
|
| 52 |
+
title = {{BPT2: Backpacker Trail German versions of BPT2}},
|
| 53 |
+
url = {https://github.com/bminixhofer/gerpt2},
|
| 54 |
+
year = {2022}
|
| 55 |
+
}
|
| 56 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_function": "gelu_new",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"GPT2LMHeadModel"
|
| 5 |
+
],
|
| 6 |
+
"attn_pdrop": 0.1,
|
| 7 |
+
"bos_token_id": 50256,
|
| 8 |
+
"embd_pdrop": 0.1,
|
| 9 |
+
"eos_token_id": 50256,
|
| 10 |
+
"gradient_checkpointing": false,
|
| 11 |
+
"id2label": {
|
| 12 |
+
"0": "LABEL_0"
|
| 13 |
+
},
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"label2id": {
|
| 16 |
+
"LABEL_0": 0
|
| 17 |
+
},
|
| 18 |
+
"layer_norm_epsilon": 1e-05,
|
| 19 |
+
"model_type": "gpt2",
|
| 20 |
+
"n_ctx": 1024,
|
| 21 |
+
"n_embd": 1280,
|
| 22 |
+
"n_head": 20,
|
| 23 |
+
"n_inner": null,
|
| 24 |
+
"n_layer": 36,
|
| 25 |
+
"n_positions": 1024,
|
| 26 |
+
"resid_pdrop": 0.1,
|
| 27 |
+
"summary_activation": null,
|
| 28 |
+
"summary_first_dropout": 0.1,
|
| 29 |
+
"summary_proj_to_labels": true,
|
| 30 |
+
"summary_type": "cls_index",
|
| 31 |
+
"summary_use_proj": true,
|
| 32 |
+
"task_specific_params": {
|
| 33 |
+
"text-generation": {
|
| 34 |
+
"do_sample": true,
|
| 35 |
+
"max_length": 50
|
| 36 |
+
}
|
| 37 |
+
},
|
| 38 |
+
"vocab_size": 50257
|
| 39 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:28e73b994389ab71c24f5b4de30f5898120340b4184da42b916f16b411c963a4
|
| 3 |
+
size 3391352276
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"bos_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "eos_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "unk_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "pad_token": "<|endoftext|>"}
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"errors": "replace", "unk_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "bos_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "eos_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "add_prefix_space": false}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|