File size: 1,619 Bytes
699601b
 
 
 
 
 
 
 
 
 
 
 
 
 
589194d
699601b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
# ebisuke/liz-nojaloli-ja

## License
[MIT License](https://opensource.org/licenses/MIT)  
  
ใƒ™ใƒผใ‚นใจใ—ใฆ[rinna/japanese-gpt-neox-3.6b](https://huggingface.co/rinna/japanese-gpt-neox-3.6b)ใ‚’ไฝฟ็”จใ—ใฆใ„ใพใ™ใ€‚

## Description
ใฎใ˜ใ‚ƒใƒญใƒช้ขจๅ‘ณใƒใƒฃใƒƒใƒˆใƒขใƒ‡ใƒซใงใ™ใ€‚  
[rinna/japanese-gpt-neox-3.6b](https://huggingface.co/rinna/japanese-gpt-neox-3.6b)ใ‚’ใƒ™ใƒผใ‚นใจใ—ใฆใƒ•ใ‚กใ‚คใƒณใƒใƒฅใƒผใƒณใ—ใฆใ„ใพใ™ใ€‚

## Usage

ใƒฆใƒผใ‚ถใƒผใฎๅ…ฅๅŠ›ใ‚’`็›ธๆ‰‹ใฏ่จ€ใ„ใพใ—ใŸใ€‚ใ€Œ๏ผˆๅ†…ๅฎน๏ผ‰ใ€\n`ใงๆ‹ฌใฃใฆใใ ใ•ใ„ใ€‚  
ใƒขใƒ‡ใƒซใฏ`ใ‚ใชใŸใฏ่จ€ใ„ใพใ—ใŸใ€‚ใ€Œ`ไปฅ้™ใฎๆ–‡่„ˆใ‚’็”Ÿๆˆใ—ใพใ™ใ€‚  
ใใ‚Œไปฅ้™ใ‚‚็ถšใๅ ดๅˆใŒใ‚ใ‚‹ใฎใงๅฟ…่ฆใซๅฟœใ˜ใฆ`ใ€`ใฎๆ–‡ๅญ—ใพใงใงๆ‰“ใกๅˆ‡ใฃใฆใใ ใ•ใ„ใ€‚

```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
import os

tokenizer = AutoTokenizer.from_pretrained("ebisuke/liz-nojaloli-ja", use_fast=False)
model = AutoModelForCausalLM.from_pretrained("ebisuke/liz-nojaloli-ja", load_in_8bit=True, device_map='auto')

text = "็›ธๆ‰‹ใฏ่จ€ใ„ใพใ—ใŸใ€‚ใ€Œ็œ ใ„ใซใ‚ƒใƒปใƒปใƒปใ€ \nใ‚ใชใŸใฏ่จ€ใ„ใพใ—ใŸใ€‚ใ€Œ"
token_ids = tokenizer.encode(text, add_special_tokens=False, return_tensors="pt")

with torch.no_grad():
    output_ids = model.generate(
        input_ids=token_ids.to(model.device),
        max_new_tokens=1000,
        do_sample=True,
        temperature=0.7,
        pad_token_id=tokenizer.pad_token_id,
        bos_token_id=tokenizer.bos_token_id,
        eos_token_id=tokenizer.eos_token_id,
    )

output = tokenizer.decode(output_ids.tolist()[0])
print(output)
```