safety bot guaranteed -- shmoocon 2017

80
January 15, 2017 SAFETY BOT GUARANTEED RICH SEYMOUR

Upload: richard-seymour

Post on 29-Jan-2018

101 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Safety Bot Guaranteed -- Shmoocon 2017

January 15, 2017

SAFETY BOT

GUARANTEED

RICH SEYMOUR

Page 2: Safety Bot Guaranteed -- Shmoocon 2017

Who Am I?

Data Scientist at Endgame

Got a PhD in Materials Science doing

nanoscale simulations on supercomputers

Play bass in a band (bleach bones)

@rseymour on twitter

2

Page 3: Safety Bot Guaranteed -- Shmoocon 2017

Outline

Bots

Safety

Their powers combined!

3

Page 4: Safety Bot Guaranteed -- Shmoocon 2017

Outline

Bots

Safety

Their powers combined!

4

Page 5: Safety Bot Guaranteed -- Shmoocon 2017

BOTS

the hype cycle peaks?

Page 6: Safety Bot Guaranteed -- Shmoocon 2017

Talking about chatbots

Image and many of these bot

slides courtesy of bot master

and coworker:

Bobby Filar @filar

6

Page 7: Safety Bot Guaranteed -- Shmoocon 2017

Popular Bots

Amazon – Alexa

Apple - Siri

Facebook - M

Google - Google Home

Microsoft – Cortana

7

Page 8: Safety Bot Guaranteed -- Shmoocon 2017

Bots are Changing Lives

8

Page 9: Safety Bot Guaranteed -- Shmoocon 2017

Bots are Changing Lives Pt 2

9

Page 10: Safety Bot Guaranteed -- Shmoocon 2017

Bots Boiled Down

Bots take words and turn them into actions.

“Alexa, turn on the lamp” “Ok”

“Open the pod bay doors HAL”

10

Page 11: Safety Bot Guaranteed -- Shmoocon 2017

Voice Recognition and Speech Synthesis

We don’t need

these pieces to

have a bot

11

Text to

Speech

bot

Speech

to Text

Page 12: Safety Bot Guaranteed -- Shmoocon 2017

Click-Through vs. Conversational Interfaces

12

+ 6 more steps

vs

Id like to order a cheese pizza.

Great! What size pizza would

you like?

Medium

Okay. I have an order for a

medium cheese pizza. Is that

all?

Yes. That is all.

Page 13: Safety Bot Guaranteed -- Shmoocon 2017

Causes of the Bot Revolution?

Platform Diversity

• Messaging

• Intelligent assistants

• Team collaboration software

App Stagnation

• More users on messaging platforms

• Hard to gain traction w/in App Stores

Ease-of-Use

• Simplifies UI/UX

• Allows user to maintain focus on current screen/activity

• Provide walkthroughs

• Eliminates need to know query languages

13

Cortana

Page 14: Safety Bot Guaranteed -- Shmoocon 2017

Bot Development Kits (BDKs)

The rise of bots is largely due to an increase in BDKs

Companies like Chatfuel, Wit.ai, and API.ai

• Provide simple UI for development

• Closed-domain, Rule-based, goal-oriented bots

• No programming skills required

How popular have these frameworks become?

• Wit.ai purchased by Facebook (Jan 2015)

• API.ai purchased by Google (Sep 2016)

Major companies pushing out frameworks too!

• Microsoft Bot Framework

• Amazon Alexa Skills Kit

14

Page 15: Safety Bot Guaranteed -- Shmoocon 2017

What bots are made of.

Page 16: Safety Bot Guaranteed -- Shmoocon 2017

GENERATIVE RETRIEVAL

16

OPEN DOMAIN CLOSED DOMAIN

LONG CONVERSATION SHORT CONVERSATION

Types of Bots

Active Research Surprisingly Easy

Page 17: Safety Bot Guaranteed -- Shmoocon 2017

GOOD BOTS

DoNotPay Bot

• Bot helps people fight parking tickets

• Wildly successfully in 3 major cities

Esterbot

• QA bot tied to a LinkedIn account or resume.

• Recruiters talk to a bot before they get to you

BAD BOTS

Microsoft TayBot

• Great idea gone terribly

awry

• Learning from internet

conversations sometimes

leads to being…

the worst.

17

Good Bots and Bad Bots

Page 18: Safety Bot Guaranteed -- Shmoocon 2017

18

GENERATIVE RETRIEVAL

PROS

• Bots of the future!

• Excellent recall ability

• Ability to learn as exposure to

user increases

• Simple to implement

• Smaller datasets

• No grammatical mistakes

CONS

• Requires a lot of data

• Complex models large

vocabularies massive training

time for model building

• Prone to grammatical errors

• Really, really inappropriate…

right TayBot?

• Not intelligent

• Limited “memory”

• Works best in closed-domain, short

conversation scenarios

Which is best?

Page 19: Safety Bot Guaranteed -- Shmoocon 2017

Bot Workflow aka Bot Vocabulary

Session

Identity

Dialogue Script

Context

Intents

Entities

Action

19

Page 20: Safety Bot Guaranteed -- Shmoocon 2017

Pattern Matching without Context (Eliza 1964-1966)

20

Page 21: Safety Bot Guaranteed -- Shmoocon 2017

Context & Intent

Context (teal)

• Current state

• Steers conversation

• Ensures all req’d parameters are

collected to perform Action

Intent (red)

• Maps Utterance (blue) specific

Action

• What does the user want?

21

Page 22: Safety Bot Guaranteed -- Shmoocon 2017

Entities

Entities are parameters needed to satisfy Intents and execute Actions.

Entities can be anything

• File hash

• IP address

• Cities

Permutations of an entity allow for diversity of vocabulary

• Regular Expressions

• Synonyms22

Page 23: Safety Bot Guaranteed -- Shmoocon 2017

Training Data

Few bot developers have necessary

training data

BDKs provide access to Domains or

pre-defined Knowledge packages:

• Reservations

• Small Talk

• Weather

BDKs log user interactions to constantly

update training set

23

Page 24: Safety Bot Guaranteed -- Shmoocon 2017

Natural Language Processing & Machine Learning

BDKs have built in ML/NLP capabilities

NLP used to handle incoming data

• Tokenization

• Word Boundary & Word Sense

• Synonym generation

• Entity extraction

ML used to classify user input to an Intent and map

to an output

• Supervised Learning

• Features: n-gram or word-based vectors

• Model constantly updated as bot gets used

24

Input NLP

Output ML

features

Page 25: Safety Bot Guaranteed -- Shmoocon 2017

NLP 101 Direct Matching (No ML)

Show flights from Washington to Denver on Monday

Show flights from Washington to Denver on Monday

Show flights from Washington to Denver on Monday

VB NNS IN NNP IN NNP IN NNP

if utterance contains show_vb AND flights_nns:

Utterance

Tokenization

Parts-of-SpeechTagging (POS)

Show flights from Washington to Denver on MondayNamed EntityRecognition (NER) Location Location Date

SHOW_FLIGHTS(Washington, Denver, Monday)

Perform Action

25

Page 26: Safety Bot Guaranteed -- Shmoocon 2017

NLP 101 ML-Based

Show flights from Washington to Denver on Monday

Show flights from Washington to Denver on Monday

Utterance

Tokenization

Show flights from Washington to Denver on MondayNamed EntityRecognition (NER)

Location Location Date

0 1 1 0 1 0 1 0 1 1 0 0 1Bag-of-Words(Feature Vector)

SHOW_FLIGHTS

CHANGE_FLIGHTS

BOOK_FLIGHTS

Intent Classification SHOW_FLIGHTS(location, location, date)

SHOW_FLIGHTS(Washington, Denver, Monday)Perform Action

26

Page 27: Safety Bot Guaranteed -- Shmoocon 2017

Getting started with this Language Stuff

I recommend spaCy available

at spacy.io

27

Page 28: Safety Bot Guaranteed -- Shmoocon 2017

How can bots help Security?

Some Ideas

Page 29: Safety Bot Guaranteed -- Shmoocon 2017

Guidance and Training

29

Is the command line a chatbot?

Page 30: Safety Bot Guaranteed -- Shmoocon 2017

Guidance and Training

30

disown

Page 31: Safety Bot Guaranteed -- Shmoocon 2017

Guidance and Training

31

Page 32: Safety Bot Guaranteed -- Shmoocon 2017

Search

32

Page 33: Safety Bot Guaranteed -- Shmoocon 2017

Search (but not security twitter, let’s say your logs)

33

“What can I help you with today?”

“Show me all of the processes running that started in the last hour”

“Ok which endpoints?”

Page 34: Safety Bot Guaranteed -- Shmoocon 2017

Search (but not security twitter, let’s say your logs)

34

“What can I help you with today?”

“Show me all of the processes running that started in the last hour”

“Ok which endpoints?”

Page 35: Safety Bot Guaranteed -- Shmoocon 2017

Search (but not security twitter, let’s say your logs)

35

“What can I help you with today?”

“Show me all of the processes running that started in the last hour”

“Ok which endpoints?”

“Everyone!”

“Ok”

Search results ensue

Page 36: Safety Bot Guaranteed -- Shmoocon 2017

Question and Answer Bots

36

Page 37: Safety Bot Guaranteed -- Shmoocon 2017

Q&A Bots

37

Page 38: Safety Bot Guaranteed -- Shmoocon 2017

Chat Ops and Checklists

38

Hubot – GitHub *

ScoreBot - Netflix

* https://www.youtube.com/watch?v=NST3u-GjjFw

Page 39: Safety Bot Guaranteed -- Shmoocon 2017

Chat Ops and Checklists

39

Ignorance

Ineptitude

Page 40: Safety Bot Guaranteed -- Shmoocon 2017

Chat Ops and Checklists

40

Page 41: Safety Bot Guaranteed -- Shmoocon 2017

Chat Ops and Checklists

41

But checklists are

the worst!

Page 42: Safety Bot Guaranteed -- Shmoocon 2017

Chat Ops and Checklists

42

Well maybe bake the checklists into the bots?

Page 43: Safety Bot Guaranteed -- Shmoocon 2017

Outline

Bots

Safety (get shmoo balls out)

How To!

43

Page 44: Safety Bot Guaranteed -- Shmoocon 2017

Safety

Page 45: Safety Bot Guaranteed -- Shmoocon 2017

Safety!

45

Page 46: Safety Bot Guaranteed -- Shmoocon 2017

Just what is Safety?

How is Safety different from

Security?

46

Page 47: Safety Bot Guaranteed -- Shmoocon 2017

Just what is Safety?

How is Safety different from

Security?

Safety generally means

preventing people getting hurt47

Page 48: Safety Bot Guaranteed -- Shmoocon 2017

Just what is Safety?

Safety ideas have historically

been borrowed by Security.

48

Page 49: Safety Bot Guaranteed -- Shmoocon 2017

Domino Theory -- Heinrich 1931

49

Page 50: Safety Bot Guaranteed -- Shmoocon 2017

Domino Theory -- Heinrich 1931

50

Bigotry

included

Page 51: Safety Bot Guaranteed -- Shmoocon 2017

Others have followed

51

Root Cause Analysis

Fault Tree Analysis

Swiss-cheese model

Page 52: Safety Bot Guaranteed -- Shmoocon 2017

Engineering a Safer World

52

Engineering a Safer WorldSystems Thinking Applied to Safety

Nancy G. Leveson2012

Systems Theoretic Process Analysis

(STPA)

Page 53: Safety Bot Guaranteed -- Shmoocon 2017

Engineering a Safer World

53

Engineering a Safer WorldSystems Thinking Applied to Safety

Nancy G. Leveson2012

Systems Theoretic Process Analysis

(STPA)

Page 54: Safety Bot Guaranteed -- Shmoocon 2017

Systems Thinking Applied to Safety

54

Bertalanffy

Wiener

Page 55: Safety Bot Guaranteed -- Shmoocon 2017

Systems Thinking Applied to Safety

55

Bertalanffy – Systems Theory

Wiener - Cybernetics

Page 56: Safety Bot Guaranteed -- Shmoocon 2017

Safety Defined

56

Hazard: a system state or set of conditions that combined with worst case environmental conditions will lead to an accident

Accident: an event that results in an unacceptable level of loss

Safety: freedom from accidents

Page 57: Safety Bot Guaranteed -- Shmoocon 2017

The Driving Force of Systems Safety

57

Accidents today happen while

the each component of the

system is working

Page 58: Safety Bot Guaranteed -- Shmoocon 2017

The Driving Force of Systems Safety

58

The accidents we see now are:

Component Interaction

Accidents

Page 59: Safety Bot Guaranteed -- Shmoocon 2017

The Driving Force (continued)

59

“Preventing future accidents requires shifting from a focus on preventing failures to the broader goal of designing and implementing controls that will enforce the necessary constraints.”

Page 60: Safety Bot Guaranteed -- Shmoocon 2017

What it doesn’t do

60

It doesn’t use Risk %s

It doesn’t catalog possible failure

It doesn’t blame operator error

It doesn’t triage

Page 61: Safety Bot Guaranteed -- Shmoocon 2017

Purpose

61

What does your system do?

Page 62: Safety Bot Guaranteed -- Shmoocon 2017

Losses

62

Unacceptable.

Not component failures.

Real. Bad. Stuff.

Page 63: Safety Bot Guaranteed -- Shmoocon 2017

Hazards

63

What could make you suffer a

loss?

Threats?

Page 64: Safety Bot Guaranteed -- Shmoocon 2017

Hazards

64

What could make you suffer a loss?

Threats?

Check out William Young’s STPA-Sec work

Page 65: Safety Bot Guaranteed -- Shmoocon 2017

Constraints

65

How can we stop hazards from

becoming losses.

How can these in turn be

violated. (iterate)

Page 66: Safety Bot Guaranteed -- Shmoocon 2017

The minimal system

66

Page 67: Safety Bot Guaranteed -- Shmoocon 2017

The minimal system

67

Yup, just

boxes

and

arrows!

Page 68: Safety Bot Guaranteed -- Shmoocon 2017

68

Nancy Leveson’s

outline of possible

“control flaws leading

to hazards”

Engineering a Safer

World

p 93

Page 69: Safety Bot Guaranteed -- Shmoocon 2017

Very High Level

69

Page 70: Safety Bot Guaranteed -- Shmoocon 2017

Maybe this is a useful process?

70

Page 71: Safety Bot Guaranteed -- Shmoocon 2017

Maybe this is a useful process?

71

Page 72: Safety Bot Guaranteed -- Shmoocon 2017

STPA takes a high level view, early in the design

72

What if we had a bot to help us

go through this process?

Page 73: Safety Bot Guaranteed -- Shmoocon 2017

Outline

Bots

Safety

How To! (SafetyBot!)

73

Page 74: Safety Bot Guaranteed -- Shmoocon 2017

SafetyBot

Page 75: Safety Bot Guaranteed -- Shmoocon 2017

STPA takes a high level view, early in the design

75

What if we had a bot to help us

go through this process?

What if you had ~ 2 weeks to

write such a bot!

Page 76: Safety Bot Guaranteed -- Shmoocon 2017

GENERATIVE RETRIEVAL

76

OPEN DOMAIN CLOSED DOMAIN

LONG CONVERSATION SHORT CONVERSATION

Types of Bots

Active Research Surprisingly Easy

Page 77: Safety Bot Guaranteed -- Shmoocon 2017

Choose a language you’ve never used!

77

Page 78: Safety Bot Guaranteed -- Shmoocon 2017

SafetyBot

78

context

Context

manager

Node

entity

Node

entity

context

Node

entity

Current

context

Next

context

The context manager is the main

loop

Prints out bot talk and pulls in

user input.

That is then passed to the current

‘node’ for processing / storage

Page 79: Safety Bot Guaranteed -- Shmoocon 2017

SafetyBot

Live Demo

Page 80: Safety Bot Guaranteed -- Shmoocon 2017

Thanks thanks thanks thanks thanks!

80

Questions?