1 of 48

Building products with

ML & TensorFlow

@svonava, svonava@gmail.com, svonava.com

2 of 48

How is ML used today (MIT Tech Review*, 2016)

Already achieved

Objectives

*375 C-suite/VP/enterprise devs across USA, EU & India

3 of 48

How is ML used today (MIT Tech Review, 2016)

Primary driver for ML?

4 of 48

How is ML used today (MIT Tech Review, 2016)

% of 2017 budget dedicated to ML

5 of 48

Strategy & tactics

6 of 48

But first a bit of history!

“a machine which senses, recognizes, remembers, and responds like the human mind”

The New Yorker

7 of 48

But first a bit of history!

“a machine which senses, recognizes, remembers, and responds like the human mind”

The New Yorker, 1958

8 of 48

The 60ties

Rosenblatt

9 of 48

The 60ties

10 of 48

The 80ties

11 of 48

The 80ties

Feature engineering!

Back propagation!

12 of 48

Deep[er] learning

13 of 48

Deep learning (mNeuron)

14 of 48

Deep learning (mNeuron)

Convolution!

15 of 48

Remember late 2010 & mobile first?

16 of 48

17 of 48

Strategy & tactics

18 of 48

Strategy: Talent

Hire

  • don’t ask a Quant to figure out your business model
  • design autonomy
  • $$$ for compute & data acquisition
  • Never alone!

Grow

  • ML ninja (SWE + PM)
  • project incubation
  • ML office hours/consulting

Spread!

ML guidelines, internal training, open-sourcing

19 of 48

Strategy: Infrastructure

Pre-trained APIs → Custom Models

General comp. (GPU) → ASIC (TPU)

Pipelines (pre/post processing)

Efficient model training (ASIC)

Model serving

or deploy to mobile

Interactive analysis

Data acquisition

Storage

Pre-trained model APIs

20 of 48

Strategy: Infrastructure

21 of 48

Strategy: Frameworks

Static comp. graph�Tensorflow

Tooling, deployment, domain-specific abstractions ...

Dynamic comp. graph�PyTorch

Variable length data is padded by zeros etc.�→ Batching & efficiency

Forward comp. like numpy�→ Easier adoption

i = tf.constant(0)�c = lambda i: tf.less(i, 10)�b = lambda i: tf.add(i, 1)�r = tf.while_loop(c, b, [i])

for _ in range(T):� h = torch.matmul(W, h) + b

22 of 48

Strategy: Risk

What can go wrong?

23 of 48

Strategy: Risk

24 of 48

Strategy: Risk

  • Self-driving autopilot failures.
  • Amplification of training-data biases saw failures in Insurance, Law enforcement, Health care.
  • Skin-color & variation in shapes of human body cause AI Vision failures.
  • User-generated content & advertising.

→ Invest in human oversight, fallback solutions & PR/expectation management.

25 of 48

Strategy: Ethics

Disruption of worker & employer negotiation, hiding behind ‘neutral’ technology.

Simple

  • Drivers don’t see the destination, so they don’t cherry-pick profitable jobs.

ML

  • Drivers are manipulated through notifications to be available during off-peak.
  • Social networks allow targeting such as ‘insecure teens’.
  • Elections & public manipulation using micro-targeting.

→ No standard ethics code and no way to transparently enforce… but check AI Now.

26 of 48

Strategy: Ethics

60% of all jobs have 30% of tasks readily automatable (McKinsey).

27 of 48

Strategy & tactics

28 of 48

Personalization

Automation

Anticipation

Forecasting

Data processing

Anomaly detection

external

internal

29 of 48

Personalization

Automation

Anticipation

Forecasting

Data processing

Anomaly detection

external

internal

UX for window-shopper vs fire-and-forget.

Receipt input for expenses.

Reactive → Proactive (Search vs. Google Now)

Web traffic forecast for Ad selling.

Sentiment analysis on users to prioritize dev.

Fraud prevention.

30 of 48

  1. What problem are we solving?
  • New feature vs. more automatic/faster?
  • Do the users want it? How much value? User journeys?
  • Success metrics?
    • Quality, latency, what do we measure against?
  • Risks?
    • How can the solution backfire? How much damage? Adversarial tests?

31 of 48

  1. What data do we need to collect?
  • What features:
    • as fine-grained as possible (notes vs live perf story)
    • don’t stress ‘feature engineering’ (evolution of vision features story)
    • IDs as features, the best for personalization but sucks for forecasting/transfer learning (need user clusters for that)
  • Needs to capture 2 spaces:
    • Feature-to-feature - “What videos are watched in session by a person?”
    • Feature-to-label - “People that watched X are more passive.
  • If we need labels, how do we get them?
    • Ask users? Human annotation? Expert-based rules?

32 of 48

  • And how much data?

Degrees of freedom:

  • 1000s of examples of each class
  • 10s of examples of every feature
  • 10s of examples for every model parameter

Complexity of the model:

  • Simple linear: 100s
  • Shallow NN: 100,000s
  • Deep learning: Tens of millions or more

→ More data & simpler models.

→ The less independent the examples, the more of them you need.

→ Easy test: How much can you sample/downscale the examples → gives “useful bits”.

33 of 48

  1. Executing the ML solution
  • Pick algorithms based on the success metrics & the data we could get.
  • Pick a simple one and invest 50% time into building quality eval (ask users if helpful, track their behavior changes, backtest forecasts, human evals etc).
  • Build an experiment framework (exposed vs control) for eval & release process.�→ Feedback loops!

34 of 48

Before AI, go HI

  1. Test the product idea using a ‘human intelligence’ backend.
  2. Scale up using mechanical turk APIs.�→ Hello training data!
  3. Roll-out ML.

35 of 48

Before AI, go HI

Google Surveys

  • targeting: android users, zip-code, screening questions
  • can be multi-question to identify relationships
  • $0.3/response for single-question
  • $3/response for multi-question

36 of 48

Before AI, go HI

body_def = {� 'title': 'Student cell phone ownership',� 'description': 'Ownership of cell.',� 'owners': owner_emails,� 'wantedResponseCount': 100,� 'audience': {� 'country': 'US',� },� 'questions': [� {� 'question': 'Do you own a cell phone?',� 'type': 'singleAnswer',� 'answers': ['Yes', 'No'],� }� ]�}�surveys_service.surveys().insert(body=body_def).execute()

37 of 48

Before AI, go HI

Amazon Mechanical Turk

  • More complex tasks (image annotation, extract data from websites etc).
  • Targeting: demo, country, language, but also stuff like ‘holds ETFs’ or ‘exercise 2-3 times a week’, etc.
  • Pricing: Worker reward up to you ($0.05/simple task at least).
  • See API sample - still pretty easy.

→ Near-real time (x minutes) with:

Alegion, StintMint, SquadRun (also possible with Amazon)

38 of 48

Getting labeled data for free?

Check out human-based computation games (wikipedia).

39 of 48

Scaling & latency beyond HI - pre-trained models!

40 of 48

Case study: Natural Language Processing (Wootric)

41 of 48

TensorFlow: Tensor-glove (Google Cloud) - low entry bar

Input: Couple 100s labeled points (3 classes) in 3D.

42 of 48

TensorFlow: Tensor-glove (Google Cloud)

Steps:

  1. Visualize & notice the linear separability.

43 of 48

TensorFlow: Tensor-glove (Google Cloud)

Steps:

  • Visualize & notice the linear separability.
  • Train a model yclasses = Wweights * xinputs + bbiases

44 of 48

TensorFlow: Tensor-glove (Google Cloud)

# define the modelimport tensorflow as tf�weights = tf.Variable(tf.zeros([3, 3]), dtype=tf.float32) # The model learns this�biases = tf.Variable(tf.zeros([3]), dtype=tf.float32) # and this.�glove_data = tf.placeholder(tf.float32) # Sensor data goes here e.g. [[5 .3 47]..]. �rps_data = tf.matmul(glove_data, weights) + biases # Encodes y=Wx+b.��# define the loss�rps_labels = tf.placeholder(tf.float32) # Labels for glove_data e.g. [[1 0 0]..].

loss = tf.losses.softmax_cross_entropy(onehot_labels=rps_labels, logits=rps_data)

Softmax - squish rps_data to [0, 1] with sum = 1 (probabilities)

Cross entropy - diff of the probabilities and the one-hot representation

45 of 48

TensorFlow: Tensor-glove (Google Cloud)

# define an optimizer�optimizer = tf.train.GradientDescentOptimizer(learning_rate=1).minimize(loss)�# create a Session�sess = tf.Session()�# init the variables�initializer = tf.global_variables_initializer()�sess.run(initializer)�# train the modelfor i in range(10000):� # train the model� sess.run(optimizer, {glove_data: g_data, rps_labels: g_label})� # print current lossif i % 1000 == 0:� l = sess.run(loss, {glove_data: g_data, rps_labels: g_label})

46 of 48

TensorFlow: Tensor-glove (Google Cloud)

47 of 48

What’s next?

  • Generative adversarial networks (GANs) (log forecasting story)
  • Variational autoencoders (VANs)

48 of 48

Thank you!

Follow @svonava for more generative goodness coming soon!