{"id":15967211,"url":"https://github.com/rishit-dagli/uoft-csc311-project","last_synced_at":"2025-07-27T16:10:47.423Z","repository":{"id":232886279,"uuid":"773399050","full_name":"Rishit-dagli/uoft-csc311-project","owner":"Rishit-dagli","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-03T23:47:44.000Z","size":2728,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T13:33:27.293Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rishit-dagli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-17T15:03:15.000Z","updated_at":"2024-04-11T21:23:44.000Z","dependencies_parsed_at":"2024-04-18T21:15:13.396Z","dependency_job_id":null,"html_url":"https://github.com/Rishit-dagli/uoft-csc311-project","commit_stats":null,"previous_names":["rishit-dagli/uoft-csc311-project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Rishit-dagli/uoft-csc311-project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rishit-dagli%2Fuoft-csc311-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rishit-dagli%2Fuoft-csc311-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rishit-dagli%2Fuoft-csc311-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rishit-dagli%2Fuoft-csc311-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rishit-dagli","download_url":"https://codeload.github.com/Rishit-dagli/uoft-csc311-project/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rishit-dagli%2Fuoft-csc311-project/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267384322,"owners_count":24078575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-07T18:21:32.076Z","updated_at":"2025-07-27T16:10:47.400Z","avatar_url":"https://github.com/Rishit-dagli.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSC311 Final Project\n\nWe give instructions on how to run the code for Part B of the project. The code resides in the `part_b` directory. Currently, our code is tested with Python 3.10.x, hiwever we believe it should work well with Python 3.9.x and above.\n\nAssuming you have cloned this repository, and you are in the `part_b` directory of the repository, you can run the following command to setup the environment:\n\n```bash\npip install -r requirements.txt\n```\n\n## Evaluation code for Part B\n\nAll our evaluation code for the models in part A which we use for evaluation in part B resides in the `part_b/evaluate/` directory. Due to size constraints on Markus, we do not include the trained parameters for the random forest model.\n\n## Training the model\n\nTo train the model, you can use the `main.py` script. The script can be used as follows:\n\n```bash\npython main.py [OPTIONS]\n```\n\nThe following options are available:\n\n- `--project`\n  - Type: `str`\n  - Default: `\"test\"`\n  - Description: Name of the project.\n\n- `--custom_loss`\n  - Action: `store_true`\n  - Description: Use custom loss function.\n\n- `--model_type`\n  - Type: `str`\n  - Default: `\"original\"`\n  - Choices: `[\"original\", \"mhsa\"]`\n  - Description: Model architecture type: 'original' or 'mhsa'.\n\n- `--optimizer`\n  - Type: `str`\n  - Default: `\"adam\"`\n  - Description: Optimizer to use.\n\n- `--lr_scheduler`\n  - Type: `str`\n  - Default: `\"none\"`\n  - Choices: `[\"none\", \"steplr\", \"cosineannealing\", \"reducelronplateau\", \"cosinedecay\"]`\n  - Description: Type of LR scheduler: steplr, cosineannealing, reducelronplateau, cosinedecay, none.\n\n- `--step_size`\n  - Type: `int`\n  - Default: `10`\n  - Description: Step size for StepLR and T_max for CosineAnnealing.\n\n- `--gamma`\n  - Type: `float`\n  - Default: `0.1`\n  - Description: Gamma for StepLR, ReduceLROnPlateau, and factor for CosineAnnealing.\n\n- `--patience`\n  - Type: `int`\n  - Default: `10`\n  - Description: Patience for ReduceLROnPlateau.\n\n- `--lr`\n  - Type: `float`\n  - Default: `1e-3`\n  - Description: Initial learning rate.\n\n- `--base_path`\n  - Type: `str`\n  - Default: `\"../../data\"`\n  - Description: Base path for the dataset.\n\n- `--gpu`\n  - Action: `store_true`\n  - Description: Use GPU for training.\n\n- `--num_devices`\n  - Type: `int`\n  - Default: `1`\n  - Description: Number of devices to use for training.\n\n- `--epochs`\n  - Type: `int`\n  - Default: `10`\n  - Description: Number of epochs.\n\n- `--batch_size`\n  - Type: `int`\n  - Default: `32`\n  - Description: Batch size.\n\n- `--save_model`\n  - Type: `str`\n  - Default: `\"model.pth\"`\n  - Description: Path to save the model.\n\n- `--checkpoint_path`\n  - Type: `str`\n  - Default: `None`\n  - Description: Path to a checkpoint to resume training from.\n\n- `--seed`\n  - Type: `int`\n  - Default: `3047`\n  - Description: Random seed.\n\n### Run our model configuration\n\nTo run our best performing model configuration for each of the two model architectures we try out (Embeddings and Multi-Head Self-Attention), you can use the following commands:\n\n```bash\n# Original model\npython main.py --project education_model --model_type original  --optimizer adamw --lr_scheduler none --lr 1e-1 --base_path ../data --epochs 8 --batch_size 64 --save_model model.pth --seed 3047\n\n# Multi-Head Self-Attention model\npython main.py --project education_model --model_type mhsa --optimizer adamw --lr_scheduler reducelronplateau --patience 15 --lr 1e-1 --base_path ../data --epochs 250 --batch_size 32 --save_model model.pth --seed 3047\n```\n\nYou should run each of these commands with `--num_devices [NUMBER_OF_DEVICES]` if you want to use more than 1 device for the training and `--gpu` if you want to use GPU for training.\n\n### Viewing the training logs\n\nYou can view the training logs using TensorBoard. To do this, you can run the following command:\n\n```bash\ntensorboard --logdir=logs\n```\n\nThis will start a TensorBoard server that you can access by visiting `http://localhost:6006` in your browser.\n\n## Evaluating the model\n\nTo evaluate the model on thew entire test set, the script can be used as follows:\n\n```bash\npython main.py --model_type original --base_path ../../data --batch_size 3543 --epochs 0 --checkpoint_path model.pth\n\npython main.py --model_type mhsa --base_path ../../data --batch_size 3543 --epochs 0 --checkpoint_path model.pth\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frishit-dagli%2Fuoft-csc311-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frishit-dagli%2Fuoft-csc311-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frishit-dagli%2Fuoft-csc311-project/lists"}