Building Intelligent Apps with
MongoDB and Google Cloud
Jane Fine
Director of Product Marketing, Analytics
jane.fine@mongodb.com
@janeuyvova
Analytics is a Constant Underachiever
2000
Business Intelligence
Data Warehouse, OLAP,
Ad-hoc, Reporting, Dashboards
Big Data
Hadoop, MapReduce,
Predictive, ML, Real-time
2010
AI
Intelligent Things, IoT,
Systems of Engagement
2017
“In 2018, 75% of AI projects will underwhelm because they fail to model operational considerations, causing
business leaders to reset the scope of AI investments.”
FORRESTER.COM/PREDICTIONS
$40B+ eCommerce platform
experience of millions of mobile
gamers
metadata for every single item
for sale on eBay.com
world’s leading design
collaboration platform
20M+ users
$150B+ traded
reinvent travel for millions of
customers
lab and clinical analysis for
innovative medicines
personal and business finance
management worldwide
Applications Change Our World
Operational
AI
ML
What We Set Out To Do
ecommerceapp
shop for
products
online
Intelligent App
mobileshoppingchatbot
get personalized
product
recommendations
shop over
MMS/WhatsApp
on mobile device
rec engine
ML
What’s an Intelligent App?
Applications are increasingly combining real-time analytics, machine learning
and AI to provide understand the customer, automate their tasks and provide
knowledge and decision support
Why Is This Hard?
Intelligent App
Developers
Data Scientists
uses: live data
guided by: user stories
produces: functionality
uses: prepared data
guided by: question
produces: insight
RELEASE DEFINE
BUILD
AGILE
DATA
PREP
BUILD
MODEL
GET
INSIGHT
VIZ
DEPLOY
TRAIN/EVAL
eCommerce App: SwagStore
eCommerce App: SwagStore
Get notified when a
sold-out item is
restocked
Browse for your favorite
MongoDB swag
Put items in cart and
checkout
View your orders
Stitch: MongoDB Serverless Platform
Streamlines app development with
simple, secure access to data and
services from the client with
thousands of lines less code to write
and no infrastructure to manage.
Getting your apps to market faster
while reducing operational costs.
SwagStore: How We Built It
UI components
Routes
Application Flow Control
Google Authentication
Twilio Notifications
Functions
Rules
Triggers
Service Integrations
Flexible Document Model
Easy to Work With Data
DEMO: SwagStore
SwagStore + RecEngine
Intelligent eCommerce App: SwagStore +
Receive personalized
product
recommendations based
on ML algorithm
Recommendation
Engine
Intelligent SwagStore: How We Built It
SwagStore
Google Cloud ML Trains and
Tunes Model
TensorFlow WALS Algorithm
Google Cloud Endpoints
Serves Recommendations
Stitch Initiates
Recommendations
developer data scientist developer
data engineer
Production Recommendation Solution on
GCP
Google Analytics
BigQuery
Google Analytics
360
Customer Web
Application
Web
Server
Application
Server
Database
Server
Rec API
App Engine
Cloud
Endpoints
Model Training
Cloud Machine Learning
Orchestration
Cloud Composer
ML Data
Training
Model files
Browser
Client
Mobile /
Tablet Client
The Recommendation API
Google Analytics
BigQuery
Rec API
App Engine
Cloud
Endpoints
Model Training
Cloud Machine Learning
ML Data
Training
Model files
UserID
User factor x
Item factors
Item ID &
User ID
Maps
Sort & Filter
Article
Index
List
Item ID &
User ID
Maps
Article ID
List
ML Model
Training Recommendation Model
1. install the model code
2. place data into your Cloud Storage Bucket
3. run training script
When the training is finished, the model data is saved in a subdirectory named model under
the job directory of the training task. This data consists of several arrays, all saved in numpy
format
./mltrain.sh train
gs://recserve_jfmlrecengine/swag_pageviews.csv
--data-type web_views
Tuning Recommendation Model
Hyperparameter tuning optimizes your machine learning model for most accuracy
Typically data scientists experimenting with various values, test the model, and then pick a combination
of parameters with the best performance.
But you can test every possible combination of parameters…. it would take a very very long time
● Each hyperparameter is passed to the
hyperparameter tuning job on Cloud ML Engine.
● The model writes a TensorFlow summary with a
special tag that's set to the metric that evaluates
the quality of the model.
● This summary metric enables the search
process of the Cloud ML Engine hyperparameter
tuning service to rank the trials.
./mltrain.sh tune
gs://recserve_jfmlrecengine/
swag_pageviews.csv
--data-type web_views
Generate Recommendations
model.py : generate_recommendations
input
user: row index of the user in the rating matrix
items: list of indexes for items that the user has
rated / viewed
latent factors: row and column factors generated by
training / tuning the model
number of desired recommendations
https://jfmlrecengine.appspot.com/recommendation?user
Id=5448543647176335931&numRecs=6
{"articles":
["299824032"
,"299935287"
,"299865757"
,"299959410"
,"298157062"
,"299816215"
]}
Serving Recommendations with Stitch
MongoDB Stitch send a HTTP GET request to
Google Cloud Endpoint to obtain
recommendations
For user who is logged in
Get list of product
recommendations
Update user profile with
that list
Service Integrations make it simple for
your app to use leading third party
services
Functions: build complex logic and orchestrate data between
clients, and services
Stitch scales precisely to meet your usage.
DEMO:
SwagStore + RecEngine
SwagStore + ChatBot
Intelligent eCommerce App: SwagStore +
Shop for products via
chat interface
AI Chatbot
Intelligent SwagStore: How We Built It
SwagStore
Google DialogFlow:
Intent, Entities, Webhooks
Stitch - Intent Fulfilment Slack - Front End
developer
data scientist
developer data engineer
DialogFlow + Stitch Architecture
Stitch HTTP
Service
Webhook
Stitch Functions to
retrieve products from
MongoDB
Me: “Can you help me find a jacket?”
ChatBot: “What color would you like?”
Me: “White, please”
ChatBot: “I found you a white Egmont Jacket”
DialogFlow: Rich and Natural
Conversational Experiences
Stitch Service
Integration
Enabling DialogFlow Fulfillment With Stitch
Stitch security enabled by default
Enabling DialogFlow Fulfillment With Stitch
return item from SwagStore Catalog to
DialogFlow
{
"fulfillmentText": "I found you a
white Egmont Packable Jacket. Check it
out here:
https://mdb-swag-store.netlify.com/pro
ducts/299824032"
}
perform $find given
parameters requested
by DialogFlow: product
type and product color
DEMO:
SwagStore + ChatBot
Working Together
Developers
Data Scientists
DATA
PREP
BUILD
MODEL
GET
INSIGHT
VIZ
DEPLOY
TRAIN/EVAL
RELEASE DEFINE
BUILD
AGILE
Build. Plug In. Innovate.
Intelligent App
Resources and Credits
Aydrian Howard, Jesse Krasnostein, Mike Lynn, Drew DiPalma, Avery Rosen, Shawn
McCarthy, Seong Park...
Lukman Ramsey & Asher Halpert
MongoDB Stitch:
https://www.mongodb.com/cloud/stitch
Google Cloud ML:
Tutorials: https://cloud.google.com/solutions/machine-learning/recommendation-system-tensorflow-train-cloud-ml-engine
GitHub: https://github.com/GoogleCloudPlatform/tensorflow-recommendation-wals
DialogFlow:
https://dialogflow.com/docs/getting-started
Thank You!

MongoDB.local Austin 2018: Building Intelligent Apps with MongoDB & Google Cloud

  • 1.
    Building Intelligent Appswith MongoDB and Google Cloud
  • 2.
    Jane Fine Director ofProduct Marketing, Analytics jane.fine@mongodb.com @janeuyvova
  • 3.
    Analytics is aConstant Underachiever 2000 Business Intelligence Data Warehouse, OLAP, Ad-hoc, Reporting, Dashboards Big Data Hadoop, MapReduce, Predictive, ML, Real-time 2010 AI Intelligent Things, IoT, Systems of Engagement 2017 “In 2018, 75% of AI projects will underwhelm because they fail to model operational considerations, causing business leaders to reset the scope of AI investments.” FORRESTER.COM/PREDICTIONS
  • 4.
    $40B+ eCommerce platform experienceof millions of mobile gamers metadata for every single item for sale on eBay.com world’s leading design collaboration platform 20M+ users $150B+ traded reinvent travel for millions of customers lab and clinical analysis for innovative medicines personal and business finance management worldwide Applications Change Our World
  • 5.
    Operational AI ML What We SetOut To Do ecommerceapp shop for products online Intelligent App mobileshoppingchatbot get personalized product recommendations shop over MMS/WhatsApp on mobile device rec engine ML
  • 6.
    What’s an IntelligentApp? Applications are increasingly combining real-time analytics, machine learning and AI to provide understand the customer, automate their tasks and provide knowledge and decision support
  • 7.
    Why Is ThisHard? Intelligent App Developers Data Scientists uses: live data guided by: user stories produces: functionality uses: prepared data guided by: question produces: insight RELEASE DEFINE BUILD AGILE DATA PREP BUILD MODEL GET INSIGHT VIZ DEPLOY TRAIN/EVAL
  • 8.
  • 9.
    eCommerce App: SwagStore Getnotified when a sold-out item is restocked Browse for your favorite MongoDB swag Put items in cart and checkout View your orders
  • 10.
    Stitch: MongoDB ServerlessPlatform Streamlines app development with simple, secure access to data and services from the client with thousands of lines less code to write and no infrastructure to manage. Getting your apps to market faster while reducing operational costs.
  • 11.
    SwagStore: How WeBuilt It UI components Routes Application Flow Control Google Authentication Twilio Notifications Functions Rules Triggers Service Integrations Flexible Document Model Easy to Work With Data
  • 12.
  • 13.
  • 14.
    Intelligent eCommerce App:SwagStore + Receive personalized product recommendations based on ML algorithm Recommendation Engine
  • 15.
    Intelligent SwagStore: HowWe Built It SwagStore Google Cloud ML Trains and Tunes Model TensorFlow WALS Algorithm Google Cloud Endpoints Serves Recommendations Stitch Initiates Recommendations developer data scientist developer data engineer
  • 16.
    Production Recommendation Solutionon GCP Google Analytics BigQuery Google Analytics 360 Customer Web Application Web Server Application Server Database Server Rec API App Engine Cloud Endpoints Model Training Cloud Machine Learning Orchestration Cloud Composer ML Data Training Model files Browser Client Mobile / Tablet Client
  • 17.
    The Recommendation API GoogleAnalytics BigQuery Rec API App Engine Cloud Endpoints Model Training Cloud Machine Learning ML Data Training Model files UserID User factor x Item factors Item ID & User ID Maps Sort & Filter Article Index List Item ID & User ID Maps Article ID List ML Model
  • 18.
    Training Recommendation Model 1.install the model code 2. place data into your Cloud Storage Bucket 3. run training script When the training is finished, the model data is saved in a subdirectory named model under the job directory of the training task. This data consists of several arrays, all saved in numpy format ./mltrain.sh train gs://recserve_jfmlrecengine/swag_pageviews.csv --data-type web_views
  • 19.
    Tuning Recommendation Model Hyperparametertuning optimizes your machine learning model for most accuracy Typically data scientists experimenting with various values, test the model, and then pick a combination of parameters with the best performance. But you can test every possible combination of parameters…. it would take a very very long time ● Each hyperparameter is passed to the hyperparameter tuning job on Cloud ML Engine. ● The model writes a TensorFlow summary with a special tag that's set to the metric that evaluates the quality of the model. ● This summary metric enables the search process of the Cloud ML Engine hyperparameter tuning service to rank the trials. ./mltrain.sh tune gs://recserve_jfmlrecengine/ swag_pageviews.csv --data-type web_views
  • 21.
    Generate Recommendations model.py :generate_recommendations input user: row index of the user in the rating matrix items: list of indexes for items that the user has rated / viewed latent factors: row and column factors generated by training / tuning the model number of desired recommendations https://jfmlrecengine.appspot.com/recommendation?user Id=5448543647176335931&numRecs=6 {"articles": ["299824032" ,"299935287" ,"299865757" ,"299959410" ,"298157062" ,"299816215" ]}
  • 22.
    Serving Recommendations withStitch MongoDB Stitch send a HTTP GET request to Google Cloud Endpoint to obtain recommendations For user who is logged in Get list of product recommendations Update user profile with that list Service Integrations make it simple for your app to use leading third party services Functions: build complex logic and orchestrate data between clients, and services Stitch scales precisely to meet your usage.
  • 23.
  • 24.
  • 25.
    Intelligent eCommerce App:SwagStore + Shop for products via chat interface AI Chatbot
  • 26.
    Intelligent SwagStore: HowWe Built It SwagStore Google DialogFlow: Intent, Entities, Webhooks Stitch - Intent Fulfilment Slack - Front End developer data scientist developer data engineer
  • 27.
    DialogFlow + StitchArchitecture Stitch HTTP Service Webhook Stitch Functions to retrieve products from MongoDB
  • 28.
    Me: “Can youhelp me find a jacket?” ChatBot: “What color would you like?” Me: “White, please” ChatBot: “I found you a white Egmont Jacket” DialogFlow: Rich and Natural Conversational Experiences Stitch Service Integration
  • 29.
    Enabling DialogFlow FulfillmentWith Stitch Stitch security enabled by default
  • 30.
    Enabling DialogFlow FulfillmentWith Stitch return item from SwagStore Catalog to DialogFlow { "fulfillmentText": "I found you a white Egmont Packable Jacket. Check it out here: https://mdb-swag-store.netlify.com/pro ducts/299824032" } perform $find given parameters requested by DialogFlow: product type and product color
  • 31.
  • 32.
  • 33.
    Build. Plug In.Innovate. Intelligent App
  • 34.
    Resources and Credits AydrianHoward, Jesse Krasnostein, Mike Lynn, Drew DiPalma, Avery Rosen, Shawn McCarthy, Seong Park... Lukman Ramsey & Asher Halpert MongoDB Stitch: https://www.mongodb.com/cloud/stitch Google Cloud ML: Tutorials: https://cloud.google.com/solutions/machine-learning/recommendation-system-tensorflow-train-cloud-ml-engine GitHub: https://github.com/GoogleCloudPlatform/tensorflow-recommendation-wals DialogFlow: https://dialogflow.com/docs/getting-started
  • 35.