-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmission.py
76 lines (66 loc) · 2.65 KB
/
submission.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
Entry point to run the submission code: this is a modified version from the template
provided in: https://github.com/RecList/evalRS-CIKM-2022/blob/main/submission.py
The main change is the model class init, since the custom model need some parameters.
Check the original template and evalRS repo (https://github.com/RecList/evalRS-CIKM-2022) for
the fully commented version, and detailed instructions on the competition.
"""
import os
from datetime import datetime
from dotenv import load_dotenv
load_dotenv('upload.env', verbose=True)
EMAIL = os.getenv('EMAIL')
assert EMAIL != '' and EMAIL is not None
BUCKET_NAME = os.getenv('BUCKET_NAME')
PARTICIPANT_ID = os.getenv('PARTICIPANT_ID')
AWS_ACCESS_KEY = os.getenv('AWS_ACCESS_KEY')
AWS_SECRET_KEY = os.getenv('AWS_SECRET_KEY')
# run the evaluation loop when the script is called directly
if __name__ == '__main__':
# import the basic classes
from evaluation.EvalRSRunner import EvalRSRunner
# import my custom recList, containing the custom test
from evaluation.EvalRSRecList import myRecList
from evaluation.EvalRSRunner import ChallengeDataset
from submission.MyModel import MyTwoTowerModel
print('\n\n==== Starting evaluation script at: {} ====\n'.format(datetime.utcnow()))
# load the dataset
print('\n\n==== Loading dataset at: {} ====\n'.format(datetime.utcnow()))
dataset = ChallengeDataset(force_download=True)
print('\n\n==== Init runner at: {} ====\n'.format(datetime.utcnow()))
# run the evaluation loop
runner = EvalRSRunner(
dataset=dataset,
aws_access_key_id=AWS_ACCESS_KEY,
aws_secret_access_key=AWS_SECRET_KEY,
participant_id=PARTICIPANT_ID,
bucket_name=BUCKET_NAME,
email=EMAIL
)
print('==== Runner loaded, starting loop at: {} ====\n'.format(datetime.utcnow()))
my_model = MyTwoTowerModel(
items_df=dataset.df_tracks,
users_df=dataset.df_users,
# Training hparams
epochs=1,
train_batch_size=8192,
lr=1e-3,
lr_decay_steps=100,
lr_decay_rate=0.96,
label_smoothing=0.0,
# Model hparams
logq_correction_factor=1.0,
embeddings_l2_reg=1e-5,
logits_temperature=1.8,
tt_mlp_layers=[128,64],
tt_mlp_activation="relu",
tt_mlp_dropout=0.3,
tt_mlp_l2_reg=5e-5,
tt_infer_embedding_sizes_multiplier=2.0
)
# run evaluation with your model
runner.evaluate(
model=my_model,
custom_RecList=myRecList # pass my custom reclist to the runner!
)
print('\n\n==== Evaluation ended at: {} ===='.format(datetime.utcnow()))