lyogavin commited on
Commit
778002f
1 Parent(s): 2126456

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -43
README.md CHANGED
@@ -48,11 +48,13 @@ Anima模型基于QLoRA开源的[33B guanaco](https://huggingface.co/timdettmers/
48
 
49
  使用以下步骤可以重现Anima 33B模型:
50
 
51
- # 1. install dependencies
52
- pip install -r requirements.txt
53
- # 2.
54
- cd training
55
- ./run_Amina_training.sh
 
 
56
 
57
 
58
 
@@ -87,47 +89,51 @@ Anima模型只通过10000 steps的训练,并没有深度优化训练数据的
87
 
88
  首先保证依赖都已经安装:
89
 
90
- pip install -r https://github.com/lyogavin/Anima/blob/main/requirements.txt?raw=true
91
-
 
 
92
  可以参考:[inferrence.ipynb](https://github.com/lyogavin/Anima/blob/main/examples/inferrence.ipynb)
93
 
94
  或者使用如下代码:
95
-
96
- # imports
97
- from peft import PeftModel
98
- from transformers import GenerationConfig, LlamaForCausalLM, LlamaTokenizer
99
- import torch
100
-
101
- # create tokenizer
102
- base_model = "timdettmers/guanaco-33b-merged"
103
- tokenizer = LlamaTokenizer.from_pretrained(base_model)
104
-
105
- # base model
106
- model = LlamaForCausalLM.from_pretrained(
107
- base_model,
108
- torch_dtype=torch.float16,
109
- device_map="auto",
110
- )
111
-
112
- # LORA PEFT adapters
113
- adapter_model = "lyogavin/Anima33B"
114
-
115
- model = PeftModel.from_pretrained(
116
- model,
117
- adapter_model,
118
- #torch_dtype=torch.float16,
119
- )
120
- model.eval()
121
-
122
- # prompt
123
- prompt = "中国的首都是哪里?"
124
- inputs = tokenizer(prompt, return_tensors="pt")
125
-
126
- # Generate
127
- generate_ids = model.generate(**inputs, max_new_tokens=30)
128
- print(tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0])
129
-
130
- # output: '中国的首都是哪里?\n中国的首都是北京。\n北京位于中国北部,是中国历史悠'
 
 
131
 
132
  ## 📚 模型使用例子
133
 
 
48
 
49
  使用以下步骤可以重现Anima 33B模型:
50
 
51
+ ``` bash
52
+ # 1. install dependencies
53
+ pip install -r requirements.txt
54
+ # 2.
55
+ cd training
56
+ ./run_Amina_training.sh
57
+ ```
58
 
59
 
60
 
 
89
 
90
  首先保证依赖都已经安装:
91
 
92
+ ``` bash
93
+ pip install -r https://github.com/lyogavin/Anima/blob/main/requirements.txt?raw=true
94
+ ```
95
+
96
  可以参考:[inferrence.ipynb](https://github.com/lyogavin/Anima/blob/main/examples/inferrence.ipynb)
97
 
98
  或者使用如下代码:
99
+
100
+ ``` python
101
+ # imports
102
+ from peft import PeftModel
103
+ from transformers import GenerationConfig, LlamaForCausalLM, LlamaTokenizer
104
+ import torch
105
+
106
+ # create tokenizer
107
+ base_model = "timdettmers/guanaco-33b-merged"
108
+ tokenizer = LlamaTokenizer.from_pretrained(base_model)
109
+
110
+ # base model
111
+ model = LlamaForCausalLM.from_pretrained(
112
+ base_model,
113
+ torch_dtype=torch.float16,
114
+ device_map="auto",
115
+ )
116
+
117
+ # LORA PEFT adapters
118
+ adapter_model = "lyogavin/Anima33B"
119
+
120
+ model = PeftModel.from_pretrained(
121
+ model,
122
+ adapter_model,
123
+ #torch_dtype=torch.float16,
124
+ )
125
+ model.eval()
126
+
127
+ # prompt
128
+ prompt = "中国的首都是哪里?"
129
+ inputs = tokenizer(prompt, return_tensors="pt")
130
+
131
+ # Generate
132
+ generate_ids = model.generate(**inputs, max_new_tokens=30)
133
+ print(tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0])
134
+
135
+ # output: '中国的首都是哪里?\n中国的首都是北京。\n北京位于中国北部,是中国历史悠'
136
+ ```
137
 
138
  ## 📚 模型使用例子
139