File size: 2,097 Bytes
c330d3b a16b389 0fe87f1 a16b389 0fe87f1 05f743f ccb8e1b 2b6f0c2 ccb8e1b c330d3b 83ca26f 05f743f c330d3b 0fe87f1 c330d3b 0fe87f1 |
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 |
---
language:
- en
- ja
---
llama3.1-8bのAWQ量子化版です。
4GB超のGPUメモリがあれば高速に動かす事ができます。
This is the AWQ quantization version of llama3.1-8b.
If you have more than 4GB of GPU memory, you can run it at high speed.
量子化時に日本語と中国語を多めに使っているため、[hugging-quants/Meta-Llama-3.1-8B-Instruct-AWQ-INT4](https://huggingface.co/hugging-quants/Meta-Llama-3.1-8B-Instruct-AWQ-INT4)より日本語データを使って計測したPerplexityが良い事がわかっています
Because Japanese and Chinese are used a lot during quantization, It is known that Perplexity measured using Japanese data is better than [hugging-quants/Meta-Llama-3.1-8B-Instruct-AWQ-INT4](https://huggingface.co/hugging-quants/Meta-Llama-3.1-8B-Instruct-AWQ-INT4).
## セットアップ(setup)
```
pip install transformers==4.43.3 autoawq==0.2.6 accelerate==0.33.0
```
## サンプルスクリプト(sample script)
```
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, AwqConfig
model_id = "dahara1/llama3.1-8b-Instruct-awq"
quantization_config = AwqConfig(
bits=4,
fuse_max_seq_len=512, # Note: Update this as per your use-case
do_fuse=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
low_cpu_mem_usage=True,
device_map="auto",
quantization_config=quantization_config
)
prompt = [
{"role": "system", "content": "あなたは親切で役に立つアシスタントです。常に海賊のように返答してください"},
{"role": "user", "content": "ディープラーニングとは何ですか?"},
]
inputs = tokenizer.apply_chat_template(
prompt,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True,
).to("cuda")
outputs = model.generate(**inputs, do_sample=True, max_new_tokens=256)
print(tokenizer.batch_decode(outputs[:, inputs['input_ids'].shape[1]:], skip_special_tokens=True)[0])
```
![kaizoku](kaizoku.png)
|