Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
CHMM Inference in PRISM
1. Inference with
Constrained Hidden Markov Models
in PRISM
Henning Christiansen Christian Theil Have
Ole Torp Lassen Matthieu Petit
Research group PLIS: Programming, Logic and Intelligent Systems
Department of Communication, Business and Information Technologies
Roskilde University, P.O.Box 260, DK-4000 Roskilde, Denmark
ICLP 2010 in Edinburgh, July 16, 2010
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
2. Outline
1 Motivation and background
Hidden Markov Models
Biological sequence alignment with pair HMMs
2 Constrained HMMs
CHMMs as a constraint program
Decoding algorithm for CHMMs
Implementation in PRISM
3 Summary and future directions
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
3. Motivation and background
Motivation
In the LoSt project we explore the use of Probabilistic Logic
programming (with PRISM) for biological sequence analysis
Hidden Markov Models are one of the most widely used models for
sequence analysis
Constrained Hidden Markov Models (CHMMs) allow us to express
relevant prior knowledge and prune the search space
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
4. Motivation and background
Contributions and similar work
Contributions
Expressing CHMMs as a constraint problem
Adaptation of Viterbi decoding algorithm for CHMMs
Efficient implementation of CHMMs in PRISM
Similar work
In [SK08] introduces the concept of CHMMs
[CPC08] express relationships in Bayesian Network as a CLP
Constrained Conditional Models [CRR08] augments (discriminative)
models with declarative constraints
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
5. Motivation and background Hidden Markov Models
Hidden Markov Models
Definition
A Hidden Markov Model (HMM) is a 4-tuple S, A, T , E , where
S = {s0 , s1 , . . . , sm } is a set of states which includes an initial state
referred to as s0 ;
A = {e1 , e2 , . . . , ek } is a finite set of emission symbols;
T = {(p(s0 ; s1 ), . . . , p(s0 ; sm )), . . . , (p(sm ; s1 ), . . . , p(sm ; sm ))} is a set
of transition probability distributions representing probabilities to
transit from one state to another;
E = {(p(s1 ; e1 ), . . . , p(s1 ; ek )), . . . , (p(sm ; e1 ), . . . , p(sm ; ek ))} is a set
of emission probability distributions representing probabilities to emit
each symbol from one state.
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
6. Motivation and background Hidden Markov Models
Hidden Markov Model, graphical example
Postcard
Greetings from wherever, where I am having a
great time. Here is what I have been doing: The
first two days, I stayed at the hotel reading a
good book. Then, on the third day I decided to
go shopping. The next three days I did nothing
but lie on the beach. On my last day, I went
shopping for some gifts to bring home and wrote
you this postcard.
Sincerely, Some friend of yours
Observation sequence
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
7. Motivation and background Hidden Markov Models
Hidden Markov Model run
Definition
A run of an HMM as a pair consisting of a sequence of states
s (0) s (1) . . . s (n) , called a path and a corresponding sequence of emissions
e (1) . . . e (n) , called an observation, such that
s (0) = s0 ;
∀i, 0 ≤ i ≤ n − 1, p(s (i) ; s (i+1) ) > 0
(probability to transit from s (i) to s (i+1) );
∀i, 0 < i ≤ n, p(s (i) ; e (i) ) > 0
(probability to emit e (i) from s (i) ).
Definition
The probability of such a run is defined as
i=1..n p(s (i−1) ; s (i) ) · p(s (i) ; e (i) )
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
8. Motivation and background Hidden Markov Models
Decoding with Hidden Markov Models
Decoding: Inferring the hidden path given the observation sequence.
argmaxpath P(path|observation)
Computed in linear time using dynamic programming:
The Viterbi algorithm can be seen as keeping track of, for each prefix of
an observed emission sequence, the most probable (partial) path leading to
each possible state, and extending those step by step into longer paths,
eventually covering the entire emission sequence.
source: wikipedia
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
9. Motivation and background Biological sequence alignment with pair HMMs
A tiny bit of biological motivation
Biologists often want to align sequences (e.g. DNA, proteins, etc.)
which are thought to have descended from a common ancestor
Sequence alignment is fundamental to bioinformatics
We (computer scientists) can just consider biological sequences as a
list of symbols
The number of possible of alignments is exponential
An optimal alignment can be found using a Pair HMM in
O(|sequence|2 ∗ |states|2 )
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
10. Motivation and background Biological sequence alignment with pair HMMs
Pair HMMs for sequence alignment
A pair HMM is a special kind of HMM that emits two sequences
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
11. Motivation and background Biological sequence alignment with pair HMMs
Pair HMMs for sequence alignment
A pair HMM is a special kind of HMM that emits two sequences
The match state emit a pair (xi yj ) of symbols
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
12. Motivation and background Biological sequence alignment with pair HMMs
Pair HMMs for sequence alignment
A pair HMM is a special kind of HMM that emits two sequences
The match state emit a pair (xi yj ) of symbols
The insert state emits one symbol xi , from sequence x
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
13. Motivation and background Biological sequence alignment with pair HMMs
Pair HMMs for sequence alignment
A pair HMM is a special kind of HMM that emits two sequences
The match state emit a pair (xi yj ) of symbols
The insert state emits one symbol xi , from sequence x
The delete state emits one symbol yj , from sequence y
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
14. Motivation and background Biological sequence alignment with pair HMMs
Pair HMMs for sequence alignment
A pair HMM is a special kind of HMM that emits two sequences
The match state emit a pair (xi yj ) of symbols
The insert state emits one symbol xi , from sequence x
The delete state emits one symbol yj , from sequence y
A run of this model produces an alignment of x and y
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
15. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x
sequence y
alignment b
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
16. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H
sequence y
alignment b i
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
17. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H G
sequence y
alignment b i i
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
18. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H G K
sequence y
alignment b i i i
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
19. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H G K K
sequence y K
alignment b i i i m
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
20. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H G K K G
sequence y K G
alignment b i i i m m
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
21. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H G K K G A
sequence y K G P
alignment b i i i m m m
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
22. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H G K K G A
sequence y K G P K
alignment b i i i m m m d
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
23. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H G K K G A
sequence y K G P K K
alignment b i i i m m m d d
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
24. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H G K K G A A
sequence y K G P K K A
alignment b i i i m m m d d m
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
25. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H G K K G A A Q
sequence y K G P K K A Q
alignment b i i i m m m d d m m
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
26. Motivation and background Biological sequence alignment with pair HMMs
Alignment with a pair Hidden Markov Model
Observation sequence x Observation sequence y
H G K K G A A Q V K G P K K A Q A
sequence x H G K K G A A Q V
sequence y K G P K K A Q A
alignment b i i i m m m d d m m m
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
27. Constrained HMMs
1 Motivation and background
Hidden Markov Models
Biological sequence alignment with pair HMMs
2 Constrained HMMs
CHMMs as a constraint program
Decoding algorithm for CHMMs
Implementation in PRISM
3 Summary and future directions
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
28. Constrained HMMs
Constrained HMMs
Definition
A constrained HMM (CHMM) is a 5-tuple S, A, T , E , C where,
S, A, T , E is an HMM
C is a set of constraints, each of which is a mapping from HMM runs
into {true, false}.
A run of a CHMM, path, observation is a run of the corresponding HMM
for which C (path, observation) is true.
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
29. Constrained HMMs
Constrained HMMs
Why extend an HMM with side-constraints?
To create better, more specific models with fewer states
Convenient to express prior knowledge in terms of constraints
No need to change underlying HMM
Sometimes it is not possible or feasible to express such constraints as
HMM structure (e.g. all different)
→ infeasibly huge state and parameter space
fewer paths to consider for any given sequence
→ decreased running time
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
30. Constrained HMMs CHMMs as a constraint program
Runs of a CHMM as a constraint program
We consider runs of CHMM as a constraint program over finite domains.
A run of CHMM is a solution of the constraint program
run([s (0) , S1 , . . . , Sn ], [E1 , . . . , En ]),
dom(Si ) = S {s0 } ∧ dom(Ei ) = E
The variable Si represents the HMM state at step i
The variable Ei represents the emission at the step i
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
31. Constrained HMMs CHMMs as a constraint program
Definition of the HMM run program
The run predicate is specified as follows,
run([s (0) , S1 , . . . , Sn ], [E1 , . . . , En ]) is true iff
∃s (1) ∈ dom(S1 ), . . . , ∃s (n) ∈ dom(Sn )∧
∃e (1) ∈ dom(E1 ), . . . , ∃e (n) ∈ dom(En )∧
C (s (0) s (1) . . . s (n) , e (1) . . . e (n) ) is true, s (0) = s0 ∧
p(s (0) ; s (1) ) · p(s (1) ; e (1) ) . . . p(s (n−1) ; s (n) ) · p(s (n) ; e (n) ) > 0.
This states that
s (0) s (1) . . . s (n) and e (1) . . . e (n) is a HMM run which satisfies C .
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
32. Constrained HMMs CHMMs as a constraint program
The HMM structure
The last line in the definition,
p(s (0) ; s (1) ) · p(s (1) ; e (1) ) . . . p(s (n−1) ; s (n) ) · p(s (n) ; e (n) ) > 0
indicates the (local) relationships between Si ,Si+1 and Si ,Ei which
correspond to the structure of the HMM. We define these relationships in
terms of constraints,
trans(Si−1 , Si ) ∧ emit(Si , Ei ), for all i, 1 ≤ i ≤ n
trans(Si , Si+1 ) is true iff emit(Si , Ei ) is true iff
∃s (i) ∈ dom(Si ) ∧ s (i+1) ∈ dom(Si+1 ) ∃s (i) ∈ dom(Si ) ∧ e (i) ∈ dom(Ei )
such that p(s (i) ; s (i+1) ) > 0 such that p(s (i) ; e (i) ) > 0
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
33. Constrained HMMs CHMMs as a constraint program
Revisiting the pair HMM
Consider adding constraints to the pair HMM introduced earlier.
For instance..
In a biological context, we may want to only
consider alignments with a limited number of
insertions and deletions given the assumption
that the two sequences are closely related.
C= {cardinality atmost(Nd , [S1 , . . . , Sn ], delete),
cardinality atmost(Ni , [S1 , . . . , Sn ], insert)} .
The constraint cardinality atmost(N, L, X ) is satisfied whenever L is a list
of elements, out of which at most N are equal to X .
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
34. Constrained HMMs CHMMs as a constraint program
Computation of best alignment with constraints
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
35. Constrained HMMs Decoding algorithm for CHMMs
Decoding with a CHMM
Decoding is the process of finding the most probable state sequence given
a known sequence of observations.
Consider a given observation e (1) . . . e (n) , a CHMM S, A, T , E , C , and its
constraint program
run([s (0) , S1 , . . . , Sn ], [e (1) , . . . , e (n) ]).
The most probable path is computed by finding the valuation s (1) , . . . , s (n)
that maximizes the objective function: the run probability.
In standard HMMs this is usually accomplished in polynomial time using
the Viterbi dynamic programming algorithm.
But we need to consider additional constraints, C .
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
36. Constrained HMMs Decoding algorithm for CHMMs
An algorithm for decoding with CHMMs
The computation starts from an initial set of 5-tuples
{ s (0) , 0, 1, , C ∧ trans(s (0) , S1 ) ∧ 1≤i≤n−1 trans(Si , Si+1 ) ∧ 1≤i≤n emit(Si , ei ) }.
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
37. Constrained HMMs Decoding algorithm for CHMMs
An algorithm for decoding with CHMMs
The computation starts from an initial set of 5-tuples
{ s (0) , 0, 1, , C ∧ trans(s (0) , S1 ) ∧ 1≤i≤n−1 trans(Si , Si+1 ) ∧ 1≤i≤n emit(Si , ei ) }.
Then, the following two rules are applied as long as possible
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
38. Constrained HMMs Decoding algorithm for CHMMs
An algorithm for decoding with CHMMs
The computation starts from an initial set of 5-tuples
{ s (0) , 0, 1, , C ∧ trans(s (0) , S1 ) ∧ 1≤i≤n−1 trans(Si , Si+1 ) ∧ 1≤i≤n emit(Si , ei ) }.
Then, the following two rules are applied as long as possible
trans ctr
Σ := Σ ∪ { s , i +1, p · p(s; s ) · p(s ; e (i+1) ), π s , σ ∧ Si+1 = s }
whenever s, i, p, π, σ ∈ Σ, p(s; s ), p(s ; e (i+1) ) > 0 and
check constraints(σ ∧ Si+1 = s ) and prune ctr does not apply.
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
39. Constrained HMMs Decoding algorithm for CHMMs
An algorithm for decoding with CHMMs
The computation starts from an initial set of 5-tuples
{ s (0) , 0, 1, , C ∧ trans(s (0) , S1 ) ∧ 1≤i≤n−1 trans(Si , Si+1 ) ∧ 1≤i≤n emit(Si , ei ) }.
Then, the following two rules are applied as long as possible
trans ctr
Σ := Σ ∪ { s , i +1, p · p(s; s ) · p(s ; e (i+1) ), π s , σ ∧ Si+1 = s }
whenever s, i, p, π, σ ∈ Σ, p(s; s ), p(s ; e (i+1) ) > 0 and
check constraints(σ ∧ Si+1 = s ) and prune ctr does not apply.
prune ctr
Σ := Σ { s, i +1, p , π , σ }
whenever there is another s, i +1, p, π, σ ∈ Σ with
p ≥ p and sol(σ ) ⊆ sol(σ)
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
40. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
41. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints → OK
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
42. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
Path extended
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
43. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
44. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints → OK
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
45. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
Path extended
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
46. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
47. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints → OK
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
48. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
Path extended
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
49. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
50. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints → OK
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
51. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
Path extended
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
52. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
53. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints → fail
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
54. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
Path not extended
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
55. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
56. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints → OK
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
57. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
Path extended
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
58. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
59. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
check constraints → fail
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
60. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the trans ctr transition rule
Constraints:
cardinality atmost(1, [S1 , . . . , Sn ], delete)
cardinality atmost(1, [S1 , . . . , Sn ], insert)
Path not extended
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
61. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the prune ctr rule
Two (partial) paths, p and p , reach the
same state at time i
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
62. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the prune ctr rule
Two (partial) paths, p and p , reach the
same state at time i
sol(σ ) ⊆ sol(σ): Are all states
reachable from p at any time j > i also
reachable from p?
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
63. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the prune ctr rule
Two (partial) paths, p and p , reach the
same state at time i
sol(σ ) ⊆ sol(σ): Are all states
reachable from p at any time j > i also
reachable from p?
no →
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
64. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the prune ctr rule
Two (partial) paths, p and p , reach the
same state at time i
sol(σ ) ⊆ sol(σ): Are all states
reachable from p at any time j > i also
reachable from p?
no →
rule not does apply (keep both paths)
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
65. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the prune ctr rule
Two (partial) paths, p and p , reach the
same state at time i
sol(σ ) ⊆ sol(σ): Are all states
reachable from p at any time j > i also
reachable from p?
no →
rule not does apply (keep both paths)
yes →
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
66. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the prune ctr rule
Two (partial) paths, p and p , reach the
same state at time i
sol(σ ) ⊆ sol(σ): Are all states
reachable from p at any time j > i also
reachable from p?
no →
rule not does apply (keep both paths)
yes → Is P(p) ≥ P(p )?
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
67. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the prune ctr rule
Two (partial) paths, p and p , reach the
same state at time i
sol(σ ) ⊆ sol(σ): Are all states
reachable from p at any time j > i also
reachable from p?
no →
rule not does apply (keep both paths)
yes → Is P(p) ≥ P(p )?
yes
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
68. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the prune ctr rule
Two (partial) paths, p and p , reach the
same state at time i
sol(σ ) ⊆ sol(σ): Are all states
reachable from p at any time j > i also
reachable from p?
no →
rule not does apply (keep both paths)
yes → Is P(p) ≥ P(p )?
yes →
discard lowest probability path p
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
69. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the prune ctr rule
Two (partial) paths, p and p , reach the
same state at time i
sol(σ ) ⊆ sol(σ): Are all states
reachable from p at any time j > i also
reachable from p?
no →
rule not does apply (keep both paths)
yes → Is P(p) ≥ P(p )?
yes →
discard lowest probability path p
no →
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
70. Constrained HMMs Decoding algorithm for CHMMs
Illustration of the prune ctr rule
Two (partial) paths, p and p , reach the
same state at time i
sol(σ ) ⊆ sol(σ): Are all states
reachable from p at any time j > i also
reachable from p?
no →
rule not does apply (keep both paths)
yes → Is P(p) ≥ P(p )?
yes →
discard lowest probability path p
no →
rule does not apply (keep both paths)
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
71. Constrained HMMs Implementation in PRISM
PRISM
PRogramming In Statistical Modelling developed by Sato, Kameya
and Zhou
An extension of Prolog with random variables, called MSWs
Provides efficient generalized inference algorithms (Viterbi, EM, etc)
using tabling
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
72. Constrained HMMs Implementation in PRISM
Example HMM in PRISM
values/2 Example HMM in PRISM
declares the outcomes values(trans(_), [sunny,rainy]).
of random variables values(emit(_), [shop,beach,read]).
msw/2 hmm(L):- run_length(T),hmm(T,start,L).
simulates a random
variable, stochastically hmm(0,_,[]).
selecting one of the hmm(T,State,[Emit|EmitRest]) :-
outcomes T > 0,
msw(trans(State),NextState),
Model in Prolog msw(emit(NextState),Emit),
Specifies relation T1 is T-1,
between variables hmm(T1,NextState,EmitRest).
run_length(7).
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
73. Constrained HMMs Implementation in PRISM
Example HMM in PRISM
values/2 Example HMM in PRISM
declares the outcomes values(trans(_), [sunny,rainy]).
of random variables values(emit(_), [shop,beach,read]).
msw/2 hmm(L):- run_length(T),hmm(T,start,L).
simulates a random
variable, stochastically hmm(0,_,[]).
selecting one of the hmm(T,State,[Emit|EmitRest]) :-
outcomes T > 0,
msw(trans(State),NextState),
Model in Prolog msw(emit(NextState),Emit),
Specifies relation T1 is T-1,
between variables hmm(T1,NextState,EmitRest).
run_length(7).
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
74. Constrained HMMs Implementation in PRISM
Example HMM in PRISM
values/2 Example HMM in PRISM
declares the outcomes values(trans(_), [sunny,rainy]).
of random variables values(emit(_), [shop,beach,read]).
msw/2 hmm(L):- run_length(T),hmm(T,start,L).
simulates a random
variable, stochastically hmm(0,_,[]).
selecting one of the hmm(T,State,[Emit|EmitRest]) :-
outcomes T > 0,
msw(trans(State),NextState),
Model in Prolog msw(emit(NextState),Emit),
Specifies relation T1 is T-1,
between variables hmm(T1,NextState,EmitRest).
run_length(7).
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
75. Constrained HMMs Implementation in PRISM
Adding constraint checking to the HMM
HMM with constraint checking
hmm(T,State,[Emit|EmitRest],StoreIn) :-
T > 0,
msw(trans(State),NxtState),
msw(emit(NxtState),Emit),
check_constraints([NxtState,Emit],StoreIn,StoreOut),
T1 is T-1,
hmm(T1,NxtState,EmitRest,StoreOut).
Call to check constraints/3 after each distinct sequence of msw
applications
Side-constaints: The constraints are assumed to be declared
elsewhere and not interleaved with model specification
Extra Store argument in the probabilistic predicate
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
76. Constrained HMMs Implementation in PRISM
Checking the constraints
The goal check constraints/3 calls constraint checkers for all
constraints declared on the model.
For instance, with our example pair HMM constraint,
C= {cardinality atmost(Nd , [S1 , . . . , Sn ], delete),
cardinality atmost(Ni , [S1 , . . . , Sn ], insert)} .
We have the following incremental constraint checker implementation
A cardinality atmost constraint checker
init_constraint_store(cardinality_atmost(_,_), 0).
check_sat(cardinality_atmost(U,Max), U, In, Out) :-
Out is In + 1,Out =< Max.
check_sat(cardinality_atmost(X,_),U,S,S) :- X = U.
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
77. Constrained HMMs Implementation in PRISM
A library of global constraints for Hidden Markov Models
Our implementation contains a few well-known global constraints adapted
to Hidden Markov Models.
Global constraints
cardinality lock to sequence
all different lock to set
In addition, the implementation provides operators which may be used to
apply constraints to a limited set of variables.
Constraint operators
state specific
emission specific
forall subseq (sliding window operator)
for range (time step range operator)
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
78. Constrained HMMs Implementation in PRISM
Improving tabling with PRISM
Problem: The extra Store argument makes PRISM table multiple goals
(for different constraint stores) when it should only store one.
hmm(T,State,[Emit|EmitRest],Store)
To get rid of the extra argument, check constraints dynamically
maintains it as a stack using assert/retract:
check_constraints(Update) :-
get_store(StoreBefore),
check_constraints(Update,StoreBefore,StoreAfter),
forward_store(StoreAfter).
get_store(S) :- store(S), !.
forward_store(S) :-
asserta(store(S)) ;
retract(store(S)),fail.
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
79. Constrained HMMs Implementation in PRISM
Impact of using a separate constraint store stack
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
80. Summary and future directions
1 Motivation and background
Hidden Markov Models
Biological sequence alignment with pair HMMs
2 Constrained HMMs
CHMMs as a constraint program
Decoding algorithm for CHMMs
Implementation in PRISM
3 Summary and future directions
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
81. Summary and future directions
Summary
We have demonstrated
That CHMMs can be a useful tool to
Incorporate prior knowledge in probabilistic model
Prune the search space and allow faster decoding
That CHMMs may be useful in biological sequence analysis
How CHMMs can be formulated as a constraint problem
An adaptation of the Viterbi algorithm for CHMMs
How CHMMs can be efficiently implemented in PRISM
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
82. Summary and future directions
Future directions
Improve method to employ existing state-of-the-art CSP techniques
Soft constraints
Parameter learning for CHMMs
Grammar constraints
More biological applications
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
83. Summary and future directions
Questions
Questions?
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM
84. Summary and future directions
Bibliography I
V.S. Costa, D. Page, and J. Cussens.
CLP(BN): Constraint logic programming for probabilistic knowledge.
Probabilistic Inductive Logic Programming, LNAI 4911:156–188, 2008.
M-W Chang, L-A Ratinov, and D. Rizzolo, N. Roth.
Learning and inference with constraints.
In Proc. of AAAI Conference on Artificial Intelligence, pages
1513–1518, Chicago, USA, July 2008.
T. Sato and Y. Kameya.
New advances in logic-based probabilistic by PRISM.
In Probabilistic Inductive Logic Programming, LNCS, pages 118–155.
Springer, 2008.
Henning Christiansen, Christian Theil Have, Ole Torp Lassen, Matthieu Petit Inference with CHMMs in PRISM