{"id":15140763,"url":"https://github.com/dohlee/samsung-ai-challenge-solution","last_synced_at":"2026-01-28T23:01:23.893Z","repository":{"id":116779448,"uuid":"610163002","full_name":"dohlee/samsung-ai-challenge-solution","owner":"dohlee","description":"⚗️ Samsung AI Challenge for Scientific Discovery 5위 솔루션입니다.","archived":false,"fork":false,"pushed_at":"2023-04-06T14:50:01.000Z","size":192,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-15T18:56:01.592Z","etag":null,"topics":["challenge","dacon","molecular-property-prediction","molecule","quantum-chemistry","solution"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dohlee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2023-03-06T08:12:39.000Z","updated_at":"2025-09-15T11:17:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"19cc8a45-3767-4202-b89d-ea3b1d97f3ef","html_url":"https://github.com/dohlee/samsung-ai-challenge-solution","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"9b7e2ca8afab58fd9c44eed35b72fde335d2e59b"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dohlee/samsung-ai-challenge-solution","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dohlee%2Fsamsung-ai-challenge-solution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dohlee%2Fsamsung-ai-challenge-solution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dohlee%2Fsamsung-ai-challenge-solution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dohlee%2Fsamsung-ai-challenge-solution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dohlee","download_url":"https://codeload.github.com/dohlee/samsung-ai-challenge-solution/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dohlee%2Fsamsung-ai-challenge-solution/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28854409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T22:56:21.783Z","status":"ssl_error","status_checked_at":"2026-01-28T22:56:00.861Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["challenge","dacon","molecular-property-prediction","molecule","quantum-chemistry","solution"],"created_at":"2024-09-26T08:40:53.332Z","updated_at":"2026-01-28T23:01:23.851Z","avatar_url":"https://github.com/dohlee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Samsung AI Challenge solution\n\n본 repository를 통해 2021년 DACON을 통해 개최된 [Samsung AI Challenge for Scientific Discovery](https://dacon.io/competitions/official/235789/overview/description) 경진대회의 5위 솔루션 코드를 정리하여 공개합니다.\n\n## 1. 개요\n\n본 챌린지에서는 분자의 3차원 구조 정보를 이용하여 S1-T1 사이의 에너지 갭을 추정할 수 있는 Machine Learning 알고리즘의 성능을 겨룹니다. \n\n## 2. 접근\n\n### 입력 feature 설명\n\n각 분자를 다음과 같이 featurize 하였습니다.\n\n**원자 수준 feature**\n- H, B, C, N, O, F, S, Si, P, Cl, Br, I 원자를 one-hot encoding (one-hot, 12-dim)\n- Hybridization (one-hot, 7-dim)\n- Aromatic ring 에 속한 atom인지 여부 (binary, 1-dim)\n- 형식 전하 (1-dim)\n- 결합된 수소 원자의 개수 (1-dim)\n- 원자가 (1-dim)\n- Donor/Acceptor status (one-hot, 2-dim)\n- Spin multiplicity (one-hot, 2-dim)\n\n**분자 수준 feature**\n- NPR1 (Normalized principal moments ratio 1, `rdkit.Chem.Descriptors3D.NPR1` 활용)\n- NPR2 (Normalized principal monents ratio 2, `rdkit.Chem.Descriptors3D.NPR2` 활용)\n\n**분자의 3차원 구조 feature**\n- 원자 쌍의 pairwise distance matrix (max_n_atoms x max_n_atoms)\n- 원자 간 결합 정보를 나타내는 Adjacency matrix\n- 결합각(bond angle) 및 이면각(torsion angle) 정보\n\n### 모델 설명\n\n분자의 원자 간 거리 행렬을 바탕으로 분자의 3차원 구조를 반영한 Transformer 모델을 사용하였습니다. 구조는 아래 그림과 같습니다.\n\n![model](/img/sac_model.png)\n\n- Transformer encoder stem 세부사항\n    - `n_layers=24`\n    - `d_model=256`\n    - `n_heads=16`\n- Prediction head 세부사항\n    - `Linear(3*d_model, 16) -\u003e ReLU -\u003e Linear(16, 1)`\n\n### 학습 방법\n\n**Pretraining**\n- 아래의 데이터셋을 이용하여 HOMO 및 LUMO를 예측하는 멀티태스크 사전학습을 수행합니다.\n    - [QM9](http://quantum-machine.org/datasets/) (n=133,246)\n    - [OE62](https://www.nature.com/articles/s41597-020-0385-y) (n=61,191)\n- Pretraining에 사용되는 molecule sdf 데이터의 메타데이터(`pretrain_metadata.csv`)는 [여기](https://dohlee-bioinfo.sgp1.digitaloceanspaces.com/sac2021-data/pretrain_metadata.csv)에서 다운로드 받을 수 있습니다. \n- Pretraining을 위해 프로세싱 완료된 molecule sdf들을 모아 둔 디렉토리 `pretrain_sdf`는 [여기](https://dohlee-bioinfo.sgp1.digitaloceanspaces.com/sac2021-data/pretrain_sdf.tar.gz)에서 다운로드 받을 수 있습니다.\n\n**Fine-tuning**\n- 사전학습된 stem을 이용합니다.\n    - 첫 9 epoch은 pretrained weight를 freeze 시킨 상태로 학습하고, 10 epoch 부터 weight unfreeze 후 모든 weight를 업데이트 시킵니다.\n- 제공된 학습 데이터로 S1-T1 gap과, S1, T1 각각의 값을 예측하는 regression head를 학습합니다.\n    - Gap, S1, T1 regression은 MSE loss를 사용합니다.\n    - Gap의 weight는 1.0이고, S1, T1 regression의 weight는 0.05로 학습합니다.\n- Optimizer = `AdamW(lr=3e-5)`\n- Scheduler = `ReduceLROnPlateau(optimizer, mode='min', factor=0.5, patience=15, threshold=0.005, threshold_mode='rel')`\n- Batch size = 64\n\n## 3. 설치 및 사용법\n본 솔루션 코드 및 모델은 PyPI에 배포되어 있습니다. 모델은 다음과 같이 설치할 수 있습니다.\n- 사용에 앞서서 `openbabel` 패키지가 환경에 설치되어 있어야 합니다. `conda install -c conda-forge openbabel`로 설치 가능합니다.\n\n```bash\n$ pip install sac2021\n```\n\n### Pretraining\n\n- 메타데이터 [`pretrain_metadata.csv`](https://dohlee-bioinfo.sgp1.digitaloceanspaces.com/sac2021-data/pretrain_metadata.csv)와 sdf 파일 디렉토리 [`pretrain_sdf`](https://dohlee-bioinfo.sgp1.digitaloceanspaces.com/sac2021-data/pretrain_sdf.tar.gz)를 다운로드 후, 아래 명령의 `--meta`와 `--data` 파라미터를 적절히 설정하여 사전학습을 진행합니다.\n\n```bash\n$ python -m sac2021.pretrain \\\n    --meta [path/to/pretrain_metadata.csv] \\\n    --data [path/to/pretrain_sdf] \\\n    --output [OUTPUT_CHECKPOINT] \\\n    --model-id [ID] \\\n    --fold 0 \\  # For validation purpose. (2.5% of the data will be held out)\n    --loss mse \\\n```\n\nPretraining 학습 로그는 [이 Weight \u0026 Biases Project](https://wandb.ai/dohlee/sac-solution?workspace=user-dohlee)에서 확인 가능합니다.\n\n### Fine-tuning\n- 학습 데이터 `traindev.csv`와 sdf 파일 디렉토리 `traindev_sdf`를 다운로드 후, 아래 명령의 `--meta`와 `--data` 파라미터를 적절히 설정하여 fine-tuning을 진행합니다.\n```bash\n$ python -m sac2021.finetune \\\n    --meta [path/to/traindev.csv] \\\n    --data [path/to/traindev_sdf] \\\n    --ckpt [path/to/pretrained_checkpoint] \\\n    --output [OUTPUT_CHECKPOINT] \\ \n    --model-id [ID] \\ \n    --fold 0 \\\n    --loss mse\n```\n\nFine-tuning 학습 로그는 [이 Weight \u0026 Biases Project](https://wandb.ai/dohlee/sac-solution?workspace=user-dohlee)에서 확인 가능합니다.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdohlee%2Fsamsung-ai-challenge-solution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdohlee%2Fsamsung-ai-challenge-solution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdohlee%2Fsamsung-ai-challenge-solution/lists"}