Locutusque commited on
Commit
af9da65
1 Parent(s): 0a74920

Upload 11 files

Browse files
adapter_config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model_name_or_path": "EleutherAI/gpt-j-6b",
3
+ "bias": "none",
4
+ "fan_in_fan_out": false,
5
+ "inference_mode": true,
6
+ "init_lora_weights": true,
7
+ "layers_pattern": null,
8
+ "layers_to_transform": null,
9
+ "lora_alpha": 32,
10
+ "lora_dropout": 0.1,
11
+ "modules_to_save": null,
12
+ "peft_type": "LORA",
13
+ "r": 16,
14
+ "revision": null,
15
+ "target_modules": [
16
+ "q_proj",
17
+ "v_proj"
18
+ ],
19
+ "task_type": "CAUSAL_LM"
20
+ }
added_tokens.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "<|ASSISTANT|>": 50257,
3
+ "<|SYSTEM|>": 50259,
4
+ "<|USER|>": 50258
5
+ }
config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "gpt2-large",
3
+ "activation_function": "gelu_new",
4
+ "architectures": [
5
+ "GPT2LMHeadModel"
6
+ ],
7
+ "attn_pdrop": 0.1,
8
+ "bos_token_id": 50256,
9
+ "embd_pdrop": 0.1,
10
+ "eos_token_id": 50256,
11
+ "initializer_range": 0.02,
12
+ "layer_norm_epsilon": 1e-05,
13
+ "model_type": "gpt2",
14
+ "n_ctx": 1024,
15
+ "n_embd": 1280,
16
+ "n_head": 20,
17
+ "n_inner": null,
18
+ "n_layer": 36,
19
+ "n_positions": 1024,
20
+ "reorder_and_upcast_attn": false,
21
+ "resid_pdrop": 0.1,
22
+ "scale_attn_by_inverse_layer_idx": false,
23
+ "scale_attn_weights": true,
24
+ "summary_activation": null,
25
+ "summary_first_dropout": 0.1,
26
+ "summary_proj_to_labels": true,
27
+ "summary_type": "cls_index",
28
+ "summary_use_proj": true,
29
+ "task_specific_params": {
30
+ "text-generation": {
31
+ "do_sample": true,
32
+ "max_length": 50
33
+ }
34
+ },
35
+ "torch_dtype": "bfloat16",
36
+ "transformers_version": "4.30.1",
37
+ "use_cache": true,
38
+ "vocab_size": 50260
39
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 50256,
4
+ "eos_token_id": 50256,
5
+ "transformers_version": "4.30.1"
6
+ }
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:bc74cffab094a7fb2e0ae37c1dcedc4a522700cf0909ee9e05d4b284f3437c0e
3
+ size 1548210205
run_model.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import GPT2Tokenizer, AutoModelForCausalLM
3
+ start_token = "<|ASSISTANT|>"
4
+ end_token = "<|"
5
+ tokenizer = GPT2Tokenizer.from_pretrained('gpt2-large')
6
+ model = AutoModelForCausalLM.from_pretrained('gpt2-large', torch_dtype=torch.bfloat16)
7
+ tokenizer.pad_token = "[PAD]"
8
+ tokenizer.eos_token = "<|endoftext|>"
9
+ tokenizer.add_special_tokens({"additional_special_tokens": ["<|ASSISTANT|>", "<|USER|>", "<|SYSTEM|>"]})
10
+ model.resize_token_embeddings(len(tokenizer))
11
+ model.load_state_dict(torch.load("/media/locutusque/T7/Projects/results/pytorch_model.bin"))
12
+ model.cuda()
13
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14
+ def generate_text(model, tokenizer, prompt, max_length=1024):
15
+ prompt = f'<|USER|> {prompt} <|ASSISTANT|> '
16
+ input_ids = tokenizer.encode(prompt, add_special_tokens=True, return_tensors="pt").to(device)
17
+ attention_mask = torch.ones_like(input_ids).to(device)
18
+ output = model.generate(input_ids,
19
+ max_length=max_length,
20
+ do_sample=True,
21
+ top_k=0,
22
+ top_p=0.1,
23
+ temperature=0.75,
24
+ repetition_penalty=1.176,
25
+ pad_token_id=tokenizer.pad_token_id,
26
+ eos_token_id=tokenizer.eos_token_id,
27
+ attention_mask=attention_mask)
28
+ output_ids = tokenizer.decode(output[0], skip_special_tokens=False)
29
+ return output_ids
30
+ # Loop to interact with the model
31
+ while True:
32
+ prompt = input("Enter a prompt (or 'q' to quit): ")
33
+ if prompt == "q":
34
+ break
35
+ output_text = generate_text(model, tokenizer, prompt)
36
+ text_between_tokens = output_text[output_text.find(start_token) + len(start_token):]
37
+ out = text_between_tokens[:text_between_tokens.find(end_token)]
38
+ print(out)
special_tokens_map.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|ASSISTANT|>",
4
+ "<|USER|>",
5
+ "<|SYSTEM|>"
6
+ ],
7
+ "bos_token": "<|endoftext|>",
8
+ "eos_token": "<|endoftext|>",
9
+ "pad_token": "[PAD]",
10
+ "unk_token": "<|endoftext|>"
11
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "bos_token": "<|endoftext|>",
4
+ "clean_up_tokenization_spaces": true,
5
+ "eos_token": "<|endoftext|>",
6
+ "model_max_length": 1024,
7
+ "tokenizer_class": "GPT2Tokenizer",
8
+ "unk_token": "<|endoftext|>"
9
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff