iansotnek commited on
Commit
31a480b
1 Parent(s): 67e3ee8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +144 -1
README.md CHANGED
@@ -1,4 +1,147 @@
1
  ---
2
  license: other
3
- commercial: false
 
 
 
 
4
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: other
3
+ datasets:
4
+ - tatsu-lab/alpaca
5
+ language:
6
+ - en
7
+ library_name: transformers
8
  ---
9
+
10
+
11
+ # Model Card for `chopt-research-125m`
12
+
13
+ <!-- Provide a quick summary of what the model is/does. -->
14
+
15
+ AI Squared's `chopt-research-125m` is a large language
16
+ model which is derived from Meta AI's Open Pre-trained Transformer language modelsand fine-tuned on a single GPU on a corpus of 50k records ([Stanford Alpaca](https://crfm.stanford.edu/2023/03/13/alpaca.html)) to help it exhibit chat-based capabilities.
17
+
18
+ The ChOPT family of models from AI Squared are licensed under the OPT-175B license, Copyright (c) Meta Platforms, Inc. All Rights Reserved.
19
+
20
+ While `chopt-research-125m` is **not a state-of-the-art model**, we believe that the level of interactivity that can be achieved on such a small model that is trained so cheaply is important to showcase, as it continues to demonstrate that creating powerful AI capabilities may be much more accessible than previously thought.
21
+
22
+
23
+ ### Model Description
24
+
25
+ <!-- Provide a longer summary of what this model is. -->
26
+
27
+ - **Developed by:** AI Squared, Inc.
28
+ - **Shared by:** AI Squared, Inc.
29
+ - **Model type:** Large Language Model
30
+ - **Language(s) (NLP):** EN
31
+ - **License:** Other
32
+ - **Finetuned from model:** OPT
33
+
34
+
35
+ ## Bias, Risks, and Limitations
36
+
37
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
38
+
39
+ **`chopt-research-125m` is not a state-of-the-art language model.** `chopt-research-125m` is an experimental technology and is not designed for use in any
40
+ environment other than for research purposes. Furthermore, the model can sometimes exhibit undesired behaviors. Some of these behaviors include,
41
+ but are not limited to: factual inaccuracies, biases, offensive responses, toxicity, and hallucinations.
42
+ Just as with any other LLM, we advise users of this technology to exercise good judgment when applying this technology.
43
+
44
+
45
+ ## Usage
46
+
47
+ The code below shows how to use `chopt-research-125m` in the way which it was trained. While the model can be used "out of the box" using the
48
+ `transformers` library, using the function defined below to create a response from the model will achieve better results.
49
+
50
+ ### Load Model and Tokenizer from this Repository Using the `transformers` Package
51
+
52
+ ```python
53
+ from transformers import AutoModelForCausalLM, AutoTokenizer
54
+ import numpy as np
55
+ import re
56
+
57
+ model_id = 'aisquared/chopt-research-125m'
58
+
59
+ tokenizer = AutoTokenizer.from_pretrained(model_id, padding_side = 'left')
60
+ model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code = True, device_map = 'auto')
61
+ ```
62
+
63
+
64
+ ### Create the Prompt Format and Other Variables
65
+
66
+ ```python
67
+ PROMPT = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
68
+
69
+ ### Instruction:
70
+ {instruction}
71
+
72
+ ### Response:
73
+ """
74
+
75
+ END_KEY = '### End'
76
+ RESPONSE_KEY = '### Response:\n'
77
+ ```
78
+
79
+
80
+ ### Create a Function to Retrieve a Response
81
+
82
+ ```python
83
+ def create_response(
84
+ instruction,
85
+ model,
86
+ tokenizer,
87
+ do_sample = True,
88
+ max_new_tokens = 256,
89
+ top_p = 0.92,
90
+ top_k = 0,
91
+ **kwargs
92
+ ):
93
+ """
94
+ Create a response from the model by using a formatted prompt
95
+ """
96
+ input_ids = tokenizer(
97
+ PROMPT.format(instruction=instruction), return_tensors="pt"
98
+ ).input_ids
99
+
100
+ gen_tokens = model.generate(
101
+ input_ids,
102
+ pad_token_id=tokenizer.pad_token_id,
103
+ do_sample=do_sample,
104
+ max_new_tokens=max_new_tokens,
105
+ top_p=top_p,
106
+ top_k=top_k,
107
+ **kwargs,
108
+ )
109
+ decoded = tokenizer.batch_decode(gen_tokens)[0]
110
+
111
+ # The response appears after "### Response:". The model has been trained to append "### End" at the end.
112
+ m = re.search(r"#+\s*Response:\s*(.+?)#+\s*End", decoded, flags=re.DOTALL)
113
+
114
+ response = None
115
+ if m:
116
+ response = m.group(1).strip()
117
+ else:
118
+ # The model might not generate the "### End" sequence before reaching the max tokens. In this case, return
119
+ # everything after "### Response:".
120
+ m = re.search(r"#+\s*Response:\s*(.+)", decoded, flags=re.DOTALL)
121
+ if m:
122
+ response = m.group(1).strip()
123
+ else:
124
+ pass
125
+ return response
126
+ ```
127
+
128
+ ### Model Performance Metrics
129
+
130
+ We present the results from various model benchmarks on the EleutherAI LLM Evaluation Harness for all models in the DLite family.
131
+ Model results are sorted by mean score, ascending, to provide an ordering. These metrics serve to further show that none of the DLite models are
132
+ state of the art, but rather further show that chat-like behaviors in LLMs can be trained almost independent of model size.
133
+
134
+ | Model | openbookqa | arc_easy | winogrande | hellaswag | arc_challenge | piqa | boolq |
135
+ |:--------------------|-------------:|-----------:|-------------:|------------:|----------------:|---------:|---------:|
136
+ | chopt-125m | 0.178 | 0.443182 | 0.501973 | 0.294165 | 0.197099 | 0.630577 | 0.476758 |
137
+ | chopt-research-125m | 0.17 | 0.436027 | 0.503552 | 0.294762 | 0.205631 | 0.62568 | 0.48685 |
138
+ | opt-125m | 0.166 | 0.435606 | 0.501973 | 0.291775 | 0.190273 | 0.6284 | 0.554434 |
139
+ | chopt-350m | 0.178 | 0.450758 | 0.508287 | 0.325334 | 0.21843 | 0.650707 | 0.559633 |
140
+ | opt_350m | 0.176 | 0.441077 | 0.52644 | 0.320056 | 0.207338 | 0.645267 | 0.57737 |
141
+ | chopt-research-350m | 0.172 | 0.462542 | 0.514601 | 0.327524 | 0.235495 | 0.643634 | 0.589908 |
142
+ | opt-1.3b | 0.234 | 0.569865 | 0.596685 | 0.414957 | 0.232935 | 0.718172 | 0.577676 |
143
+ | chopt-research-1_3b | 0.232 | 0.564815 | 0.59116 | 0.424716 | 0.276451 | 0.713275 | 0.634557 |
144
+ | chopt-1_3b | 0.236 | 0.569444 | 0.584057 | 0.42621 | 0.268771 | 0.723069 | 0.658104 |
145
+ | opt-2.7b | 0.25 | 0.608165 | 0.608524 | 0.458176 | 0.267918 | 0.738303 | 0.603058 |
146
+ | chopt-2_7b | 0.276 | 0.616582 | 0.601421 | 0.472615 | 0.288396 | 0.75136 | 0.552294 |
147
+ | chopt-research-2_7b | 0.262 | 0.610269 | 0.625099 | 0.458176 | 0.295222 | 0.742111 | 0.636697 |