Intent resolution#
Intent resolution from ambiguous commands and context cues (robots, assistants, interfaces).
A user’s intent is one of K options (“fetch the red cup”, “fetch the blue cup”, …). Each context cue (a word, a gesture, a gaze direction, the time of day) carries a likelihood over intents. Classical Bayesian updating multiplies the likelihoods, so the order in which cues arrive does not matter.
QuantumIntentResolver represents belief as amplitudes \(\psi = \sqrt{\text{prior}}\) and
applies each cue c as a Kraus operator
where \(R(\theta_c)\) rotates the intent basis by the cue’s incompatibility angle \(\theta_c\), in the plane of the cue’s two most likely intents. With every \(\theta_c = 0\) the posterior is exactly Bayes’ rule; \(\theta_c \neq 0\) makes cues incompatible, so their order matters, as in question-order effects. The angles can be fitted to observed choices.
Examples
>>> from quantum_mind.applications.intent import QuantumIntentResolver
>>> r = QuantumIntentResolver(['red cup', 'blue cup', 'bowl'])
>>> _ = r.add_cue('points left', [0.70, 0.20, 0.10], theta=0.5)
>>> _ = r.add_cue('looks right', [0.25, 0.60, 0.15], theta=0.5)
>>> r.posterior(['points left', 'looks right']).round(3)
array([0.482, 0.498, 0.02 ])
>>> round(r.order_effect('points left', 'looks right'), 3)
0.079
Classes
Quantum-like intent resolver; it reduces to |
|
Classical baseline: posterior proportional to the prior times the cue likelihoods. |
- class QuantumIntentResolver(intents, prior=None)[source]#
Bases:
BayesIntentResolverQuantum-like intent resolver; it reduces to
BayesIntentResolverwhen every angle is 0.- Parameters:
intents (
sequenceofstr) – Names of the K possible intents.prior (
array_like, optional) – Prior over intents; the initial amplitudes are its square roots.
- add_cue(name, likelihood, theta=0.0)[source]#
Register a cue as a Kraus operator.
- Parameters:
- Returns:
QuantumIntentResolver–self.
- posterior(cues)[source]#
Intent probabilities \(|\psi|^2\) after applying the cues in order.
- Parameters:
cues (
sequenceofstr) – Names of registered cues, in the order they arrived.- Returns:
- class BayesIntentResolver(intents, prior=None)[source]#
Bases:
objectClassical baseline: posterior proportional to the prior times the cue likelihoods.
- Parameters:
intents (
sequenceofstr) – Names of the K possible intents.prior (
array_like, optional) – Prior over intents (normalised); uniform by default.
- Variables:
cues (
dict) – Registered cues, by name.
- add_cue(name, likelihood, theta=0.0)[source]#
Register a cue.
- Parameters:
name (
str) – Cue name.likelihood (
array_like) – Non-negative likelihood of the cue under each intent.theta (
float, optional) – Ignored here (classical cues commute); used byQuantumIntentResolver.
- Returns:
BayesIntentResolver–self, so calls can be chained.
- posterior(cues)[source]#
Intent probabilities after a sequence of cues.
- Parameters:
cues (
sequenceofstr) – Names of registered cues.- Returns:
numpy.ndarray– Posterior over intents (independent of the order ofcues).