Jumtra commited on
Commit
82ae251
·
1 Parent(s): c1efe6e

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +96 -0
README.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - Composer
5
+ - MosaicML
6
+ - llm-foundry
7
+ - StreamingDatasets
8
+ - mpt-7b
9
+ datasets:
10
+ - kunishou/databricks-dolly-15k-ja
11
+ - Jumtra/oasst1_ja
12
+ - Jumtra/jglue_jsquad
13
+ - Jumtra/jglue_jsquads_with_input
14
+ inference: false
15
+ language:
16
+ - ja
17
+ ---
18
+
19
+ # MPT-7B-base
20
+
21
+ このモデルは、MosaicMLのllm-foundryリポジトリを使用して[mosaicml/mpt-7b](https://huggingface.co/mosaicml/mpt-7b)をファインチューニングしたモデルです。
22
+
23
+ ## Model Date
24
+
25
+ June 28, 2023
26
+
27
+ ## Model License
28
+
29
+ Apache-2.0
30
+
31
+ ## 使用方法
32
+
33
+ 注意:このモデルでは、from_pretrainedメソッドにtrust_remote_code=Trueを渡す必要があります。
34
+ これは、Hugging Faceのtransformersパッケージにはまだ含まれていないカスタムのMPTモデルアーキテクチャを使用しているためです。
35
+ MPTには、FlashAttention、ALiBi、QK LayerNormなど、多くのトレーニング効率化機能のオプションが含まれています。
36
+
37
+ ```python
38
+ # 使用したプロンプトフォーマット
39
+ INSTRUCTION_KEY = "### Instruction:"
40
+ RESPONSE_KEY = "### Response:"
41
+ INTRO_BLURB = "Below is an instruction that describes a task. Write a response that appropriately completes the request."
42
+ PROMPT_FOR_GENERATION_FORMAT = """{intro}
43
+ {instruction_key}
44
+ {instruction}
45
+ {response_key}
46
+ """.format(
47
+ intro=INTRO_BLURB,
48
+ instruction_key=INSTRUCTION_KEY,
49
+ instruction="{instruction}",
50
+ response_key=RESPONSE_KEY,
51
+ )
52
+ ```
53
+
54
+
55
+ ```python
56
+ import torch
57
+ import transformers
58
+ name = 'Jumtra/mpt-7b-base'
59
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
60
+ config.attn_config['attn_impl'] = 'torch'
61
+ config.init_device = 'cuda:0' # For fast initialization directly on GPU!
62
+ model = transformers.AutoModelForCausalLM.from_pretrained(
63
+ name,
64
+ config=config,
65
+ torch_dtype=torch.bfloat16, # Load model weights in bfloat16
66
+ trust_remote_code=True
67
+ ).to("cuda:0")
68
+ model.eval()
69
+
70
+ input_text = PROMPT_FOR_GENERATION_FORMAT.format(instruction = "ニューラルネットワークとは何ですか?")
71
+
72
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
73
+ input_length = inputs.input_ids.shape[1]
74
+
75
+ # Without streaming
76
+ with torch.no_grad():
77
+ generation_output = model.generate(
78
+ **inputs,
79
+ max_new_tokens=2048,
80
+ do_sample=True,
81
+ temperature=0.01,
82
+ top_p=0.01,
83
+ top_k=60,
84
+ repetition_penalty=1.1,
85
+ return_dict_in_generate=True,
86
+ remove_invalid_values=True,
87
+ pad_token_id=tokenizer.pad_token_id,
88
+ bos_token_id=tokenizer.bos_token_id,
89
+ eos_token_id=tokenizer.eos_token_id,
90
+ )
91
+ token = generation_output.sequences[0, input_length:]
92
+ output = tokenizer.decode(token)
93
+ print(output)
94
+
95
+ #ニューラルネットワーク(NN)は、人工知能の分野で最も重要なアプローチの1つです。これらのモデルは、自動学習を使用して、大量のデータから学習されたパターンや関係を特定することができます。ニューラルネットワークは、人間の脳に似たように機能します。<|endoftext|>
96
+ ```