Text Generation
Transformers
PyTorch
Japanese
mpt
Composer
MosaicML
llm-foundry
StreamingDatasets
mpt-7b
custom_code
text-generation-inference
Jumtra commited on
Commit
a8e18a0
1 Parent(s): 81752cf

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +110 -0
README.md ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-inst
20
+
21
+ このモデルは、MosaicMLのllm-foundryリポジトリを使用して[mosaicml/mpt-7b-instruct](https://huggingface.co/mosaicml/mpt-7b-instruct)をファインチューニングしたモデルです。
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-inst'
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)は、人工知能の分野で使用される深い学習アルゴリズムの一種です。これらのアルゴリズムは、データを使って自動的に学習し、特定の目的を達成するために予測や決定を行うことができます。ニューラルネットワークは、多くの異なるアプリケーションで使用されており、自動車の運転システム、検索エンジン、画像認識などです。<|endoftext|>
96
+ ```
97
+
98
+ ## 引用
99
+
100
+ ```
101
+ @online{MosaicML2023Introducing,
102
+ author = {MosaicML NLP Team},
103
+ title = {Introducing MPT-7B: A New Standard for Open-Source,
104
+ ly Usable LLMs},
105
+ year = {2023},
106
+ url = {www.mosaicml.com/blog/mpt-7b},
107
+ note = {Accessed: 2023-03-28}, % change this date
108
+ urldate = {2023-03-28} % change this date
109
+ }
110
+ ```