mooshiponz commited on
Commit
0c9efb6
·
verified ·
1 Parent(s): 5a2d80c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +232 -21
README.md CHANGED
@@ -1,22 +1,233 @@
1
- ---
2
- base_model: unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit
3
- tags:
4
- - text-generation-inference
5
- - transformers
6
- - unsloth
7
- - llama
8
- - trl
9
- license: apache-2.0
10
- language:
11
- - en
12
- ---
 
 
 
 
13
 
14
- # Uploaded model
15
-
16
- - **Developed by:** mooshiponz
17
- - **License:** apache-2.0
18
- - **Finetuned from model :** unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit
19
-
20
- This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
21
-
22
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Key to config.json file.
3
+ */
4
+ key: string;
5
+ etag: string;
6
+ lastModified: Date;
7
+ size: number;
8
+ modelId: ModelId;
9
+ author?: AuthorId;
10
+ siblings: IS3ObjectWRelativeFilename[];
11
+ config: Obj;
12
+ configTxt?: string; /// if flag is set when fetching.
13
+ downloads?: number; /// if flag is set when fetching.
14
+ naturalIdx: number;
15
+ cardSource?: Source;
16
+ cardData?: Obj;
17
 
18
+ constructor(o: Partial<ModelInfo>) {
19
+ return Object.assign(this, o);
20
+ }
21
+
22
+ get jsonUrl(): string {
23
+ return Bucket.R.models.urlForKey(this.key);
24
+ }
25
+
26
+ get cdnJsonUrl(): string {
27
+ return Bucket.R.models.cdnUrlForKey(this.key);
28
+ }
29
+
30
+ async validate(): Promise<Ajv.ErrorObject[] | undefined> {
31
+ const jsonSchema = JSON.parse(
32
+ await fs.promises.readFile(CONFIG_JSON_SCHEMA, 'utf8')
33
+ );
34
+ const ajv = new Ajv();
35
+ ajv.validate(jsonSchema, this.config);
36
+ return ajv.errors ?? undefined;
37
+ }
38
+
39
+ /**
40
+ * Readme key, w. and w/o S3 prefix.
41
+ */
42
+ get readmeKey(): string {
43
+ return this.key.replace("config.json", "README.md");
44
+ }
45
+ get readmeTrimmedKey(): string {
46
+ return Utils.trimPrefix(this.readmeKey, S3_MODELS_PREFIX);
47
+ }
48
+
49
+ /**
50
+ * ["pytorch", "tf", ...]
51
+ */
52
+ get mlFrameworks(): string[] {
53
+ return Object.keys(FileType).filter(k => {
54
+ const filename = FileType[k];
55
+ const isExtension = filename.startsWith(".");
56
+ return isExtension
57
+ ? this.siblings.some(sibling => sibling.rfilename.endsWith(filename))
58
+ : this.siblings.some(sibling => sibling.rfilename === filename);
59
+ });
60
+ }
61
+ /**
62
+ * What to display in the code sample.
63
+ */
64
+ get autoArchitecture(): string {
65
+ const useTF = this.mlFrameworks.includes("tf") && ! this.mlFrameworks.includes("pytorch");
66
+ const arch = this.autoArchType[0];
67
+ return useTF ? `TF${arch}` : arch;
68
+ }
69
+ get autoArchType(): [string, string | undefined] {
70
+ const architectures = this.config.architectures;
71
+ if (!architectures || architectures.length === 0) {
72
+ return ["AutoModel", undefined];
73
+ }
74
+ const architecture = architectures[0].toString() as string;
75
+ if (architecture.endsWith("ForQuestionAnswering")) {
76
+ return ["AutoModelForQuestionAnswering", "question-answering"];
77
+ }
78
+ else if (architecture.endsWith("ForTokenClassification")) {
79
+ return ["AutoModelForTokenClassification", "token-classification"];
80
+ }
81
+ else if (architecture.endsWith("ForSequenceClassification")) {
82
+ return ["AutoModelForSequenceClassification", "text-classification"];
83
+ }
84
+ else if (architecture.endsWith("ForMultipleChoice")) {
85
+ return ["AutoModelForMultipleChoice", "multiple-choice"];
86
+ }
87
+ else if (architecture.endsWith("ForPreTraining")) {
88
+ return ["AutoModelForPreTraining", "pretraining"];
89
+ }
90
+ else if (architecture.endsWith("ForMaskedLM")) {
91
+ return ["AutoModelForMaskedLM", "masked-lm"];
92
+ }
93
+ else if (architecture.endsWith("ForCausalLM")) {
94
+ return ["AutoModelForCausalLM", "causal-lm"];
95
+ }
96
+ else if (
97
+ architecture.endsWith("ForConditionalGeneration")
98
+ || architecture.endsWith("MTModel")
99
+ || architecture == "EncoderDecoderModel"
100
+ ) {
101
+ return ["AutoModelForSeq2SeqLM", "seq2seq"];
102
+ }
103
+ else if (architecture.includes("LMHead")) {
104
+ return ["AutoModelWithLMHead", "lm-head"];
105
+ }
106
+ else if (architecture.endsWith("Model")) {
107
+ return ["AutoModel", undefined];
108
+ }
109
+ else {
110
+ return [architecture, undefined];
111
+ }
112
+ }
113
+ /**
114
+ * All tags
115
+ */
116
+ get tags(): string[] {
117
+ const x = [
118
+ ...this.mlFrameworks,
119
+ ];
120
+ if (this.config.model_type) {
121
+ x.push(this.config.model_type);
122
+ }
123
+ const arch = this.autoArchType[1];
124
+ if (arch) {
125
+ x.push(arch);
126
+ }
127
+ if (arch === "lm-head" && this.config.model_type) {
128
+ if ([
129
+ "t5",
130
+ "bart",
131
+ "marian",
132
+ ].includes(this.config.model_type)) {
133
+ x.push("seq2seq");
134
+ }
135
+ else if ([
136
+ "gpt2",
137
+ "ctrl",
138
+ "openai-gpt",
139
+ "xlnet",
140
+ "transfo-xl",
141
+ "reformer",
142
+ ].includes(this.config.model_type)) {
143
+ x.push("causal-lm");
144
+ }
145
+ else {
146
+ x.push("masked-lm");
147
+ }
148
+ }
149
+ x.push(
150
+ ...this.languages() ?? []
151
+ );
152
+ x.push(
153
+ ...this.datasets().map(k => `dataset:${k}`)
154
+ );
155
+ for (let [k, v] of Object.entries(this.cardData ?? {})) {
156
+ if (!['tags', 'license'].includes(k)) {
157
+ /// ^^ whitelist of other accepted keys
158
+ continue;
159
+ }
160
+ if (typeof v === 'string') {
161
+ v = [ v ];
162
+ } else if (Utils.isStrArray(v)) {
163
+ /// ok
164
+ } else {
165
+ c.error(`Invalid ${k} tag type`, v);
166
+ c.debug(this.modelId);
167
+ continue;
168
+ }
169
+ if (k === 'license') {
170
+ x.push(...v.map(x => `license:${x.toLowerCase()}`));
171
+ } else {
172
+ x.push(...v);
173
+ }
174
+ }
175
+ if (this.config.task_specific_params) {
176
+ const keys = Object.keys(this.config.task_specific_params);
177
+ for (const key of keys) {
178
+ x.push(`pipeline:${key}`);
179
+ }
180
+ }
181
+ const explicit_ptag = this.cardData?.pipeline_tag;
182
+ if (explicit_ptag) {
183
+ if (typeof explicit_ptag === 'string') {
184
+ x.push(`pipeline_tag:${explicit_ptag}`);
185
+ } else {
186
+ x.push(`pipeline_tag:invalid`);
187
+ }
188
+ }
189
+ return [...new Set(x)];
190
+ }
191
+
192
+ get pipeline_tag(): (keyof typeof PipelineType) | undefined {
193
+ if (isBlacklisted(this.modelId) || this.cardData?.inference === false) {
194
+ return undefined;
195
+ }
196
+
197
+ const explicit_ptag = this.cardData?.pipeline_tag;
198
+ if (explicit_ptag) {
199
+ if (typeof explicit_ptag == 'string') {
200
+ return explicit_ptag as keyof typeof PipelineType;
201
+ } else {
202
+ c.error(`Invalid explicit pipeline_tag`, explicit_ptag);
203
+ return undefined;
204
+ }
205
+ }
206
+
207
+ const tags = this.tags;
208
+ /// Special case for translation
209
+ /// Get the first of the explicit tags that matches.
210
+ const EXPLICIT_PREFIX = "pipeline:";
211
+ const explicit_tag = tags.find(x => x.startsWith(EXPLICIT_PREFIX + `translation`));
212
+ if (!!explicit_tag) {
213
+ return "translation";
214
+ }
215
+ /// Otherwise, get the first (most specific) match **from the mapping**.
216
+ for (const ptag of ALL_PIPELINE_TYPES) {
217
+ if (tags.includes(ptag)) {
218
+ return ptag;
219
+ }
220
+ }
221
+ /// Extra mapping
222
+ const mapping = new Map<string, keyof typeof PipelineType>([
223
+ ["seq2seq", "text-generation"],
224
+ ["causal-lm", "text-generation"],
225
+ ["masked-lm", "fill-mask"],
226
+ ]);
227
+ for (const [tag, ptag] of mapping) {
228
+ if (tags.includes(tag)) {
229
+ return ptag;
230
+ }
231
+ }
232
+ }
233
+ }