{
  "id": "din",
  "name": "Deep Interest Network (DIN)",
  "description": "Alibaba 2018 DIN - the candidate item is the QUERY over the behaviour sequence, so the user embedding is computed per candidate instead of once. Local activation unit + MLP -> CTR.",
  "icon": "🎯",
  "category": "Recommendation",
  "components": [
    {
      "id": "in-seq",
      "type": "input",
      "name": "Behavior Seq (50 items)",
      "position": {
        "x": 80,
        "y": 60
      },
      "params": {
        "shape": [
          50
        ]
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "seq-emb",
      "type": "embedding",
      "name": "Item Embed",
      "position": {
        "x": 80,
        "y": 180
      },
      "params": {
        "vocabSize": 1000000,
        "embeddingDim": 64
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "in-tgt",
      "type": "input",
      "name": "Candidate Item",
      "position": {
        "x": 340,
        "y": 60
      },
      "params": {
        "shape": [
          1
        ]
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "tgt-emb",
      "type": "embedding",
      "name": "Candidate Embed",
      "position": {
        "x": 340,
        "y": 180
      },
      "params": {
        "vocabSize": 1000000,
        "embeddingDim": 64
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "din-att",
      "type": "targetAttention",
      "name": "Local Activation Unit",
      "position": {
        "x": 210,
        "y": 320
      },
      "params": {
        "embedDim": 64,
        "hiddenDim": 36,
        "activation": "dice"
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "in-user",
      "type": "input",
      "name": "User Profile",
      "position": {
        "x": 600,
        "y": 60
      },
      "params": {
        "shape": [
          16
        ]
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "user-fc",
      "type": "linear",
      "name": "User Tower",
      "position": {
        "x": 600,
        "y": 180
      },
      "params": {
        "inFeatures": 16,
        "outFeatures": 32
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "cat",
      "type": "concatenate",
      "name": "[interest; user]",
      "position": {
        "x": 400,
        "y": 440
      },
      "params": {
        "dim": 0,
        "numInputs": 2
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "fc1",
      "type": "linear",
      "name": "MLP 200",
      "position": {
        "x": 400,
        "y": 540
      },
      "params": {
        "inFeatures": 96,
        "outFeatures": 200
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "act1",
      "type": "prelu",
      "name": "Dice (~PReLU)",
      "position": {
        "x": 400,
        "y": 620
      },
      "params": {
        "numParameters": 1
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "fc2",
      "type": "linear",
      "name": "MLP 80",
      "position": {
        "x": 400,
        "y": 700
      },
      "params": {
        "inFeatures": 200,
        "outFeatures": 80
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "act2",
      "type": "prelu",
      "name": "Dice (~PReLU)",
      "position": {
        "x": 400,
        "y": 780
      },
      "params": {
        "numParameters": 1
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "ctr",
      "type": "linear",
      "name": "CTR Head",
      "position": {
        "x": 400,
        "y": 860
      },
      "params": {
        "inFeatures": 80,
        "outFeatures": 1
      },
      "inputs": [],
      "outputs": []
    },
    {
      "id": "sig",
      "type": "sigmoid",
      "name": "Sigmoid",
      "position": {
        "x": 400,
        "y": 940
      },
      "params": {},
      "inputs": [],
      "outputs": []
    },
    {
      "id": "out",
      "type": "output",
      "name": "pCTR",
      "position": {
        "x": 400,
        "y": 1020
      },
      "params": {},
      "inputs": [],
      "outputs": []
    }
  ],
  "connections": [
    {
      "id": "c1",
      "from": "in-seq",
      "to": "seq-emb",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c2",
      "from": "in-tgt",
      "to": "tgt-emb",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c3",
      "from": "tgt-emb",
      "to": "din-att",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c4",
      "from": "seq-emb",
      "to": "din-att",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c5",
      "from": "in-user",
      "to": "user-fc",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c6",
      "from": "din-att",
      "to": "cat",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c7",
      "from": "user-fc",
      "to": "cat",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c8",
      "from": "cat",
      "to": "fc1",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c9",
      "from": "fc1",
      "to": "act1",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c10",
      "from": "act1",
      "to": "fc2",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c11",
      "from": "fc2",
      "to": "act2",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c12",
      "from": "act2",
      "to": "ctr",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c13",
      "from": "ctr",
      "to": "sig",
      "fromPort": "bottom",
      "toPort": "top"
    },
    {
      "id": "c14",
      "from": "sig",
      "to": "out",
      "fromPort": "bottom",
      "toPort": "top"
    }
  ]
}