Coder Social home page Coder Social logo

auxten / go-ctr Goto Github PK

View Code? Open in Web Editor NEW
229.0 14.0 16.0 2.85 MB

Go DeepLearning based Recommendation Framework

Home Page: https://go-ctr.auxten.com/

License: GNU Affero General Public License v3.0

Go 87.72% Shell 0.02% JavaScript 1.78% HTML 0.08% Handlebars 0.03% Vue 7.26% TypeScript 2.70% SCSS 0.30% Makefile 0.10%
deep-learning golang ctr recommender-system

go-ctr's Introduction

go-ctr

logo

Recommendation(Click-Through Rate Prediction) Framework for Go, including:

  1. Model Training & Prediction
  2. Item2vec Embedding
  3. Feature-Engineering
  4. Common Cost Functions and Metric Functions: AUC, Accuracy, MSE, RMS, Binary Cross Entropy, etc.
  5. Common Models

Models implemented

GAUC on MovieLens 20M: 0.771258

GAUC on MovieLens 20M: 0.760381

GAUC on MovieLens 20M: 0.790542

Demo

You can run the MovieLens training and predict demo by:

# download and unzip the SQLite DB file
wget https://github.com/auxten/go-ctr/files/9895974/movielens.db.zip && \
  unzip movielens.db.zip
# compile the go-ctr and put it in the current directory
GOBIN=`pwd` go install github.com/auxten/go-ctr@latest && \
  ./go-ctr

Wait for the message shown: Listening and serving HTTP on :8080.

Then test the API in another terminal:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"userId":108,"itemIdList":[1,2,39]}' \
  http://localhost:8080/api/v1/recommend

Should get the response like this:

{"itemScoreList":[
  {"itemId":1,"score":0.7517360474797006},
  {"itemId":2,"score":0.5240565619788571},
  {"itemId":39,"score":0.38496231172036016}
]}

So, with a higher score, user #108 may prefer movie #1 over #2 and #39.

Quick Start

To create a deep learning based recommendation system, you need to follow the steps below:

if you prefer show me the code, just go to MovieLens Example

  1. Implement the recommend.RecSys interface including func below:

    GetUserFeature(context.Context, int) (Tensor, error)
    GetItemFeature(context.Context, int) (Tensor, error)
    SampleGenerator(context.Context) (<-chan Sample, error)
  2. Call the functions to Train and StartHttpApi

    model, _ = recommend.Train(recSys)
    recommend.StartHttpApi(model, "/api/v1/recommend", ":8080")
  3. If you want better AUC with item embedding, you can implement the recommend.ItemEmbedding interface including func below:

    //ItemEmbedding is an interface used to generate item embedding with item2vec model
    //by just providing a behavior based item sequence.
    // Example: user liked items sequence, user bought items sequence, 
    //   user viewed items sequence
    type ItemEmbedding interface {
        ItemSeqGenerator() (<-chan string, error)
    }

    All you need to do is implement the functions of the gray part:

Docs

For more usage, please refer to the docs

Features

  • Pure Golang implementation, battery included.
  • Parameter Server based Online Learning
  • Training & Inference all in one binary powered by golang
  • Databases support
    • MySQL support
    • SQLite support
    • Database Aggregation accelerated Feature Normalization
  • Feature Engineering
    • Item2vec embedding
    • Rule based FE config
    • DeepL based Auto Feature Engineering
  • Demo
    • MovieLens Demo

Benchmark

Embedding

  • Apple M1 Max
  • Database: SQLite3
  • Model: SkipGram, Optimizer: HierarchicalSoftmax
  • WindowSize: 5
  • Data: MovieLens 10m
read 9520886 words 12.169282375s
trained 9519544 words 17.155356791s

Search Embedding of:
   59784 "Kung Fu Panda (2008)" Action|Animation|Children|Comedy

  RANK | WORD  | SIMILARITY  | TITLE & GENRES
-------+-------+-------------+-------------
     1 | 60072 |   0.974392  | Wanted (2008) Action|Thriller
     2 | 60040 |   0.974080  | Incredible Hulk, The (2008) Action|Fantasy|Sci-Fi
     3 | 60069 |   0.973728  | WALL·E (2008) Adventure|Animation|Children|Comedy|Romance|Sci-Fi
     4 | 60074 |   0.970396  | Hancock (2008) Action|Comedy|Drama|Fantasy
     5 | 63859 |   0.969845  | Bolt (2008) Action|Adventure|Animation|Children|Comedy
     6 | 57640 |   0.969305  | Hellboy II: The Golden Army (2008) Action|Adventure|Comedy|Fantasy|Sci-Fi
     7 | 58299 |   0.967733  | Horton Hears a Who! (2008) Adventure|Animation|Children|Comedy
     8 | 59037 |   0.966410  | Speed Racer (2008) Action|Adventure|Children
     9 | 59315 |   0.964556  | Iron Man (2008) Action|Adventure|Sci-Fi
    10 | 58105 |   0.963332  | Spiderwick Chronicles, The (2008) Adventure|Children|Drama|Fantasy

Movie Recommend Performance

Thanks

To make this project work, quite a lot of code are copied and modified from the following libraries:

Papers related

go-ctr's People

Contributors

auxten avatar daniel-robbins avatar nmreadelf avatar pengxiaotian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-ctr's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.