chiru112 commited on
Commit
e4cdf3c
·
verified ·
1 Parent(s): 521e56c

Upload folder using huggingface_hub

Browse files
Files changed (10) hide show
  1. .dockerignore +8 -0
  2. Dockerfile +9 -0
  3. README.md +123 -0
  4. ec_vocabulary.json +0 -0
  5. inputs.py +26 -0
  6. predict.py +25 -0
  7. requirements.txt +3 -0
  8. task.json +19 -0
  9. train.py +36 -0
  10. weights/baseline.json +7 -0
.dockerignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ .git/
5
+ .cache/
6
+ predictions.csv
7
+ predictions.jsonl
8
+ output/
Dockerfile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim-bookworm
2
+ RUN useradd --create-home --uid 1000 user
3
+ WORKDIR /app
4
+ COPY requirements.txt .
5
+ RUN pip install --no-cache-dir -r requirements.txt
6
+ COPY --chown=user:user . .
7
+ USER user
8
+ ENV OMP_NUM_THREADS=2 OPENBLAS_NUM_THREADS=2
9
+ CMD ["python", "/app/predict.py", "--help"]
README.md ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - leak-curber
4
+ - enzyme
5
+ - leaderboard
6
+ ---
7
+ # Leak CURBER enzyme classification model starter
8
+
9
+ This is a starter model for the enzyme classification task. You train a model on your computer and upload it to a public Hugging Face (HF) model repository. Then you submit that repository to the Leak CURBER leaderboard. A free HF account is enough.
10
+
11
+ ## Task
12
+
13
+ The input is a Parquet file with the columns `id` and `sequence` (the enzyme amino acid sequence). Predict one EC number for each unique input. The output is JSON Lines with the keys `id` and `prediction`. The prediction is a list of distinct ECs, best first:
14
+
15
+ ```json
16
+ {"id":"v_0000001","prediction":["1.1.1.1"]}
17
+ ```
18
+
19
+ The public data are `train.parquet` (with the `ec_number` label) and `val_inputs.parquet` (inputs only). Validation labels and test data are private. `ec_vocabulary.json` lists the permitted ECs.
20
+
21
+ An input can have several recorded ECs. `train.parquet` has one input–EC pair per row. We group identical inputs within each split, keep the first ID, and score each unique input once. Predict only the first ID of each unique input; do not predict repeat IDs. `inputs.py` applies the same grouping. Do not normalize sequences.
22
+
23
+ Only the first predicted EC counts. You can list up to 10, but the others do not change the score. We report top-1 accuracy at EC levels L4, L3, L2, and L1, and rank by L4. Equal scores favor the earlier submission.
24
+
25
+ If an input has n recorded ECs, the first prediction earns 1/n for each recorded EC whose first L components match it. We average this over unique inputs. With recorded ECs 1.1.1.1 and 1.1.1.2, the prediction 1.1.1.1 scores 0.5 at L4 and 1.0 at L3, L2, and L1. An empty prediction scores zero.
26
+
27
+ `ec_vocabulary.json` comes from ExPASy ENZYME, release 02-Sep-2026. SIB provides it under CC BY 4.0: https://enzyme.expasy.org/
28
+
29
+ ## Baseline
30
+
31
+ The baseline ignores the input. It predicts the most frequent training EC for every input. It uses only the training split.
32
+
33
+ ## Run the baseline
34
+
35
+ ```bash
36
+ python -m pip install huggingface-hub==2.2.0
37
+ hf download starkAhmed43/leak-curber-enzyme-classification-starter --local-dir model
38
+ hf download starkAhmed43/leak-curber-enzyme-classification train.parquet val_inputs.parquet --repo-type dataset --local-dir data
39
+ cd model
40
+ python -m pip install -r requirements.txt
41
+ python predict.py --input ../data/val_inputs.parquet --output predictions.jsonl
42
+ ```
43
+
44
+ To retrain the baseline:
45
+
46
+ ```bash
47
+ python train.py --train ../data/train.parquet --output weights/baseline.json
48
+ ```
49
+
50
+ To write the unique validation inputs to a file:
51
+
52
+ ```bash
53
+ python inputs.py --input ../data/val_inputs.parquet --output unique_validation.parquet
54
+ ```
55
+
56
+ ## Check with Docker
57
+
58
+ Run these commands in the `model` directory:
59
+
60
+ ```bash
61
+ mkdir -p output && chmod 777 output
62
+ docker build --platform linux/amd64 -t my-enzyme-model .
63
+ docker run --rm --platform linux/amd64 --user 1000:1000 --network none --cpus 2 --memory 16g \
64
+ -v "$PWD/../data:/input:ro" -v "$PWD/output:/output" \
65
+ my-enzyme-model python /app/predict.py \
66
+ --input /input/val_inputs.parquet --output /output/predictions.jsonl
67
+ ```
68
+
69
+ `output/predictions.jsonl` must contain every unique input ID exactly once.
70
+
71
+ ## Replace the baseline
72
+
73
+ Use any model or library. Train wherever you like, but the model runs on CPU only. The evaluator gives it 2 vCPUs, 16 GB RAM, and 10 minutes for all inputs. It has no GPU and no network. Change `Dockerfile`, `requirements.txt`, and `predict.py`. Put the weights in your repository, with all other files that inference needs. Do not add the downloaded data or the `output` directory.
74
+
75
+ We build the image from your `Dockerfile`. The image must meet these limits:
76
+
77
+ - Linux x86-64, with Python at `/usr/local/bin/python` and working directory `/app`.
78
+ - The command is `python /app/predict.py --input INPUT --output OUTPUT`.
79
+ - The build must finish in 30 minutes. The repository must be 4 GiB or less.
80
+ - No file that `predict.py` writes may exceed 16 MiB.
81
+
82
+ We start Python directly. Docker entrypoints and shell startup hooks do not run. Use `/tmp` for temporary files.
83
+
84
+ An evaluation fails in these cases:
85
+
86
+ - A line is blank, or is not a JSON object with exactly the keys `id` and `prediction`.
87
+ - A unique input ID is missing, duplicated, or added.
88
+ - A prediction has a duplicate EC, more than 10 ECs, or an EC that is not in `ec_vocabulary.json`.
89
+ - Inference needs more than 10 minutes, or needs the network.
90
+
91
+ ## Submit
92
+
93
+ Choose the task assigned to you in [this sheet](https://docs.google.com/spreadsheets/d/12c2PaYcNDpa6bA0JPmKi6tHsdV-EdFe2IYQ70RqpGRI/edit?usp=sharing).
94
+
95
+ 1. Sign in: `hf auth login`.
96
+ 2. Upload the `model` directory to a public model repository:
97
+
98
+ ```bash
99
+ hf upload YOUR_USERNAME/YOUR_MODEL . --repo-type model --no-private --exclude ".cache/**" "output/**" "predictions.jsonl"
100
+ ```
101
+
102
+ For an existing repository, make sure it is public. The `--no-private` flag does not change an existing repository.
103
+ The repository must contain `Dockerfile`, `predict.py`, and `README.md`.
104
+ 3. Open the [leaderboard](https://huggingface.co/spaces/starkAhmed43/leak-curber-leaderboard), select the Enzyme classification tab, and sign in with your registered account.
105
+ 4. Under Submit model, enter the repository ID, the revision (default `main`), and a model name. Select Submit for validation.
106
+ 5. Watch the progress under My submissions.
107
+
108
+ A submission records a fixed commit. Later changes to the repository do not change it. The validation score appears when the evaluation ends.
109
+
110
+ ## Limits and deadline
111
+
112
+ - Each team has 2 submissions per day and 20 in total for each task.
113
+ - Failed model runs count against these limits.
114
+ - Only one of your evaluations can be active at a time.
115
+ - Under My submissions, nominate one completed submission for the test evaluation. Each task has its own nomination. If you do not nominate, we use your best validation score.
116
+ - Your best and your nominated submissions stay protected. Other successful archives expire after 7 days.
117
+ - Submit and nominate before November 7, 2026, 23:59 IST. We will publish test scores after that.
118
+
119
+ ## Help
120
+
121
+ - If the leaderboard says your account is not approved, post your HF username in the Moodle course discussion forum.
122
+ - If the leaderboard says the evaluator is unavailable, refresh shortly. Post in the Moodle course discussion forum if the error persists.
123
+ - Post any other question in the Moodle course discussion forum.
ec_vocabulary.json ADDED
The diff for this file is too large to render. See raw diff
 
inputs.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Prepare exactly the unique input rows used by the evaluator."""
2
+ import argparse
3
+ import json
4
+ from pathlib import Path
5
+
6
+ import pandas as pd
7
+
8
+
9
+ def prepare_inputs(frame):
10
+ config = json.loads((Path(__file__).parent / 'task.json').read_text())
11
+ columns = ['id'] + config['input_columns']
12
+ if not set(columns) <= set(frame.columns):
13
+ raise ValueError('Missing input columns: ' + ', '.join(columns))
14
+ if frame.id.isna().any() or frame.id.duplicated().any():
15
+ raise ValueError('Input IDs must be present and unique.')
16
+ return frame[columns].drop_duplicates(config['input_columns'], keep='first').reset_index(drop=True)
17
+
18
+
19
+ if __name__ == '__main__':
20
+ parser = argparse.ArgumentParser(description=__doc__)
21
+ parser.add_argument('--input', required=True)
22
+ parser.add_argument('--output', required=True)
23
+ args = parser.parse_args()
24
+ frame = prepare_inputs(pd.read_parquet(args.input))
25
+ frame.to_parquet(args.output, index=False)
26
+ print(f'Wrote {len(frame)} unique inputs to {args.output}')
predict.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Offline CPU inference. Replace the frequency baseline with your own model."""
2
+ import argparse
3
+ import json
4
+ from pathlib import Path
5
+
6
+ import pandas as pd
7
+ from inputs import prepare_inputs
8
+
9
+
10
+ def predict_file(input_path, output_path):
11
+ root = Path(__file__).parent
12
+ frame = prepare_inputs(pd.read_parquet(input_path))
13
+ weights = json.loads((root / 'weights/baseline.json').read_text())
14
+ # Load your model once. Batch its predictions here.
15
+ with Path(output_path).open('w') as output:
16
+ for key in frame.id:
17
+ output.write(json.dumps({'id':key, 'prediction':weights['prediction']}) + '\n')
18
+
19
+
20
+ if __name__ == '__main__':
21
+ parser = argparse.ArgumentParser(description=__doc__)
22
+ parser.add_argument('--input', required=True)
23
+ parser.add_argument('--output', required=True)
24
+ args = parser.parse_args()
25
+ predict_file(args.input, args.output)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ numpy==2.4.4
2
+ pandas==2.3.3
3
+ pyarrow==23.0.1
task.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "title": "Leak CURBER enzyme classification",
3
+ "slug": "leak-curber-enzyme-classification",
4
+ "benchmark_id": "leak-curber-enzyme-classification-20261023",
5
+ "input_columns": [
6
+ "sequence"
7
+ ],
8
+ "label_column": "ec_number",
9
+ "output_format": "jsonl",
10
+ "primary_metric": "accuracy_l4",
11
+ "metrics": [
12
+ "accuracy_l4",
13
+ "accuracy_l3",
14
+ "accuracy_l2",
15
+ "accuracy_l1"
16
+ ],
17
+ "data_dir": "data/enzyme_tasks/classification",
18
+ "task_id": "enzyme-classification"
19
+ }
train.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Train a small EC-frequency baseline using only the training split."""
2
+ import argparse
3
+ from collections import Counter
4
+ import json
5
+ from pathlib import Path
6
+
7
+ import pandas as pd
8
+
9
+
10
+ def train(path, output):
11
+ root = Path(__file__).parent
12
+ task = json.loads((root / 'task.json').read_text())
13
+ valid = set(json.loads((root / 'ec_vocabulary.json').read_text()))
14
+ frame = pd.read_parquet(path)
15
+ unique = frame.drop_duplicates(task['input_columns'] + ['ec_number'])
16
+ if not set(unique.ec_number) <= valid:
17
+ raise ValueError('Training data contains ECs outside the pinned vocabulary.')
18
+ counts = Counter(unique.ec_number)
19
+ ranked = sorted(counts, key=lambda ec: (-counts[ec], ec))
20
+ if not ranked:
21
+ raise ValueError('Training data is empty.')
22
+ limit = 1 # Both tasks are scored on the first EC only.
23
+ result = {'prediction': ranked[:limit], 'training_pairs': len(unique),
24
+ 'baseline': 'EC frequency; ignores the input'}
25
+ target = Path(output)
26
+ target.parent.mkdir(parents=True, exist_ok=True)
27
+ target.write_text(json.dumps(result, indent=2) + '\n')
28
+ print(f'Trained on {len(unique)} input–EC pairs; saved {target}')
29
+
30
+
31
+ if __name__ == '__main__':
32
+ parser = argparse.ArgumentParser(description=__doc__)
33
+ parser.add_argument('--train', required=True)
34
+ parser.add_argument('--output', default='weights/baseline.json')
35
+ args = parser.parse_args()
36
+ train(args.train, args.output)
weights/baseline.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "prediction": [
3
+ "2.7.7.48"
4
+ ],
5
+ "training_pairs": 223764,
6
+ "baseline": "EC frequency; ignores the input"
7
+ }