BOJ PS problem Recsys Server bulit with
This GitHub repository contains the source code for BOJ problem recommendation system server, which provides APIs that the baekjoon Bot server can request in various user needs situations. The recommendation was implemented through a sequential recommendation model and a hybrid graph model combining Collaborative Filtering (CF) and Knowledge Graph (KG). These AI models were built with Pytorch and served with FastAPI. In addition, appropriate transformation was performed on the pre-loaded PostgreSQL data and a data mart for the model server was built using duckdb.
Used the problem solving status and problem information data of silver level or higher users crawled from BOJ.
- user number : about 110,000 people
- problum number : about 30000
- interaction : about 17 million
- SASRec is a classically used model in the field of sequential recommendation.
- Chose SASRec as a personalized recommendation model due to its parallel processing capability, efficiency in space complexity, and fast inference time.
- The paper author's legacy tensorflow code was rewritten in pytorch.
- The default values from the paper were used as hyperparameters.
- KGAT is a hybrid graph model that models Collaborative Filtering information and side information as CF graph and knowledge graph, respectively.
- Used KGAT to generate item embeddings by appropriately using CF information and side information.
- Some typos and unnecessary operations were corrected in the existing author's code.
- For most hyperparameters, the default values from the paper were used. However, we reduce the embedding dimension and number of layers
- As a result of the experiment, when the embedding dimension was low, loss was reduced better. Perhaps the recommendation problem we are trying to solve is expected to be at a low dimension.
Figure describing overall system design of the recommendation system.
cd baekjoon-model
uvicorn server:app --host 0.0.0.0 --port {PORTNUM} --reload
endpoint | method | Model | explanation | Request | Response |
---|---|---|---|---|---|
baekjun/user_id | POST | SASRec | Recommend problems based on the user's history of problems solved in the past. | { ”user_id_list”: List[str], ”problem_num”:int } |
{ ”{user_id1}”:[problems_list], ”{user_id2}”: [problems_list] ...} |
baekjun/category | POST | SASRec | Recommend problems of the problem type selected by user. | { ”user_id_list”: str, ”category”:int ”problem_num”:int } |
{ ”user_id” : List[int] } |
baekjun/group_rec | POST | SASRec | Recommend problems of the tier and problem type selected by group users. | { ”user_id_list” : List[str], ”tier” : int, ”category_num” : List[int] } |
{ ”0” : List[int], ”1” : List[int], …, ”9” List[int] } |
baekjun/similar_id | POST | KGAT | Recommend problems similar to the problem submitted by the user. | { ”problem_id” : int, ”problem_num” : int } |
{ ”problem_id” : List[int] } |
@inproceedings{kang2018self,
title={Self-attentive sequential recommendation},
author={Kang, Wang-Cheng and McAuley, Julian},
booktitle={2018 IEEE international conference on data mining (ICDM)},
pages={197--206},
year={2018},
organization={IEEE}
}
@inproceedings{wang2019kgat,
title={Kgat: Knowledge graph attention network for recommendation},
author={Wang, Xiang and He, Xiangnan and Cao, Yixin and Liu, Meng and Chua, Tat-Seng},
booktitle={Proceedings of the 25th ACM SIGKDD international conference on knowledge discovery \& data mining},
pages={950--958},
year={2019}
}