Top Banner
x.ai a personal assistant who schedules meetings for you MONGO WORLD 2015 NEW YORK CITY VISIT X.AI TO JOIN THE WAITLIST Using MongoDB at x.ai varun vijayaraghavan @xdotai
23

Building an An AI Startup with MongoDB at x.ai

Jul 25, 2015

Download

Technology

MongoDB
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building an An AI Startup with MongoDB at x.ai

x.ai a personal assistant who schedules meetings for you

MONGO WORLD 2015 NEW YORK CITY VISIT X.AI TO JOIN THE WAITLIST

Using MongoDB at x.ai

varun vijayaraghavan@xdotai

Page 2: Building an An AI Startup with MongoDB at x.ai

Magically Schedule Meetings

Just Cc: [email protected]

Page 3: Building an An AI Startup with MongoDB at x.ai

Pain Solution Jane John Jane [email protected] John

CC: Amy @ x.ai“Amy, please set something up for Jane and I next week.”

Page 4: Building an An AI Startup with MongoDB at x.ai

Product Characteristics

● Need quick response

● Supervised Learning requires large training data set

● # meetings scale linearly with # users

● 1 user meets with N people

● People share meeting, places, times and company

Page 5: Building an An AI Startup with MongoDB at x.ai

Technical challenges

● Natural language understanding with extremely high accuracy

● Natural conversation over email with people

● Complex data relationship

● Optimize for sparse data

● Speed of development and change

Page 6: Building an An AI Startup with MongoDB at x.ai

Stack

Page 7: Building an An AI Startup with MongoDB at x.ai

Queue Based Architecture

Page 8: Building an An AI Startup with MongoDB at x.ai

Modeling Meetings

Meetings

People

Places Times

1:N and N:N relationships across various collections

Page 9: Building an An AI Startup with MongoDB at x.ai

Modeling Meetings{

host : Participant,guests : [Participant],time : { start : Date,

end: Date, recurring: String},

timezone : String,duration : Number,locations : [Location],timeInitiated : Date,timeRescheduled: [Date],timeCompleted: Date,status : String,landmarks: [Landmark],activities: [Activity]…...

}

Page 10: Building an An AI Startup with MongoDB at x.ai

Embedding vs. Referencing

{ host : { name : {.....}, nicknames : [String], phones : [{Type: String}] primaryEmail : String, secondaryEmails : [String], title : String, signatures: [String], …... }, travelTime : String, status : String, timezone : String, duration : Number, …...}

{ host : Participant, travelTime : String, status : String, timezone : String, duration : Number, …...}

Participant { name : {.....}, nicknames : [String], phones : [{Type: String}] primaryEmail : String, secondaryEmails : [String], title : String, signatures: [String], …... },

Embedding ReferencingConsiderations

● Query patterns

● Access to embedded doc

● # references to a doc

● Application level join

● 1-way or 2-way referencing

Page 11: Building an An AI Startup with MongoDB at x.ai

Assistant is a PERSON Assistant is an Attribute of PERSON

Assistant is a PROFILE, a separate and smaller

entity

Modeling someone’s assistant1st try 2nd try 3rd try

{ name : {.....}, nicknames : [String], phones : [{Type: String}] primaryEmail : String, secondaryEmails : [String], title : String, signatures: [String] …...}

{ name : { first : String, last: String }, primaryEmail : String }

{ name : {.....}, nicknames : [String], phones : [{Type: String}] primaryEmail : String, secondaryEmails : [String], title : String, signatures: [String], assistant : { name : {.....}, primaryEmail : String } …...}

Page 12: Building an An AI Startup with MongoDB at x.ai

Dealing with schema changes

Issues

● Inconsistent character offsets

● Inconsistent time representation

● Improper sent date (yr 2026)

● Key info not saved

Fixes

● Recalculate character offsets

● Reconstruct time entities

● Recalculate timezone based on context

● Filter out unsalvageable data

Page 13: Building an An AI Startup with MongoDB at x.ai

Schemaless vs. Typesafe

● Discrepancy between models in Scala versus stored data in mongo.

○ MongoDB stores free form nested structures

○ Scala relies on strict, type safed models for data

● Models in flux

○ Data extraction (write) vs. decision making (read) formats

○ We are continuously learning new edge case about scheduling meetings

Page 14: Building an An AI Startup with MongoDB at x.ai

Mongoose

● A very nice object modeling and querying library for mongodb with node.js.

● Client side schema layer

● Useful features

○ Data validation

○ “Virtual” fields

○ Nested documents with automatic _id reference

○ Client side joins across collections and databases

Page 15: Building an An AI Startup with MongoDB at x.ai

Interactive Applications Architecture

Internal API powered by express-restify-mongo provides a plug-n-play API layer for mongoose and MongoDB

Page 16: Building an An AI Startup with MongoDB at x.ai

Model evolution with mongoose

{ host : Participant guests : [Participant] ... activity: String ...}

Meeting Format in Mongo

Activity Model

New Scala Model for Meeting

case class Meeting (host: Participantguests:

List[Participant]...activities:

List[Activity]...

)

case class Meeting (host: Participantguests:

List[Participant]...activity: String...

)

case class Activity (id: String,activity: String

)

Initial Scala Model for Meeting

Page 17: Building an An AI Startup with MongoDB at x.ai

Ease transition with Virtual field

MeetingSchema.virtual( "activities" ).get( function() { var virtualActivity = { id: randomString(), activity: this.activity } return [virtualActivity];});

Page 18: Building an An AI Startup with MongoDB at x.ai

Feeding data science

Page 19: Building an An AI Startup with MongoDB at x.ai

ML training architecture

Page 20: Building an An AI Startup with MongoDB at x.ai

Using Mongo for ML: What we need

● Heavy on experimentation○ Need to train on different parameters, algorithms, data sets

● Nested data sets that are dependent on the specific experiment○ Emails have several feature types, each of which have several

parameters

● Mongo models to work well with Scala models

Page 21: Building an An AI Startup with MongoDB at x.ai

Using Mongo for ML: The beginning

{"messageId":"<somerandommessage@xxxx>",

"classes" : ["A", "B", "C"],

"featureVector" : [ [

"OneGrams", [ { "work" : 3 }, { "that" : 1 }, … ] ],

[ "TwoGrams",

[ { "that work" : 1 }, { "you then" : 1 }, ]],...

}

case class Features (messageId: String,classes: List[String],featureVector:

List[Tuple2[String, List[Map[String, Integer]]]])

Scala

Mongo

Page 22: Building an An AI Startup with MongoDB at x.ai

Mongo for ML: Make it work with Scala

{ "messageId" : "<somerandommessage@xxxx>", "classifierLabels" : [ { "classifier" : "MeetingClassifier", "class" : "A" } ], "featureVector" : [ { "featureType" : "TaggedOneGram", "featureKeys" : [ { "featureKey" : "work", "featureValue" : 3 }, { "featureKey" : "that", "featureValue" : 1 }, ... ] }, ... ]}

case class Features (messageId: String,classes: List[Classes],featureVector:

List[FeatureVectors])

case class Classes (classifier: String,class: String

)

case class FeatureVectors(featureType: String,featureKeys: List[FeatureKeys]

)

case class FeatureKey(featureKey: String,featureValue: 1

)

ScalaMongo

Page 23: Building an An AI Startup with MongoDB at x.ai

varun @ human.x.aibackend engineer

25 Broadway. 9th FloorNew York, 10004 NY

E: [email protected]: @xdotai

Visit x.ai to join the waitlist