prithivida commited on
Commit
0aeea22
1 Parent(s): eaa5622

Added "how to use"

Browse files
Files changed (1) hide show
  1. README.md +59 -160
README.md CHANGED
@@ -27,174 +27,73 @@ Asimov will be a series of language models that are trained to act as a useful w
27
  - **License:** [More Information Needed]
28
  - **Finetuned from model [optional]:** [More Information Needed]
29
 
30
- ### Model Sources [optional]
31
-
32
-
33
- - **Repository:** [More Information Needed]
34
- - **Paper [optional]:** [More Information Needed]
35
- - **Demo [optional]:** [More Information Needed]
36
-
37
- ## Uses
38
-
39
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
40
-
41
- ### Direct Use
42
-
43
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
44
-
45
- [More Information Needed]
46
-
47
- ### Downstream Use [optional]
48
-
49
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
50
-
51
- [More Information Needed]
52
-
53
- ### Out-of-Scope Use
54
-
55
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
56
-
57
- [More Information Needed]
58
 
59
  ## Bias, Risks, and Limitations
60
 
61
  Asimov-7B-v2 has not been aligned to human preferences, so the model can produce problematic outputs (especially when prompted to do so). It is also unknown what the size and composition of the corpus was used to train the base model (mistralai/Mistral-7B-v0.1), however it is likely to have included a mix of Web data and technical sources like books and code. See the Falcon 180B model card for an example of this.
62
 
63
- ### Recommendations
64
-
65
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
66
-
67
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
68
 
69
  ## How to Get Started with the Model
70
 
71
  Use the code below to get started with the model.
72
 
73
- [More Information Needed]
74
-
75
- ## Training Details
76
-
77
- ### Training Data
78
-
79
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
80
-
81
- [More Information Needed]
82
-
83
- ### Training Procedure
84
-
85
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
86
-
87
- #### Preprocessing [optional]
88
-
89
- [More Information Needed]
90
-
91
-
92
- #### Training Hyperparameters
93
-
94
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
95
-
96
- #### Speeds, Sizes, Times [optional]
97
-
98
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
99
-
100
- [More Information Needed]
101
-
102
- ## Evaluation
103
-
104
- <!-- This section describes the evaluation protocols and provides the results. -->
105
-
106
- ### Testing Data, Factors & Metrics
107
-
108
- #### Testing Data
109
-
110
- <!-- This should link to a Dataset Card if possible. -->
111
-
112
- [More Information Needed]
113
-
114
- #### Factors
115
-
116
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
117
-
118
- [More Information Needed]
119
-
120
- #### Metrics
121
-
122
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
123
-
124
- [More Information Needed]
125
-
126
- ### Results
127
-
128
- [More Information Needed]
129
-
130
- #### Summary
131
-
132
-
133
-
134
- ## Model Examination [optional]
135
-
136
- <!-- Relevant interpretability work for the model goes here -->
137
-
138
- [More Information Needed]
139
-
140
- ## Environmental Impact
141
-
142
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
143
-
144
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
145
-
146
- - **Hardware Type:** [More Information Needed]
147
- - **Hours used:** [More Information Needed]
148
- - **Cloud Provider:** [More Information Needed]
149
- - **Compute Region:** [More Information Needed]
150
- - **Carbon Emitted:** [More Information Needed]
151
-
152
- ## Technical Specifications [optional]
153
-
154
- ### Model Architecture and Objective
155
-
156
- [More Information Needed]
157
-
158
- ### Compute Infrastructure
159
-
160
- [More Information Needed]
161
-
162
- #### Hardware
163
-
164
- [More Information Needed]
165
-
166
- #### Software
167
-
168
- [More Information Needed]
169
-
170
- ## Citation [optional]
171
-
172
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
173
-
174
- **BibTeX:**
175
-
176
- [More Information Needed]
177
-
178
- **APA:**
179
-
180
- [More Information Needed]
181
-
182
- ## Glossary [optional]
183
-
184
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
185
-
186
- [More Information Needed]
187
-
188
- ## More Information [optional]
189
-
190
- [More Information Needed]
191
-
192
- ## Model Card Authors [optional]
193
-
194
- [More Information Needed]
195
-
196
- ## Model Card Contact
197
-
198
- [More Information Needed]
199
-
200
 
 
27
  - **License:** [More Information Needed]
28
  - **Finetuned from model [optional]:** [More Information Needed]
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  ## Bias, Risks, and Limitations
32
 
33
  Asimov-7B-v2 has not been aligned to human preferences, so the model can produce problematic outputs (especially when prompted to do so). It is also unknown what the size and composition of the corpus was used to train the base model (mistralai/Mistral-7B-v0.1), however it is likely to have included a mix of Web data and technical sources like books and code. See the Falcon 180B model card for an example of this.
34
 
 
 
 
 
 
35
 
36
  ## How to Get Started with the Model
37
 
38
  Use the code below to get started with the model.
39
 
40
+ ```python
41
+ import torch
42
+ from transformers import AutoModelForCausalLM, AutoTokenizer,GenerationConfig
43
+ from peft import PeftModel, PeftConfig
44
+
45
+ model_name = "prithivida/Asimov-7B-v2"
46
+ peft_config = PeftConfig.from_pretrained(model_name)
47
+
48
+ base_model = AutoModelForCausalLM.from_pretrained(
49
+ peft_config.base_model_name_or_path,
50
+ return_dict=True,
51
+ device_map="auto",
52
+ torch_dtype=torch.float16,
53
+ low_cpu_mem_usage=True,
54
+ )
55
+
56
+ model = PeftModel.from_pretrained(
57
+ base_model,
58
+ model_name,
59
+ torch_dtype=torch.float16,
60
+ device_map="auto",
61
+ )
62
+
63
+ tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True)
64
+ model.config.pad_token_id = tokenizer.unk_token_id
65
+
66
+ def run_inference(messages):
67
+ chat = []
68
+ for i, message in enumerate(messages):
69
+ if i % 2 ==0:
70
+ chat.append({"role": "Human", "content": f"{message}"})
71
+ else:
72
+ chat.append({"role": "Assistant", "content": f"{message}"})
73
+
74
+
75
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
76
+
77
+ inputs = tokenizer(prompt, return_tensors="pt")
78
+ input_ids = inputs["input_ids"].cuda()
79
+
80
+ generation_output = model.generate(
81
+ input_ids=input_ids,
82
+ generation_config=GenerationConfig(pad_token_id=tokenizer.pad_token_id,
83
+ do_sample=True,
84
+ temperature=1.0,
85
+ top_k=50,
86
+ top_p=0.95),
87
+ return_dict_in_generate=True,
88
+ output_scores=True,
89
+ max_new_tokens=128
90
+ )
91
+
92
+ for seq in generation_output.sequences:
93
+ output = tokenizer.decode(seq)
94
+ print(output.split("### Assistant: ")[1].strip())
95
+
96
+
97
+ run_inference(["What's the longest side of the right angled triangle called and how is it related to the Pythagoras theorem?"])
98
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99