Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
1099 lines (924 sloc) 19.3 KB

Jungian personality in a chatbot

Please interupt

I like discussion..

Communication training

  • Important
  • Expensive

Communicate!

./img/client-communicate.png

Editor

./img/editor.png

Salve

Social practice

  • Context
  • Culture
  • Activity

Emotions

  • OCC
  • Decay based
  • In drools

Scenes

  • Group patterns
  • More argressive

Architecture

./img/abstract-architecture.png

AIML

<aiml>
<categroy>
    <pattern>
        Hello
    </pattern>
    <template>
        Hi
    </template>
</categroy>
<category>
    <pattern>
        How are you *
    </pattern>
    <template>
        Not doing too well today.
    </template>
</category>
</aiml>

S-AIML

<aiml>
<category>
    <pattern>why are you here</pattern>
    <preconditions>not healthProblemAsked</preconditions>
    <template>
        <insert
            packageName="sp.anamnesi.health_problem"
            typeName="HealthProblemAsked"
        />
        I'm experiencing a <getDroolsTemplate />. It's quite strong.
    </template>
</category>
</aiml>

Drools rule

rule "Greetings goals achieved"
when
	GreetingReceived()
then
	FinishedSceneEvent f = new FinishedSceneEvent();	
	f.setSceneName("Greetings");
	insert(f);
end
rule "Greeting not received in time"
when
	$startScene:EnterScene(scene.name=="Greetings")	
	not(GreetingReceived(this after[0ms,10000ms] $startScene))
then
	OCCNotHappenedEvent e=new OCCNotHappenedEvent();
	don(e,DesirableEvent.class);
	don(e,ProspectedRelevantEvent.class);
	insert(e);
	controller.respond("Did you want something from me..?");
end

Client view

./img/client.png

Goals

  • Compare personality theories
  • As a process
  • Use Salve game

Personality theories

OCEAN

  • Taxonomy mining
  • Factor analyses
  • No theory
  • Accepted
  • Measure: NEO-PI, NEO-FFI

Jung

  • Personality types
  • Free form questions
  • Introversion vs Extroversion
  • Rational vs Irattional

\[\mathcal{J} = \{ T_e, T_i, F_e, F_i, S_e, S_i, N_e, N_i\} \]

Rationale: Thinking

/<>
$T_e$Thinking extroverted
$T_i$Thinking introverted

Rationale: Feeling

/<>
$F_e$Feeling extroverted
$F_i$Feeling introverted

Irationale: Sensing

/<>
$S_e$Sensing extroverted
$S_i$Sensing introverted

Irationale: Intuition

/<>
$N_e$Intuition extroverted
$N_i$Intuition introverted

MBTI

  • Carl Jung
  • Quesstionaire measurement
  • In order
  • Critizised
  • PPSDQ, SL-TDI

\[ INTJ = N_i > T_e > F_i > S_e \]

Which one is the best?

We need:

  • Realism
  • Implementable

OCEAN

Has:

  • Realism
  • Implementable

Because:

  • Accepted,
  • very broad

MBTI

Has:

  • Realism
  • Implementable

Because:

  • Solid thoery
  • Finite types (16)

Which one is the best?

Jung

  • Can assume MBTI
  • Later PPSDQ or SL-TDI
  • Mapping to OCEAN

Dialogue as process

Some syntax

  • Categories
  • Arrows

\[ a → a \] \[ a → b \]

Model the idea

Type signatures

\[a → b → c \] \[a → (b → c) \]

partial apply with $a$

\[ b → c \]

Data

\[ \text{a and b}=(a,b) \] \[ \text{list a}=[a] \]

Every agent ever

\[ B → π → (B, Δ) \]

/<>
$B$Believes
$π$Sense information
$Δ$Actions

Every chatbot ever

Stateless: \[ σ → σ \]

Statefull: \[ B → σ → (σ, B) \]

/<>
$σ$String
$B$Believes

Core idea

Add in between step: \[ σ → s \] \[ s → σ\]

/<>
$σ$String
$s$Symbol

Statefull symbol chatbot

\[B → s → (s, B)\]

/<>
$B$Believes
$s$Symbol

Connect symbols in graph

\[ c = (s_1, s_2) \] \[ s_1, s_2 ∈ \mathcal{S} ∧ c ∈ G \]

/<>
$c$connection
$s$Symbol
$\mathcal{S}$All encoded symbols
$G$Symbol graph

Add game tree

\[ u = (a,s) \] \[ D = (u, [D])\]

/<>
$u$Utterance
$a$Actor
$s$Symbol
$D$Dialogue tree

Reasoning model

\[ B → D \overset{f_a}{→} (B, D) \]

/<>
$B$Believes
$D$Dialogue tree
$f_a$Jungian function

In order

\[ f_a → f_a \]

or

\[ \text{personality} = [f_a] \]

Define process per function

Rational vs Irrational

  • Action generation
  • Sort by preference
  • Modify the Dialogue tree

Irrational

Action generation

  • $N_i$ Depth first
  • $N_e$ Depth + $x$ breath
  • $S_e$ Breath (all available)
  • $S_i$ Learned connection else random

Rational

Sorts by preference

  • $T_e$ Priority on goals, else scene transitions
  • $T_i$ Priority on goals, else favour more options
  • $F_i$ Interal perlocutionary values
  • $F_e$ Learned perlocutionary values

Goals

\[ φ = (a, s) \]

/<>
$a$Actor
$s$Symbol
$φ$Goal
  • Can compare priority
  • Can see if finished

Perlocutionary values

Modified connections:

\[ c = (s_1, s_2, P) \]

/<>
$c$connection
$s$Symbol
$P$Perlocutionary value set

Use Salve game

Remember

Every chat bot ever: \[ σ → σ \]

/<>
$σ$String

Even Alice with AIML

\[ σ → σ \]

<aiml>
<category>
    <pattern>
        How are you
    </pattern>
    <template>
        Not doing too well today.
    </template>
</category>
</aiml>

#+RESULTS[cdac880ca96d70107675a3e4cdecac66c5964660]: fig:pres:depaimlcats img/uml/pres:depaimlcats.svg

The in between step

\[ σ → s \] \[ s → σ\]

/<>
$σ$String
$s$Symbol

$σ → s$

<aiml>
<category>
    <pattern>
        How are you
    </pattern>
    <symbol>
      StatusInquiry
    </symbol>
</category>
</aiml>

#+RESULTS[f83625dd3fa507ca4453e722687426a5ec24e8a2]: fig:pres:aimlsyms img/uml/pres:aimlsyms.svg

$s → σ$

<aiml>
<category>
    <literal>
        How are you?
    </literal>
    <patterns>
        <pattern>How * you</pattern>
        <pattern>How are you *</pattern>
    </patterns>
    <symbol>
      StatusInquiry
    </symbol>
</category>
</aiml>

#+RESULTS[aa85d6107856d0b7663a997957e89a8222357207]: fig:pres:aimlliters img/uml/pres:aimlliters.svg

Terser

<literal>
    How are you?
</literal>
<patterns>
    <pattern>How * you</pattern>
    <pattern>How are you *</pattern>
</patterns>

With:

  • Symbol name in filename
    • Free uniqueness gauranteed by FS
  • Drop aiml tags
  • Drop category tags

But Illegal XML

So we use YAML

literals:
  - How are you
patterns:
  - How * you
  - How are you *

Still with symbol name as filename.

Symbol graph

\[ c = (P, A, s_1, s_2) \] \[ s_1, s_2 ∈ \mathcal{S} ∧ c ∈ G \]

/<>
$c$connection
$s$Symbol
$P$Perlocutionary values
$A$Restricted to
$\mathcal{S}$All encoded symbols
$G$Symbol graph

In YAML

from:
 - greeting
to:
 - symbol: status_inquery
 - symbol: greeting

#+RESULTS[0089ec823ad6cc3d0e145d4f62c3fe471a7895b6]: fig:pres:connections img/uml/pres:connections.svg

Steering

Starting from a dialogue

WhoUtterance
DoctorHi
SanderHello
DoctorHow can I help you?
SanderI have a back pain.
DoctorWhen did this first occur?
SanderWhen I lifted a heavy object.
DoctorOh, yes then you need some pain killers for this.
SanderThank you doctor

Create

literals:
  - Hello
  - Hi
from:
 - greeting
to:
 - symbol: greeting
 - symbol: status
 - symbol: ask_reason_here
   scene: information_gathering

Make believes

Goals

\[ φ = (a, s) \]

/<>
$a$Actor
$s$Symbol
$φ$Goal
goals:
  - actor: doctor
    scene: diagnoses
    symbol: have_painkillers
  - actor: patient
    scene: information_gathering
    symbol: back_pain

Values

values:
  enthusiasm: 8
  polite: 5
from:
 - greeting
to:
 - symbol: greeting 
   values:
   - Polite
 - symbol: status
   restricted_to: patient
   values:
   - Polite
   - Enthusiasm

Actors

self: patient
actors:
  - patient
  - doctor

Personality

# ENFP
personality: [Ne, Fi, Te, Si]

All together

goals:
  - actor: doctor
    scene: diagnoses
    symbol: have_painkillers
  - actor: patient
    scene: information_gathering
    symbol: back_pain
values:
  enthusiasm: 8
  polite: 5

self: patient
actors:
  - patient
  - doctor

# ENFP
personality: [Ne, Fi, Te, Si]

Can also add drool rules

rule "Low level hello replies with hello first time"
when
	$pre:PreProcessed(
      $symbol:utterance.what, 
      $symbol.name == "introduction/greeting", 
      $actor:utterance.byWhom
    )
	$believes:Believes($actor != self)
then
	log.info("low level entry");
	delete($pre);

	final Informative infor = new Informative($believes.self, $symbol);
	final Utterance resulting = $believes.findToFromLastUttTo(infor)
		.map(Utterance::createFromConnection)
		.orElse(Utterance.create(infor.who, infor.what, PerlocutionaryValueSet.empty));
	insert(new Reply(resulting.setByWhom(infor.who), QueryDatabase.empty));
end

Current architecture

./img/uml/architecture-concept.svg

Testing

  • Create dialogue
  • Implement
  • Act like doctor
  • Expect replies
  • INTJ, ENFP, ISTP

Conclusion

  • Used Jung theory
  • Replaced AIML
  • Center of deliberation
  • Works for scenario

Future work

Social practice

  • Culture
  • Context
  • Norms

Multilogue architecture

./img/uml/n-agent-arch.svg

Other ideas

  • Use linguistic theory
  • Dynamically create symbol graph
  • Fuzzy matching
  • Statistical matching
  • GPU based matching
  • Emotions
  • UI improvements

Questions?