48
Building Cognitive Applications with Watson APIs CON 3054 @sandhyakapoor9 @frankgreco

Building Cognitive Applications with Watson APIs

Embed Size (px)

Citation preview

Page 1: Building Cognitive Applications with Watson APIs

Building Cognitive Applicationswith Watson APIsCON 3054@sandhyakapoor9 @frankgreco

Page 2: Building Cognitive Applications with Watson APIs

Background

Chairman NYJavaSIG (javasig.com) Largest Java UG in NA 8k+ members First Java UG ever! Sept 1995 mail: [email protected] twitter: @frankgreco yell: “Hey Frank!”

Developer Advocate – IBM Cloud Security Architect – WebSphere AS Mail: [email protected] twitter: @sandhyakapoor9

Page 3: Building Cognitive Applications with Watson APIs

To understand cognitive and machine learning applications

Why are they important

How to enhance your apps with cognitive services

Review the Watson Java SDK, and discuss how to enhance your apps with cognitive servives

Goal

Page 4: Building Cognitive Applications with Watson APIs

What Are We Going to Cover?

What Problems Are We Trying to Solve? Didn’t AI Try This Years Ago? Machine Learning Use Cases The Near Future Who are the Players What is Cognitive Computing? IBM Watson and Cognitive Computing Demos

Page 5: Building Cognitive Applications with Watson APIs

What Problems Need to be Solved?

Many applications are not explicitly programmable…

Cursive writing

translationAutonomous Driving

Face recognition

http://vision.ics.uci.edu/images/fun/IMG_1183_augmented_reality_faces1.jpghttps://commons.wikimedia.org/wiki/File:Looped_cursive_sample.jpg

Page 6: Building Cognitive Applications with Watson APIs

We are Used to Deterministic Solutions

Input Output

Same Input gives us the Same Output

Same Input gives us the Same Output

Same Input gives us the Same Output

Page 7: Building Cognitive Applications with Watson APIs

Most of Us are Not Used to Non-Deterministic Solutions

Output1

InputInputInputInput

InputInputInputImput

InputInputInputInputt

Output2

Output3

Lots of Noisy Datasets Sensors, voice, images, video Many variables with noisy data

Probabilistic Outputs Uncertainty, noisy data, randomness, statistical, different contexts, etc.

ModelA ModelB

ModelC ModelD

Page 8: Building Cognitive Applications with Watson APIs

Artificial Intelligence – But Didn’t We Try This Already?

AI had very Broad Scope

“Intelligent agents, first-order logic, knowledge ontologies, probabilistic reasoning, learning theory, NLP, robotics,…”

Wha’ Happened?

Funding was erratic due to lofty goals and missed milestones

Page 9: Building Cognitive Applications with Watson APIs

And Unfortunate Marketing…

Hey I thought “;” was a Terminator?

I’m Sorry Dave… But I did Inform You I was a Beta

Page 10: Building Cognitive Applications with Watson APIs

The Real Problem with AI

Much of historical AI was clever, but much of it was just conventional programming techniques.

Systems still had to be explicitly programmed…

Page 11: Building Cognitive Applications with Watson APIs

Machine Learning - ML

“Machine Learning” (1959) – Computers that learn without being explicitly

programmed

Page 12: Building Cognitive Applications with Watson APIs

AI and ML History

1956 – Dartmouth Research Project on AI 1961 – Arthur Samuel Checkers program beats

Champion 1970s – Minimal AI funding and progress 1980s – Expert Systems 1990s – Minimal AI funding and progress 1997 – IBM Deep Blue beats Chess Master Garry

Kasparov 2011 – IBM Watson beats 2 top Jeopardy

Champions 2014 – ML vision recognition surpasses humans

(Google,FB) 2016 – Google AlphaGo beats Go Champ 4 out of

5 games

We are now in accelerated growth era of ML and Cognitive Computing

Page 13: Building Cognitive Applications with Watson APIs

Software vs. Humans

Jeopardy2011

Chess 1997

Go 2016

Page 14: Building Cognitive Applications with Watson APIs

Already Being Used in Production

USPS Zip Code Scanning

Bank Checks Image

Submissions

Credit Card Anti Fraud

YouTube Recommendations

Spam filters Facebook Friend

Face Recognition

Apple Photos Image Recognition

Amazon Recommendations

Genome Discovery

Microsoft Skype Translation

Anti Terrorism Patterns

Autonomous Driving

Weather Prediction

Trading Systems

Natural Language Processing

Hacker Intrusion Detection

Page 15: Building Cognitive Applications with Watson APIs

Why the Growth All of a Sudden?

Page 16: Building Cognitive Applications with Watson APIs

We are in a Machine Learning “Spring”

No… not *that* Spring...

Huge advances over the past 10-15 years

Easy, cheap access to ML software via Services

Access to OSS frameworks and enginesWatson SDKs, etc.

Page 17: Building Cognitive Applications with Watson APIs

What’s in the Near Future

More sophisticated computer vision and image detection

Widespread video/media/et-al recommendation subsystems Separate of multiple voices in a crowd Musical instrument detection Brain, MRI and other medical pattern analysis

Over next 3-5 years, ML techniques/skills will be in huge demand

Make existing apps more usable -> more usage

Page 18: Building Cognitive Applications with Watson APIs

Who Are the Players?

Page 19: Building Cognitive Applications with Watson APIs

Now… What is Cognitive Computing?

“Cognitive computing has been used to refer to new hardware and/or software that mimics the functioning of the human brain and helps to improve human decision-making”- Wikipedia

Page 20: Building Cognitive Applications with Watson APIs

Cognitive Computing is Probabilistic

“Cognitive systems are probabilistic. They generate not just answers to numerical problems, but hypotheses, reasoned arguments and recommendations about more complex — and meaningful — bodies of data.” - Dr John E Kelly (IBM)

Page 21: Building Cognitive Applications with Watson APIs

So… Are There Categories of Cognitive Computing?

Data Enrichment, Augmentation

Translation

Image Recognition

Understandingunstructured data

Interacting with Humans

Page 22: Building Cognitive Applications with Watson APIs

Btw, written mostly in Java…

Page 23: Building Cognitive Applications with Watson APIs

IBM Watson and Cognitive Computing

Cognitive apps are built with Watson APIsWatson APIs use NLP and various Machine Learning models/algorithms “under the

hood”

Page 24: Building Cognitive Applications with Watson APIs

Cognitive apps are “mildly” cognitive or “highly” cognitive

IBM Watson and Cognitive Computing

Clever mimicry of the human brain using

conventional techniques

Apps that use deep learning ML algorithms

Cognitive Apps

mild

high

Page 25: Building Cognitive Applications with Watson APIs

Watson Services

Page 26: Building Cognitive Applications with Watson APIs

Java SDK for IBM Watson Services

The Moment You All Have Been Waiting For…

Page 27: Building Cognitive Applications with Watson APIs

https://github.com/watson-developer-cloud/java-sdk

Page 28: Building Cognitive Applications with Watson APIs

https://github.com/watson-developer-cloud/java-sdk

Page 29: Building Cognitive Applications with Watson APIs

public class Frank {

public static void main(String[] args) {

ToneAnalyzer service = new ToneAnalyzer(ToneAnalyzer.VERSION_DATE_2016_05_19);

service.setUsernameAndPassword(USER, PSWD); service.setEndPoint( "https://gateway.watsonplatform.net/tone-analyzer/api");

// Call the service and get the tone ToneOptions options = new ToneOptions.Builder().addTone(Tone.EMOTION) .addTone(Tone.LANGUAGE) .addTone(Tone.SOCIAL) .build();

ToneAnalysis tone = service.getTone(getInput(), options).execute();

System.out.println(tone); }

Page 30: Building Cognitive Applications with Watson APIs

% java FrankThe NullPointers are an awesome band and great musicians{ "document_tone": { "tone_categories": [ { "category_id": "emotion_tone", "category_name": "Emotion Tone", "tones": [ { "tone_id": "anger", "tone_name": "Anger", "score": 0.081246 },… { "tone_id": "joy", "tone_name": "Joy", "score": 0.811292 }, { "tone_id": "sadness", "tone_name": "Sadness", "score": 0.102273...

Page 31: Building Cognitive Applications with Watson APIs
Page 32: Building Cognitive Applications with Watson APIs

https://github.com/watson-developer-cloud/java-sdk

Page 33: Building Cognitive Applications with Watson APIs
Page 34: Building Cognitive Applications with Watson APIs

Cognitive Application : AskCognitiveCar.mybluemix.net

https://github.com/sandhya9/conversation-enhanced

Page 35: Building Cognitive Applications with Watson APIs

• Clone - git clone https://github.com/sandhya9/conversation-enhanced.git

• Click on “Deploy to Bluemix” button• Provide appname• Provide login credentials• Click Deploy

Steps to Setup, Build, Deploy and Test Cognitive Application

Page 36: Building Cognitive Applications with Watson APIs

On Successful Deployment:

Page 37: Building Cognitive Applications with Watson APIs

On click Edit Code – Your project is setup for Edits & Git Plugin

Page 38: Building Cognitive Applications with Watson APIs

Build and Deploy Pipeline

Page 39: Building Cognitive Applications with Watson APIs

Cognitive App bound to Watson services

Page 40: Building Cognitive Applications with Watson APIs

Conversing : Web Interface

Page 41: Building Cognitive Applications with Watson APIs

Conversation flow handled by Watson Conversation Service

Page 42: Building Cognitive Applications with Watson APIs

Flow in Conversation Tool

Page 43: Building Cognitive Applications with Watson APIs

Conversation handled by Retrieve and Rank

Page 44: Building Cognitive Applications with Watson APIs

Conversation Flow for answers retrieved from R&R Corpus

Page 45: Building Cognitive Applications with Watson APIs

Q, A, Rel, A, Rel..Q, A, Rel, A, Rel..Q, A, Rel, A, Rel..Q, A, Rel, A, Rel..…

Retrieve

Rank

Q

A3 A

7A2

1. Load & Index content in Solr

2. Train a model based on ground truth

3. Query the service with Natural language

4. Return re-ranked results based on machine learning model

How does R&R work?

Page 46: Building Cognitive Applications with Watson APIs

Resources

Working with intentshttps://www.youtube.com/watch?v=DmvN6ZJrZE4Working with entitieshttps://www.youtube.com/watch?v=oSNF-QCbuDc

Working with dialoghttps://www.youtube.com/watch?v=3HSaVfr3ty0

Building w/ Watson: Training Watson to Detect User Intenthttps://www.youtube.com/watch?v=uYw4Tv1Y5tcBuilding with Watson : New Tools for Dialog Scriptinghttps://www.youtube.com/watch?v=QuR54--vD5o

Page 47: Building Cognitive Applications with Watson APIs

Ask Technical Questions to NAO Robot and Amazon Echo

See AskDevoxxWatson Cognitive application in action at IBM’s Keynote on Thursday 9 am – 10:45 am.

Page 48: Building Cognitive Applications with Watson APIs

Thank You!

@sandhyakapoor9@frankgreco