{"id":16451062,"url":"https://github.com/auxten/go-ctr","last_synced_at":"2026-01-12T08:04:01.956Z","repository":{"id":47957563,"uuid":"502649029","full_name":"auxten/go-ctr","owner":"auxten","description":"Go DeepLearning based Recommendation Framework","archived":false,"fork":false,"pushed_at":"2022-12-14T03:31:15.000Z","size":2922,"stargazers_count":238,"open_issues_count":1,"forks_count":17,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-09-01T12:47:34.615Z","etag":null,"topics":["ctr","deep-learning","golang","recommender-system"],"latest_commit_sha":null,"homepage":"https://go-ctr.auxten.com/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auxten.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}},"created_at":"2022-06-12T15:09:01.000Z","updated_at":"2025-08-18T23:19:46.000Z","dependencies_parsed_at":"2023-01-28T16:45:16.902Z","dependency_job_id":null,"html_url":"https://github.com/auxten/go-ctr","commit_stats":null,"previous_names":["auxten/edgerec","auxten/dnn-ranker"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/auxten/go-ctr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auxten%2Fgo-ctr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auxten%2Fgo-ctr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auxten%2Fgo-ctr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auxten%2Fgo-ctr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auxten","download_url":"https://codeload.github.com/auxten/go-ctr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auxten%2Fgo-ctr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28337007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["ctr","deep-learning","golang","recommender-system"],"created_at":"2024-10-11T10:07:06.781Z","updated_at":"2026-01-12T08:04:01.933Z","avatar_url":"https://github.com/auxten.png","language":"Go","readme":"# go-ctr\n\n\u003cimg src=\"art/logo.png\" alt=\"logo\" width=\"800\"\u003e\n\nRecommendation(Click-Through Rate Prediction) Framework for Go, including:\n\n1. Model Training \u0026 Prediction\n1. Item2vec Embedding\n1. Feature-Engineering\n1. Common Cost Functions and Metric Functions: AUC, Accuracy, MSE, RMS, Binary Cross Entropy, etc.\n1. Common Models\n\n# Models implemented\n\n### [Simple 2 layer MLP](./model/mlp/mlp.go)\n\nGAUC on MovieLens 20M: **0.771258**\n\n  - [x] [Simple 2 layer MLP test on MovieLens](./example/movielens/feature_test.go)\n  - [x] Dropout and L2 regularization\n  - [x] Batch Normalization\n\n### [YouTube DNN](./model/youtube/dnn.go)\n\nGAUC on MovieLens 20M: **0.760381**\n\n  - [x] [YouTube DNN test on MovieLens](./example/movielens/youtube_test.go)\n  - [x] Dropout and L2 regularization\n  - [ ] Batch Normalization\n\n### [Deep Interest Network](./model/din/din.go)\n\nGAUC on MovieLens 20M: **0.790542**\n\n  - [x] [DIN test on MovieLens](./example/movielens/dinimpl_test.go)\n  - [x] [Euclidean Distance](model/activation.go) and [Cosine Similarity](model/activation.go) based attention\n  - [x] Dropout and L2 regularization\n  - [ ] Batch Normalization\n\n# Demo\n\nYou can run the MovieLens training and predict demo by:\n\n```shell\n# download and unzip the SQLite DB file\nwget https://github.com/auxten/go-ctr/files/9895974/movielens.db.zip \u0026\u0026 \\\n  unzip movielens.db.zip\n# compile the go-ctr and put it in the current directory\nGOBIN=`pwd` go install github.com/auxten/go-ctr@latest \u0026\u0026 \\\n  ./go-ctr\n```\n\nWait for the message shown: `Listening and serving HTTP on :8080`.\n\nThen test the API in another terminal:\n\n```shell\ncurl --header \"Content-Type: application/json\" \\\n  --request POST \\\n  --data '{\"userId\":108,\"itemIdList\":[1,2,39]}' \\\n  http://localhost:8080/api/v1/recommend\n```\nShould get the response like this:\n\n```json\n{\"itemScoreList\":[\n  {\"itemId\":1,\"score\":0.7517360474797006},\n  {\"itemId\":2,\"score\":0.5240565619788571},\n  {\"itemId\":39,\"score\":0.38496231172036016}\n]}\n```\n\nSo, with a higher score, user #108 may prefer movie #1 over #2 and #39.\n\n\n# Quick Start\n\nTo create a deep learning based recommendation system, you need to follow the steps below:\n\nif you prefer `show me the code`, just go to [MovieLens Example](example/movielens)\n\n1. Implement the `recommend.RecSys` interface including func below:\n    ```golang\n   GetUserFeature(context.Context, int) (Tensor, error)\n   GetItemFeature(context.Context, int) (Tensor, error)\n   SampleGenerator(context.Context) (\u003c-chan Sample, error)\n   ```\n2. Call the functions to `Train` and `StartHttpApi`\n\n     ```golang\n    model, _ = recommend.Train(recSys)\n    recommend.StartHttpApi(model, \"/api/v1/recommend\", \":8080\")\n    ```\n\n3. If you want better AUC with item embedding, you can implement the `recommend.ItemEmbedding` interface including func below:\n    ```golang\n    //ItemEmbedding is an interface used to generate item embedding with item2vec model\n    //by just providing a behavior based item sequence.\n    // Example: user liked items sequence, user bought items sequence, \n    //   user viewed items sequence\n    type ItemEmbedding interface {\n        ItemSeqGenerator() (\u003c-chan string, error)\n    }\n    ```\n   All you need to do is implement the functions of the gray part:\n   ![](art/go-ctr.png)\n\n# Docs\n\nFor more usage, please refer to the [docs](https://go-ctr.auxten.com/)\n\n# Features\n\n- [x] Pure Golang implementation, battery included.\n- [ ] Parameter Server based Online Learning\n- [x] Training \u0026 Inference all in one binary powered by golang\n- Databases support\n  - [x] MySQL support\n  - [x] SQLite support\n  - [ ] Database Aggregation accelerated Feature Normalization\n- Feature Engineering\n  - [x] Item2vec embedding\n  - [ ] Rule based FE config\n  - [ ] DeepL based Auto Feature Engineering\n- Demo\n  - [x] MovieLens Demo \n\n\n# Benchmark\n\n## Embedding\n\n- Apple M1 Max\n- Database: SQLite3\n- Model: SkipGram, Optimizer: HierarchicalSoftmax\n- WindowSize: 5\n- Data: [MovieLens 10m](https://grouplens.org/datasets/movielens/10m/)\n```\nread 9520886 words 12.169282375s\ntrained 9519544 words 17.155356791s\n\nSearch Embedding of:\n   59784 \"Kung Fu Panda (2008)\" Action|Animation|Children|Comedy\n\n  RANK | WORD  | SIMILARITY  | TITLE \u0026 GENRES\n-------+-------+-------------+-------------\n     1 | 60072 |   0.974392  | Wanted (2008) Action|Thriller\n     2 | 60040 |   0.974080  | Incredible Hulk, The (2008) Action|Fantasy|Sci-Fi\n     3 | 60069 |   0.973728  | WALL·E (2008) Adventure|Animation|Children|Comedy|Romance|Sci-Fi\n     4 | 60074 |   0.970396  | Hancock (2008) Action|Comedy|Drama|Fantasy\n     5 | 63859 |   0.969845  | Bolt (2008) Action|Adventure|Animation|Children|Comedy\n     6 | 57640 |   0.969305  | Hellboy II: The Golden Army (2008) Action|Adventure|Comedy|Fantasy|Sci-Fi\n     7 | 58299 |   0.967733  | Horton Hears a Who! (2008) Adventure|Animation|Children|Comedy\n     8 | 59037 |   0.966410  | Speed Racer (2008) Action|Adventure|Children\n     9 | 59315 |   0.964556  | Iron Man (2008) Action|Adventure|Sci-Fi\n    10 | 58105 |   0.963332  | Spiderwick Chronicles, The (2008) Adventure|Children|Drama|Fantasy\n\n```\n\n## Movie Recommend Performance\n\n- Dataset: MovieLens 100k, split by [80%+20% userId randomly](example/movielens/readme.md)\n- Code: [example/movielens](example/movielens)\n- Training time: 28s\n- AUC: 0.782\n\n# Thanks\n\nTo make this project work, quite a lot of code are copied and modified from the following libraries:\n- Neural Network \u0026 Parameter Server: \n  - [gorgonia](https://github.com/gorgonia/gorgonia)\n  - [goro](https://github.com/aunum/goro)\n  - [go-deep](https://github.com/patrikeh/go-deep)\n  - [pa-m/sklearn](https://github.com/pa-m/sklearn)\n- Feature Engineering:\n  - [go-featureprocessing](https://github.com/nikolaydubina/go-featureprocessing)\n  - [featuremill](https://github.com/dustin-decker/featuremill)\n  - [wego](https://github.com/ynqa/wego)\n- FastAPI like framework:\n  - [go-fastapi](https://github.com/sashabaranov/go-fastapi)\n- Gopher logo with [GIMP](https://www.gimp.org/):\n  - [ashleymcnamara/gophers](https://github.com/ashleymcnamara/gophers)\n- [JetBrains](https://www.jetbrains.com/?from=auxten/go-ctr) for providing free license for this project.\n\n# Papers related\n\n- [YouTube DNN](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/45530.pdf)\n- [Deep Interest Network for Click-Through Rate Prediction](https://arxiv.org/abs/1706.06978)\n- [Document Embedding with Paragraph Vectors](https://arxiv.org/abs/1507.07998)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauxten%2Fgo-ctr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauxten%2Fgo-ctr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauxten%2Fgo-ctr/lists"}