File size: 2,776 Bytes
8bfcdb1
 
 
 
 
f9a2323
8bfcdb1
f9a2323
8bfcdb1
f9a2323
8bfcdb1
f9a2323
 
8bfcdb1
f9a2323
8bfcdb1
0a52e6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8bfcdb1
73e3dd9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0afac74
73e3dd9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
library_name: transformers
tags: []
---

## Llama-3-SURPASSONE-JP-8B

![Llama-3-SURPASSONE-JP-8B-image](./visual.png)

### Model Description

**Llama-3-SURPASSONE-JP-8B** is a large language model trained by [SURPASSONE, Inc](https://surpassone.com/). 
Based on [meta-llama/Meta-Llama-3-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct), it has been enhanced for Japanese usage through additional pre-training and instruction tuning. (Built with Meta Llama3)

For more details, please refer to [our blog post](https://surpassone.com/).

### Usage

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

bnb_config = BitsAndBytesConfig(
   load_in_4bit=True,
   bnb_4bit_use_double_quant=True,
   bnb_4bit_quant_type="nf4",
   bnb_4bit_compute_dtype=torch.bfloat16,
)

model_id = "surpassone/Llama-3-SURPASSONE-JP-8B"
            
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
   model_id,
   device_map="auto",
   quantization_config=None, # Use bnb_config, if need to use 4 bit quantization else None
)
if tokenizer.pad_token is None:
   tokenizer.pad_token = tokenizer.eos_token

model.eval()
alpaca_prompt = """以下は、タスクを説明する指示と、さらに詳しいコンテキストを提供する入力を組み合わせたものです。要求を適切に完了する応答を記述してください。

### 説明書:
{}

### 入力:
{}

### 応答:
{}"""

EOS_TOKEN = "<|endoftext|>"  # Define the EOS token, adjust according to your tokenizer

inputs = tokenizer(
[
   alpaca_prompt.format(
       "次のトピックに関する複数選択問題を生成します。", # instruction
       "介護:体の仕組み", # input
       "", # output - leave this blank for generation!
   )
], return_tensors = "pt").to("cuda")

from transformers import TextStreamer
text_streamer = TextStreamer(tokenizer)
_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 1028)
```

### Developers

Listed in alphabetical order.

- [Mustain Billah](https://huggingface.co/Mustain)
- [Shugo Saito](https://huggingface.co/shugo3110)
- [Leo Uno](https://huggingface.co/leouno12)

### License

[Meta Llama 3 Community License](https://llama.meta.com/llama3/license/)

### How to Cite

```tex
@misc{surpassonellama2024,
      title={surpassone/Llama-3-SURPASSONE-JP-8B},
      url={https://huggingface.co/surpassone/Llama-3-SURPASSONE-JP-8B},
      author={Mustain Billah and Shugo Saito and Leo Uno},
      year={2024},
}
```

### Citations

```tex
@article{llama3modelcard,
    title={Llama 3 Model Card},
    author={AI@Meta},
    year={2024},
    url = {https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md}
}
```