Update README.md
Browse files
README.md
CHANGED
@@ -1,25 +0,0 @@
|
|
1 |
-
```
|
2 |
-
gen_kwargs = {
|
3 |
-
"max_new_tokens": 100,
|
4 |
-
"top_k": 70,
|
5 |
-
"top_p": 0.8,
|
6 |
-
"do_sample": True,
|
7 |
-
"no_repeat_ngram_size": 2,
|
8 |
-
"bos_token_id": tokenizer.bos_token_id,
|
9 |
-
"eos_token_id": tokenizer.eos_token_id,
|
10 |
-
"pad_token_id": tokenizer.pad_token_id,
|
11 |
-
"temperature": 0.8,
|
12 |
-
"use_cache": True,
|
13 |
-
"repetition_penalty": 1.2,
|
14 |
-
"num_return_sequences": 1
|
15 |
-
}
|
16 |
-
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
|
17 |
-
ft = 'gpt-j-onlyk_v2'
|
18 |
-
tokenizer = AutoTokenizer.from_pretrained(ft)
|
19 |
-
model = AutoModelForCausalLM.from_pretrained(ft, torch_dtype=torch.float16, low_cpu_mem_usage=True)
|
20 |
-
model.to(device)
|
21 |
-
|
22 |
-
prepared = tokenizer.encode(inp, return_tensors='pt').to(model.device)
|
23 |
-
out = model.generate(input_ids=prepared, **gen_kwargs)
|
24 |
-
generated = tokenizer.decode(out[0])
|
25 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|