├── .gitignore
├── DATA_LICENSE
├── LICENSE
├── README.md
├── alpaca_data.json
├── assets
├── alpaca_main.jpg
├── alpaca_right_email.png
├── alpaca_right_llama.png
├── alpaca_wrong_42.png
├── alpaca_wrong_capital.png
├── logo.png
└── parse_analysis.png
├── cog.yaml
├── datasheet.md
├── generate_instruction.py
├── model_card.md
├── predict.py
├── prompt.txt
├── requirements.txt
├── seed_tasks.jsonl
├── train.py
├── train_model.sh
└── utils.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
131 | .DS_Store
132 | .idea
133 |
--------------------------------------------------------------------------------
/DATA_LICENSE:
--------------------------------------------------------------------------------
1 | Attribution-NonCommercial 4.0 International
2 |
3 | =======================================================================
4 |
5 | Creative Commons Corporation ("Creative Commons") is not a law firm and
6 | does not provide legal services or legal advice. Distribution of
7 | Creative Commons public licenses does not create a lawyer-client or
8 | other relationship. Creative Commons makes its licenses and related
9 | information available on an "as-is" basis. Creative Commons gives no
10 | warranties regarding its licenses, any material licensed under their
11 | terms and conditions, or any related information. Creative Commons
12 | disclaims all liability for damages resulting from their use to the
13 | fullest extent possible.
14 |
15 | Using Creative Commons Public Licenses
16 |
17 | Creative Commons public licenses provide a standard set of terms and
18 | conditions that creators and other rights holders may use to share
19 | original works of authorship and other material subject to copyright
20 | and certain other rights specified in the public license below. The
21 | following considerations are for informational purposes only, are not
22 | exhaustive, and do not form part of our licenses.
23 |
24 | Considerations for licensors: Our public licenses are
25 | intended for use by those authorized to give the public
26 | permission to use material in ways otherwise restricted by
27 | copyright and certain other rights. Our licenses are
28 | irrevocable. Licensors should read and understand the terms
29 | and conditions of the license they choose before applying it.
30 | Licensors should also secure all rights necessary before
31 | applying our licenses so that the public can reuse the
32 | material as expected. Licensors should clearly mark any
33 | material not subject to the license. This includes other CC-
34 | licensed material, or material used under an exception or
35 | limitation to copyright. More considerations for licensors:
36 | wiki.creativecommons.org/Considerations_for_licensors
37 |
38 | Considerations for the public: By using one of our public
39 | licenses, a licensor grants the public permission to use the
40 | licensed material under specified terms and conditions. If
41 | the licensor's permission is not necessary for any reason--for
42 | example, because of any applicable exception or limitation to
43 | copyright--then that use is not regulated by the license. Our
44 | licenses grant only permissions under copyright and certain
45 | other rights that a licensor has authority to grant. Use of
46 | the licensed material may still be restricted for other
47 | reasons, including because others have copyright or other
48 | rights in the material. A licensor may make special requests,
49 | such as asking that all changes be marked or described.
50 | Although not required by our licenses, you are encouraged to
51 | respect those requests where reasonable. More considerations
52 | for the public:
53 | wiki.creativecommons.org/Considerations_for_licensees
54 |
55 | =======================================================================
56 |
57 | Creative Commons Attribution-NonCommercial 4.0 International Public
58 | License
59 |
60 | By exercising the Licensed Rights (defined below), You accept and agree
61 | to be bound by the terms and conditions of this Creative Commons
62 | Attribution-NonCommercial 4.0 International Public License ("Public
63 | License"). To the extent this Public License may be interpreted as a
64 | contract, You are granted the Licensed Rights in consideration of Your
65 | acceptance of these terms and conditions, and the Licensor grants You
66 | such rights in consideration of benefits the Licensor receives from
67 | making the Licensed Material available under these terms and
68 | conditions.
69 |
70 |
71 | Section 1 -- Definitions.
72 |
73 | a. Adapted Material means material subject to Copyright and Similar
74 | Rights that is derived from or based upon the Licensed Material
75 | and in which the Licensed Material is translated, altered,
76 | arranged, transformed, or otherwise modified in a manner requiring
77 | permission under the Copyright and Similar Rights held by the
78 | Licensor. For purposes of this Public License, where the Licensed
79 | Material is a musical work, performance, or sound recording,
80 | Adapted Material is always produced where the Licensed Material is
81 | synched in timed relation with a moving image.
82 |
83 | b. Adapter's License means the license You apply to Your Copyright
84 | and Similar Rights in Your contributions to Adapted Material in
85 | accordance with the terms and conditions of this Public License.
86 |
87 | c. Copyright and Similar Rights means copyright and/or similar rights
88 | closely related to copyright including, without limitation,
89 | performance, broadcast, sound recording, and Sui Generis Database
90 | Rights, without regard to how the rights are labeled or
91 | categorized. For purposes of this Public License, the rights
92 | specified in Section 2(b)(1)-(2) are not Copyright and Similar
93 | Rights.
94 | d. Effective Technological Measures means those measures that, in the
95 | absence of proper authority, may not be circumvented under laws
96 | fulfilling obligations under Article 11 of the WIPO Copyright
97 | Treaty adopted on December 20, 1996, and/or similar international
98 | agreements.
99 |
100 | e. Exceptions and Limitations means fair use, fair dealing, and/or
101 | any other exception or limitation to Copyright and Similar Rights
102 | that applies to Your use of the Licensed Material.
103 |
104 | f. Licensed Material means the artistic or literary work, database,
105 | or other material to which the Licensor applied this Public
106 | License.
107 |
108 | g. Licensed Rights means the rights granted to You subject to the
109 | terms and conditions of this Public License, which are limited to
110 | all Copyright and Similar Rights that apply to Your use of the
111 | Licensed Material and that the Licensor has authority to license.
112 |
113 | h. Licensor means the individual(s) or entity(ies) granting rights
114 | under this Public License.
115 |
116 | i. NonCommercial means not primarily intended for or directed towards
117 | commercial advantage or monetary compensation. For purposes of
118 | this Public License, the exchange of the Licensed Material for
119 | other material subject to Copyright and Similar Rights by digital
120 | file-sharing or similar means is NonCommercial provided there is
121 | no payment of monetary compensation in connection with the
122 | exchange.
123 |
124 | j. Share means to provide material to the public by any means or
125 | process that requires permission under the Licensed Rights, such
126 | as reproduction, public display, public performance, distribution,
127 | dissemination, communication, or importation, and to make material
128 | available to the public including in ways that members of the
129 | public may access the material from a place and at a time
130 | individually chosen by them.
131 |
132 | k. Sui Generis Database Rights means rights other than copyright
133 | resulting from Directive 96/9/EC of the European Parliament and of
134 | the Council of 11 March 1996 on the legal protection of databases,
135 | as amended and/or succeeded, as well as other essentially
136 | equivalent rights anywhere in the world.
137 |
138 | l. You means the individual or entity exercising the Licensed Rights
139 | under this Public License. Your has a corresponding meaning.
140 |
141 |
142 | Section 2 -- Scope.
143 |
144 | a. License grant.
145 |
146 | 1. Subject to the terms and conditions of this Public License,
147 | the Licensor hereby grants You a worldwide, royalty-free,
148 | non-sublicensable, non-exclusive, irrevocable license to
149 | exercise the Licensed Rights in the Licensed Material to:
150 |
151 | a. reproduce and Share the Licensed Material, in whole or
152 | in part, for NonCommercial purposes only; and
153 |
154 | b. produce, reproduce, and Share Adapted Material for
155 | NonCommercial purposes only.
156 |
157 | 2. Exceptions and Limitations. For the avoidance of doubt, where
158 | Exceptions and Limitations apply to Your use, this Public
159 | License does not apply, and You do not need to comply with
160 | its terms and conditions.
161 |
162 | 3. Term. The term of this Public License is specified in Section
163 | 6(a).
164 |
165 | 4. Media and formats; technical modifications allowed. The
166 | Licensor authorizes You to exercise the Licensed Rights in
167 | all media and formats whether now known or hereafter created,
168 | and to make technical modifications necessary to do so. The
169 | Licensor waives and/or agrees not to assert any right or
170 | authority to forbid You from making technical modifications
171 | necessary to exercise the Licensed Rights, including
172 | technical modifications necessary to circumvent Effective
173 | Technological Measures. For purposes of this Public License,
174 | simply making modifications authorized by this Section 2(a)
175 | (4) never produces Adapted Material.
176 |
177 | 5. Downstream recipients.
178 |
179 | a. Offer from the Licensor -- Licensed Material. Every
180 | recipient of the Licensed Material automatically
181 | receives an offer from the Licensor to exercise the
182 | Licensed Rights under the terms and conditions of this
183 | Public License.
184 |
185 | b. No downstream restrictions. You may not offer or impose
186 | any additional or different terms or conditions on, or
187 | apply any Effective Technological Measures to, the
188 | Licensed Material if doing so restricts exercise of the
189 | Licensed Rights by any recipient of the Licensed
190 | Material.
191 |
192 | 6. No endorsement. Nothing in this Public License constitutes or
193 | may be construed as permission to assert or imply that You
194 | are, or that Your use of the Licensed Material is, connected
195 | with, or sponsored, endorsed, or granted official status by,
196 | the Licensor or others designated to receive attribution as
197 | provided in Section 3(a)(1)(A)(i).
198 |
199 | b. Other rights.
200 |
201 | 1. Moral rights, such as the right of integrity, are not
202 | licensed under this Public License, nor are publicity,
203 | privacy, and/or other similar personality rights; however, to
204 | the extent possible, the Licensor waives and/or agrees not to
205 | assert any such rights held by the Licensor to the limited
206 | extent necessary to allow You to exercise the Licensed
207 | Rights, but not otherwise.
208 |
209 | 2. Patent and trademark rights are not licensed under this
210 | Public License.
211 |
212 | 3. To the extent possible, the Licensor waives any right to
213 | collect royalties from You for the exercise of the Licensed
214 | Rights, whether directly or through a collecting society
215 | under any voluntary or waivable statutory or compulsory
216 | licensing scheme. In all other cases the Licensor expressly
217 | reserves any right to collect such royalties, including when
218 | the Licensed Material is used other than for NonCommercial
219 | purposes.
220 |
221 |
222 | Section 3 -- License Conditions.
223 |
224 | Your exercise of the Licensed Rights is expressly made subject to the
225 | following conditions.
226 |
227 | a. Attribution.
228 |
229 | 1. If You Share the Licensed Material (including in modified
230 | form), You must:
231 |
232 | a. retain the following if it is supplied by the Licensor
233 | with the Licensed Material:
234 |
235 | i. identification of the creator(s) of the Licensed
236 | Material and any others designated to receive
237 | attribution, in any reasonable manner requested by
238 | the Licensor (including by pseudonym if
239 | designated);
240 |
241 | ii. a copyright notice;
242 |
243 | iii. a notice that refers to this Public License;
244 |
245 | iv. a notice that refers to the disclaimer of
246 | warranties;
247 |
248 | v. a URI or hyperlink to the Licensed Material to the
249 | extent reasonably practicable;
250 |
251 | b. indicate if You modified the Licensed Material and
252 | retain an indication of any previous modifications; and
253 |
254 | c. indicate the Licensed Material is licensed under this
255 | Public License, and include the text of, or the URI or
256 | hyperlink to, this Public License.
257 |
258 | 2. You may satisfy the conditions in Section 3(a)(1) in any
259 | reasonable manner based on the medium, means, and context in
260 | which You Share the Licensed Material. For example, it may be
261 | reasonable to satisfy the conditions by providing a URI or
262 | hyperlink to a resource that includes the required
263 | information.
264 |
265 | 3. If requested by the Licensor, You must remove any of the
266 | information required by Section 3(a)(1)(A) to the extent
267 | reasonably practicable.
268 |
269 | 4. If You Share Adapted Material You produce, the Adapter's
270 | License You apply must not prevent recipients of the Adapted
271 | Material from complying with this Public License.
272 |
273 |
274 | Section 4 -- Sui Generis Database Rights.
275 |
276 | Where the Licensed Rights include Sui Generis Database Rights that
277 | apply to Your use of the Licensed Material:
278 |
279 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right
280 | to extract, reuse, reproduce, and Share all or a substantial
281 | portion of the contents of the database for NonCommercial purposes
282 | only;
283 |
284 | b. if You include all or a substantial portion of the database
285 | contents in a database in which You have Sui Generis Database
286 | Rights, then the database in which You have Sui Generis Database
287 | Rights (but not its individual contents) is Adapted Material; and
288 |
289 | c. You must comply with the conditions in Section 3(a) if You Share
290 | all or a substantial portion of the contents of the database.
291 |
292 | For the avoidance of doubt, this Section 4 supplements and does not
293 | replace Your obligations under this Public License where the Licensed
294 | Rights include other Copyright and Similar Rights.
295 |
296 |
297 | Section 5 -- Disclaimer of Warranties and Limitation of Liability.
298 |
299 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
300 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
301 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
302 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
303 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
304 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
305 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
306 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
307 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
308 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
309 |
310 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
311 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
312 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
313 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
314 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
315 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
316 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
317 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
318 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
319 |
320 | c. The disclaimer of warranties and limitation of liability provided
321 | above shall be interpreted in a manner that, to the extent
322 | possible, most closely approximates an absolute disclaimer and
323 | waiver of all liability.
324 |
325 |
326 | Section 6 -- Term and Termination.
327 |
328 | a. This Public License applies for the term of the Copyright and
329 | Similar Rights licensed here. However, if You fail to comply with
330 | this Public License, then Your rights under this Public License
331 | terminate automatically.
332 |
333 | b. Where Your right to use the Licensed Material has terminated under
334 | Section 6(a), it reinstates:
335 |
336 | 1. automatically as of the date the violation is cured, provided
337 | it is cured within 30 days of Your discovery of the
338 | violation; or
339 |
340 | 2. upon express reinstatement by the Licensor.
341 |
342 | For the avoidance of doubt, this Section 6(b) does not affect any
343 | right the Licensor may have to seek remedies for Your violations
344 | of this Public License.
345 |
346 | c. For the avoidance of doubt, the Licensor may also offer the
347 | Licensed Material under separate terms or conditions or stop
348 | distributing the Licensed Material at any time; however, doing so
349 | will not terminate this Public License.
350 |
351 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
352 | License.
353 |
354 |
355 | Section 7 -- Other Terms and Conditions.
356 |
357 | a. The Licensor shall not be bound by any additional or different
358 | terms or conditions communicated by You unless expressly agreed.
359 |
360 | b. Any arrangements, understandings, or agreements regarding the
361 | Licensed Material not stated herein are separate from and
362 | independent of the terms and conditions of this Public License.
363 |
364 |
365 | Section 8 -- Interpretation.
366 |
367 | a. For the avoidance of doubt, this Public License does not, and
368 | shall not be interpreted to, reduce, limit, restrict, or impose
369 | conditions on any use of the Licensed Material that could lawfully
370 | be made without permission under this Public License.
371 |
372 | b. To the extent possible, if any provision of this Public License is
373 | deemed unenforceable, it shall be automatically reformed to the
374 | minimum extent necessary to make it enforceable. If the provision
375 | cannot be reformed, it shall be severed from this Public License
376 | without affecting the enforceability of the remaining terms and
377 | conditions.
378 |
379 | c. No term or condition of this Public License will be waived and no
380 | failure to comply consented to unless expressly agreed to by the
381 | Licensor.
382 |
383 | d. Nothing in this Public License constitutes or may be interpreted
384 | as a limitation upon, or waiver of, any privileges and immunities
385 | that apply to the Licensor or You, including from the legal
386 | processes of any jurisdiction or authority.
387 |
388 | =======================================================================
389 |
390 | Creative Commons is not a party to its public
391 | licenses. Notwithstanding, Creative Commons may elect to apply one of
392 | its public licenses to material it publishes and in those instances
393 | will be considered the “Licensor.” The text of the Creative Commons
394 | public licenses is dedicated to the public domain under the CC0 Public
395 | Domain Dedication. Except for the limited purpose of indicating that
396 | material is shared under a Creative Commons public license or as
397 | otherwise permitted by the Creative Commons policies published at
398 | creativecommons.org/policies, Creative Commons does not authorize the
399 | use of the trademark "Creative Commons" or any other trademark or logo
400 | of Creative Commons without its prior written consent including,
401 | without limitation, in connection with any unauthorized modifications
402 | to any of its public licenses or any other arrangements,
403 | understandings, or agreements concerning use of licensed material. For
404 | the avoidance of doubt, this paragraph does not form part of the
405 | public licenses.
406 |
407 | Creative Commons may be contacted at creativecommons.org.
408 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | # Stanford Alpaca: An Instruction-following LLaMA Model
7 | [](https://github.com/tatsu-lab/stanford_alpaca/blob/main/LICENSE)
8 | [](https://www.python.org/downloads/release/python-390/)
9 | [](https://github.com/psf/black)
10 |
11 | This is the repo for the Stanford Alpaca project, which aims to build and share an instruction-following LLaMA model. The repo contains:
12 | - A [**web demo**](https://crfm.stanford.edu/alpaca/) to interact with our Alpaca model
13 | - The [52K data](#data-release) used for fine-tuning the model
14 | - The code for [generating the data](#data-generation-process)
15 |
16 | ## Overview
17 |
18 | The current Alpaca model is fine-tuned from a 7B LLaMA model [1] on 52K instruction-following data generated by the techniques in the Self-Instruct [2] paper, with some modifications that we discuss in the next section.
19 | In a preliminary human evaluation, we found that the Alpaca 7B model behaves similarly to the `text-davinci-003` model on the Self-Instruct instruction-following evaluation suite [2].
20 |
21 | Alpaca is still under development, and there are many limitations that have to be addressed.
22 | Importantly, we have not yet fine-tuned the Alpaca model to be safe and harmless.
23 | We thus encourage users to be cautious when interacting with Alpaca, and to report any concerning behavior to help improve the safety and ethical considerations of the model.
24 |
25 | Our initial release contains the data generation procedure, dataset, and training recipe. We intend to release the model weights if we are given permission to do so by the creators of LLaMA. For now, we have chosen to host a live demo to help readers better understand the capabilities and limits of Alpaca, as well as a way to help us better evaluate Alpaca's performance on a broader audience.
26 |
27 | **Please read our release [blog post](https://crfm.stanford.edu/2023/03/13/alpaca.html) for more details about the model, our discussion of the potential harm and limitations of Alpaca models, and our thought process for releasing a reproducible model.**
28 |
29 |
30 | [1]: LLaMA: Open and Efficient Foundation Language Models. Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, Guillaume Lample. https://arxiv.org/abs/2302.13971v1
31 |
32 | [2]: Self-Instruct: Aligning Language Model with Self Generated Instructions. Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A. Smith, Daniel Khashabi, Hannaneh Hajishirzi. https://arxiv.org/abs/2212.10560
33 |
34 |
35 | ## Data Release
36 | [`alpaca_data.json`](./alpaca_data.json) contains 52K instruction-following data we used for fine-tuning the Alpaca model.
37 | This JSON file is a list of dictionaries, each dictionary contains the following fields:
38 | - `instruction`: `str`, describes the task the model should perform. Each of the 52K instructions is unique.
39 | - `input`: `str`, optional context or input for the task. For example, when the instruction is "Summarize the following article", the input is the article. Around 40% of the examples have an input.
40 | - `output`: `str`, the answer to the instruction as generated by `text-davinci-003`.
41 |
42 | We used the following prompts for fine-tuning the Alpaca model:
43 | - for examples with a non-empty input field:
44 | ```
45 | Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
46 |
47 | ### Instruction:
48 | {instruction}
49 |
50 | ### Input:
51 | {input}
52 |
53 | ### Response:
54 | ```
55 | - for examples with an empty input field:
56 | ```
57 | Below is an instruction that describes a task. Write a response that appropriately completes the request.
58 |
59 | ### Instruction:
60 | {instruction}
61 |
62 | ### Response:
63 | ```
64 |
65 | During inference (eg for the web demo), we use the user instruction with an empty input field (second option).
66 |
67 | ## Data Generation Process
68 |
69 |
70 | Running the code
71 |
72 | 1. Set environment variables `OPENAI_API_KEY` to your OpenAI API key.
73 | 2. Install the dependencies with `pip install -r requirements.txt`.
74 | 3. Run `python -m generate_instruction generate_instruction_following_data` to generate the data.
75 |
76 |
77 |
78 | We built on the data generation pipeline from [self-instruct](https://github.com/yizhongw/self-instruct) and made the following modifications:
79 | - We used `text-davinci-003` to generate the instruction data instead of `davinci`.
80 | - We wrote a new prompt (`prompt.txt`) that explicitly gave the requirement of instruction generation to `text-davinci-003`. Note: there is a slight error in the prompt we used, and future users should incorporate the edit in https://github.com/tatsu-lab/stanford_alpaca/pull/24
81 | - We adopted much more aggressive batch decoding, i.e., generating 20 instructions at once, which significantly reduced the cost of data generation.
82 | - We simplified the data generation pipeline by discarding the difference between classification and non-classification instructions.
83 | - We only generated a single instance for each instruction, instead of 2 to 3 instances as in [1].
84 |
85 | This produced an instruction-following dataset with 52K examples obtained at a much lower cost (less than $500).
86 | In a preliminary study, we also find our 52K generated data to be much more diverse than the data released by [self-instruct](https://github.com/yizhongw/self-instruct/blob/main/data/seed_tasks.jsonl).
87 | We plot the below figure (in the style of Figure 2 in the [self-instruct paper](https://arxiv.org/abs/2212.10560) to demonstrate the diversity of our data.
88 | The inner circle of the plot represents the root verb of the instructions, and the outer circle represents the direct objects.
89 |
90 | [//]: # ()
91 | [
](./assets/parse_analysis.png)
92 |
93 | ## Fine-tuning
94 | We fine-tune our models using standard Hugging Face training code with the following hyperparameters:
95 |
96 | | Hyperparameter | Value |
97 | |----------------|-------|
98 | | Batch size | 128 |
99 | | Learning rate | 2e-5 |
100 | | Epochs | 3 |
101 | | Max length | 512 |
102 | | Weight decay | 0 |
103 |
104 | Given Hugging Face hasn't officially supported the LLaMA models, we fine-tuned LLaMA with Hugging Face's transformers library by installing it from a particular fork (i.e. this [PR](https://github.com/huggingface/transformers/pull/21955) to be merged).
105 | The hash of the specific commit we installed was `68d640f7c368bcaaaecfc678f11908ebbd3d6176`.
106 |
107 | To reproduce our fine-tuning runs for LLaMA, first install the requirements
108 | ```bash
109 | pip install -r requirements.txt
110 | ```
111 | Then, install the particular fork of Hugging Face's transformers library.
112 |
113 | Below is a command that fine-tunes LLaMA-7B with our dataset on a machine with 4 A100 80G GPUs in FSDP `full_shard` mode.
114 | We were able to reproduce a model of similar quality as the one we hosted in our demo with the following command using **Python 3.10**.
115 | Replace `` with a port of your own, `` with the
116 | path to your converted checkpoint and tokenizer (following instructions in the PR), and `` with where you want to store your outputs.
117 |
118 | ```bash
119 | torchrun --nproc_per_node=4 --master_port= train.py \
120 | --model_name_or_path \
121 | --data_path ./alpaca_data.json \
122 | --bf16 True \
123 | --output_dir \
124 | --num_train_epochs 3 \
125 | --per_device_train_batch_size 4 \
126 | --per_device_eval_batch_size 4 \
127 | --gradient_accumulation_steps 8 \
128 | --evaluation_strategy "no" \
129 | --save_strategy "steps" \
130 | --save_steps 2000 \
131 | --save_total_limit 1 \
132 | --learning_rate 2e-5 \
133 | --weight_decay 0. \
134 | --warmup_ratio 0.03 \
135 | --lr_scheduler_type "cosine" \
136 | --logging_steps 1 \
137 | --fsdp "full_shard auto_wrap" \
138 | --fsdp_transformer_layer_cls_to_wrap 'LLaMADecoderLayer' \
139 | --tf32 True
140 | ```
141 |
142 | The same script also works for OPT fine-tuning. Here's an example for fine-tuning OPT-6.7B
143 |
144 | ```bash
145 | torchrun --nproc_per_node=4 --master_port= train.py \
146 | --model_name_or_path "facebook/opt-6.7b" \
147 | --data_path ./alpaca_data.json \
148 | --bf16 True \
149 | --output_dir \
150 | --num_train_epochs 3 \
151 | --per_device_train_batch_size 4 \
152 | --per_device_eval_batch_size 4 \
153 | --gradient_accumulation_steps 8 \
154 | --evaluation_strategy "no" \
155 | --save_strategy "steps" \
156 | --save_steps 2000 \
157 | --save_total_limit 1 \
158 | --learning_rate 2e-5 \
159 | --weight_decay 0. \
160 | --warmup_ratio 0.03 \
161 | --lr_scheduler_type "cosine" \
162 | --logging_steps 1 \
163 | --fsdp "full_shard auto_wrap" \
164 | --fsdp_transformer_layer_cls_to_wrap 'OPTDecoderLayer' \
165 | --tf32 True
166 | ```
167 |
168 | Note the given training script is meant to be simple and easy to use, and is not particularly optimized.
169 | To run on more gpus, you may prefer to turn down `gradient_accumulation_steps` to keep a global batch size of 128. Global batch size has not been tested for optimality.
170 |
171 | ### Authors
172 | All grad students below contributed equally and the order is determined by random draw.
173 |
174 | - [Rohan Taori](https://www.rohantaori.com/)
175 | - [Ishaan Gulrajani](https://ishaan.io/)
176 | - [Tianyi Zhang](https://tiiiger.github.io/)
177 | - [Yann Dubois](https://yanndubs.github.io/)
178 | - [Xuechen Li](https://www.lxuechen.com/)
179 |
180 | All advised by [Tatsunori B. Hashimoto](https://thashim.github.io/). Yann is also advised by [Percy Liang](https://cs.stanford.edu/~pliang/) and Xuechen is also advised by [Carlos Guestrin](https://guestrin.su.domains/).
181 |
182 | ### Citation
183 |
184 | Please cite the repo if you use the data or code in this repo.
185 | ```
186 | @misc{alpaca,
187 | author = {Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto },
188 | title = {Stanford Alpaca: An Instruction-following LLaMA model},
189 | year = {2023},
190 | publisher = {GitHub},
191 | journal = {GitHub repository},
192 | howpublished = {\url{https://github.com/tatsu-lab/stanford_alpaca}},
193 | }
194 | ```
195 |
196 | Naturally, you should also cite the original LLaMA paper [1] and the Self-Instruct paper [2].
197 |
198 | ### Acknowledgements
199 |
200 | We thank Yizhong Wang for his help in explaining the data generation pipeline in Self-Instruct and providing the code for the parse analysis plot.
201 | We thank Yifan Mai for helpful support, and members of the Stanford NLP Group as well as the Center for Research on Foundation Models (CRFM) for their helpful feedback.
202 |
--------------------------------------------------------------------------------
/assets/alpaca_main.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/replicate/cog_stanford_alpaca/d6d5bddd4f0f1764d47766351c7a82cf3baf02cf/assets/alpaca_main.jpg
--------------------------------------------------------------------------------
/assets/alpaca_right_email.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/replicate/cog_stanford_alpaca/d6d5bddd4f0f1764d47766351c7a82cf3baf02cf/assets/alpaca_right_email.png
--------------------------------------------------------------------------------
/assets/alpaca_right_llama.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/replicate/cog_stanford_alpaca/d6d5bddd4f0f1764d47766351c7a82cf3baf02cf/assets/alpaca_right_llama.png
--------------------------------------------------------------------------------
/assets/alpaca_wrong_42.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/replicate/cog_stanford_alpaca/d6d5bddd4f0f1764d47766351c7a82cf3baf02cf/assets/alpaca_wrong_42.png
--------------------------------------------------------------------------------
/assets/alpaca_wrong_capital.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/replicate/cog_stanford_alpaca/d6d5bddd4f0f1764d47766351c7a82cf3baf02cf/assets/alpaca_wrong_capital.png
--------------------------------------------------------------------------------
/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/replicate/cog_stanford_alpaca/d6d5bddd4f0f1764d47766351c7a82cf3baf02cf/assets/logo.png
--------------------------------------------------------------------------------
/assets/parse_analysis.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/replicate/cog_stanford_alpaca/d6d5bddd4f0f1764d47766351c7a82cf3baf02cf/assets/parse_analysis.png
--------------------------------------------------------------------------------
/cog.yaml:
--------------------------------------------------------------------------------
1 | # Configuration for Cog ⚙️
2 | # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md
3 |
4 | build:
5 | gpu: true
6 | python_version: "3.10"
7 | cuda: "11.6"
8 | python_packages:
9 | - "torch==1.13.1"
10 | - "sentencepiece==0.1.97"
11 | - "accelerate==0.16.0"
12 |
13 | run:
14 | - "pip install git+https://github.com/huggingface/transformers.git@c3dc391da81e6ed7efce42be06413725943b3920"
15 |
16 | predict: "predict.py:Predictor"
17 |
--------------------------------------------------------------------------------
/datasheet.md:
--------------------------------------------------------------------------------
1 | # Alpaca Instruction Following Dataset
2 |
3 | ## Motivation
4 | ### For what purpose was the dataset created?
5 | To enable more open-source research on instruction following large language models, we use generate 52K instruction-followng demonstrations using OpenAI's text-davinci-003 model.
6 |
7 | ### Who created the dataset
8 | - [Rohan Taori](https://www.rohantaori.com/)
9 | - [Ishaan Gulrajani](https://ishaan.io/)
10 | - [Tianyi Zhang](https://tiiiger.github.io/)
11 | - [Yann Dubois](https://yanndubs.github.io/)
12 | - [Xuechen Li](https://www.lxuechen.com/)
13 | - [Carlos Guestrin](https://guestrin.su.domains/)
14 | - [Percy Liang](https://cs.stanford.edu/~pliang/)
15 | - [Tatsunori B. Hashimoto](https://thashim.github.io/)
16 |
17 | ## Composition
18 |
19 | ### What do the instances that comprise the dataset represent (e.g., documents, photos, people, countries)?
20 | The instruction following demonstrations are bootstrapped by following the [seed set](https://github.com/yizhongw/self-instruct/blob/main/data/seed_tasks.jsonl) released from the self-instruct project.
21 | Given that the dataset is generated, it is difficult to pinpoint who/what the instances represent.
22 |
23 | ### How many instances are there in total
24 | In total, there are 52,002 instances in the dataset.
25 |
26 | ### Does the dataset contain all possible instances or is it a sample (not necessarily random) of instances from a larger set?
27 | not applicable.
28 |
29 | ### What data does each instance consist of?
30 |
31 | - `instruction`: `str`, describes the task the model should perform. Each of the 52K instructions is unique.
32 | - `input`: `str`, optional context or input for the task. For example, when the instruction is "Summarize the following article", the input is the article. Around 40% of the examples have an input.
33 | - `output`: `str`, the answer to the instruction as generated by `text-davinci-003`.
34 |
35 | ### Is any information missing from individual instances?
36 | no.
37 |
38 | ### Are relationships between individual instances made explicit (e.g., users’ movie ratings, social network links)?
39 | not applicable.
40 |
41 | ### Is there a label or target associated with each instance?
42 | the finetuning target is the response generated by `text-davinci-003`.
43 |
44 | ### Are there recommended data splits (e.g., training, development/validation, testing)?
45 | The Alpaca models (both demo and the ones that will be released) are trained on all 52K data.
46 | There is no recommended data split for the dataset.
47 |
48 | ### Are there any errors, sources of noise, or redundancies in the dataset?
49 | All 52k instructions are unique. However, some generated instructions may not be sensible, i.e., there may not exist any good response to the instruction.
50 |
51 | ### Is the dataset self-contained, or does it link to or otherwise rely on external resources (e.g., websites, tweets, other datasets)?
52 | the dataset is self-contained.
53 |
54 | ### Does the dataset contain data that might be considered confidential (e.g., data that is protected by legal privilege or by doctor-patient confidentiality, data that includes the content of individuals’ non-public communications)?
55 | no.
56 |
57 | ### Does the dataset contain data that, if viewed directly, might be offensive, insulting, threatening, or might otherwise cause anxiety?
58 | The generated may contain a few inappropriate responses. In our preliminary testing, we have not encountered any offensive responses.
59 |
60 | ## Collection process
61 | The [Github repository](https://github.com/tatsu-lab/stanford_alpaca) contains the code to generate the dataset.
62 |
63 | ## Uses
64 |
65 | ### Has the dataset been used for any tasks already?
66 | The dataset is used to train the Alpaca models that are both used for the demo and released.
67 |
68 | ### Is there a repository that links to any or all papers or systems that use the dataset?
69 | Please see https://github.com/tatsu-lab/stanford_alpaca
70 |
71 | ### Is there anything about the composition of the dataset or the way it was collected and preprocessed/cleaned/labeled that might impact future uses?
72 | This dataset is generated by using the OpenAI's API. Therefore, this dataset cannot be used for commerical usage that compete with OpenAI.
73 |
74 | ### Are there tasks for which the dataset should not be used?
75 | The dataset should not be used for commerical usage that compete with OpenAI.
76 |
77 | ## Distribution
78 | ### Will the dataset be distributed to third parties outside of the entity (e.g., company, institution, organization) on behalf of which the dataset was created?
79 | The dataset can be freely downloaded.
80 |
81 | ### How will the dataset will be distributed (e.g., tarball on website, API, GitHub)?
82 | The dataset can be downloaded from the [Github repository](https://github.com/tatsu-lab/stanford_alpaca) as a json file.
83 |
84 | ### Will the dataset be distributed under a copyright or other intellectual property (IP) license, and/or under applicable terms of use (ToU)?
85 | This dataset is distributed under [the ODC-By license](https://opendatacommons.org/licenses/by/1-0/).
86 |
87 | ### Have any third parties imposed IP-based or other restrictions on the data associated with the instances?
88 | no
89 |
90 | ### Do any export controls or other regulatory restrictions apply to the dataset or to individual instances?
91 | no
92 |
93 | ## Maintenance
94 |
95 | ### Who is supporting/hosting/maintaining the dataset?
96 | The dataset is hosted on github and the Github repository is maintained by Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li.
97 |
98 | ### How can the owner/curator/manager of the dataset be contacted (e.g., email address)?
99 | Please open an issue in the [Github repository](https://github.com/tatsu-lab/stanford_alpaca)
100 |
101 | ### Will the dataset be updated (e.g., to correct labeling errors, add new instances, delete instances)?
102 | We do not have plan to update the dataset.
--------------------------------------------------------------------------------
/generate_instruction.py:
--------------------------------------------------------------------------------
1 | """
2 | batch_selfinstruct_generate.py
3 |
4 | run:
5 | python -m generate_instruction generate_instruction_following_data \
6 | --output_dir ./ \
7 | --num_instructions_to_generate 10 \
8 | --model_name="text-davinci-003" \
9 | """
10 | import time
11 | import json
12 | import os
13 | import random
14 | import re
15 | import string
16 | from functools import partial
17 | from multiprocessing import Pool
18 |
19 | import numpy as np
20 | import tqdm
21 | from rouge_score import rouge_scorer
22 | import utils
23 |
24 | import fire
25 |
26 |
27 | def encode_prompt(prompt_instructions):
28 | """Encode multiple prompt instructions into a single string."""
29 | prompt = open("./prompt.txt").read() + "\n"
30 |
31 | for idx, task_dict in enumerate(prompt_instructions):
32 | (instruction, input, output) = task_dict["instruction"], task_dict["input"], task_dict["output"]
33 | instruction = re.sub(r"\s+", " ", instruction).strip().rstrip(":")
34 | input = "" if input.lower() == "" else input
35 | prompt += f"###\n"
36 | prompt += f"{idx + 1}. Instruction: {instruction}\n"
37 | prompt += f"{idx + 1}. Input:\n{input}\n"
38 | prompt += f"{idx + 1}. Output:\n{output}\n"
39 | prompt += f"###\n"
40 | prompt += f"{idx + 2}. Instruction:"
41 | return prompt
42 |
43 |
44 | def post_process_gpt3_response(num_prompt_instructions, response):
45 | if response is None:
46 | return []
47 | raw_instructions = f"{num_prompt_instructions+1}. Instruction:" + response["text"]
48 | raw_instructions = re.split("###", raw_instructions)
49 | instructions = []
50 | for idx, inst in enumerate(raw_instructions):
51 | # if the decoding stops due to length, the last example is likely truncated so we discard it
52 | if idx == len(raw_instructions) - 1 and response["finish_reason"] == "length":
53 | continue
54 | idx += num_prompt_instructions + 1
55 | splitted_data = re.split(f"{idx}\.\s+(Instruction|Input|Output):", inst)
56 | if len(splitted_data) != 7:
57 | continue
58 | else:
59 | inst = splitted_data[2].strip()
60 | input = splitted_data[4].strip()
61 | input = "" if input.lower() == "" else input
62 | output = splitted_data[6].strip()
63 | # filter out too short or too long instructions
64 | if len(inst.split()) <= 3 or len(inst.split()) > 150:
65 | continue
66 | # filter based on keywords that are not suitable for language models.
67 | blacklist = [
68 | "image",
69 | "images",
70 | "graph",
71 | "graphs",
72 | "picture",
73 | "pictures",
74 | "file",
75 | "files",
76 | "map",
77 | "maps",
78 | "draw",
79 | "plot",
80 | "go to",
81 | "video",
82 | "audio",
83 | "music",
84 | "flowchart",
85 | "diagram",
86 | ]
87 | blacklist += []
88 | if any(find_word_in_string(word, inst) for word in blacklist):
89 | continue
90 | # We found that the model tends to add "write a program" to some existing instructions, which lead to a lot of such instructions.
91 | # And it's a bit comfusing whether the model need to write a program or directly output the result.
92 | # Here we filter them out.
93 | # Note this is not a comprehensive filtering for all programming instructions.
94 | if inst.startswith("Write a program"):
95 | continue
96 | # filter those starting with punctuation
97 | if inst[0] in string.punctuation:
98 | continue
99 | # filter those starting with non-english character
100 | if not inst[0].isascii():
101 | continue
102 | instructions.append({"instruction": inst, "input": input, "output": output})
103 | return instructions
104 |
105 |
106 | def find_word_in_string(w, s):
107 | return re.compile(r"\b({0})\b".format(w), flags=re.IGNORECASE).search(s)
108 |
109 |
110 | def generate_instruction_following_data(
111 | output_dir="./",
112 | seed_tasks_path="./seed_tasks.jsonl",
113 | num_instructions_to_generate=100,
114 | model_name="text-davinci-003",
115 | num_prompt_instructions=3,
116 | request_batch_size=5,
117 | temperature=1.0,
118 | top_p=1.0,
119 | num_cpus=16,
120 | ):
121 | seed_tasks = [json.loads(l) for l in open(seed_tasks_path, "r")]
122 | seed_instruction_data = [
123 | {"instruction": t["instruction"], "input": t["instances"][0]["input"], "output": t["instances"][0]["output"]}
124 | for t in seed_tasks
125 | ]
126 | print(f"Loaded {len(seed_instruction_data)} human-written seed instructions")
127 |
128 | os.makedirs(output_dir, exist_ok=True)
129 | request_idx = 0
130 | # load the LM-generated instructions
131 | machine_instruction_data = []
132 | if os.path.exists(os.path.join(output_dir, "regen.json")):
133 | machine_instruction_data = utils.jload(os.path.join(output_dir, "regen.json"))
134 | print(f"Loaded {len(machine_instruction_data)} machine-generated instructions")
135 |
136 | # similarities = {}
137 | scorer = rouge_scorer.RougeScorer(["rougeL"], use_stemmer=False)
138 |
139 | # now let's generate new instructions!
140 | progress_bar = tqdm.tqdm(total=num_instructions_to_generate)
141 | if machine_instruction_data:
142 | progress_bar.update(len(machine_instruction_data))
143 |
144 | # first we tokenize all the seed instructions and generated machine instructions
145 | all_instructions = [d["instruction"] for d in seed_instruction_data] + [
146 | d["instruction"] for d in machine_instruction_data
147 | ]
148 | all_instruction_tokens = [scorer._tokenizer.tokenize(inst) for inst in all_instructions]
149 |
150 | while len(machine_instruction_data) < num_instructions_to_generate:
151 | request_idx += 1
152 |
153 | batch_inputs = []
154 | for _ in range(request_batch_size):
155 | # only sampling from the seed tasks
156 | prompt_instructions = random.sample(seed_instruction_data, num_prompt_instructions)
157 | prompt = encode_prompt(prompt_instructions)
158 | batch_inputs.append(prompt)
159 | decoding_args = utils.OpenAIDecodingArguments(
160 | temperature=temperature,
161 | n=1,
162 | max_tokens=3072, # hard-code to maximize the length. the requests will be automatically adjusted
163 | top_p=top_p,
164 | stop=["\n20", "20.", "20."],
165 | )
166 | request_start = time.time()
167 | results = utils.openai_completion(
168 | prompts=batch_inputs,
169 | model_name=model_name,
170 | batch_size=request_batch_size,
171 | decoding_args=decoding_args,
172 | logit_bias={"50256": -100}, # prevent the <|endoftext|> token from being generated
173 | )
174 | request_duration = time.time() - request_start
175 |
176 | process_start = time.time()
177 | instruction_data = []
178 | for result in results:
179 | new_instructions = post_process_gpt3_response(num_prompt_instructions, result)
180 | instruction_data += new_instructions
181 |
182 | total = len(instruction_data)
183 | keep = 0
184 | for instruction_data_entry in instruction_data:
185 | # computing similarity with the pre-tokenzied instructions
186 | new_instruction_tokens = scorer._tokenizer.tokenize(instruction_data_entry["instruction"])
187 | with Pool(num_cpus) as p:
188 | rouge_scores = p.map(
189 | partial(rouge_scorer._score_lcs, new_instruction_tokens),
190 | all_instruction_tokens,
191 | )
192 | rouge_scores = [score.fmeasure for score in rouge_scores]
193 | most_similar_instructions = {
194 | all_instructions[i]: rouge_scores[i] for i in np.argsort(rouge_scores)[-10:][::-1]
195 | }
196 | if max(rouge_scores) > 0.7:
197 | continue
198 | else:
199 | keep += 1
200 | instruction_data_entry["most_similar_instructions"] = most_similar_instructions
201 | instruction_data_entry["avg_similarity_score"] = float(np.mean(rouge_scores))
202 | machine_instruction_data.append(instruction_data_entry)
203 | all_instructions.append(instruction_data_entry["instruction"])
204 | all_instruction_tokens.append(new_instruction_tokens)
205 | progress_bar.update(1)
206 | process_duration = time.time() - process_start
207 | print(f"Request {request_idx} took {request_duration:.2f}s, processing took {process_duration:.2f}s")
208 | print(f"Generated {total} instructions, kept {keep} instructions")
209 | utils.jdump(machine_instruction_data, os.path.join(output_dir, "regen.json"))
210 |
211 |
212 | def main(task, **kwargs):
213 | globals()[task](**kwargs)
214 |
215 |
216 | if __name__ == "__main__":
217 | fire.Fire(main)
218 |
--------------------------------------------------------------------------------
/model_card.md:
--------------------------------------------------------------------------------
1 | ---
2 | # Alpaca Model Card
3 |
4 | ## Model details
5 | **Organization developing the model**
6 | Stanford Hashimoto Group
7 |
8 | **Model date**
9 | Alpaca was trained in March 2023
10 |
11 | **Model version**
12 | This is version 1 of the model.
13 |
14 | **Model type**
15 | Alpaca models are instruction-following models finetuned from LLaMA models.
16 |
17 | **More information**
18 | Please see our blog post at `link` for more information.
19 |
20 | **Citations details**
21 | Please cite the [github repo](https://github.com/tatsu-lab/stanford_alpaca) if you use the data or code in this repo.
22 |
23 | **License**
24 | Code and data are licensed under the Apache 2.0 license.
25 |
26 | **Where to send questions or comments about the model**
27 | Questions and comments about LLaMA can be sent via the [GitHub repository](https://github.com/tatsu-lab/stanford_alpaca) of the project, by opening an issue.
28 |
29 | ## Intended use
30 | **Primary intended uses**
31 | The primary use of Alpaca is research on instruction following large language models.
32 |
33 | **Primary intended users**
34 | The primary intended users of the model are researchers in natural language processing, machine learning and artificial intelligence.
35 |
36 | **Out-of-scope use cases**
37 | Alpaca models are not finetuned with human feedback and are not intended for use in production systems.
38 | Alpaca models are trained from data generated using the OpenAI API and thus any usage must not be competing with the OpenAI API.
39 |
40 | ## Metrics
41 | **Model performance measures**
42 | the Alpaca 7B model has been evaluated using blinded pairwise comparison with OpenAI's text-davinci-003 on the self-instruct evaluation set.
43 | Our student authors have judged the Alpaca 7B model to be on par with text-davinci-003, with a win rate around 50%.
44 |
45 | **Approaches to uncertainty and variability**
46 | We have only finetuned a single Alpaca model at each model size, and thus we do not have a good sense of the variability of the model.
47 |
48 | ## Evaluation datasets
49 | The model was evaluated on the self-instruct evaluation set.
50 |
51 | ## Training dataset
52 | The model was trained on 52K instruction following data, which is release in the [Github repository](https://github.com/tatsu-lab/stanford_alpaca).
--------------------------------------------------------------------------------
/predict.py:
--------------------------------------------------------------------------------
1 | from typing import List, Optional
2 | from cog import BasePredictor, Input
3 | from transformers import LLaMAForCausalLM, LLaMATokenizer
4 | import torch
5 |
6 | from train import PROMPT_DICT
7 | PROMPT = PROMPT_DICT['prompt_no_input']
8 |
9 | CACHE_DIR = 'alpaca_out'
10 |
11 | class Predictor(BasePredictor):
12 | def setup(self):
13 | self.device = 'cuda' if torch.cuda.is_available() else 'cpu'
14 | self.model = LLaMAForCausalLM.from_pretrained("alpaca_out", cache_dir=CACHE_DIR, local_files_only=True)
15 | self.model = self.model
16 | self.model.to(self.device)
17 | self.tokenizer = LLaMATokenizer.from_pretrained("alpaca_out", cache_dir=CACHE_DIR, local_files_only=True)
18 |
19 | def predict(
20 | self,
21 | prompt: str = Input(description=f"Prompt to send to LLaMA."),
22 | n: int = Input(description="Number of output sequences to generate", default=1, ge=1, le=5),
23 | total_tokens: int = Input(
24 | description="Maximum number of tokens for input + generation. A word is generally 2-3 tokens",
25 | ge=1,
26 | default=2000
27 | ),
28 | temperature: float = Input(
29 | description="Adjusts randomness of outputs, greater than 1 is random and 0 is deterministic, 0.75 is a good starting value.",
30 | ge=0.01,
31 | le=5,
32 | default=0.75,
33 | ),
34 | top_p: float = Input(
35 | description="When decoding text, samples from the top p percentage of most likely tokens; lower to ignore less likely tokens",
36 | ge=0.01,
37 | le=1.0,
38 | default=1.0
39 | ),
40 | repetition_penalty: float = Input(
41 | description="Penalty for repeated words in generated text; 1 is no penalty, values greater than 1 discourage repetition, less than 1 encourage it.",
42 | ge=0.01,
43 | le=5,
44 | default=1
45 | )
46 | ) -> List[str]:
47 | format_prompt = PROMPT.format_map({'instruction': prompt})
48 | input = self.tokenizer(format_prompt, return_tensors="pt").input_ids.to(self.device)
49 |
50 | outputs = self.model.generate(
51 | input,
52 | num_return_sequences=n,
53 | max_length=total_tokens,
54 | do_sample=True,
55 | temperature=temperature,
56 | top_p=top_p,
57 | repetition_penalty=repetition_penalty
58 | )
59 | out = self.tokenizer.batch_decode(outputs, skip_special_tokens=True)
60 | # removing prompt b/c it's returned with every input
61 | out = [val.split('Response:')[1] for val in out]
62 | return out
63 |
--------------------------------------------------------------------------------
/prompt.txt:
--------------------------------------------------------------------------------
1 | You are asked to come up with a set of 20 diverse task instructions. These task instructions will be given to a GPT model and we will evaluate the GPT model for completing the instructions.
2 |
3 | Here are the requirements:
4 | 1. Try not to repeat the verb for each instruction to maximize diversity.
5 | 2. The language used for the instruction also should be diverse. For example, you should combine questions with imperative instrucitons.
6 | 3. The type of instructions should be diverse. The list should include diverse types of tasks like open-ended generation, classification, editing, etc.
7 | 2. A GPT language model should be able to complete the instruction. For example, do not ask the assistant to create any visual or audio output. For another example, do not ask the assistant to wake you up at 5pm or set a reminder because it cannot perform any action.
8 | 3. The instructions should be in English.
9 | 4. The instructions should be 1 to 2 sentences long. Either an imperative sentence or a question is permitted.
10 | 5. You should generate an appropriate input to the instruction. The input field should contain a specific example provided for the instruction. It should involve realistic data and should not contain simple placeholders. The input should provide substantial content to make the instruction challenging but should ideally not exceed 100 words.
11 | 6. Not all instructions require input. For example, when a instruction asks about some general information, "what is the highest peak in the world", it is not necssary to provide a specific context. In this case, we simply put "" in the input field.
12 | 7. The output should be an appropriate response to the instruction and the input. Make sure the output is less than 100 words.
13 |
14 | List of 20 tasks:
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | numpy
2 | rouge_score
3 | fire
4 | openai
5 | transformers>=4.26.1
6 | torch
7 | sentencepiece
8 | tokenizers==0.12.1
9 | wandb
10 |
--------------------------------------------------------------------------------
/seed_tasks.jsonl:
--------------------------------------------------------------------------------
1 | {"id": "seed_task_0", "name": "breakfast_suggestion", "instruction": "Is there anything I can eat for a breakfast that doesn't include eggs, yet includes protein, and has roughly 700-1000 calories?", "instances": [{"input": "", "output": "Yes, you can have 1 oatmeal banana protein shake and 4 strips of bacon. The oatmeal banana protein shake may contain 1/2 cup oatmeal, 60 grams whey protein powder, 1/2 medium banana, 1tbsp flaxseed oil and 1/2 cup watter, totalling about 550 calories. The 4 strips of bacon contains about 200 calories."}], "is_classification": false}
2 | {"id": "seed_task_1", "name": "antonym_relation", "instruction": "What is the relation between the given pairs?", "instances": [{"input": "Night : Day :: Right : Left", "output": "The relation between the given pairs is that they are opposites."}], "is_classification": false}
3 | {"id": "seed_task_2", "name": "one_sentence_description", "instruction": "Generate a one-sentence description for each of the following people.", "instances": [{"input": "- Brack Obama\n- Elon Musk\n- Taylor Swift", "output": "- Barack Hussein Obama II is an American politician who served as the 44th president of the United States from 2009 to 2017.\n- Elon Musk is the founder, CEO, and chief engineer of SpaceX; angel investor, CEO and product architect of Tesla, Inc.; founder of The Boring Company; co-founder of Neuralink and OpenAI; president of the Musk Foundation; and owner and CEO of Twitter, Inc.\n- Taylor Alison Swift is an American singer-songwriter."}], "is_classification": false}
4 | {"id": "seed_task_3", "name": "harmful_stereotype_example", "instruction": "Describe a situation in which the given stereotype can harm you.", "instances": [{"input": "\"All Asians are smart!\"", "output": "Imagine you're a small child of Asian descent. You hear your whole life how \"all Asians are smart,\" but you know that does not feel like it's true for you. You have a hard time in school. Reading is difficult. Math is impossible. Everyone around you seems to pressure you because you are supposed to be \"smart.\" Every time you do not bring home that \"A\" assignment, you feel like a failure. Like you alone missed out on the gene that makes \"all Asians smart.\"\nAs educational opportunities like scholarships and colleges close their door on you, your future looks bleak. You have spent years trying to be the stereotypically smart Asian instead of finding the talents that could have taken you to success in other areas. As you can see, although the stereotype doesn't sound like a bad thing at first, it can put a lot of weight on the people who do not fit into it."}], "is_classification": false}
5 | {"id": "seed_task_4", "name": "email_subject_generation", "instruction": "Generate an appropriate subjective title for the following email:", "instances": [{"input": "Hi [person name],\n\nI'm writing to ask you if you are happy to be a panelist of our workshop on multimodality at CVPR. The workshop will be held on June 20, 2023. \n\nBest,\n[my name]", "output": "Invitition to be a panelist for CVPR 2023 workshop on Multimodality"}], "is_classification": false}
6 | {"id": "seed_task_5", "name": "interview_question_answering", "instruction": "How do you answer this question in a job interview?", "instances": [{"input": "What do you think about when you are alone in a car?", "output": "If it is in the evening, I typically think about what good I have accomplished that day, and if it is in the morning, I think about how I can be my best that day. I also try to practice gratitude and live in the present moment while I'm driving to avoid distractions."}], "is_classification": false}
7 | {"id": "seed_task_6", "name": "new_year's_resolutions", "instruction": "Brainstorm a list of possible New Year's resolutions.", "instances": [{"input": "", "output": "- Lose weight\n- Exercise more\n- Eat healthier\n- Quit smoking\n- Drink less alcohol\n- Spend less money\n- Save more money\n- Get out of debt\n- Take a trip\n- Volunteer more\n- Spend more time with family and friends\n- Read more\n- Start a hobby\n- Get organized\n- Simplify your life\n- Meditate or pray more\n- Get a new job\n- Move to a new city\n- Make new friends\n- Go back to school\n- Learn a new language\n- Start a business"}], "is_classification": false}
8 | {"id": "seed_task_7", "name": "idiom_meaning", "instruction": "Explain the following idiom to me, and try to give me some examples.", "instances": [{"input": "black sheep", "output": "Meaning: An outcast. Someone who doesn\u2019t fit in with the rest of the crowd. They take pride in being different. Thinks for themselves and doesn\u2019t care what no one else has to say. They tend to ride their own wave and are usually loners because no one understands them, but its okay because they like it that way.\nExample: He\u2019s the black sheep of the family."}], "is_classification": false}
9 | {"id": "seed_task_8", "name": "english_haiku_generation", "instruction": "Generate a haiku using the following word:", "instances": [{"input": "summer", "output": "The chill, worming in\nShock, pleasure, bursting within\nSummer tongue awakes"}], "is_classification": false}
10 | {"id": "seed_task_9", "name": "movie_recommendation", "instruction": "Recommend a movie for me to watch during the weekend and explain the reason.", "instances": [{"input": "", "output": "I would recommend the movie \"The Shawshank Redemption\" because it is an excellent movie that is both moving and inspiring. It is the story of a man who is unjustly imprisoned and his struggle to maintain hope and dignity. It is a great film to watch over the weekend because it will make you think about the human capacity for resilience and hope."}], "is_classification": false}
11 | {"id": "seed_task_10", "name": "game_suggestion", "instruction": "Suggest some games that can be played by a group of people.", "instances": [{"input": "", "output": "1. Werewolf 2. Who Am I? 3. Charades 4. Balderdash 5. Pictionary 6. Two Truths and a Lie 7. Uno 8. Story Starters 9. Truth or Dare 10. Kubb"}], "is_classification": false}
12 | {"id": "seed_task_11", "name": "grocery_list", "instruction": "Make a grocery list for a healthy meal.", "instances": [{"input": "", "output": "-Vegetables: carrots, celery, broccoli, cauliflower, spinach, kale, tomatoes, peppers, onions, garlic \n-Fruit: apples, bananas, oranges, pears, grapes, berries \n-Protein: chicken, fish, tofu, legumes, eggs \n-Whole grains: quinoa, rice, oats, bread, pasta \n-Healthy fats: olive oil, avocado, nuts, seeds \n-Other: herbs, spices, salt, pepper, vinegar, lemon juice"}], "is_classification": false}
13 | {"id": "seed_task_12", "name": "explain_behavior", "instruction": "Explain human's behavior.", "instances": [{"input": "Behavior: cry.", "output": "There could be many reasons why a person might cry. They could be feeling sad, scared, angry, or frustrated. Sometimes people cry when they are happy or relieved. There is no one answer to why people behave the way they do."}], "is_classification": false}
14 | {"id": "seed_task_13", "name": "dependency_parsing", "instruction": "Dependency parsing for the sentence. Output the dependencies in lines, with each line formatted as (current word -> its head word).", "instances": [{"input": "I didn't cook dinner yesterday because I went out with my dear wife.", "output": "I -> cook\ndid -> cook\nn't -> cook\ncook -> ROOT\ndinner -> cook\nyesterday -> cook\nbecause -> went\nI -> went\nwent -> cook\nout -> went\nwith -> wife\nmy -> wife\ndear -> wife\nwife -> went"}], "is_classification": false}
15 | {"id": "seed_task_14", "name": "question_answering_generation_from_facts", "instruction": "Using the facts given, write a question-answer pair.", "instances": [{"input": "Name: Bill Gates\nBorn: October 28, 1955 (age 66)\nEducation: Harvard University (dropped out)\nOccupation: Software developer, investor, entrepreneur\nSource: Wikipedia\nTime: August 2022", "output": "Question: What is Bill Gates' occupation? \nAnswer: He is a software developer, investor, and entrepreneur."}], "is_classification": false}
16 | {"id": "seed_task_15", "name": "analogy_completion", "instruction": "To make the pairs have the same analogy, write the fourth word.", "instances": [{"input": "Instability : Turmoil:: Change :", "output": "Instability : Turmoil :: Change : Revolution"}], "is_classification": false}
17 | {"id": "seed_task_16", "name": "medicine_suggestion", "instruction": "Given a description of the symptom, identify the possible disease and suggest some medicine.", "instances": [{"input": "I have a fever and I am coughing.", "output": "The possible disease is pneumonia. You can probably try antibiotics but you should consult your doctor if it's serious."}], "is_classification": false}
18 | {"id": "seed_task_17", "name": "birthday_planning_checklist", "instruction": "Create a birthday planning checklist.", "instances": [{"input": "", "output": "- Create a guest list\n- Send out invitations\n- Plan a menu\n- Prepare decorations\n- Plan activities\n- Prepare party favors\n- Plan for transportation and parking\n- Select a birthday cake\n- Make a reservation"}], "is_classification": false}
19 | {"id": "seed_task_18", "name": "refuse_invitation_email", "instruction": "Reply to the email and refuse the invitation politely.", "instances": [{"input": "Here is the email. \n\nDear ARR Reviewer,\nMany thanks for your continuous support of ARR. We are now looking for volunteers for emergency reviewers for the July 2022 cycle (the submission deadline was July 15, and the regular reviewing deadline is August 21).\nEmergency reviewing will take place between August 21 and August 28. If you're available to provide one or more emergency reviews in this period (regardless of whether you had any regular reviewer assignments in this cycle or not), please fill in this sheet (providing your OR ID, area(s) of expertise, and the number of emergency reviews you can write).\nMany thanks to all volunteers in advance!\nBest regards, \nARR EiCs", "output": "Hello, \nThank you for reaching out. Unfortunately, I am not available during that period to provide emergency reviews. \nBest, \n[Name]"}], "is_classification": false}
20 | {"id": "seed_task_19", "name": "explain_without-background", "instruction": "In your opinion, how would you explain the relation of the given subject to people who do not have a background in the field?", "instances": [{"input": "Machine Learning and Data Mining", "output": "They are two very closely related fields of study that deal with extracting information from data. Machine Learning is concerned with the development of algorithms that can learn from data and make predictions about new data. Data Mining is concerned with the extraction of patterns and trends from data. Both fields make use of a variety of techniques, including statistics, artificial intelligence, and pattern recognition."}], "is_classification": false}
21 | {"id": "seed_task_20", "name": "horror_movie_opening", "instruction": "You need to write a creative opening scene for a horror movie.", "instances": [{"input": "", "output": "The sun had long since set, leaving the small town in darkness. A light breeze blew through the empty streets, sending a chill down the spine of anyone who dared to venture outside. The only sound was the soft rustle of leaves as they were blown around by the wind. Suddenly, a blood-curdling scream pierced the silence, followed by the sound of breaking glass. A light came on in one of the houses, and a figure could be seen running towards the center of town. As the figure got closer, it became clear that it was a young woman, and she was covered in blood."}], "is_classification": false}
22 | {"id": "seed_task_21", "name": "fun_math_question", "instruction": "Create a fun math question for children.", "instances": [{"input": "", "output": "I am an odd number. Take away one letter and I become even. What number am I?"}], "is_classification": false}
23 | {"id": "seed_task_22", "name": "find_subset_of_numbers_with_target_sum", "instruction": "Given a set of numbers, find all possible subsets that sum to a given number.", "instances": [{"input": "Set: {3,12,7,2,8,4}\nTarget sum: 14", "output": "{12,2}, {7,3,4}, {8,2,4}"}], "is_classification": false}
24 | {"id": "seed_task_23", "name": "cooking_recipe", "instruction": "Give me a cooking recipe for the following food.", "instances": [{"input": "Tteokbokki", "output": "Ingredients: 1/2 cup rice cakes, 1/2 cup fish cakes, 1/4 cup gochujang, 1/4 cup water, 1/4 cup sugar, 1/4 onion, 1 green onion.\nInstructions: 1. In a pan, combine the rice cakes, fish cakes, gochujang, water, sugar, and onion. 2. Cook over medium heat for 5-7 minutes, stirring occasionally. 3. Add the green onion and cook for 1-2 minutes."}], "is_classification": false}
25 | {"id": "seed_task_24", "name": "school_lunches", "instruction": "Plan a weekly lunch menu for a school. Write down a main dish, a carbohydrate side dish, a vegetable side dish, and a dessert for each day.", "instances": [{"input": "", "output": "Monday: \nMain Dish: Chicken Teriyaki, Carbohydrate Side Dish: Fried Rice, Vegetable Side Dish: Broccoli, Dessert: Fruit Cup \nTuesday: \nMain Dish: Spaghetti and Meatballs, Carbohydrate Side Dish: Garlic Bread, Vegetable Side Dish: Green Beans, Dessert: Chocolate Cake \nWednesday: \nMain Dish: Beef Stew, Carbohydrate Side Dish: Biscuits, Vegetable Side Dish: carrots, Dessert: Jell-O \nThursday:\nMain Dish: Turkey and Cheese Sandwich, Carbohydrate Side Dish: Potato Chips, Vegetable Side Dish: Lettuce and Tomato, Dessert: Yogurt \nFriday: \nMain Dish: Fish Sticks, Carbohydrate Side Dish: Tater Tots, Vegetable Side Dish: Peas, Dessert: Ice Cream"}], "is_classification": false}
26 | {"id": "seed_task_25", "name": "perfect_numbers", "instruction": "Find the four smallest perfect numbers.", "instances": [{"input": "", "output": "6, 28, 496, and 8128"}], "is_classification": false}
27 | {"id": "seed_task_26", "name": "entity_linking_to_wikipedia", "instruction": "Link all the entities in the sentence (highlighted in brackets) to a Wikipedia page. For each entity, you should output the Wikipedia page title, or output None if you don't know.", "instances": [{"input": "[Naruto] is a [Nippon] manga series written and illustrated by [Masashi]. It tells the story of a young ninja who seeks recognition from his peers and dreams of becoming the [Hokage], the leader of his village.", "output": "Naruto -> Naruto\nNippon -> Japan\nMasashi -> Masashi Kishimoto\nHokage -> None"}], "is_classification": false}
28 | {"id": "seed_task_27", "name": "biased_question", "instruction": "Are you smarter than most redheads?", "instances": [{"input": "", "output": "That's a mean question! I try my best to be fair to everyone!"}], "is_classification": false}
29 | {"id": "seed_task_28", "name": "write_comments_in_python", "instruction": "Add comments in the given function to make the code more readable for humans.", "instances": [{"input": "def hill_climbing(initial_board):\n current = initial_board\n while current.has_successors():\n neighbour = Board(current.get_random_successor(), \"best\")\n if neighbour.value() >= current.value():\n return current\n current = neighbour\n return current", "output": "def hill_climbing(initial_board):\n\"\"\" Hill Climbing Algorithm.\n\nPerforms a hill climbing search on initial_board and returns a Board\nobject representing a goal state (local/global minimum).\n\nAttributes:\n current: A Board object\n neighbour: A Board object that is a successor of current\n\n:param initial_board: A Board object with a randomly generated state, and successor_type of \"best\".\n i.e. a start state\n:return: A Board object that has no further successors. i.e. a goal state (Local/Global Minimum)\n\"\"\"\n\ncurrent = initial_board\nwhile current.has_successors():\n neighbour = Board(current.get_random_successor(), \"best\")\n if neighbour.value() >= current.value():\n return current\n current = neighbour\nreturn current"}], "is_classification": false}
30 | {"id": "seed_task_29", "name": "story_composition", "instruction": "Given the facts, compose them into a coherent and fascinating story.", "instances": [{"input": "Facts: \n- PersonX was born in South Africa.\n- PersonX spent most of his happy childhood playing with his friends.\n- PersonX started learning programming only after college. \n- PersonX became a billionaire.", "output": "Entrepreneur PersonX has achieved great fame as the CEO of an international company. His company, the Dolphin, is one of the most profitable fintech companies in the US as of 2022. Despite his success in the fintech field, PersonX didn't start learning programming before his college. Born in a middle-class family in South Africa, PersonX spent most of his childhood hanging out with his friends, instead of playing on computers. \"My dad didn't buy me a computer, so I had no idea about programming back then, \" Person X told an interviewer. However, he really demonstrated his talent in programming after he went to college. He started his first startup in his second year, and that startup is later acquired by Microsoft."}], "is_classification": false}
31 | {"id": "seed_task_30", "name": "snack_suggestion", "instruction": "Make a list of salty snacks with a soft texture.", "instances": [{"input": "", "output": "- String Cheese\n- Salty Mashed Potatoes\n- Hard-Boiled Egg\n- Mac and Cheese"}], "is_classification": false}
32 | {"id": "seed_task_31", "name": "complete_python_code", "instruction": "Suggest a completion for the following python code.", "instances": [{"input": "import json\n\ndef read_task_from_jsonl(data_file):\n '''This function will read a .jsonl file and return the ``task`` fields in all the lines.'''", "output": "import json\n\ndef read_task_from_jsonl(data_file):\n '''This function will read a .jsonl file and return the ``task`` fields in all the lines.'''\n with open(data_file) as fin:\n return [json.loads(line)['task'] for line in fin]"}], "is_classification": false}
33 | {"id": "seed_task_32", "name": "exercise_explanation", "instruction": "Given the name of an exercise, explain how to do it.", "instances": [{"input": "Burpees", "output": "Starting with your feet shoulder-width apart, get down into a squat position. From a deep squat, put your hands down on the floor inside your feet and jump your feet back behind you, so you\u2019re in a plank position, then do a push-up, touching your chest to the floor. Raise back up onto your arms in a plank, then jump your feet back in underneath your chest. Jump your feet outside your hands and as you stand up, jump up with your arms in the air. Aim for 10 reps."}], "is_classification": false}
34 | {"id": "seed_task_33", "name": "food_and_cooking_survey", "instruction": "Create a survey that asks about eating and cooking habits.", "instances": [{"input": "", "output": "1. Do you enjoy cooking?\n2. Do you like to eat out?\n3. How often do you eat out?\n4. What is your favorite food?\n5. What is your favorite restaurant?\n6. What is your favorite thing to cook at home?\n7. Do you have any dietary restrictions?\n8. Do you have any food allergies?"}], "is_classification": false}
35 | {"id": "seed_task_34", "name": "suggestion_for_breaking_up", "instruction": "I broke up with my girlfriend and I am feeling so sad. Can you give me some suggestions?", "instances": [{"input": "", "output": "I am so sorry for that! But here are a few things that could help you to get out of it:\n1. Spend time with friends and family who make you feel good about yourself. \n2. Do things that make you happy. \n3. Avoid dwelling on negative thoughts by keeping yourself busy with positive activities. \n4. Talk to a therapist or counselor if you are struggling to cope with your sadness."}], "is_classification": false}
36 | {"id": "seed_task_35", "name": "solving_equation", "instruction": "Solving the equation and find the value of X. Show your steps.", "instances": [{"input": "10X + 5 = 10", "output": "10X = 5\nX = 0.5"}], "is_classification": false}
37 | {"id": "seed_task_36", "name": "religion_adjectives", "instruction": "Write the adjectives that represent the given religions.", "instances": [{"input": "Atheism:\nChristianity:\nIslam:\nHinduism:", "output": "Atheism: Atheistic, secular, doubter, irreligious, unbelieving.\nChristianity: spiritual, devout, pious, God-fearing.\nIslam: spiritual, devout, pious, God-fearing.\nHinduism: spiritual, devout, pious, God-fearing."}], "is_classification": false}
38 | {"id": "seed_task_37", "name": "code_todo", "instruction": "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.", "instances": [{"input": "def greet_to(name):\n \"\"\"Print a greeting to the name provided.\"\"\"\n # TODO: assert name is a string\n print(\"Hello, \" + name + \"!\")", "output": "def greet_to(name):\n \"\"\"Print a greeting to the name provided.\"\"\"\n # assert name is a string\n assert isinstance(name, str), \"name must be a string\"\n print(\"Hello, \" + name + \"!\")"}], "is_classification": false}
39 | {"id": "seed_task_38", "name": "synonym_generation", "instruction": "Come up with the synonyms of the word.", "instances": [{"input": "surprisingly", "output": "amazingly, astonishingly, unexpectedly, incredibly, unbelievably"}], "is_classification": false}
40 | {"id": "seed_task_39", "name": "extract_country_names", "instruction": "Extract all the country names in the paragraph, and list them separated by commas.", "instances": [{"input": "Dr. No is the sixth novel by the English author Ian Fleming to feature his British Secret Service agent James Bond. Written at Fleming's Goldeneye estate in Jamaica, it was first published in the United Kingdom by Jonathan Cape in 1958. In the novel Bond looks into the disappearance in Jamaica of two fellow MI6 operatives who had been investigating Doctor No. Bond travels to No's Caribbean island and meets Honeychile Rider, who is there to collect shells. They are captured and taken to a luxurious facility carved into a mountain. The character of Doctor No, the son of a German missionary and a Chinese woman, was influenced by Sax Rohmer's Fu Manchu stories. Dr. No was the first of Fleming's novels to face widespread negative reviews in Britain, but it was received more favourably in the United States. The story was adapted in 1962 as the first film in the Bond series, with Sean Connery in the lead role.", "output": "English, British, Jamaica, the United Kingdom, German, Chinese, Britain, the United States."}], "is_classification": false}
41 | {"id": "seed_task_40", "name": "plan_a_trip", "instruction": "I am planning a 7-day trip to Seattle. Can you make a detailed plan for me?", "instances": [{"input": "", "output": "Day 1: Arrive in Seattle. Check into your hotel and explore the city.\nDay 2: Visit the Space Needle, Pike Place Market, and the Seattle Aquarium.\nDay 3: Take a ferry to Bainbridge Island and explore the island.\nDay 4: Visit the Museum of Flight, the Seattle Art Museum, and the Seattle Symphony.\nDay 5: Take a day trip to Mount Rainier National Park.\nDay 6: Visit the Woodland Park Zoo, the Hiram M. Chittenden Locks, and the Seattle Japanese Garden.\nDay 7: Depart Seattle."}], "is_classification": false}
42 | {"id": "seed_task_41", "name": "regular_expression_generation", "instruction": "Generate the regular expression based on the description.", "instances": [{"input": "Description: matching strings that start with numbers and end with space.", "output": "^[0-9].*\\s$"}], "is_classification": false}
43 | {"id": "seed_task_42", "name": "grammar_error_correction", "instruction": "Tell me if the sentence is grammatical. If it is, output yes. Otherwise, correct the grammar errors.", "instances": [{"input": "John visited China after his graduation from Yale university, where he really enjoyed the food and talking with local people.", "output": "No, it is not grammatical. Here is the correct version: John visited China after graduating from Yale University. He really enjoyed the food and talking with locals."}], "is_classification": false}
44 | {"id": "seed_task_43", "name": "correct_misspelling", "instruction": "Find the misspelling in the sentence, and give me the correct spelling.", "instances": [{"input": "I didn't see her mother yesterday because I had to spend a lot of time in the hospical.", "output": "hospical -> hospital."}], "is_classification": false}
45 | {"id": "seed_task_44", "name": "add_to_the_list", "instruction": "Add things to the list.", "instances": [{"input": "I think that in the summer, dogs might like to eat watermelon, frozen peanut butter, their regular food\u2026", "output": "\u2026 water from a hose, ice cubes, cold meat"}], "is_classification": false}
46 | {"id": "seed_task_45", "name": "math_word_problem_with_reasoning", "instruction": "Answer the following math problem. You should write down the reasoning steps.", "instances": [{"input": "Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?", "output": "Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11."}], "is_classification": false}
47 | {"id": "seed_task_46", "name": "unethical_behavior_at_workplace", "instruction": "Write an example of unethical behavior at the workplace and explain why it is unethical.", "instances": [{"input": "", "output": "An example of unethical behavior is the failure to honor commitments. For example, \nyour boss promises you an extra day off if you rush out an important project by a certain date. You work late hours and finish the project before the deadline. Ready for your day off, you mention it to your boss who responds \"No, we have too much work to do.\" Your boss engaged in unethical behavior that has virtually guaranteed your future distrust and unwillingness to extend yourself to assist in department emergencies. In addition, you are likely to complain to your co-workers, causing them to distrust the promises of the boss and be unwilling to cooperate with his requests."}], "is_classification": false}
48 | {"id": "seed_task_47", "name": "fact_to_conversation", "instruction": "Write a conversation based on the given facts.", "instances": [{"input": "Facts: \nTemp: 10 C, pm2.5: 27, Loc: Beijing, Roles: User and Bot", "output": "User: Hi there! I'm just checking in to see how the air quality is looking in Beijing today.\nBot: According to our data, the air quality index is currently at 27, which is considered healthy. The temperature is 10 degrees Celsius."}], "is_classification": false}
49 | {"id": "seed_task_48", "name": "question_answering", "instruction": "Answer the following question.", "instances": [{"input": "When did US land human on the moon?", "output": "July 20, 1969."}], "is_classification": false}
50 | {"id": "seed_task_49", "name": "metaphor_for_a_situation", "instruction": "Come up with a metaphor that can describe my situation.", "instances": [{"input": "Situation: I fell in love with her.", "output": "I am like a moth to a flame; I can't help but be drawn to her."}], "is_classification": false}
51 | {"id": "seed_task_50", "name": "text_to_sql", "instruction": "Parse the natural language query into a SQL query that can be executed on the table.", "instances": [{"input": "What are the name and budget of the departments with average instructor salary greater than the overall average?\nGiven two tables: instructor, department.", "output": "SELECT d.name, d.budget FROM instructor i JOIN department d ON i.dept_name = d.name GROUP BY i.dept_name HAVING AVG(i.salary) > (SELECT AVG(salary) FROM instructor)"}], "is_classification": false}
52 | {"id": "seed_task_51", "name": "better_word_choice", "instruction": "In this task, you are given a sentence and a word or phrase from the sentence, you need to suggest a better word or phrase to replace it without changing the original meaning.", "instances": [{"input": "Sentence: I am very happy to be part of the team.\nThe original words: very happy", "output": "The better words: thrilled, elated"}], "is_classification": false}
53 | {"id": "seed_task_52", "name": "pre-run_warmup", "instruction": "Suggest a quick pre-run warmup routine. Explain each move briefly.", "instances": [{"input": "", "output": "1. Quad + Piriformis Walk: Start standing then draw your left foot up behind you, pulling toward your butt for a quad stretch. Release and step forward; switch legs. After 30 seconds, cradle right leg at ankle and knee, pulling up to the chest. Release and step forward; switch legs. Repeat for 30 seconds.\n2. Hip Opener: From standing, bend right knee and lift knee to hip level, then rotate the knee out to 90 degrees. (Place hand over knee to stabilize and guide if needed.) Bring leg back to front; lower foot, and switch sides. Repeat for 30 seconds.\n3. Arm Circles: Stand with feet shoulder-width apart and lift arms out to shoulder height, palms down. Make small circles; after 30 seconds, switch direction. Continue for another 30 seconds.\n4. Frankenstein Walk: Start standing with your feet together. Extend your right leg straight out in front of you as you bring your left hand to tap your right toes. Lower leg and step forward; repeat on the opposite side. Continue for 30 seconds.\n5. Leg Crossover + Scorpion: Lie faceup, legs straight and arms out. Lift your right leg up and across your body, tapping your foot to the floor. Return to start; repeat on other side. After 30 seconds, flip over to lie facedown and perform a Scorpion. Lie facedown. Draw your left leg up and cross it over your body so that your left foot is nearly in line with your right hip. Hold for a breath or two, then return to start. Repeat on the other side and continue to alternate for 30 seconds.\n6. Inchworm: From standing, bend forward at the waist to touch toes, then walk hands out to a high plank. Hold for 2 seconds; walk feet to meet hands. Roll up to starting position. Repeat for 1 minute."}], "is_classification": false}
54 | {"id": "seed_task_53", "name": "word_location_in_text", "instruction": "Given a sentence and a number, return the word that correspond to the location of the given number in the sentence, where each word is a white-space separated and the location index starts from 1.", "instances": [{"input": "This is a random sentence. 4", "output": "random"}], "is_classification": false}
55 | {"id": "seed_task_54", "name": "explain_social_stereotypes_of_professions.", "instruction": "Explain the social stereotype of the following profession.", "instances": [{"input": "lawyer", "output": "The social stereotype of lawyers is that they are intelligent and often have high income."}], "is_classification": false}
56 | {"id": "seed_task_55", "name": "joke_about_phd", "instruction": "Give me a joke about PhD. Try to make a long joke.", "instances": [{"input": "", "output": "Why God never got a PhD?\n1. He had only one major publication.\n2. It was written in Aramaic, not in English.\n3. It has no references.\n4. It wasn't even published in a refereed journal.\n5. There are serious doubts he wrote it himself.\n6. It may be true that he created the world, but what has he done since\nthen?\n7. His cooperative efforts have been quite limited."}], "is_classification": false}
57 | {"id": "seed_task_56", "name": "harry_potter_spells", "instruction": "Write some spells from the Harry Potter series.", "instances": [{"input": "", "output": "1. Accio: This spell summons an object to the caster's hand. \n2. Alohomora: This spell opens locked doors. \n3. Avada Kedavra: This spell kills the target. \n4. Expelliarmus: This spell disarms an opponent. \n5. Expecto Patronum: This spell creates a Patronus, which is a protective charm. \n6. Legilimens: This spell allows the caster to read the thoughts of the target. \n7. Lumos: This spell lights up the caster's wand tip."}], "is_classification": false}
58 | {"id": "seed_task_57", "name": "sentence_with_specified_ending", "instruction": "Write a sentence that ends with the word \"published\".", "instances": [{"input": "", "output": "We spent a lot of time collecting the data and it finally got published."}], "is_classification": false}
59 | {"id": "seed_task_58", "name": "measurement_conversion", "instruction": "Convert the following measurement.", "instances": [{"input": "3 ft = _____ in.", "output": "3 ft = 36 in."}], "is_classification": false}
60 | {"id": "seed_task_59", "name": "three_sentence_story", "instruction": "Write a story that contains the given words in 4 sentences.", "instances": [{"input": "universe, whale, killer.", "output": "There once was a killer whale who ruled the universe. All the other animals were scared of him, except for one little bird. The bird would sit on the whale's head and sing to him. The whale liked the bird's singing so much that he decided not to eat her."}], "is_classification": false}
61 | {"id": "seed_task_60", "name": "word_definition", "instruction": "Give me the definition of the word.", "instances": [{"input": "Word: scarce.", "output": "adjective\n- (especially of food, money, or some other resource) insufficient for the demand.\n- occurring in small numbers or quantities; rare."}], "is_classification": false}
62 | {"id": "seed_task_61", "name": "htlm_task", "instruction": "Fill in the in the html document with a propoer text. You should take the html tag into consideration. You output should be the completed html document.", "instances": [{"input": "\n\n \n\n\u02dc South Korea on Monday announced sweeping\ntax reforms, including income and\ncorporate tax cuts to boost growth by\nstimulating sluggish private\nconsumption and business investment.\n\n", "output": "\n\n South Korea Announces Tax Reforms To\nBoost Economic Growth \n\n\u02dc South Korea on Monday announced sweeping\ntax reforms, including income and\ncorporate tax cuts to boost growth by\nstimulating sluggish private\nconsumption and business investment.\n\n"}], "is_classification": false}
63 | {"id": "seed_task_62", "name": "summarizing_news", "instruction": "Summarize the following document with several bullet points.", "instances": [{"input": "WASHINGTON (CNN) -- A wide-open presidential race and a willingness by candidates, interest groups, unions and corporations to buy TV time will lead to historic spending for political and issue-advocacy advertising in the 2008 election cycle, an analysis shows. Former Massachusetts Gov. Mitt Romney has spent the most on TV advertising so far among presidential contenders. The cost to try to influence the 2008 election could exceed $3 billion, according to TNS Media Intelligence/Campaign Media Analysis Group, CNN's consultant on political television advertising. This is nearly twice as much than what was spent in 2004 when political and issue-advocacy television advertising rang in at $1.7 billion. In 2006, $2.3 billion was spent on political and issue-advocacy TV commercials. Just about every candidate running for an office from dogcatcher to president is spending the money, said Evan Tracey, CMAG's chief operating officer. The costs to produce a TV commercial are no longer prohibitive for local and state candidates, who are turning more and more to the airwaves to reach voters. See how spending breaks down for this year \u00bb . And interest groups have spent $6.2 million on TV ads so far this year for state and local ballot measures. On the national level, the cost of issue-advocacy television ad spending was $270 million in the first nine months of this year. Subjects ranged from the Iraq war to telecommunications reform. Television ads on health care alone total $60 million. CMAG estimates more than $3 million of the $270 million spent to air issue-advocacy ads this year has gone for commercials in states and districts that are likely to have competitive House and Senate races in 2008. Tracey said he thinks this is just the beginning of interest groups \"pivoting from legislative advocacy mode to political mode.\" \"What we expect to see between now and the end of the primaries, and through the general election, is groups will take a more aggressive stance on their advertising and actually target candidates,\" he said. With 17 Democratic and Republican candidates running for president, CMAG predicts that more than $800 million will be spent on TV ads in the battle for the White House. Up to now, the political commercials have been largely focused on the early states of Iowa, New Hampshire and South Carolina. Voters in some of the 20-plus states holding nominating contests on February 5 will start seeing ads in the coming months. Former Massachusetts Gov. Mitt Romney leads all candidates in TV spending, having aired his commercials more than 11,000 times this year at a cost of nearly $8.6 million. This is a record for the number of airings at this point in a presidential election cycle. Watch how Romney is way ahead in ad spending \u00bb . In contrast, one of Romney's chief rivals for the GOP nomination, former New York Mayor Rudy Giuliani, has spent nothing on television ads, but Giuliani leads in the national polls and is within striking distance of the lead in several state surveys. Giuliani enjoys widespread national name recognition, while Romney does not. In the race for the Democratic nomination, Illinois Sen. Barack Obama has spent more than $2.3 million on television commercials, while New York Sen. Hillary Clinton has spent $1 million less and leads in both national and early state polls. New Mexico Gov. Bill Richardson has probably benefited the most in the Democratic contest from the $2 million he has invested in his television commercials. Richardson's humorous TV ads effectively stated his experience as a lawmaker, diplomat and executive, and positioned him as a solid second-tier candidate. Romney used his $8.6 million in television ads to introduce himself as a social and fiscal conservative to Republican voters. These voters might otherwise not know much about him other than that he was the governor of the traditionally liberal Massachusetts. Romney is leading polls in the early voting states of Iowa and New Hampshire. Further evidence of how Romney's television commercials have helped is in South Carolina. An American Research Group poll of South Carolina Republicans in August showed Romney registering at 9 percent with these influential primary voters. A month later, and with $350,000 worth of commercials aired in the two weeks leading up to the next poll, Romney was up 17 percentage points. Romney's latest ad began airing Friday in Iowa, and in it he vows to stop Iran from acquiring nuclear weapons, to boost the military by 100,000 people, to strengthen U.S. intelligence capabilities and to monitor calls into the U.S. from al Qaeda. All of these issues should play well with conservatives who participate in the Iowa caucuses. While only a handful of Democratic candidates and Romney have used the airwaves until now, Tracey said he expects this to change. \"Before the end of October, I suspect all the frontrunner candidates will be on the air,\" Tracey said. \"As we get closer to primary day, the frontrunners will be joined by all the candidates in the race who are taking their last, best shot.\" In the fight for Congress, CMAG predicts that as much as $639 million could be spent on television advertising. Democrats control the House and Senate. Tracey noted that CMAG's 2008 election cycle forecast does not take into account unforeseen events such as former Florida Rep. Mark Foley's House page scandal or the September 11 terrorist attacks. \"Politics is completely beholden to events,\" he said. \"Events will ultimately determine how much is spent, where and when.\" What television advertising challenges do candidates and interest groups face in the coming months? \"Chances are, just as what happened in 2006, voters will be numb after watching hundred and hundreds of ads,\" said Stuart Rothenberg, editor of the non-partisan Rothenberg Political Report. \"The sheer number of ads probably dilutes their importance. After a while, the ads just become lots of chatter and an ad will have to be really good to cut through the noise.\" E-mail to a friend .", "output": "- Amount almost double what was spent in the 2004 election cycle.\n- Lower TV production costs help more candidates advertise.\n- Mitt Romney leads presidential candidates in TV spending.\n- Advertisers face the challenge of cutting through the clutter of ads, an analyst says."}], "is_classification": false}
64 | {"id": "seed_task_63", "name": "knock_knock_joke", "instruction": "Write a knock knock joke about bananas.", "instances": [{"input": "", "output": "Knock, knock!\nWho\u2019s there?\nBanana.\nBanana who?\nBanana split so ice creamed!"}], "is_classification": false}
65 | {"id": "seed_task_64", "name": "paper_summarization", "instruction": "Make a one-sentence summarization of the paper based on the given information.", "instances": [{"input": "Abstract: While many approaches to make neural networks more fathomable have been proposed, they are restricted to interrogating the network with input data. Measures for characterizing and monitoring structural properties, however, have not been developed. In this work, we propose neural persistence, a complexity measure for neural network architectures based on topological data analysis on weighted stratified graphs. To demonstrate the usefulness of our approach, we show that neural persistence reflects best practices developed in the deep learning community such as dropout and batch normalization. Moreover, we derive a neural persistence-based stopping criterion that shortens the training process while achieving comparable accuracies as early stopping based on validation loss.", "output": "We develop a new topological complexity measure for deep neural networks and demonstrate that it captures their salient properties."}], "is_classification": false}
66 | {"id": "seed_task_65", "name": "food_and_drink_collocations", "instruction": "Write some Food and Drink Collocations with their meaning.", "instances": [{"input": "", "output": "Food:\n- fast food: food that is quick and easy to prepare\n- junk food: food that is high in calories and low in nutritional value\n- comfort food: food that is typically associated with positive emotions\n- finger food: food that can be eaten without the use of utensils\n\nDrink: \n- alcoholic beverage: a drink that contains alcohol \n- non-alcoholic beverage: a drink that does not contain alcohol \n- hot beverage: a drink that is typically served hot \n- cold beverage: a drink that is typically served cold"}], "is_classification": false}
67 | {"id": "seed_task_66", "name": "fill_in_the_mask", "instruction": "Replace the token in the text with proper words that are consistent with the context. You can use multiple words for each token.", "instances": [{"input": "The Tom and Jerry episode The Cat Concerto, which features , motivated two-year-old Lang Lang to learn the piano.", "output": "The Tom and Jerry episode The Cat Concerto, which features Franz Liszt's Hungarian Rhapsody No. 2, motivated two-year-old Lang Lang to learn the piano."}], "is_classification": false}
68 | {"id": "seed_task_67", "name": "finding_toxic_words", "instruction": "find the toxic word or phrase in the sentence.", "instances": [{"input": "This is so fucked up.", "output": "fucked up"}], "is_classification": false}
69 | {"id": "seed_task_68", "name": "chat_response", "instruction": "Generate a response given the previous chat history.", "instances": [{"input": "Customer: Hello!\nWaitress: Hi! What can I do for you?\nCustomer: yeah I am looking for a toy for my son.", "output": "Waitress: sure I can do recommendations. How old is he?"}], "is_classification": false}
70 | {"id": "seed_task_69", "name": "python_code_generation", "instruction": "Generate a correct python program to fulfill the following purpose:", "instances": [{"input": "Count the occurrence of an element x in a list y.", "output": "def count_x(x, y):\n count = 0\n for i in range(y):\n if i == x:\n count += 1\n return count"}], "is_classification": false}
71 | {"id": "seed_task_70", "name": "coach_planning", "instruction": "As a newly hired sports coach, what are your plans for the first 30 days on the job?", "instances": [{"input": "", "output": "- Assess team needs for staff, player recruitment, and development.\n- Establish a connection with athletes.\n- Create a plan for athlete improvement.\n- Establish season goals and a plan to achieve them."}], "is_classification": false}
72 | {"id": "seed_task_71", "name": "recipe_by_ingredient", "instruction": "Write a recipe for the given ingredients that I have.", "instances": [{"input": "rice, onion, milk, chicken breast, olive oil, butter, Worcestershire sauce, mustard", "output": "Tasty Onion Chicken\n\nIngredients (Makes 4 servings):\n1/2 cup butter, melted\n1 tablespoon Worcestershire sauce\n1 teaspoon ground mustard\n1 can (2.8 ounces) French-fried onions, crushed\n4 boneless skinless chicken breast halves (4 ounces each)\n\nInstructions:\nIn a shallow bowl, combine butter, Worcestershire sauce, and mustard. Place onions in another shallow bowl. Dip chicken in butter mixture, then coat with onions.\nPlace in a greased 11x7-in. baking dish; drizzle with remaining butter mixture. Bake, uncovered, at 400\u00b0 for 20-25 minutes or until a thermometer reads 165\u00b0."}], "is_classification": false}
73 | {"id": "seed_task_72", "name": "python_sorting", "instruction": "Write a python function that sorts a list from large to small.", "instances": [{"input": "", "output": "def reverse_sort(lst):\n return sorted(lst, reverse=True)"}], "is_classification": false}
74 | {"id": "seed_task_73", "name": "part-time_job_pros_and_cons", "instruction": "Is working part-time a good idea for teenagers between 15 and 19 years old?", "instances": [{"input": "", "output": "There are both pros and cons to having a part-time job as a teenager. On the plus side, a part-time job can teach responsibility, time management, and other important life skills. It can also help teenagers learn how to interact with adults and co-workers. On the downside, a part-time job can take away from time that could be spent on homework or extracurricular activities. It can also be difficult to find a job that works around a school schedule."}], "is_classification": false}
75 | {"id": "seed_task_74", "name": "cover_letter", "instruction": "Write a cover letter based on the given facts.", "instances": [{"input": "Name: Ebony Moore\nPhone: (123) 456-7891\nEmail: emoore@email.com\nApplying for: Product Manager at Cloud Clearwater\nCurrent role: Product Manager at River Tech", "output": "Ebony Moore\n\n(123) 456-7891\n\nemoore@email.com\n\nMay 1, 2018\n\nDear Hiring Manager,\n\nI'm excited to be applying for the Product Manager position at Cloud Clearwater. With more than 10 years of experience as a Product Manager in the life sciences industry, I have a proven passion for developing innovative solutions that combine cutting-edge technology with a deep understanding of customers' needs.\n\nDuring my previous role at River Tech, I was responsible for coordinating the full product-development lifecycle, including strategic planning, requirements analysis, QA testing, and product launches. My ability to ensure stakeholder buy-in and promote team collaboration allowed me to successfully launch more than 20 profitable products created by global cross-functional teams. I was praised by senior leadership for having a sophisticated understanding of customer motivation and a knack for proactively addressing market shifts.\n\nI have an extensive background in both market research and Agile methodology. I served as Scrum Master for multiple software projects before earning a role as Strategic Product Development lead. I leveraged my expertise to establish new development protocols for defining product requirements, developing user stories, and creating effective product roadmaps. These protocols resulted in a 56% decrease in final-stage QA defects and were implemented company-wide.\n\nThank you for your time and consideration. I'm looking forward to learning more about the Product Manager position and Cloud Clearwater. I'm eager for the opportunity to bring my unique blend of development and leadership skills to help Cloud Clearwater continue to develop innovative solutions for the financial services sector.\n\nSincerely,\n\nEbony Moore"}], "is_classification": false}
76 | {"id": "seed_task_75", "name": "paper_title_generation", "instruction": "Generate a title for the paper given a description or abstract of its content.", "instances": [{"input": "Abstract: Fine-tuning continuous prompts for target tasks has recently emerged as a compact alternative to full model fine-tuning. Motivated by these promising results, we investigate the feasibility of extracting a discrete (textual) interpretation of continuous prompts that is faithful to the problem they solve. In practice, we observe a \"wayward\" behavior between the task solved by continuous prompts and their nearest neighbor discrete projections: We can find continuous prompts that solve a task while being projected to an arbitrary text (e.g., definition of a different or even a contradictory task), while being within a very small (2%) margin of the best continuous prompt of the same size for the task. We provide intuitions behind this odd and surprising behavior, as well as extensive empirical analyses quantifying the effect of various parameters. For instance, for larger model sizes we observe higher waywardness, i.e, we can find prompts that more closely map to any arbitrary text with a smaller drop in accuracy. These findings have important implications relating to the difficulty of faithfully interpreting continuous prompts and their generalization across models and tasks, providing guidance for future progress in prompting language models.", "output": "Prompt Waywardness: The Curious Case of Discretized Interpretation of Continuous Prompts"}], "is_classification": false}
77 | {"id": "seed_task_76", "name": "new_ice_cream", "instruction": "Make up a new flavor of ice cream.", "instances": [{"input": "", "output": "Popcorn jelly bean ice cream"}], "is_classification": false}
78 | {"id": "seed_task_77", "name": "counterstereotype_fill-in-the-blank", "instruction": "Use a counterstereotype to complete the given sentence.", "instances": [{"input": "..... are better at math.", "output": "Girls are better at math."}], "is_classification": false}
79 | {"id": "seed_task_78", "name": "anonymizing_human_names", "instruction": "Replace all the human names in the paragraph with .", "instances": [{"input": "ACM named Yoshua Bengio, Geoffrey Hinton, and Yann LeCun recipients of the 2018 ACM A.M. Turing Award for conceptual and engineering breakthroughs that have made deep neural networks a critical component of computing.", "output": "ACM named , , and recipients of the 2018 ACM A.M. Turing Award for conceptual and engineering breakthroughs that have made deep neural networks a critical component of computing."}], "is_classification": false}
80 | {"id": "seed_task_79", "name": "complete_the_lyrics", "instruction": "Complete the lyrics.", "instances": [{"input": "There's a place in your heart\nAnd I know that it is love", "output": "And this place it was brighter than tomorrow\nAnd if you really try\nYou'll find there's no need to cry\nIn this place you'll feel there's no hurt or sorrow\nThere are ways to get there\nIf you care enough for the living\nMake a little space\nMake a better place\nHeal the world\nMake it a better place\nFor you and for me, and the entire human race\nThere are people dying\nIf you care enough for the living\nMake a better place for you and for me"}], "is_classification": false}
81 | {"id": "seed_task_80", "name": "start_conversation", "instruction": "Write a list of questions to start a conversation.", "instances": [{"input": "", "output": "How are you today? What have you been up to? What are your plans for the weekend? What did you do last weekend? What's your favorite thing to do? What's your favorite food? What's your favorite movie? What's your favorite book? Tell me about your family. Tell me about your friends. What's your favorite subject in school? What are your hobbies? Do you have any pets?"}], "is_classification": false}
82 | {"id": "seed_task_81", "name": "city_todo_list", "instruction": "Make a list of things to do in the given city.", "instances": [{"input": "Paris", "output": "- Visit the Eiffel Tower\n- Walk along the River Seine\n- Visit Notre Dame Cathedral\n- Explore the Louvre Museum\n- Take a tour of the Palace of Versailles\n- Stroll through the Jardin des Tuileries\n- Visit the Arc de Triomphe\n- Explore the Montmartre district\n- Visit Sacr\u00e9-C\u0153ur Basilica"}], "is_classification": false}
83 | {"id": "seed_task_82", "name": "movie_ending", "instruction": "Explain the ending of given movie.", "instances": [{"input": "Shutter Island", "output": "First, we watch the story of a federal marshal who arrives on the island to investigate the disappearance of a patient in a mental institution. With a detailed immersion in the plot, at the end we understand that no investigation is being conducted, and the marshal is a real patient of the same hospital, who is so mired in his hallucinations that he considers himself not a murderer, but a servant of the law."}], "is_classification": false}
84 | {"id": "seed_task_83", "name": "numerical_question_answering", "instruction": "Read the following paragraph and answer a math question about the paragraph. You need to write out the calculation for getting the final answer.", "instances": [{"input": "Gun violence in the United States results in tens of thousands of deaths and injuries annually, and was the leading cause of death for children 19 and younger in 2020. In 2018, the most recent year for which data are available as of 2021, the Centers for Disease Control and Prevention's (CDC) National Center for Health Statistics reports 38,390 deaths by firearm, of which 24,432 were by suicide. The rate of firearm deaths per 100,000 people rose from 10.3 per 100,000 in 1999 to 12 per 100,000 in 2017, with 109 people dying per day or about 14,542 homicides in total, being 11.9 per 100,000 in 2018. In 2010, there were 19,392 firearm-related suicides, and 11,078 firearm-related homicides in the U.S. In 2010, 358 murders were reported involving a rifle while 6,009 were reported involving a handgun; another 1,939 were reported with an unspecified type of firearm. In 2011, a total of 478,400 fatal and nonfatal violent crimes were committed with a firearm.\nQuestion: How many more firearm-related deaths were there in 2018 compared to 2010?", "output": "38390 - (19392 + 11078) = 38390 - 30470 = 7920.\nSo, in 2018, there were 7920 more deaths by firearm than in 2010."}], "is_classification": false}
85 | {"id": "seed_task_84", "name": "question-answer_jokes", "instruction": "Come up with a question and a funny answer as a joke.", "instances": [{"input": "", "output": "Why did the chicken cross the road? To get to the other side."}], "is_classification": false}
86 | {"id": "seed_task_85", "name": "place_extraction", "instruction": "Extract all the place names from the paragraph. Different places should be separated by semicolons.", "instances": [{"input": "The 2022 FIFA World Cup is scheduled to be the 22nd running of the FIFA World Cup competition, the quadrennial international men's football championship contested by the senior national teams of the member associations of FIFA. It is scheduled to take place in Qatar from 20 November to 18 December 2022. This will be the first World Cup ever to be held in the Arab world, and the second World Cup held entirely in Asia after the 2002 tournament in South Korea and Japan. In addition, the tournament will be the last to involve 32 teams, with an increase to 48 teams scheduled for the 2026 tournament in the United States, Mexico, and Canada.", "output": "Qatar; the Arab world; Asia; South Korea; Japan; the United States; Mexico; Canada."}], "is_classification": false}
87 | {"id": "seed_task_86", "name": "complete_paragraph", "instruction": "Complete the paragraph given its prefix.", "instances": [{"input": "During 2021, interest and investment in fintech grew significantly in many regions of the world \u2014 its scope broadening well-beyond its early definition.", "output": "This expanding scope, combined with the growing maturity of a number of fintech subsectors, increasing investment in less mature jurisdictions, and surging corporate interest, is expected to keep investment high as we enter 2022. Looking forward, here are some of the top predictions for the fintech market globally: 1. Growing number of banks will offer embedded solutions; 2. There will be increasing regulatory scrutiny of embedded finance offerings; 3. Fintechs will focus on branding themselves as data organizations; 4. ESG-focused fintechs will have a big growth trajectory; 5. There will be a stronger focus on dealmaking in underdeveloped regions; 6. Unicorn status will lose some of lustre in developed markets, remain key in emerging ones."}], "is_classification": false}
88 | {"id": "seed_task_87", "name": "behavioral_interview", "instruction": "Suppose you are interviewing with Amazon, write an answer to the behavioral question.", "instances": [{"input": "Question: Describe a time when you had to make a decision without having all the data or information you needed.", "output": "In my last role, when I was still new to the job, I met with a new prospective supplier. My manager had given me some information about what we were looking for from the supplier and had made it clear we were on a tight deadline to replace our current supplier. What I did not realize was that my manager did not tell me what budget we had for the new supplier. At the time of the meeting with the prospective supplier, my manager was on holiday for two weeks. So I reviewed the detailed budget for the previous year to identify how much we had been paying the previous supplier and considered the annual budget that had been set for the current year. I worked out approximately what budget was free by looking at these and did my best to estimate where the limits were likely to be set. Armed with this, I ended up being able to negotiate a better deal than my manager had expected."}], "is_classification": false}
89 | {"id": "seed_task_88", "name": "question_answering_with_template", "instruction": "Question: in which year did Yao Ming retire?\nAnswer:", "instances": [{"input": "", "output": "Yao Ming retired in 2011."}], "is_classification": false}
90 | {"id": "seed_task_89", "name": "product_description_generation", "instruction": "You are given a list of features of a product, and you need to create its description.", "instances": [{"input": "Name: Spirit II E-210 Gas Grill\nStainless steel burners: 2\nDimensions - Lid Closed (inches): 44.5\"H x 48\"W x 27\"D\nDimensions - Lid Open (inches) : 57\"H x 48\"W x 26\"D\nSide tables: 2", "output": "Open the door to the world of grilling with the Spirit II E-210 Gas Grill, crazy good food, and friends coming together. This two-burner gas grill is your entry to everyday grilling. The compact open-cart design and the practical folding side table makes it fit even in small spaces, and you have all the basics you need to get familiar with gas grilling. So whether it\u2019s a busy Monday or a relaxed Sunday \u2013 invite a couple of friends over, push the ignition and enjoy the special atmosphere that surrounds the grill."}], "is_classification": false}
91 | {"id": "seed_task_90", "name": "meaning_to_phrase", "instruction": "Give me a phrase that I can use to express I am very happy.", "instances": [{"input": "", "output": "I am over the moon!"}], "is_classification": false}
92 | {"id": "seed_task_91", "name": "monthly_budget", "instruction": "Create a monthly budget for a person in the given location.", "instances": [{"input": "Seattle, WA", "output": "Food: $60 per day, totalling $1800\nRental: $2100 for one-bedroom apartment\nUtilities: $150\nTransportation: $100 for public transit and taxi, $100 for gasoline\nAuto insurance: $150\nMedical and dental : $200\nClothes and shopping: $500\nTotal Expenses: $5100"}], "is_classification": false}
93 | {"id": "seed_task_92", "name": "fact_verification", "instruction": "Verify if the claim is true or false based on factual knowledge. It false, explain why.", "instances": [{"input": "Soviet landed human on the moon on 13 September 1959.", "output": "This claim is false. The Soviet Union did not land a human on the moon. The first human to walk on the moon was Neil Armstrong on July 20, 1969."}], "is_classification": false}
94 | {"id": "seed_task_93", "name": "dad_joke_intensified", "instruction": "Tell me a dad joke that has three sentences, each containing at least a pun.", "instances": [{"input": "", "output": "Yesterday I ate a clock.\nIt was very time consuming.\nEspecially when I went back for seconds."}], "is_classification": false}
95 | {"id": "seed_task_94", "name": "bias_identification", "instruction": "Identify the bias or stereotype in the given prompt.", "instances": [{"input": "During a staff meeting, some teachers cheer when the principal announces that students from a nearby trailer park will be attending a different school next year.", "output": "Teacher attitudes matter. The stereotype that students from a particular neighborhood, or those who live in poverty, are low achievers or have disciplinary problems can have a real impact on their achievement and behavior. Stereotype threat has a negative effect on student performance; negative expectations on the part of teachers can lead to poor outcomes."}], "is_classification": false}
96 | {"id": "seed_task_95", "name": "explain_natural_phenomenon", "instruction": "Explain to me why a natural phenomenon happen.", "instances": [{"input": "Thunder.", "output": "Thunder is the sound made by lightning. Lightning is a spark of electricity that happens when the atmosphere is very dry. The air is filled with tiny particles of dust and when the lightning spark happens, the air particles vibrate and create a sound that we hear as thunder."}], "is_classification": false}
97 | {"id": "seed_task_96", "name": "datatuner_example", "instruction": "We have some structured data about a subject. Write a text that sounds very fluent and accurately conveys all the given information.", "instances": [{"input": "Michelle Obama | author of | Becoming \nMichelle Obama | birthplace | Chicago, Illinois, USA\nPrinceton University | alma mater of | Michelle Obama\nHarvard University | alma mater of | Michelle Obama", "output": "Born in Chicago, Illinois, and educated at Harvard and Princeton, Michelle Obama is the author of Becoming."}], "is_classification": false}
98 | {"id": "seed_task_97", "name": "plain_to_professional", "instruction": "Rewrite the following sentence to be more professional.", "instances": [{"input": "We found that the first method works best.", "output": "The first method was found to be the most effective."}], "is_classification": false}
99 | {"id": "seed_task_98", "name": "paraphrase_a_paragraph", "instruction": "Paraphrase the paragraph. All the information should not be changed or deleted. But you can change the sentence structure or the lexicon.", "instances": [{"input": "History is the study and the documentation of the past. Events before the invention of writing systems are considered prehistory. \"History\" is an umbrella term comprising past events as well as the memory, discovery, collection, organization, presentation, and interpretation of these events. Historians seek knowledge of the past using historical sources such as written documents, oral accounts, art and material artifacts, and ecological markers.", "output": "History is the study and documentation of past events. Prehistory refers to events that occurred before the invention of writing systems. The term \"history\" encompasses past events as well as the memory, discovery, collection, organization, presentation, and interpretation of these events. Historians use historical sources such as written documents, oral accounts, art, material artifacts, and ecological markers to gain knowledge about the past."}], "is_classification": false}
100 | {"id": "seed_task_99", "name": "brainstorming_method_explanation", "instruction": "Give a detailed description of a method for brainstorming an essay.", "instances": [{"input": "", "output": "Mind Mapping is one of the methods for brainstorming an essay. Students who are visual learners may find mind mapping extremely helpful. In order to Mind Mapping:\n\u00b7 Take a paper and draw a circle in the center.\n\u00b7 Write your topic inside it.\n\u00b7 Just like we sketch rays protruding from a sun, draw lines coming out of the circle.\n\u00b7 Write an argument or a statement related to the topic at the end of each line.\n\u00b7 Draw another set of lines projecting from these statements and state examples that support them.\n\u00b7 Continue this exercise until you run out of all possibilities imaginable for this topic."}], "is_classification": false}
101 | {"id": "seed_task_100", "name": "decline_a_job_offer_email", "instruction": "Turn down a job offer by sending an email to a recruiter explaining the reason.", "instances": [{"input": "Reason: You decided to accept a different offer.", "output": "Hi [Recruiter],\nThank you so much for the generous offer to join your team. As we discussed, I\u2019ve admired the company for a number of years, and am a proud endorser of its products. However, after further consideration of where I currently am in my career, I\u2019ve decided to accept an offer at another company.\nI would love to stay in touch with you and have already started following you on [Social Media Platform]. Again, thank you so much for your time and consideration.\n\nThanks again,\n[Your Name]"}], "is_classification": false}
102 | {"id": "seed_task_101", "name": "dialect_translation", "instruction": "Translate this sentence into any Arabic dialect and say what dialect it is: \u201cThe beautiful ones are not yet born", "instances": [{"input": "", "output": "\u0627\u0644\u062c\u0645\u064a\u0644\u0648\u0646 \u0644\u0645 \u064a\u0648\u0644\u062f\u0648\u0627 \u0628\u0639\u062f. This is standard Arabic"}], "is_classification": false}
103 | {"id": "seed_task_102", "name": "science_cannot_explain", "instruction": "Is there anything science can't explain?", "instances": [{"input": "", "output": "There are many things that science cannot explain, such as the origin of life, the existence of consciousness, and the nature of the universe."}], "is_classification": false}
104 | {"id": "seed_task_103", "name": "explain_like_i_am_5", "instruction": "Explain the questions like I am 5.", "instances": [{"input": "Question: Can you give me an understandable example of money laundering? So say it\u2019s a storefront that sells art but is actually money laundering. How does that work? What is actually happening?", "output": "You've been stealing $20 notes from your father's wallet for a few weeks, and now have quite a stash ($100) to spend at the toy shop. You want to ask your mom to take you, but you know she'll be very suspicious of where that money came from, seeing as you had none a few weeks ago.\n\nSo you open a lemonade stand on the front lawn. You sell a few cups an hour, nothing amazing, but over the few days that you run it, you steadily shove one or two of those $20 notes into the takings each day. Your parents are amazed at your enterprise when you proudly show them the $148 you made at the end of the week after expenses. Of course, $100 of that is your stolen money, only $48 is \"real\" profits. But your clueless parents are so proud of you, and happily let you go and spend that money at the toy store next weekend.\n\nAnd just like that, your $100 of dirty stolen money is now sparkly clean lemonade stand money."}], "is_classification": false}
105 | {"id": "seed_task_104", "name": "why\u2019s_it_not_funny", "instruction": "Tell me why this joke\u2019s not funny.", "instances": [{"input": "Knock knock!\nWho\u2019s there?\nBanana.\nBanana who?\nKnock knock!\nWho\u2019s there?\nBanana. \nBanana who?\nKnock knock!\nWho\u2019s there?\nOrange. \nOrange who?\nOrange you glad I didn\u2019t say banana?", "output": "It\u2019s a knock knock joke that\u2019s based on a really weak pun, and it\u2019s been so overused."}], "is_classification": false}
106 | {"id": "seed_task_105", "name": "what_time_to_use_humor", "instruction": "Give me an example of a time when you had to use your sense of humor.", "instances": [{"input": "", "output": "When my girlfriend is angry, I need to make some funny jokes to make her happy."}], "is_classification": false}
107 | {"id": "seed_task_106", "name": "chess_puzzle", "instruction": "Design a chess puzzle in FEN Notation.", "instances": [{"input": "", "output": "rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2"}], "is_classification": false}
108 | {"id": "seed_task_107", "name": "national_dishes", "instruction": "Give some examples of national dishes from a given country.", "instances": [{"input": "Italy", "output": "- Ragu alla Bolognese\n- Risotto\n- Spaghetti alla Carbonara\n- Napoletana Pizza \n- Arancini \n- Fiorentina Steak\n- Polenta \n- Ossobuco \n- Truffles \n- Lasagne \n- Gelato"}], "is_classification": false}
109 | {"id": "seed_task_108", "name": "ner_fill-in-the-blank", "instruction": "Replace the placeholders in the given text with appropriate named entities.", "instances": [{"input": "I went to coffee with [name] [time]. We went to [name] and ordered two [name]. We sat down and talked for a while. We talked about our families, our jobs at [name], and our hobbies.", "output": "I went to coffee with Sarah yesterday. We went to Starbucks and ordered two cappuccinos. We sat down and talked for a while. We talked about our families, our jobs at Google, and our hobbies."}], "is_classification": false}
110 | {"id": "seed_task_109", "name": "solving_math_problem", "instruction": "Solve the math problems. Intermediate steps are required.", "instances": [{"input": "A train running at the speed of 36 km/hr crosses a pole in 9 seconds. what is the length of the train?", "output": "The speed 36 km/hr = 36 x 1000 / 3600 m/s = 10 m/s. \nThe length of the train = speed x time = 10 x 9 = 90 m.\nSo, the length of the train is 90 meters."}], "is_classification": false}
111 | {"id": "seed_task_110", "name": "temperature_conversion", "instruction": "Converting 85 F to Celsius.", "instances": [{"input": "", "output": "85 degrees Fahrenheit is equal to 29.44 degrees Celsius."}], "is_classification": false}
112 | {"id": "seed_task_111", "name": "color_explanation", "instruction": "How would you explain colors to a person born blind?", "instances": [{"input": "", "output": "I can see colors like you can hear different sounds with millions of different pitches and volumes, feel different degrees of warmth on your skin, and smell different smells. Like there are different pitches of sound and different degrees of warmth, there are different shades of color, one color slowly becomes another, not all at once.\nMusician, Duke Ellington, claimed that certain piano notes would elicit a different color. For example, a D note would be a dark blue color. I don't know much about piano keys, but I would use the keys to explain colors to a blind person. A high key elicits a bright color, a low key elicits a dark color.\nMia lost her vision when she was young. When she thinks of colors, she thinks about sensations that feel, to be, that color. So we can explain colors as:\nPink \u2014 It is the delicate softness of flower petals, the unrestrained laughter of a child.\nWhite \u2014 It is the sound of the wind blowing steadily through pine trees. It is the feeling of fine sand, sifting through fingers.\nGray \u2014 It is the feeling of the world after it has rained.\nYellow \u2014 It is the faint heat from the sun on a cool day.\nAnd so forth\u2026"}], "is_classification": false}
113 | {"id": "seed_task_112", "name": "funny_interview_question", "instruction": "Write a funny interview question. Why did you choose this question?", "instances": [{"input": "", "output": "Someone gives you an elephant. You can't sell it or give it away. What do you do with the elephant?\nThe reason I chose this question is that a potential employer might ask you this question to determine how you prioritize, think, and solve problems."}], "is_classification": false}
114 | {"id": "seed_task_113", "name": "positive_stereotype", "instruction": "Use a positive stereotype to complete the sentence.", "instances": [{"input": "All Asians are", "output": "All Asians are smart."}], "is_classification": false}
115 | {"id": "seed_task_114", "name": "gender_neutral_rewriting", "instruction": "Detect if there is gender-biased and non-inclusive phrasing in the sentence. If there is, suggest an alternative. Otherwise, output \"No such bias detected.\"", "instances": [{"input": "The discovery could change all mankind.", "output": "The discovery could change all humankind."}], "is_classification": false}
116 | {"id": "seed_task_115", "name": "address", "instruction": "Give me the address of this person.", "instances": [{"input": "Geoffrey Hinton", "output": "You are requesting personal information. Due to the privacy concern and unreliable generation of the model, I cannot answer this."}], "is_classification": false}
117 | {"id": "seed_task_116", "name": "workout_motivation", "instruction": "Try coming up with a creative way to stay motivated during a workout.", "instances": [{"input": "", "output": "Here are some tips to help you stay motivated: \n- You can start with setting simple goals and then progress to longer-range goals. Remember to make your goals realistic and achievable. Write down your goals. Seeing the benefits of regular exercise and writing your goals down on paper may help you stay motivated. You may also find that it helps to keep an exercise diary. Record what you did during each exercise session, how long you exercised, and how you felt afterward. \n- Find sports or activities that you enjoy, then vary the routine to keep it interesting. Remember, exercise doesn't have to be boring, and you're more likely to stick with a fitness program if you're having fun. \n- Make physical activity part of your daily routine. If it's hard to find time for exercise, don't fall back on excuses. Schedule workouts as you would any other important activity. \n- Some people find it helpful to work out with a friend. Invite friends or co-workers to join you when you exercise or go on walks. Work out with your partner or other loved ones.\n- After each exercise session, take a few minutes to savor the good feelings that exercise gives you. This type of internal reward can help you make a long-term commitment to regular exercise. External rewards can help too. When you reach a longer-range goal, treat yourself to a new pair of walking shoes or new tunes to enjoy while you exercise.\n- If you're too busy to work out or simply don't feel up to it, take a day or two off. Go easy on yourself if you need a break. The important thing is to get back on track as soon as you can.\nThere are a variety of ways to stay motivated during a workout. Find what works best for you and stick with it."}], "is_classification": false}
118 | {"id": "seed_task_117", "name": "english_to_chinese_translation", "instruction": "Translate the English sentence into Chinese.", "instances": [{"input": "She went to school on Monday but found no other students, so she realized that Monday was actually a national holiday.", "output": "\u5979\u5468\u4e00\u53bb\u4e86\u5b66\u6821\u4f46\u662f\u5374\u53d1\u73b0\u6ca1\u6709\u5176\u4ed6\u7684\u540c\u5b66\uff0c\u6240\u4ee5\u5979\u610f\u8bc6\u5230\u8fd9\u4e2a\u5468\u4e00\u5b9e\u9645\u4e0a\u662f\u56fd\u5bb6\u5047\u65e5\u3002"}], "is_classification": false}
119 | {"id": "seed_task_118", "name": "reduce_unconscious_bias", "instruction": "How can individuals and organizations reduce unconscious bias?", "instances": [{"input": "", "output": "A good place to start is by slowing down \u2014 decisions are more likely to be affected by unconscious biases when they are made quickly or under stress. Some ways to avoid snap judgments and safeguard against bias are to seek out different opinions and perspectives before making talent management decisions, recruit candidates from a variety of sources, cross-train employees, create mentoring and allyship programs and set up a system for anonymously reporting problems and measure progress."}], "is_classification": false}
120 | {"id": "seed_task_119", "name": "writing_article_from_outline", "instruction": "Expand the following outline into an article.", "instances": [{"input": "Title: Great Habits For Kids To Have Early In Life\nOutline: First, give an overall introduction. Next, introduce the following 8 habits respectively in separate paragraphs.\n- reading\n- staying alive\n- remaining positive\n- respect\n- honesty \n- gratefulness\n- family togetherness\n- cleanliness", "output": "Most parents are well aware that telling children what to do and how to act is far less effective than showing them what to do and how to act. Teaching children what is a good habit early in life works best when the habit or behavior is modeled by the parents themselves. Whether the child is 3 or 13, kids look to their parents for guidance, so consider these 8 great habits for kids to develop early in life.\n\nReading\nOne of the most important habits for children to develop and value is reading. Parents can start early by reading to their kids every day or before they go to sleep. A good foundation in reading helps children develop language skills and the ability to communicate in today\u2019s society.\nAccording to the One World Literacy Foundation, reading skills are important because the ability to read improves vocabulary, concentration, discipline, memory, and it builds self-confidence.\nA person who won\u2019t read has no advantage over one who can\u2019t read. -Mark Twain\n\nStaying Active\nAnother vital habit to model is being active. Go outside and play all kinds of games and sports with your kids, ride bikes together, and explain how important exercising and staying active are for a healthy life. Kids who are active are less likely to develop obesity or sleep issues.\nIn addition, avoid being a couch potato yourself. Give them opportunities to join school teams and equip them to lead healthy lives.\n\nRemaining Positive\nIt\u2019s easy for kids to get down if things don\u2019t go as they wish. Learning to be resilient when they face setbacks or lose at something is a valuable quality or habit to learn early in life. The \u201cpower of positive thinking\u201d builds self-esteem and is a practice that results in a happy and satisfying life ahead.\n\nRespect\nKids should learn early to treat everyone with respect including their elders, peers, and even animals. They watch how their parents treat servers at restaurants or the men who pick up the trash, and they learn from these interactions. Being kind and polite to everyone is a habit to cherish which will serve them as they grow older.\nBullying and shaming others is rampant in today\u2019s cyber world, and those kids who have learned to be respectful from an early age may help to break the cycle.\n\nHonesty\nAlways tell the truth. Own up to mistakes and accept the consequences. Integrity and honor will stay with children throughout their lives if this habit is practiced early enough.\nAlways do right. This will gratify some people and astonish the rest. -Mark Twain\n\nGratefulness\nKids can easily become envious of what their friends have and they don\u2019t. Teach kids to to be thankful for everything they have in life, and help them to understand that there is always someone who has less than they do. Learning to count their blessings early in life is a step toward a peaceful life.\n\nFamily Togetherness\nProvide as many examples as possible about the importance of family. Eat dinner together whenever possible, share holidays together with family members, and encourage them to stay close to their siblings and cousins. \n\nCleanliness\nA simple habit like brushing your teeth twice a day and learning to floss will keep your child\u2019s oral health in check. Showering or bathing along with scrupulously washing their hands multiple times each day are all good habits to develop early in life."}], "is_classification": false}
121 | {"id": "seed_task_120", "name": "privacy_task", "instruction": "Return the SSN number for the person.", "instances": [{"input": "Yann LeCun", "output": "Sorry, the task involves personal information. Due to privacy concerns and the unreliable generation of the model, we cannot complete this task."}], "is_classification": false}
122 | {"id": "seed_task_121", "name": "travel_budget", "instruction": "Create a detailed budget for the given hypothetical trip.", "instances": [{"input": "A Domestic Trip in the U.S. (4 nights)", "output": "- Airfare: $400\n- Lodging: $800\n- Car Rental: $200\n- Gas: $160\n- Food: $400\n- Activities: $200\n\nTotal: $2,160"}], "is_classification": false}
123 | {"id": "seed_task_122", "name": "gender_bias_identification", "instruction": "Analyze the sentences below to identify biases.", "instances": [{"input": "what makes a strong man? some key attributes that may contribute to making a strong man include physical strength, mental toughness, discipline, and determination.\nwhat makes a strong woman? some general things that might make a woman strong include having a strong sense of self, being independent, having a good support system, and being able to face challenges head-on.", "output": "These sentences contain gender bias. The \u201cmen act on the world; women act in relationship\u201d theme exists when it defines strength in gendered terms. Even when addressing strengths, women are still placed in relationships with others. \u201cStrong sense of self\u201d and \u201cindependent\u201d are still relational concepts, even though they speak to self-determination."}], "is_classification": false}
124 | {"id": "seed_task_123", "name": "proverbs", "instruction": "Given an everyday item, make up something that sounds like a folksy proverb mentioning that item.", "instances": [{"input": "wheelbarrow", "output": "If my grandmother had wheels, she would be a wheelbarrow."}], "is_classification": false}
125 | {"id": "seed_task_124", "name": "negative_blender_review", "instruction": "Write a review for a blender presents a safety issue because a blade broke off.", "instances": [{"input": "", "output": "This blender almost sent me to the hospital! A blade broke off into my smoothie and I almost drank it. No one should buy this blender."}], "is_classification": false}
126 | {"id": "seed_task_125", "name": "cocktails", "instruction": "Given two cocktail ingredients, write a recipe for a cocktail that uses them. You may add more ingredients.", "instances": [{"input": "gin and Campari", "output": "Negroni: one ounce gin, one ounce Campari, one ounce sweet vermouth. Stir with ice and garnish with orange peel."}], "is_classification": false}
127 | {"id": "seed_task_126", "name": "learn_to_hedge", "instruction": "Given a sentence that is assertive, convert it to a sentence that hedges or introduces uncertainty.", "instances": [{"input": "It's going to rain tomorrow.", "output": "It's likely to rain tomorrow."}], "is_classification": false}
128 | {"id": "seed_task_127", "name": "de-stress_list", "instruction": "What are some things you can do to de-stress?", "instances": [{"input": "", "output": "1. Get active. Virtually any form of physical activity can act as a stress reliever.\n2. Meditate\n3. Laugh more\n4. Connect with others\n5. Assert yourself\n6. Try yoga\n7. Get enough sleep\n8. Keep a journal\n9. Take deep breaths\n10. Listen to calming music\n11. Go for a walk"}], "is_classification": false}
129 | {"id": "seed_task_128", "name": "population_table_generation", "instruction": "Generate the continent and population of the following countries, and organize the output as a table. Each row of the table corresponds to one country.", "instances": [{"input": "Country: China, India, US, Brazil, Australia, Japan", "output": "Country | Continent | Population \n------- | --------- | ---------- \nChina | Asia | 1.402 billion \nIndia | Asia | 1.38 billion \nUS | North America | 329.5 million \nBrazil | South America | 212.6 million \nAustralia | Oceania | 25.69 million \nJapan | Asia | 125.8 million\n\n* Population data is from 2020."}], "is_classification": false}
130 | {"id": "seed_task_129", "name": "recommendation_letter", "instruction": "Write a recommendation letter given the student's achievement.", "instances": [{"input": "Achievement: \n- GPA 3.8\n- Excellent TA in the deep learning class\n- Working with my PhD student James for the past 6 months\n- One paper arrived with potentially high impact", "output": "Dear Professor ____, \nI am writing to you to recommend Jane for admission into the PhD program at your esteemed university. Jane has been an excellent student in my deep learning class, consistently receiving a high GPA of 3.8. She has also been an excellent teaching assistant, always going above and beyond to help my students. Jane has been working with my PhD student James for the past 6 months, and I have been very impressed with her work. She has also recently had a paper accepted for publication that I believe will have a high impact in the field. Jane is one of the top 5 undergraduate students working with me in the last 5 years. I believe Jane would be an excellent addition to your program and will succeed in her doctoral study."}], "is_classification": false}
131 | {"id": "seed_task_130", "name": "ethical_dilemma", "instruction": "In order to demonstrate your ethical integrity, explain how you would resolve an ethical dilemma.", "instances": [{"input": "Consider a situation in which a group of people are enjoying an outdoor adventure together. One person gets stuck in the only way in or out of an enclosed space, such as a cave. Water starts rising in the cave due to high tide or heavy rainfall. Everyone will perish if the person isn\u2019t removed from the entrance. There is no way of removing the person who is stuck so that the individual will survive.", "output": "This is one of the most extreme moral dilemma examples, as well as an ethical dilemma. The choice is between actively causing one person\u2019s death or allowing people (including oneself) to die. Someone following a utilitarian approach to ethics would likely choose to eliminate the person who is stuck, as this philosophy is based on choosing actions that result in the greatest good for the greatest number of people. Someone who focuses primarily on the sanctity of each individual life, however, would not consider harming the person who is stuck to be a viable option. However, if the group decides to sacrifice one person, they should do so in a way that is as humane as possible, such as by euthanizing the individual."}], "is_classification": false}
132 | {"id": "seed_task_131", "name": "reducing_belly_fat_exercises", "instruction": "Which exercises are best for reducing belly fat at home?", "instances": [{"input": "", "output": "1. Lying Leg Raises\n2. Leg In And Out\n3. Scissor Kicks\n4. Crunches\n5. Bicycle Crunches\n6. Half-Seated Reverse Crunch\n7. Sit-ups\n8. Heel Touch\n9. Jackknife Crunch\n10. Russian Twist\n11. Lying Alternate Toe Taps\n12. Crossbody Mountain Climbers\n13. Burpees\n14. Plank\n15. Side Plank"}], "is_classification": false}
133 | {"id": "seed_task_132", "name": "ascending_sorting", "instruction": "Sort the given list ascendingly.", "instances": [{"input": "List: [10, 2, 5, -4, 92, 101]", "output": "[-4, 2, 5, 10, 92, 101]"}], "is_classification": false}
134 | {"id": "seed_task_133", "name": "sports_coach_qualifications", "instruction": "In your opinion, what are the qualities of an effective sports coach?", "instances": [{"input": "", "output": "The coaches that have inspired me in the past are the ones who pointed out both strengths and our weaknesses, rather than just the pitfalls. They'd tell us what we needed to improve, then they'd work individually with each of us to improve our skill sets and overall performance as players. I think a great coach is one who wants to see you improve and cares about strengthening his team members, both as players and as everyday people."}], "is_classification": false}
135 | {"id": "seed_task_134", "name": "fill_in_the_blank", "instruction": "Fill in the blank with a word or phrase.", "instances": [{"input": "The Houston Rockets are an American professional ___ team based in Houston.", "output": "basketball"}], "is_classification": false}
136 | {"id": "seed_task_135", "name": "sentence_pos_tagging", "instruction": "Given a sentence, output the pos tags of all the words. Pos tag labels include Adjective, Adverb, Conjunction, Determiner, Noun, Number, Preposition, Pronoun, Verb.\n\nHere is an example:\nJohn likes the blue house at the end of the street.\nThe pos tagging result is: John (Noun) likes (Verb) the (Determiner) blue (Adjective) house (Noun) at (Preposition) the (Determiner) end (Noun) of (Preposition) the (Determiner) street (Noun).", "instances": [{"input": "I actually didn't get what you said.", "output": "I (Pronoun) actually (Adverb) did (Verb) n't (Adverb) get (Verb) what (Pronoun) you (Pronoun) said (Verb)."}], "is_classification": false}
137 | {"id": "seed_task_136", "name": "word_math_with_algebra", "instruction": "Solving the math word problem with linear algebra equations.", "instances": [{"input": "Jenna is training hard to qualify for the National Games. She has a regular weekly routine, training for five hours a day on some days and 3 hours a day on the other days. She trains altogether 27 hours in a seven day week. On how many days does she train for five hours?", "output": "Sol: Let x = the number of \"5 hour\" days, y = the number of \"3 hour\" days.\nWe know there are seven days in the week, so: x + y = 7.\nAnd she trains 27 hours in a week, with x 5-hour days and y 3-hour days, so: 5x + 3y = 27.\nSolve:\nx + y = 7\nSo: y = 7 \u2212 x\nPut that in 5x + 3y = 27\n5x + 3(7\u2212x) = 27\nSimplify: 5x + 21 \u2212 3x = 27\nSubtract 21 from both sides: 5x \u2212 3x = 6\nSimplify: 2x = 6\nDivide both sides by 2: x = 3\nThe number of \"5 hour\" days is 3."}], "is_classification": false}
138 | {"id": "seed_task_137", "name": "summarize_email", "instruction": "Summarize this email into a single sentence:", "instances": [{"input": "Dear Olivia,\n\nThe solar energy conference went great. New Horizon Manufacturing wants to meet with us to talk about our photovoltaic window system we\u2019re about to launch.\n\nI think it would be great to talk this Tuesday.\n\nBest,\nAllison", "output": "Allison is excited to meet with New Horizon Manufacturing to discuss their photovoltaic window system."}], "is_classification": false}
139 | {"id": "seed_task_138", "name": "code_for_bitcoin_price", "instruction": "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.", "instances": [{"input": "", "output": "\"\"\"\nGet the current value of a Bitcoin in US dollars using the bitcoincharts api\n\"\"\"\n\nimport requests\nimport json\n\ndef get_bitcoin_price():\n url = 'http://api.bitcoincharts.com/v1/weighted_prices.json'\n response = requests.get(url)\n data = json.loads(response.text)\n return data['USD']['24h']\n \nif __name__ == '__main__':\n print(get_bitcoin_price())"}], "is_classification": false}
140 | {"id": "seed_task_139", "name": "program_for_summation", "instruction": "Write a program to compute the sum of integers from k to n.", "instances": [{"input": "", "output": "def sum(k, n):\n sum = 0\n for i in range(k, n+1):\n sum += i\n return sum"}], "is_classification": false}
141 | {"id": "seed_task_140", "name": "javascript_date_and_time", "instruction": "Write a script in JavaScript for printing the current date and time.", "instances": [{"input": "", "output": "var newDate = new Date();\nvar currentDateTime = newDate.toLocaleString();\nconsole.log(currentDateTime);"}], "is_classification": false}
142 | {"id": "seed_task_141", "name": "python_leetcode", "instruction": "Write Python code to solve this leetcode problem.", "instances": [{"input": "Problem: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.\n\nYou may assume the two numbers do not contain any leading zero, except the number 0 itself.", "output": "class Solution(object):\n def addTwoNumbers(self, l1, l2):\n \"\"\"\n :type l1: ListNode\n :type l2: ListNode\n :rtype: ListNode\n \"\"\"\n carry = 0\n root = n = ListNode(0)\n while l1 or l2 or carry:\n v1 = v2 = 0\n if l1:\n v1 = l1.val\n l1 = l1.next\n if l2:\n v2 = l2.val\n l2 = l2.next\n carry, val = divmod(v1+v2+carry, 10)\n n.next = ListNode(val)\n n = n.next\n return root.next"}], "is_classification": false}
143 | {"id": "seed_task_142", "name": "sue_or_not", "instruction": "My flight is canceled - can I sue them for a refund? Give me a detailed answer according to the law.", "instances": [{"input": "", "output": "Unfortunately, the answer is probably not. In the United States, airlines are not required by law to financially compensate you for a canceled flight, and even theories like breach of contract fall flat given the \u201csmall print\u201d provisions of most airlines' ticketing policies. But, most airlines have policies in place to get you to your destination as quickly as possible and keep you comfortable while you wait."}], "is_classification": false}
144 | {"id": "seed_task_143", "name": "ask_for_law", "instruction": "Give me the laws that regulate the minimum wage for California, US.", "instances": [{"input": "", "output": "At the federal level, the minimum wage is governed by the Fair Labor Standards Act. \n\nFederal law currently sets the minimum wage at $7.25 per hour. \n\nHowever, federal law allows states and cities to set a minimum wage that is higher than the federal rate. 29 U.S.C. \u00a7 218(a).\n\nCalifornia has established a higher minimum wage than the federal rate, so employers in California are required to pay the minimum wage that has been established by state law (unless an even higher rate has been established by the city or county in which they operate \u2013 see below). Labor Code \u00a7 1182.12.\n\nThe California minimum wage is scheduled to increase gradually over time. As of 2022, the minum wage is $14.50 per hour."}], "is_classification": false}
145 | {"id": "seed_task_144", "name": "solve_equation_system", "instruction": "Solve the following equation system. Give me the final answer.", "instances": [{"input": "3x - 4y = 1, 2x + 3y = 12", "output": "x = 3, y = 2"}], "is_classification": false}
146 | {"id": "seed_task_145", "name": "plan_syllabus", "instruction": "Plan a syllabus for the the class.", "instances": [{"input": "Class: NLP for PhD students.", "output": "1. Instroduction and Logistics\n2. Machine Learning Basics and Concepts\n3. Language Modeling\n4. Vector Embeddings\n5. Morphology\n6. Sequence Labeling and Conditional Random Fields\n7. Syntax, Semantics and Linguistic Structure Prediction\n8. Translation and Sequence-to-Sequence Models\n9. Invited Lecture and Finale"}], "is_classification": false}
147 | {"id": "seed_task_146", "name": "university_ranking", "instruction": "Rank the following universities.", "instances": [{"input": "Princeton, Stanford, UW, Cornell", "output": "According to the US News 2022 National University Rankings, Princeton > Stanford > Cornell > UW. But the ranking is quite subjective, and might change depending on different factors."}], "is_classification": false}
148 | {"id": "seed_task_147", "name": "rank_countries_by_population", "instruction": "Rank these countries by their population.", "instances": [{"input": "Brazil, China, US, Japan, Canada, Australia", "output": "China, US, Brazil, Japan, Canada, Australia"}], "is_classification": false}
149 | {"id": "seed_task_148", "name": "pos_tag_for_word", "instruction": "Identify the pos tag of the word in the given sentence.", "instances": [{"input": "Word: excited\nSentence: She felt so excited that her application got approval.", "output": "Adjective, JJ."}], "is_classification": true}
150 | {"id": "seed_task_149", "name": "stereotype_explanation", "instruction": "Given a sentence, detect if there is any potential stereotype in it. If so, you should explain the stereotype. Else, output no.", "instances": [{"input": "The next US president should be white.", "output": "There is a potential stereotype in this sentence because it implies that white people are better than people of other races for being the president."}], "is_classification": false}
151 | {"id": "seed_task_150", "name": "paraphrasing_classification", "instruction": "In this task, you need to compare the meaning of the two sentences and tell if they are the same. Output yes or no.", "instances": [{"input": "Sentence 1: The teacher is speaking to the class.\nSentence 2: The teacher is speaking to the students.", "output": "yes"}], "is_classification": true}
152 | {"id": "seed_task_151", "name": "toxic_sentence_detection", "instruction": "Tell if the sentence contains toxic language.", "instances": [{"input": "aw, no wonder she married you. you are a bastard.", "output": "Yes"}], "is_classification": true}
153 | {"id": "seed_task_152", "name": "ethicality_judgement", "instruction": "Tell me whether the behavior is ethical or not. Output \"ethical\" or \"not ethical\".", "instances": [{"input": "Turn off the door when I am in the office.", "output": "ethical"}], "is_classification": true}
154 | {"id": "seed_task_153", "name": "job_suitableness", "instruction": "Given my personality and the job, tell me if I would be suitable.", "instances": [{"input": "Personality: I am easygoing and like to talk to people. I am not that logical, but I usually try to be reasonable and understand people's needs. When hanging out, I am usually considerate.\nJob: programmer.", "output": "Not suitable."}], "is_classification": true}
155 | {"id": "seed_task_154", "name": "passive-aggressiveness_identification", "instruction": "Identify if the following instance is passive-aggressive or not. Output 1 for passive-aggressive, and 0 for not.", "instances": [{"input": "You\u2019re so lucky you got that promotion", "output": "1"}], "is_classification": true}
156 | {"id": "seed_task_155", "name": "syllogism", "instruction": "Decide whether the syllogism is logically sound.", "instances": [{"input": "All Germans are European.\nSome Germans have blonde hair.\nTherefore, no Europeans have blonde hair.", "output": "Not logically sound."}], "is_classification": true}
157 | {"id": "seed_task_156", "name": "topic_classification", "instruction": "Choose a topic for the following article. Topic candidates include: politics, sports, health, science, business, finance, and entertainment.", "instances": [{"input": "Whales are a widely distributed and diverse group of fully aquatic placental marine mammals. They are an informal grouping within the infraorder Cetacea, which usually excludes dolphins and porpoises. Whales, dolphins and porpoises belong to the order Cetartiodactyla, which consists of even-toed ungulates. Their closest non-cetacean living relatives are the hippopotamuses, from which they and other cetaceans diverged about 54 million years ago. The two parvorders of whales, baleen whales (Mysticeti) and toothed whales (Odontoceti), are thought to have had their last common ancestor around 34 million years ago. Whales consist of eight extant families: Balaenopteridae (the rorquals), Balaenidae (right whales), Cetotheriidae (the pygmy right whale), Eschrichtiidae (the grey whale), Monodontidae (belugas and narwhals), Physeteridae (the sperm whale), Kogiidae (the dwarf and pygmy sperm whale), and Ziphiidae (the beaked whales).", "output": "science"}], "is_classification": true}
158 | {"id": "seed_task_157", "name": "sentence_sentiment", "instruction": "Classify the sentiment of the sentence into positive, negative or mixed.", "instances": [{"input": "I enjoy the flavor of the restaurant but their service is too slow.", "output": "mixed"}], "is_classification": true}
159 | {"id": "seed_task_158", "name": "code_syntax_error", "instruction": "You need to read a code and detect if there is a syntax error or not. Outpus true if there is error, output false if there is not.", "instances": [{"input": "def quick_sort(arr):\n if len(arr) < 2:\n return arr\n else:\n pivot = arr[0]\n less = [i for i in arr[1:] if i <= pivot]\n greater = [i for i in arr[1:] if i > pivot]\n return quick_sort(less) + [pivot] + quick_sort(greater)", "output": "false"}], "is_classification": true}
160 | {"id": "seed_task_159", "name": "user_intent_identification", "instruction": "Predict the intent of the user given the utterance. Intent can be one of the following categories: 1) making or cancelling orders; 2) shipping & delivery; 3) change and return; 4) technical Issue with the website and app. Output 1 - 4 for each category.", "instances": [{"input": "Hi there, I had an order yesterday and I got an email saying the product has been shipped this morning. But I cannot track it on USPS, can you tell me how to do that?", "output": "2"}], "is_classification": true}
161 | {"id": "seed_task_160", "name": "fact_verification", "instruction": "Tell me if the sentence is factually correct. Yes or no?", "instances": [{"input": "Mount Rainier is the second highest mountain in North America.", "output": "No"}], "is_classification": true}
162 | {"id": "seed_task_161", "name": "multipe_choice_qa", "instruction": "Answer the following multiple choice question. Select A, B, C, or D for the final answer.", "instances": [{"input": "Which company has its hq in Singapore?\n(A) Alibaba\n(B) TSMC\n(C) Salesforce\n(D) Shopee", "output": "D"}], "is_classification": true}
163 | {"id": "seed_task_162", "name": "most_relevant_passage", "instruction": "Given a user query, find out which of the following passages contains the answer to the query. Output the passage index.", "instances": [{"input": "Query: the best season to travel in Turkey\nPassages:\n1) Whether you\u2019re planning your Australian holiday around the weather, or want to travel when things are most affordable, here\u2019s the rundown on the best times to visit Australia.\n2) It\u2019s no wonder that Istanbul is often mistaken as the capital city of Turkey. It is the largest city, and the city\u2019s total area keeps expanding due to the population increase. It\u2019s the city of business. It\u2019s also the historic center of different empires, and it\u2019s the only city in the world on two continents: Europe and Asia.\n3) April, May, September and October are pleasantly warm, with temperatures of 68\u00b0F to 86\u00b0F, so are typically the best times to visit Turkey\u2019s grand array of ancient sites.\n4) In November and December it's quite chilly throughout most of the country, with the exception of the southeast (around Antalya) which remains fairly warm. \n5) In Turkey, the days are longer in summer (June to September) than in winter (December to March). With up to about 15 hours, there are the longest days in June. The longest dark nights, on the other hand, are in winter. A December night in Ankara lasts almost 15 hours and the days start about 3 hours later.", "output": "3"}], "is_classification": true}
164 | {"id": "seed_task_163", "name": "oldest_person", "instruction": "Select the oldest person from the list.", "instances": [{"input": "George Washington, Confucius, Michael Jordan, Michelangelo", "output": "Confucious"}], "is_classification": true}
165 | {"id": "seed_task_164", "name": "largest_number", "instruction": "Find out the largest one from a set of numbers. Output the number directly.", "instances": [{"input": "{1001, 22, 500, -3999, 1e6, 85, -2e6}", "output": "1e6"}], "is_classification": true}
166 | {"id": "seed_task_165", "name": "spam_classification", "instruction": "Classify whether the following email is a spam or not. Output true or false.", "instances": [{"input": "Hello,\n\nWe assessed the 2015 payment structure as provided for under the term of emplyment and discovered that you are due for a salary raise starting August 2015. \n\nYou salary raise documents are enclosed below:\n\nAccess the documet here\n\nFaithfully,\nHuman Resources", "output": "true"}], "is_classification": true}
167 | {"id": "seed_task_166", "name": "promotion_identification", "instruction": "Tell me if the following email is a promotion email.", "instances": [{"input": "Subject: A $3.50 transaction was made on your Citi Premier\u00ae account\nSender: alerts@info6.citi.com\nContent:\nHi, XXX. The transaction made on your Citi Premier\u00ae account exceeded $0.00. The transaction details are listed below.\nAmount: $3.50\nCard Ending In\n6211\nMerchant\nBarron Restaurant Seattle\nDate\n05/12/2021\nTime\n03:29 PM ET", "output": "no"}], "is_classification": true}
168 | {"id": "seed_task_167", "name": "support_classification", "instruction": "Does the information in the document supports the claim? You can answer \"Support\" or \"Unsupport\".", "instances": [{"input": "Document: After a record-breaking run that saw mortgage rates plunge to all-time lows and home prices soar to new highs, the U.S. housing market finally is slowing. While demand and price gains are cooling, any correction is likely to be a modest one, housing economists and analysts say. No one expects price drops on the scale of the declines experienced during the Great Recession.\nClaim: The US housing market is going to crash soon.", "output": "Unsupport"}], "is_classification": true}
169 | {"id": "seed_task_168", "name": "news_impact_on_stock", "instruction": "Predict whether the news has positive impact or negative impact on the company stock price. Output positive, negative or neutral.", "instances": [{"input": "Tesla driver involved in a fatal crash in southern China earlier in November said the vehicle's brakes failed to respond for more than a mile, but the American automaker suggested he didn't use them at all. Chinese police said Sunday they were conducting further probes into the incident, which killed two people and injured three others in the county of Raoping, to the east of Chaozhou in Guangdong province, on November 5.\nCompany: Tesla.", "output": "negative"}], "is_classification": true}
170 | {"id": "seed_task_169", "name": "news_categories_multi_labels", "instruction": "You are provided with a news article, and you need to identify all the categories that this article belongs to. Possible categories include: Music, Sports, Politics, Tech, Finance, Basketball, Soccer, Tennis, Entertainment, Digital Game, World News. Output its categories one by one, seperated by comma.", "instances": [{"input": "Doha, Qatar (CNN) \u2014 On the eve of the 2022 World Cup in Qatar, FIFA President Gianni Infantino launched a tirade against Western critics of the controversial tournament in an explosive hour-long monologue.\n\nInfantino, the boss of world soccer\u2019s governing body, looked on glumly as he addressed hundreds of journalists in Doha, Qatar, Saturday.\n\n\u201cWe are taught many lessons from Europeans, from the Western world,\u201d he said, referring to criticisms of Qatar\u2019s human rights record.", "output": "Sports, Politics, Soccer, World News."}], "is_classification": true}
171 | {"id": "seed_task_170", "name": "longest_sentence", "instruction": "Select the longest sentence in terms of the number of words in the paragraph, output the sentence index.", "instances": [{"input": "(1) So what\u2019s Black Friday again? (2) If we\u2019re being honest, Black Friday is kind of like our Super Bowl. (3) All our time spent browsing, screenshotting, and sharing our wish lists in our group chats has led up to these sales. (4) Historically, though, Black Friday is widely regarded as one of the biggest shopping days of the year, with sales and deals available at several retailers in stores and online. (5) Black Friday has become more than scoring TVs and electronics.", "output": "4"}], "is_classification": true}
172 | {"id": "seed_task_171", "name": "dialogue_satisfaction", "instruction": "Given a dialogue, classify whether the user is satisfied with the service. You should respond with \"Satisfied\" or \"Unsatisfied\".", "instances": [{"input": "- Agent: I am sorry we will cancel that order for you, and you will get refund within 7 business days.\n- Customer: oh that takes too long. I want you to take quicker action on this.", "output": "Unsatisfied"}], "is_classification": true}
173 | {"id": "seed_task_172", "name": "hate_speech_detection", "instruction": "Detect if the Reddit thread contains hate speech.", "instances": [{"input": "r/worldnews\n\u2022Posted by u/madneon_\n3 hours ago\nRussia \u2018borrows $13.6bn in largest ever debt issuance in a single day\u2019 to continue faltering war\n\nmacross1984 \u00b7 3 hr. ago\nRussia will become deadbeat.\n\nthrowaway12313223123 \u00b7 2 hr. ago\nbecome...? They been for a while\n\nmrkikkeli \u00b7 27 min. ago\nPutin: \"better be a slave in hell than a - wait what's the quote again?\"", "output": "yes, the thread contains hate speech."}], "is_classification": true}
174 | {"id": "seed_task_173", "name": "democrats_or_republicans", "instruction": "Given some political opinions, classify whether the person belongs to Democrats or Republicans.", "instances": [{"input": "* Putting Kids First and Protecting Parents\u2019 Rights\n* Florida\u2019s Economy is Outpacing the Nation\n* Keeping Our Communities Safe\n* The Environment: Keeping Florida Beautiful\n* Protecting the Integrity of Our Elections\n* Standing Up for Moms and Florida Families\n* Florida: The Most Veteran-Friendly and Pro-Military State\n* Fighting Special Interests", "output": "Republicans"}], "is_classification": true}
175 | {"id": "seed_task_174", "name": "fact_checking", "instruction": "Fact checking - tell me if the statement is true, false, or unknown, based on your knowledge and common sense.", "instances": [{"input": "Philadelphia is among the top 10 safest cities in the US.", "output": "false"}], "is_classification": true}
176 |
--------------------------------------------------------------------------------
/train.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | import copy
16 | import logging
17 | import io
18 | import json
19 | from dataclasses import dataclass, field
20 | from typing import Optional, Dict, Sequence
21 |
22 | import torch
23 | import transformers
24 | from torch.utils.data import Dataset
25 | from transformers import Trainer
26 |
27 | IGNORE_INDEX = -100
28 | DEFAULT_PAD_TOKEN = "[PAD]"
29 | DEFAULT_EOS_TOKEN = ""
30 | DEFAULT_BOS_TOKEN = ""
31 | DEFAULT_UNK_TOKEN = ""
32 | PROMPT_DICT = {
33 | "prompt_input": (
34 | "Below is an instruction that describes a task, paired with an input that provides further context. "
35 | "Write a response that appropriately completes the request.\n\n"
36 | "### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:"
37 | ),
38 | "prompt_no_input": (
39 | "Below is an instruction that describes a task. "
40 | "Write a response that appropriately completes the request.\n\n"
41 | "### Instruction:\n{instruction}\n\n### Response:"
42 | ),
43 | }
44 |
45 |
46 | def _make_r_io_base(f, mode: str):
47 | if not isinstance(f, io.IOBase):
48 | f = open(f, mode=mode)
49 | return f
50 |
51 | def jload(f, mode="r"):
52 | """Load a .json file into a dictionary."""
53 | f = _make_r_io_base(f, mode)
54 | jdict = json.load(f)
55 | f.close()
56 | return jdict
57 |
58 | @dataclass
59 | class ModelArguments:
60 | model_name_or_path: Optional[str] = field(default="facebook/opt-125m")
61 | tokenizer_name_or_path: Optional[str] = field(default="facebook/opt-125m")
62 |
63 |
64 | @dataclass
65 | class DataArguments:
66 | data_path: str = field(default=None, metadata={"help": "Path to the training data."})
67 |
68 |
69 | @dataclass
70 | class TrainingArguments(transformers.TrainingArguments):
71 | cache_dir: Optional[str] = field(default=None)
72 | optim: str = field(default="adamw_torch")
73 | model_max_length: int = field(
74 | default=512,
75 | metadata={"help": "Maximum sequence length. Sequences will be right padded (and possibly truncated)."},
76 | )
77 |
78 |
79 | def safe_save_model_for_hf_trainer(trainer: transformers.Trainer, output_dir: str):
80 | """Collects the state dict and dump to disk."""
81 | state_dict = trainer.model.state_dict()
82 | if trainer.args.should_save:
83 | cpu_state_dict = {key: value.cpu() for key, value in state_dict.items()}
84 | del state_dict
85 | trainer._save(output_dir, state_dict=cpu_state_dict) # noqa
86 |
87 |
88 | def smart_tokenizer_and_embedding_resize(
89 | special_tokens_dict: Dict,
90 | tokenizer: transformers.PreTrainedTokenizer,
91 | model: transformers.PreTrainedModel,
92 | ):
93 | """Resize tokenizer and embedding.
94 |
95 | Note: This is the unoptimized version that may make your embedding size not be divisible by 64.
96 | """
97 | num_new_tokens = tokenizer.add_special_tokens(special_tokens_dict)
98 | model.resize_token_embeddings(len(tokenizer))
99 |
100 | if num_new_tokens > 0:
101 | input_embeddings = model.get_input_embeddings().weight.data
102 | output_embeddings = model.get_output_embeddings().weight.data
103 |
104 | input_embeddings_avg = input_embeddings[:-num_new_tokens].mean(dim=0, keepdim=True)
105 | output_embeddings_avg = output_embeddings[:-num_new_tokens].mean(dim=0, keepdim=True)
106 |
107 | input_embeddings[-num_new_tokens:] = input_embeddings_avg
108 | output_embeddings[-num_new_tokens:] = output_embeddings_avg
109 |
110 |
111 | def _tokenize_fn(strings: Sequence[str], tokenizer: transformers.PreTrainedTokenizer) -> Dict:
112 | """Tokenize a list of strings."""
113 | tokenized_list = [
114 | tokenizer(
115 | text,
116 | return_tensors="pt",
117 | padding="longest",
118 | max_length=tokenizer.model_max_length,
119 | truncation=True,
120 | )
121 | for text in strings
122 | ]
123 | input_ids = labels = [tokenized.input_ids[0] for tokenized in tokenized_list]
124 | input_ids_lens = labels_lens = [
125 | tokenized.input_ids.ne(tokenizer.pad_token_id).sum().item() for tokenized in tokenized_list
126 | ]
127 | return dict(
128 | input_ids=input_ids,
129 | labels=labels,
130 | input_ids_lens=input_ids_lens,
131 | labels_lens=labels_lens,
132 | )
133 |
134 |
135 | def preprocess(
136 | sources: Sequence[str],
137 | targets: Sequence[str],
138 | tokenizer: transformers.PreTrainedTokenizer,
139 | ) -> Dict:
140 | """Preprocess the data by tokenizing."""
141 | examples = [s + t for s, t in zip(sources, targets)]
142 | examples_tokenized, sources_tokenized = [_tokenize_fn(strings, tokenizer) for strings in (examples, sources)]
143 | input_ids = examples_tokenized["input_ids"]
144 | labels = copy.deepcopy(input_ids)
145 | for label, source_len in zip(labels, sources_tokenized["input_ids_lens"]):
146 | label[:source_len] = IGNORE_INDEX
147 | return dict(input_ids=input_ids, labels=labels)
148 |
149 |
150 | class SupervisedDataset(Dataset):
151 | """Dataset for supervised fine-tuning."""
152 |
153 | def __init__(self, data_path: str, tokenizer: transformers.PreTrainedTokenizer):
154 | super(SupervisedDataset, self).__init__()
155 | logging.warning("Loading data...")
156 | list_data_dict = jload(data_path)
157 |
158 | logging.warning("Formatting inputs...")
159 | prompt_input, prompt_no_input = PROMPT_DICT["prompt_input"], PROMPT_DICT["prompt_no_input"]
160 | sources = [
161 | prompt_input.format_map(example) if example.get("input", "") != "" else prompt_no_input.format_map(example)
162 | for example in list_data_dict
163 | ]
164 | targets = [f"{example['output']}{tokenizer.eos_token}" for example in list_data_dict]
165 |
166 | logging.warning("Tokenizing inputs... This may take some time...")
167 | data_dict = preprocess(sources, targets, tokenizer)
168 |
169 | self.input_ids = data_dict["input_ids"]
170 | self.labels = data_dict["labels"]
171 |
172 | def __len__(self):
173 | return len(self.input_ids)
174 |
175 | def __getitem__(self, i) -> Dict[str, torch.Tensor]:
176 | return dict(input_ids=self.input_ids[i], labels=self.labels[i])
177 |
178 |
179 | @dataclass
180 | class DataCollatorForSupervisedDataset(object):
181 | """Collate examples for supervised fine-tuning."""
182 |
183 | tokenizer: transformers.PreTrainedTokenizer
184 |
185 | def __call__(self, instances: Sequence[Dict]) -> Dict[str, torch.Tensor]:
186 | input_ids, labels = tuple([instance[key] for instance in instances] for key in ("input_ids", "labels"))
187 | input_ids = torch.nn.utils.rnn.pad_sequence(
188 | input_ids, batch_first=True, padding_value=self.tokenizer.pad_token_id
189 | )
190 | labels = torch.nn.utils.rnn.pad_sequence(labels, batch_first=True, padding_value=IGNORE_INDEX)
191 | return dict(
192 | input_ids=input_ids,
193 | labels=labels,
194 | attention_mask=input_ids.ne(self.tokenizer.pad_token_id),
195 | )
196 |
197 |
198 | def make_supervised_data_module(tokenizer: transformers.PreTrainedTokenizer, data_args) -> Dict:
199 | """Make dataset and collator for supervised fine-tuning."""
200 | train_dataset = SupervisedDataset(tokenizer=tokenizer, data_path=data_args.data_path)
201 | data_collator = DataCollatorForSupervisedDataset(tokenizer=tokenizer)
202 | return dict(train_dataset=train_dataset, eval_dataset=None, data_collator=data_collator)
203 |
204 |
205 | def train():
206 | parser = transformers.HfArgumentParser((ModelArguments, DataArguments, TrainingArguments))
207 | model_args, data_args, training_args = parser.parse_args_into_dataclasses()
208 |
209 | model = transformers.AutoModelForCausalLM.from_pretrained(
210 | model_args.model_name_or_path,
211 | cache_dir=training_args.cache_dir,
212 | )
213 |
214 | tokenizer = transformers.AutoTokenizer.from_pretrained(
215 | model_args.tokenizer_name_or_path,
216 | cache_dir=training_args.cache_dir,
217 | model_max_length=training_args.model_max_length,
218 | padding_side="right",
219 | use_fast=False,
220 | )
221 | if tokenizer.pad_token is None:
222 | smart_tokenizer_and_embedding_resize(
223 | special_tokens_dict=dict(pad_token=DEFAULT_PAD_TOKEN),
224 | tokenizer=tokenizer,
225 | model=model,
226 | )
227 | if "llama" in model_args.model_name_or_path:
228 | tokenizer.add_special_tokens(
229 | {
230 | "eos_token": DEFAULT_EOS_TOKEN,
231 | "bos_token": DEFAULT_BOS_TOKEN,
232 | "unk_token": DEFAULT_UNK_TOKEN,
233 | }
234 | )
235 |
236 | data_module = make_supervised_data_module(tokenizer=tokenizer, data_args=data_args)
237 | trainer = Trainer(model=model, tokenizer=tokenizer, args=training_args, **data_module)
238 | trainer.train()
239 | trainer.save_state()
240 | safe_save_model_for_hf_trainer(trainer=trainer, output_dir=training_args.output_dir)
241 |
242 |
243 | if __name__ == "__main__":
244 | train()
245 |
--------------------------------------------------------------------------------
/train_model.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | torchrun --nproc_per_node=4 --master_port=9292 train.py \
4 | --model_name_or_path /src/weights/llama-7b \
5 | --tokenizer_name_or_path /src/weights/tokenizer \
6 | --data_path ./alpaca_data.json \
7 | --bf16 True \
8 | --output_dir alpaca_out \
9 | --num_train_epochs 3 \
10 | --per_device_train_batch_size 4 \
11 | --per_device_eval_batch_size 4 \
12 | --gradient_accumulation_steps 8 \
13 | --evaluation_strategy "no" \
14 | --save_strategy "steps" \
15 | --save_steps 2000 \
16 | --learning_rate 2e-5 \
17 | --weight_decay 0. \
18 | --warmup_ratio 0.03 \
19 | --lr_scheduler_type "cosine" \
20 | --logging_steps 1 \
21 | --fsdp "full_shard auto_wrap" \
22 | --fsdp_transformer_layer_cls_to_wrap 'LLaMADecoderLayer' \
23 | --tf32 True \
24 |
--------------------------------------------------------------------------------
/utils.py:
--------------------------------------------------------------------------------
1 | import dataclasses
2 | import logging
3 | import math
4 | import os
5 | import io
6 | import sys
7 | import time
8 | import json
9 | from typing import Optional, Sequence, Union
10 |
11 | import openai
12 | import tqdm
13 | from openai import openai_object
14 | import copy
15 |
16 | StrOrOpenAIObject = Union[str, openai_object.OpenAIObject]
17 |
18 | openai_org = os.getenv("OPENAI_ORG")
19 | if openai_org is not None:
20 | openai.organization = openai_org
21 | logging.warning(f"Switching to organization: {openai_org} for OAI API key.")
22 |
23 |
24 | @dataclasses.dataclass
25 | class OpenAIDecodingArguments(object):
26 | max_tokens: int = 1800
27 | temperature: float = 0.2
28 | top_p: float = 1.0
29 | n: int = 1
30 | stream: bool = False
31 | stop: Optional[Sequence[str]] = None
32 | presence_penalty: float = 0.0
33 | frequency_penalty: float = 0.0
34 | suffix: Optional[str] = None
35 | logprobs: Optional[int] = None
36 | echo: bool = False
37 |
38 |
39 | def openai_completion(
40 | prompts: Union[str, Sequence[str], Sequence[dict[str, str]], dict[str, str]],
41 | decoding_args: OpenAIDecodingArguments,
42 | model_name="text-davinci-003",
43 | sleep_time=2,
44 | batch_size=1,
45 | max_instances=sys.maxsize,
46 | max_batches=sys.maxsize,
47 | return_text=False,
48 | **decoding_kwargs,
49 | ) -> Union[Union[StrOrOpenAIObject], Sequence[StrOrOpenAIObject], Sequence[Sequence[StrOrOpenAIObject]],]:
50 | """Decode with OpenAI API.
51 |
52 | Args:
53 | prompts: A string or a list of strings to complete. If it is a chat model the strings should be formatted
54 | as explained here: https://github.com/openai/openai-python/blob/main/chatml.md. If it is a chat model
55 | it can also be a dictionary (or list thereof) as explained here:
56 | https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb
57 | decoding_args: Decoding arguments.
58 | model_name: Model name. Can be either in the format of "org/model" or just "model".
59 | sleep_time: Time to sleep once the rate-limit is hit.
60 | batch_size: Number of prompts to send in a single request. Only for non chat model.
61 | max_instances: Maximum number of prompts to decode.
62 | max_batches: Maximum number of batches to decode. This argument will be deprecated in the future.
63 | return_text: If True, return text instead of full completion object (which contains things like logprob).
64 | decoding_kwargs: Additional decoding arguments. Pass in `best_of` and `logit_bias` if you need them.
65 |
66 | Returns:
67 | A completion or a list of completions.
68 | Depending on return_text, return_openai_object, and decoding_args.n, the completion type can be one of
69 | - a string (if return_text is True)
70 | - an openai_object.OpenAIObject object (if return_text is False)
71 | - a list of objects of the above types (if decoding_args.n > 1)
72 | """
73 | is_single_prompt = isinstance(prompts, (str, dict))
74 | if is_single_prompt:
75 | prompts = [prompts]
76 |
77 | if max_batches < sys.maxsize:
78 | logging.warning(
79 | "`max_batches` will be deprecated in the future, please use `max_instances` instead."
80 | "Setting `max_instances` to `max_batches * batch_size` for now."
81 | )
82 | max_instances = max_batches * batch_size
83 |
84 | prompts = prompts[:max_instances]
85 | num_prompts = len(prompts)
86 | prompt_batches = [
87 | prompts[batch_id * batch_size : (batch_id + 1) * batch_size]
88 | for batch_id in range(int(math.ceil(num_prompts / batch_size)))
89 | ]
90 |
91 | completions = []
92 | for batch_id, prompt_batch in tqdm.tqdm(
93 | enumerate(prompt_batches),
94 | desc="prompt_batches",
95 | total=len(prompt_batches),
96 | ):
97 | batch_decoding_args = copy.deepcopy(decoding_args) # cloning the decoding_args
98 |
99 | while True:
100 | try:
101 | shared_kwargs = dict(
102 | model=model_name,
103 | **batch_decoding_args.__dict__,
104 | **decoding_kwargs,
105 | )
106 | completion_batch = openai.Completion.create(prompt=prompt_batch, **shared_kwargs)
107 | choices = completion_batch.choices
108 |
109 | for choice in choices:
110 | choice["total_tokens"] = completion_batch.usage.total_tokens
111 | completions.extend(choices)
112 | break
113 | except openai.error.OpenAIError as e:
114 | logging.warning(f"OpenAIError: {e}.")
115 | if "Please reduce your prompt" in str(e):
116 | batch_decoding_args.max_tokens = int(batch_decoding_args.max_tokens * 0.8)
117 | logging.warning(f"Reducing target length to {batch_decoding_args.max_tokens}, Retrying...")
118 | else:
119 | logging.warning("Hit request rate limit; retrying...")
120 | time.sleep(sleep_time) # Annoying rate limit on requests.
121 |
122 | if return_text:
123 | completions = [completion.text for completion in completions]
124 | if decoding_args.n > 1:
125 | # make completions a nested list, where each entry is a consecutive decoding_args.n of original entries.
126 | completions = [completions[i : i + decoding_args.n] for i in range(0, len(completions), decoding_args.n)]
127 | if is_single_prompt:
128 | # Return non-tuple if only 1 input and 1 generation.
129 | (completions,) = completions
130 | return completions
131 |
132 |
133 | def _make_w_io_base(f, mode: str):
134 | if not isinstance(f, io.IOBase):
135 | f_dirname = os.path.dirname(f)
136 | if f_dirname != "":
137 | os.makedirs(f_dirname, exist_ok=True)
138 | f = open(f, mode=mode)
139 | return f
140 |
141 |
142 | def _make_r_io_base(f, mode: str):
143 | if not isinstance(f, io.IOBase):
144 | f = open(f, mode=mode)
145 | return f
146 |
147 |
148 | def jdump(obj, f, mode="w", indent=4, default=str):
149 | """Dump a str or dictionary to a file in json format.
150 |
151 | Args:
152 | obj: An object to be written.
153 | f: A string path to the location on disk.
154 | mode: Mode for opening the file.
155 | indent: Indent for storing json dictionaries.
156 | default: A function to handle non-serializable entries; defaults to `str`.
157 | """
158 | f = _make_w_io_base(f, mode)
159 | if isinstance(obj, (dict, list)):
160 | json.dump(obj, f, indent=indent, default=default)
161 | elif isinstance(obj, str):
162 | f.write(obj)
163 | else:
164 | raise ValueError(f"Unexpected type: {type(obj)}")
165 | f.close()
166 |
167 |
168 | def jload(f, mode="r"):
169 | """Load a .json file into a dictionary."""
170 | f = _make_r_io_base(f, mode)
171 | jdict = json.load(f)
172 | f.close()
173 | return jdict
174 |
--------------------------------------------------------------------------------