What is a heuristic?
by Stephen M. Walker II, CoFounder / CEO
What is a heuristic?
In the realm of Artificial Intelligence (AI) and Large Language Models (LLMs), a heuristic is a practical method for problemsolving. Although not always optimal, it's efficient for achieving immediate objectives. Heuristics expedite the process of finding a satisfactory solution by enabling 'educated guesses' or 'rules of thumb'. They are especially beneficial in AI areas like search algorithms, where they can identify the most promising path, and in machine learning, where they can steer the learning process.
A heuristic is a practical approach to problemsolving that employs a method not guaranteed to be optimal, perfect, or rational, but is nevertheless sufficient for reaching an immediate, shortterm goal or approximation. It's a technique that aids learning, discovery, or problemsolving, often by experimental and especially trialanderror methods.
Heuristics can be mental shortcuts that ease the cognitive load of making a decision. Examples of heuristics include using trial and error, a rule of thumb, or an educated guess. These strategies are derived from previous experiences with similar problems and depend on using readily accessible, though loosely applicable, information to control problemsolving in human beings, machines, and abstract issues.
In the context of computer science and mathematical optimization, a heuristic is a technique designed for problemsolving more quickly when classic methods are too slow or fail to find any exact solution in a search space. This is achieved by trading optimality, completeness, accuracy, or precision for speed. A heuristic function, also simply called a heuristic, is a function that ranks alternatives in search algorithms at each branching step based on available information to decide which branch to follow.
In essence, heuristics are simple strategies that humans, animals, organizations, and even machines use to quickly form judgments, make decisions, and find solutions to complex problems.
What are some common heuristics used in AI?
Heuristics are used in AI to solve complex problems more quickly when classic methods are too slow or when it's impractical to find an exact solution. They prioritize speed over accuracy, often providing approximate solutions that are "good enough" for the problem at hand. Here are some common heuristics used in AI:

BreadthFirst Search (BFS) and DepthFirst Search (DFS) — These are fundamental search algorithms used in AI. BFS explores all the vertices of a graph at the present depth before moving on to vertices at the next depth level, while DFS explores as far as possible along each branch before backtracking.

Bidirectional Search — This search algorithm starts simultaneously from both the source and the goal and meets in the middle, reducing time complexity.

A Search* — This algorithm uses a bestfirst search and finds the leastcost path from a given initial node to one goal node. It uses a heuristic function to estimate the cost to reach the goal, which helps in providing an optimized solution.

Simulated Annealing — This is a probabilistic technique used for finding an approximate solution to an optimization problem. It mimics the process of slow cooling of material to decrease defects and find an optimal arrangement of atoms.

Hill Climbing — This is an iterative algorithm that starts with an arbitrary solution to a problem, then attempts to find a better solution by incrementally changing a single element of the solution.

BestFirst Search — This is a search algorithm which explores a graph by expanding the most promising node chosen according to a specified rule.

Trial and Error — This method involves testing various solutions until finding one that works.

Guesswork — This involves making an educated guess based on available information.

Process of Elimination — This involves eliminating options that are known to be incorrect to identify the correct solution.

Historical Data Analysis — This involves using past data to predict future outcomes.
These heuristics are used in various domains, including machine learning, machine reasoning, trading & finance, cybersecurity, and fraud detection & prevention. However, it's important to note that while heuristics can speed up the problemsolving process, they may not always provide the optimal solution and can sometimes even lead to incorrect results.
How do heuristics help AI systems solve problems?
Heuristics help AI systems solve problems by providing a method for finding workable solutions in a feasible amount of time, rather than seeking perfect solutions. Heuristic functions prioritize speed over accuracy and are often used in AI and machine learning when it's impractical to tackle a problem with a stepbystep approach. These functions estimate how close a state is to the desired state and are tailored to specific challenges.
Heuristics are particularly useful in situations with large amounts of information, data, and constraints, where the goal is to reach a desired state. Some common heuristic techniques include A* Search, Bestfirst search, Tabu search, Bidirectional search, Constraint satisfaction problems, and Hill climbing.
In AI, heuristics are often based on cognitive science principles that revolve around how humans think. They enable systems to produce approximate solutions rather than exact ones, trading optimality, completeness, accuracy, or precision for speed. This approach is valuable in producing solutions that are good enough for solving the problem at hand, especially when exact methods are too slow or fail to find any solution.
What are some drawbacks of using heuristics?
Heuristics, while useful for simplifying complex problems and speeding up decisionmaking processes, do have several drawbacks:

NonOptimal Results — Heuristics often lead to "good enough" solutions rather than the best or most rational ones. This is because they are mental shortcuts that prioritize speed over thoroughness.

Prone to Errors and Biases — Heuristics can lead to errors, as they are prone to biases and prejudices. These biases can influence the decisionmaking process and lead to inaccurate or faulty judgments.

Reliance on Limited Data — Heuristics often rely on a limited set of data or information, which can lead to poor decisionmaking. They may not take into account all relevant factors or possibilities, leading to decisions based on incomplete information.

Exacerbation of Stereotypes and Prejudices — Heuristics can reinforce and exacerbate existing prejudices and stereotypes, as they often rely on past experiences and assumptions.

Difficulty in Adapting to New Situations — Heuristics can make it difficult to see alternative solutions or come up with new ideas, as they often rely on past experiences and established patterns of thinking.

Subjectivity and Dependence on Expertise — Heuristic evaluations are only as good as the experts conducting them. This means that the quality of the evaluation can vary greatly depending on the expertise and judgment of the evaluators. Furthermore, it can be timeconsuming and expensive to find and hire these experts.

Potential for Inaccurate Assumptions — Heuristics often involve making assumptions, which can lead to inaccurate conclusions if these assumptions are not valid.
While heuristics can be useful tools for simplifying complex problems and speeding up decisionmaking, they also have several drawbacks, including the potential for errors, biases, and nonoptimal results.
How can heuristics be improved?
Heuristics can be improved through various methods, including the use of metaheuristics, iterative refinement, learning improvement heuristics, and understanding and mitigating biases.

Use of Metaheuristics — Metaheuristics are strategies that guide the search process. They aim to explore the search space to find nearoptimal solutions. Metaheuristics are not problemspecific and may incorporate mechanisms to avoid getting trapped in confined areas of the search space.

Iterative Refinement — This involves making small changes to the heuristic and observing the impact on performance. For example, in a game engine, you could adjust the weight values of different heuristics and observe the success rate of the engine's predictions. This process can be done through evolution (making pseudorandom changes to the heuristics and keeping the changes if they improve performance) or by generating thousands of different heuristics with different weight values from the start and keeping the set that scores best.

Learning Improvement Heuristics — This approach involves using machine learning techniques to improve heuristics. For instance, in routing problems, improvement heuristics can be learned to refine an initial solution by iteratively performing neighborhood search based on certain local operators, towards the direction of improving solution quality.

Understanding and Mitigating Biases — Heuristics can lead to biases and errors in decisionmaking. Understanding these biases can help in improving the heuristics. For example, just because a heuristic has worked in the past does not mean it will work again, and relying on a heuristic can make it difficult to see alternative solutions or come up with new ideas.

Heuristic Hacks — This involves learning how your heuristics and biases can lead to irrational decisions and finding ways to "hack" your heuristics to make better decisions.

Improvement Heuristics — These are specific techniques used to refine the results of an optimization run. They include neighborhoods (refinement methods that modify the order in which stops are performed) and metaheuristics (which define the search framework used to refine the first solutions).
Remember, while heuristics can provide quick and practical solutions, they may not always yield the optimal result. Therefore, continuous improvement and refinement of heuristics are crucial for better performance.