lewtun HF staff commited on
Commit
958473e
β€’
1 Parent(s): dac027d

Add template files

Browse files
README.md ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SUPERB Submission Template
2
+
3
+ Welcome to the [SUPERB benchmark](https://superbbenchmark.org)! SUPERB is a collection of benchmarking resources to evaluate the capability of a universal shared representation for speech processing. SUPERB consists of the following:
4
+
5
+ 1. A benchmark of ten speech processing tasks built on established public datasets
6
+ 2. A benchmark toolkit designed to evaluate and analyze pretrained model performance on various downstream tasks following the conventional evaluation protocols from speech communities
7
+ 3. A public leaderboard for submission and performance tracking on the benchmark
8
+
9
+ SUPERB aims to offer the community a standard and comprehensive framework to train, evaluate, and compare the generalizability of universal speech representations on speech processing tasks. A universal speech representation can be leveraged to quickly adapt to diverse downstream tasks with minimum architectural change and downstream fine-tuning, so as to reduce the model development cycle time for new tasks. To emphasize on evaluating the quality of the learned universal representation, SUPERB puts an explicit constraint on the downstream model and limits its parameter size.
10
+
11
+ The ultimate goal of SUPERB is to democratize the advancement in speech processing with powerful, generalizable, and reusable speech representations. SUPERB is a long-term maintained and continuously developing project. As we are gradually releasing new tasks and opening new tracks, we invite researchers to participate in the challenge and advance the research frontier together.
12
+
13
+ This repository can be used to generate a template so you can submit your predictions for evaluation on [the leaderboard](https://huggingface.co/spaces/superb/superb-leaderboard).
14
+
15
+ ## Quickstart
16
+
17
+ ### 1. Create an account and organisation on the Hugging Face Hub
18
+
19
+ First create an account on the Hugging Face Hub and you can sign up [here](https://huggingface.co/join) if you haven't already! Next, create a a new organisation for your submissions and invite the following benchmark organisers join it:
20
+
21
+ * Shu-wen (Leo) Yang: [leo19941227](https://huggingface.co/leo19941227)
22
+
23
+ ### 2. Create a template repository on your machine
24
+
25
+ The next step is to create a template repository on your local machine that contains various files and a CLI to help you validate and submit your pretrained models. The Hugging Face Hub uses [Git Large File Storage (LFS)](https://git-lfs.github.com) to manage large files, so first install it if you don't have it already. For example, on macOS you can run:
26
+
27
+ ```bash
28
+ brew install git-lfs
29
+ git lfs install
30
+ ```
31
+
32
+ Next, run the following commands to create the repository. We recommend creating a Python virtual environment for the project, e.g. with Anaconda:
33
+
34
+ ```bash
35
+ # Create and activate a virtual environment
36
+ conda create -n superb python=3.8 && conda activate superb
37
+ # Install the following libraries
38
+ pip install cookiecutter huggingface-hub==0.0.16
39
+ # Create the template repository
40
+ cookiecutter git+https://huggingface.co/superb/superb-submission
41
+ ```
42
+
43
+ This will ask you to specify your Hugging Face Hub username, password, organisation, and the name of the repository:
44
+
45
+ ```
46
+ hf_hub_username [<huggingface>]:
47
+ hf_hub_password [<password>]:
48
+ hf_hub_organisation [superb-submissions]:
49
+ repo_name [<my-superb-submissions>]:
50
+ ```
51
+
52
+ This will trigger the following steps:
53
+
54
+ 1. Create a private dataset repository on the Hugging Face Hub under `{hf_hub_organisation}/{repo_name}`
55
+ 2. Clone the repository to your local machine
56
+ 3. Add various template files, commit them locally to the repository, and push them to the Hub
57
+
58
+ The resulting repository should have the following structure:
59
+
60
+ ```
61
+ my-superb-submission
62
+ β”œβ”€β”€ LICENSE
63
+ β”œβ”€β”€ README.md <- The README with submission instructions
64
+ β”œβ”€β”€ cli.py <- The CLI for validating predictions etc
65
+ └── requirements.txt <- The requirements file for the submissions
66
+ ```
67
+
68
+ ### 3. Install the dependencies
69
+
70
+ The final step is to install the project's dependencies:
71
+
72
+ ```bash
73
+ # Navigate to the template repository
74
+ cd my-superb-submission
75
+ # Install dependencies
76
+ python -m pip install -r requirements.txt
77
+ ```
78
+
79
+ That's it! You're now all set to start pretraining your speech models - see the instructions below on how to submit them to the Hub.
80
+
81
+
82
+ ## Submitting to the leaderboard
83
+
84
+ To make a submission to the [leaderboard](https://huggingface.co/spaces/superb/superb-leaderboard)), there are three main steps:
85
+
86
+ 1. Generate predictions on the unlabeled test set of each task
87
+ 2. Validate the predictions are compatible with the evaluation framework
88
+ 3. Push the predictions to the Hub!
89
+
90
+ See the instructions below for more details.
91
+
92
+ ### Rules
93
+
94
+ 1. To prevent overfitting to the public leaderboard, we only evaluate **one submission per week**. You can push predictions to the Hub as many times as you wish, but we will only evaluate the most recent commit in a given week.
95
+ 2. Transfer or meta-learning using other datasets, including further pre-training on other corpora, is allowed.
96
+ 3. Use of unlabeled test data is allowed, as is it always available in the applied setting. For example, further pre-training using the unlabeled data for a task would be permitted.
97
+ 4. Systems may be augmented with information retrieved from the internet, e.g. via automated web searches.
98
+
99
+ ### Submission file format
100
+
101
+ ### Validate your submission
102
+
103
+ To ensure that your submission files are correctly formatted, run the following command from the root of the repository:
104
+
105
+ ```
106
+ python cli.py validate
107
+ ```
108
+
109
+ If everything is correct, you should see the following message:
110
+
111
+ ```
112
+ All submission files validated! ✨ πŸš€ ✨
113
+ Now you can make a submission πŸ€—
114
+ ```
115
+
116
+ ### Push your submission to the Hugging Face Hub!
117
+
118
+ The final step is to commit your files and push them to the Hub:
119
+
120
+ ```
121
+ python cli.py submit
122
+ ```
123
+
124
+ If there are no errors, you should see the following message:
125
+
126
+ ```
127
+ Submission successful! πŸŽ‰ πŸ₯³ πŸŽ‰
128
+ Your submission will be fine-tuned and evaulated on Sunday 05 September 2021 ⏳
129
+ ```
130
+
131
+ where the evaluation is run every Sunday and your results will be visible on the leaderboard.
cookiecutter.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "hf_hub_username": "huggingface",
3
+ "hf_hub_password": "password",
4
+ "hf_hub_organisation": "superb-submissions",
5
+ "repo_name": "my-superb-submission"
6
+ }
hooks/post_gen_project.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import subprocess
2
+
3
+ subprocess.call("git pull origin main".split())
4
+ subprocess.call(["git", "add", "."])
5
+ subprocess.call(["git", "commit", "-m", "Add template files"])
6
+ subprocess.call("git push origin main".split())
hooks/pre_gen_project.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import HfApi, HfFolder, Repository
2
+
3
+ hf_user = "{{cookiecutter.hf_hub_username}}"
4
+ hf_password = "{{cookiecutter.hf_hub_password}}"
5
+ hf_org = "{{cookiecutter.hf_hub_organisation}}"
6
+ huggingface_token = HfApi().login(username=hf_user, password=hf_password)
7
+ HfFolder.save_token(huggingface_token)
8
+
9
+ repo_url = HfApi().create_repo(
10
+ token=huggingface_token,
11
+ name="{{cookiecutter.repo_name}}",
12
+ organization=hf_org,
13
+ exist_ok=True,
14
+ private=True
15
+ )
16
+
17
+ model_repo = Repository(local_dir=".", clone_from=repo_url, use_auth_token=huggingface_token)
18
+ model_repo.add_file("README.md")
{{cookiecutter.repo_name}}/.gitignore ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
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
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
98
+ __pypackages__/
99
+
100
+ # Celery stuff
101
+ celerybeat-schedule
102
+ celerybeat.pid
103
+
104
+ # SageMath parsed files
105
+ *.sage.py
106
+
107
+ # Environments
108
+ .env
109
+ .venv
110
+ env/
111
+ venv/
112
+ ENV/
113
+ env.bak/
114
+ venv.bak/
115
+
116
+ # Spyder project settings
117
+ .spyderproject
118
+ .spyproject
119
+
120
+ # Rope project settings
121
+ .ropeproject
122
+
123
+ # mkdocs documentation
124
+ /site
125
+
126
+ # mypy
127
+ .mypy_cache/
128
+ .dmypy.json
129
+ dmypy.json
130
+
131
+ # Pyre type checker
132
+ .pyre/
133
+
134
+ # pytype static type analyzer
135
+ .pytype/
136
+
137
+ # Cython debug symbols
138
+ cython_debug/
139
+
140
+ # Datasets file locks
141
+ *.lock
{{cookiecutter.repo_name}}/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 [yyyy] [name of copyright owner]
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.
{{cookiecutter.repo_name}}/README.md ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ benchmark: superb
3
+ type: model-upload
4
+ submission_nme: none
5
+ ---
6
+
7
+ # SUPERB submissions for {{cookiecutter.repo_name}}
8
+
9
+ ## Submitting to the leaderboard
10
+
11
+ To make a submission to the [leaderboard](https://huggingface.co/spaces/superb/superb-leaderboard)), there are three main steps:
12
+
13
+ 1. Generate predictions on the unlabeled test set of each task
14
+ 2. Validate the predictions are compatible with the evaluation framework
15
+ 3. Push the predictions to the Hub!
16
+
17
+ See the instructions below for more details.
18
+
19
+ ### Rules
20
+
21
+ 1. To prevent overfitting to the public leaderboard, we only evaluate **one submission per week**. You can push predictions to the Hub as many times as you wish, but we will only evaluate the most recent commit in a given week.
22
+ 2. Transfer or meta-learning using other datasets, including further pre-training on other corpora, is allowed.
23
+ 3. Use of unlabeled test data is allowed, as is it always available in the applied setting. For example, further pre-training using the unlabeled data for a task would be permitted.
24
+ 4. Systems may be augmented with information retrieved from the internet, e.g. via automated web searches.
25
+
26
+ ### Submission file format
27
+
28
+ ### Validate your submission
29
+
30
+ To ensure that your submission files are correctly formatted, run the following command from the root of the repository:
31
+
32
+ ```
33
+ python cli.py validate
34
+ ```
35
+
36
+ If everything is correct, you should see the following message:
37
+
38
+ ```
39
+ All submission files validated! ✨ πŸš€ ✨
40
+ Now you can make a submission πŸ€—
41
+ ```
42
+
43
+ ### Push your submission to the Hugging Face Hub!
44
+
45
+ The final step is to commit your files and push them to the Hub:
46
+
47
+ ```
48
+ python cli.py submit
49
+ ```
50
+
51
+ If there are no errors, you should see the following message:
52
+
53
+ ```
54
+ Submission successful! πŸŽ‰ πŸ₯³ πŸŽ‰
55
+ Your submission will be fine-tuned and evaulated on Sunday 05 September 2021 ⏳
56
+ ```
57
+
58
+ where the evaluation is run every Sunday and your results will be visible on the leaderboard.
{{cookiecutter.repo_name}}/cli.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datetime
2
+ import re
3
+ import subprocess
4
+ from pathlib import Path
5
+
6
+ import pandas as pd
7
+ import typer
8
+ from datasets import get_dataset_config_names, load_dataset
9
+
10
+ CSV_SCHEMA = {
11
+ "banking_77": (5000, 2),
12
+ "overruling": (2350, 2),
13
+ "semiconductor_org_types": (449, 2),
14
+ "ade_corpus_v2": (5000, 2),
15
+ "twitter_complaints": (3399, 2),
16
+ "neurips_impact_statement_risks": (150, 2),
17
+ "systematic_review_inclusion": (2244, 2),
18
+ "terms_of_service": (5000, 2),
19
+ "tai_safety_research": (1639, 2),
20
+ "one_stop_english": (518, 2),
21
+ "tweet_eval_hate": (2966, 2),
22
+ }
23
+
24
+ app = typer.Typer()
25
+
26
+
27
+ def _update_submission_name(submission_name: str):
28
+ replacement = ""
29
+ with open("README.md", "r") as f:
30
+ lines = f.readlines()
31
+
32
+ for line in lines:
33
+ if line.startswith("submission_name:"):
34
+ changes = re.sub(r"submission_name:.+", f"submission_name: {submission_name}", line)
35
+ replacement += changes
36
+ else:
37
+ replacement += line
38
+
39
+ with open("README.md", "w") as f:
40
+ f.write(replacement)
41
+
42
+
43
+ @app.command()
44
+ def validate():
45
+ # TODO(lewtun): Consider using great_expectations for the data validation
46
+ tasks = get_dataset_config_names("ought/raft")
47
+
48
+ # Check that all the expected files exist
49
+ prediction_files = list(Path("data").rglob("predictions.csv"))
50
+ mismatched_files = set(tasks).symmetric_difference(set([f.parent.name for f in prediction_files]))
51
+ if mismatched_files:
52
+ raise ValueError(f"Incorrect number of files! Expected {len(tasks)} files, but got {len(prediction_files)}.")
53
+
54
+ # Check all files have the expected shape (number of rows, number of columns)
55
+ # TODO(lewtun): Add a check for the specific IDs per file
56
+ shape_errors = []
57
+ column_errors = []
58
+ for prediction_file in prediction_files:
59
+ df = pd.read_csv(prediction_file)
60
+ incorrect_shape = df.shape != CSV_SCHEMA[prediction_file.parent.name]
61
+ if incorrect_shape:
62
+ shape_errors.append(prediction_file)
63
+ incorrect_columns = sorted(df.columns) != ["ID", "Label"]
64
+ if incorrect_columns:
65
+ column_errors.append(prediction_file)
66
+
67
+ if shape_errors:
68
+ raise ValueError(f"Incorrect CSV shapes in files: {shape_errors}")
69
+
70
+ if column_errors:
71
+ raise ValueError(f"Incorrect CSV columns in files: {column_errors}")
72
+
73
+ # Check we can load the dataset for each task
74
+ load_errors = []
75
+ for task in tasks:
76
+ try:
77
+ _ = load_dataset("../{{cookiecutter.repo_name}}", task)
78
+ except Exception as e:
79
+ load_errors.append(e)
80
+
81
+ if load_errors:
82
+ raise ValueError(f"Could not load predictions! Errors: {load_errors}")
83
+
84
+ typer.echo("All submission files validated! ✨ πŸš€ ✨")
85
+ typer.echo("Now you can make a submission πŸ€—")
86
+
87
+
88
+ @app.command()
89
+ def submit(submission_name: str = typer.Option(..., prompt="Please provide a name for your submission, e.g. GPT-4 😁")):
90
+ subprocess.call("git pull origin main".split())
91
+ _update_submission_name(submission_name)
92
+ subprocess.call(["git", "add", "data/*predictions.csv", "README.md"])
93
+ subprocess.call(["git", "commit", "-m", f"Submission: {submission_name} "])
94
+ subprocess.call(["git", "push"])
95
+
96
+ today = datetime.date.today()
97
+ # MON = 0, SUN = 6 -> SUN = 0 .. SAT = 6
98
+ idx = (today.weekday() + 1) % 7
99
+ sun = today + datetime.timedelta(7 - idx)
100
+ typer.echo("Submission successful! πŸŽ‰ πŸ₯³ πŸŽ‰")
101
+ typer.echo(f"Your submission will be evaulated on {sun:%A %d %B %Y} ⏳")
102
+
103
+
104
+ if __name__ == "__main__":
105
+ app()
{{cookiecutter.repo_name}}/expert.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from packaging import version
2
+
3
+ import torch
4
+ import torch.nn as nn
5
+ import torch.nn.functional as F
6
+ from torch.nn.utils.rnn import pad_sequence
7
+
8
+ import fairseq
9
+ from s3prl.upstream.interfaces import UpstreamBase
10
+
11
+
12
+ SAMPLE_RATE = 16000
13
+ EXAMPLE_SEC = 5
14
+
15
+ class UpstreamExpert(UpstreamBase):
16
+ def __init__(self, ckpt, **kwargs):
17
+ super().__init__(**kwargs)
18
+ assert version.parse(fairseq.__version__) > version.parse(
19
+ "0.10.2"
20
+ ), "Please install the fairseq master branch."
21
+
22
+ model, cfg, task = fairseq.checkpoint_utils.load_model_ensemble_and_task(
23
+ [ckpt]
24
+ )
25
+ self.model = model[0]
26
+ self.task = task
27
+
28
+ if len(self.hooks) == 0:
29
+ module_name = "self.model.encoder.layers"
30
+ for module_id in range(len(eval(module_name))):
31
+ self.add_hook(
32
+ f"{module_name}[{module_id}]",
33
+ lambda input, output: input[0].transpose(0, 1),
34
+ )
35
+ self.add_hook("self.model.encoder", lambda input, output: output[0])
36
+
37
+ def forward(self, wavs):
38
+ if self.task.cfg.normalize:
39
+ wavs = [F.layer_norm(wav, wav.shape) for wav in wavs]
40
+
41
+ device = wavs[0].device
42
+ wav_lengths = torch.LongTensor([len(wav) for wav in wavs]).to(device)
43
+ wav_padding_mask = ~torch.lt(
44
+ torch.arange(max(wav_lengths)).unsqueeze(0).to(device),
45
+ wav_lengths.unsqueeze(1),
46
+ )
47
+ padded_wav = pad_sequence(wavs, batch_first=True)
48
+
49
+ features, feat_padding_mask = self.model.extract_features(
50
+ padded_wav,
51
+ padding_mask=wav_padding_mask,
52
+ mask=None,
53
+ )
54
+ return {
55
+ "default": features,
56
+ }
{{cookiecutter.repo_name}}/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ typer