Meet YOLO26: next-gen vision AI.
Ultralytics
Back to Ultralytics Glossary

Hidden Markov Model (HMM)

Explore Hidden Markov Models (HMM) for statistical AI. Learn how HMMs work with Ultralytics YOLO26 for action recognition, sequence analysis, and temporal logic.

A Hidden Markov Model (HMM) is a statistical framework used to model systems where the internal process is not directly visible—hence "hidden"—but can be inferred through a sequence of observable events. While modern deep learning has evolved to handle complex sequences, the HMM remains a foundational concept in statistical AI and probability theory. It is particularly effective for analyzing time-series analysis data where the order of events provides crucial context, relying on the core principle that the probability of a future state depends solely on the current state, not on the history that preceded it.

Link to this sectionCore Mechanisms of HMMs#

To understand how an HMM functions, it is essential to distinguish between the two distinct layers of the model: the invisible states and the visible outputs. The model assumes that the system transitions between hidden states according to specific probabilities, emitting an observation at each step.

An HMM is defined by a set of parameters that govern these transitions and emissions:

  • Hidden States: These represent the underlying reality of the system at a given time. In a speech model, a hidden state might represent a specific phoneme or word.
  • Observable Events: These are the data points actually collected by sensors or inputs. In the speech example, the observation would be the audio waveform or spectrogram data.
  • Transition Probabilities: This matrix describes the likelihood of moving from one hidden state to another. For instance, the probability of the weather changing from "Rainy" to "Sunny."
  • Emission Probabilities: These define the likelihood of seeing a specific observation given a current hidden state.
  • Initial Probabilities: The distribution that determines the state in which the system is most likely to begin.

Training an HMM generally involves the Baum-Welch algorithm to estimate these parameters from training data. Once trained, the Viterbi algorithm is commonly used to decode the most likely sequence of hidden states from a new set of observations.

Link to this sectionHMMs vs. Other Sequence Models#

While HMMs share similarities with other sequence processing tools, they differ significantly in architecture and application:

  • HMM vs. Recurrent Neural Networks (RNN): RNNs and Long Short-Term Memory (LSTM) networks are deep learning models that can capture long-range dependencies and non-linear patterns, whereas HMMs are simpler, probabilistic models limited by the Markov assumption (short-term memory). However, HMMs require significantly less data and are far more interpretable.
  • HMM vs. Kalman Filter (KF): Both are used for state estimation. However, Kalman Filters are designed for continuous states (like tracking the precise location of a moving car), while HMMs are used for discrete states (like determining if the car is "parked," "driving," or "stopped").

Link to this sectionReal-World Applications#

Despite the rise of deep learning (DL), Hidden Markov Models are still widely used in scenarios requiring probabilistic inference over sequences.

Link to this sectionSpeech and Handwriting Recognition#

Historically, HMMs were the backbone of speech recognition systems. In this context, the spoken words are the "hidden" states, and the audio signals recorded by the microphone are the observations. HMMs help determine the most likely sequence of words that produced the audio signal. Similarly, they aid in deciphering cursive handwriting by modeling the transition between character strokes.

Link to this sectionBiological Sequence Analysis#

In the field of bioinformatics, HMMs are crucial for gene prediction and protein alignment. They analyze sequences of DNA or amino acids to identify functional regions, such as genes within a genome. The "hidden" states might represent coding or non-coding regions, while the specific nucleotides (A, C, G, T) act as the observations.

Link to this sectionAction Recognition in Computer Vision#

In modern computer vision, HMMs can be combined with models like YOLO26 to perform action recognition. While YOLO detects objects or poses in individual frames, an HMM can analyze the sequence of these poses over time to classify an action, such as "walking," "running," or "falling."

Link to this sectionIntegrating Vision and State Analysis#

For developers using the Ultralytics Platform to manage datasets and models, understanding sequential logic is vital. A vision model provides the raw observations (detections), which can then be fed into a state-space model like an HMM to infer temporal context.

The following example demonstrates how to generate a sequence of observations using YOLO26 pose estimation. These keypoints can serve as the "observable events" input for a downstream HMM or similar logic to classify behaviors over time.

from ultralytics import YOLO

# Load the YOLO26n-pose model for efficient keypoint detection
model = YOLO("yolo26n-pose.pt")

# Run inference on a video source (the 'observable' sequence)
# stream=True creates a generator for memory efficiency
results = model.predict(source="path/to/video.mp4", stream=True)

# Iterate through frames to extract observations
for result in results:
    # Each 'keypoints' object is an observation for a potential HMM
    keypoints = result.keypoints.xyn.cpu().numpy()

    if keypoints.size > 0:
        print(f"Observation (Normalized Keypoints): {keypoints[0][:5]}...")
        # In a full pipeline, these points would be fed into an HMM decoder

Link to this sectionImportance in Modern AI#

Although transformers and large language models (LLMs) have overtaken HMMs for tasks like natural language processing (NLP), HMMs remain relevant in edge computing and low-latency environments. Their computational efficiency makes them ideal for systems with limited resources where heavy GPU usage is not feasible. Furthermore, because they are based on transparent probability matrices, they offer higher observability compared to the "black box" nature of many neural networks.

Explore solutions

Real-time AI tailored to your operation

AI in Agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.

Learn more
Real-time AI that works with your operation

AI in Automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.

Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.

Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.

Learn more
Real-time AI that works with your team

AI in Robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.

Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.

Learn more
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.

Learn more
Real-time AI tailored to your operation

AI in Agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.

Learn more
Real-time AI that works with your operation

AI in Automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.

Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.

Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.

Learn more
Real-time AI that works with your team

AI in Robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.

Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.

Learn more
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.

Learn more
Real-time AI tailored to your operation

AI in Agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.

Learn more
Real-time AI that works with your operation

AI in Automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.

Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.

Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.

Learn more
Real-time AI that works with your team

AI in Robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.

Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.

Learn more
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.

Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning