What inference means in AI
Inference means reaching a conclusion from evidence or from rules. In artificial intelligence, the word has two related meanings. In classic AI, inference is logical reasoning: starting from known facts and rules to reach new conclusions. In machine learning, inference usually means running a trained model on new input to get a prediction.
The types of inference are usually grouped by how the conclusion relates to the evidence. The main ones are deductive, inductive and abductive reasoning. Probabilistic inference and the way rule-based systems chain their rules are also common topics. The machine learning sense is covered near the end.
Deductive inference
Deductive inference moves from general rules to a specific conclusion. If the rules and facts are true, the conclusion must also be true. The classic example is:
- All humans are mortal.
- Socrates is human.
- Therefore, Socrates is mortal.
Deduction is the kind of reasoning that rule-based systems and logic programs rely on. Its strength is that a valid argument with true premises gives a certain conclusion. Its limit is that it only draws out what the rules already contain. It does not, by itself, discover new rules from data.
Inductive inference
Inductive inference moves from specific observations to a general rule. The conclusion is probable, not certain, and a single counterexample can overturn it. Imagine someone who has only seen white swans and concludes that all swans are white. Black swans, which live in Australia, show that the general rule was wrong.
Much of machine learning works this way. A model is fitted to many labeled examples and then applied to new cases. Its predictions are estimates, and they can fail on inputs that differ from the examples it learned from. Each candidate general rule a learner considers is called a hypothesis, a term explained in types of hypothesis in machine learning.
Abductive inference
Abductive inference starts from an observation and works back to the most likely explanation. Its conclusions are best guesses, not proofs. Take the observation that the grass is wet. Rain would explain it, so the best guess is that it rained recently. A sprinkler could explain it too, so the guess stays open until more evidence arrives.
Diagnostic systems are a common example of this reasoning. They list possible causes of what they observe and rank them by how well each one explains the evidence. As new information comes in, the ranking can change.
Probabilistic inference
Probabilistic inference works with uncertain information. Instead of a yes-or-no conclusion, it gives a degree of belief. Bayes’ theorem is the usual rule for updating a belief when new evidence arrives. The system starts with a prior probability, takes in evidence, and calculates a revised probability.
A Bayesian network is one common tool. It represents variables and how they depend on one another as a graph, so a system can answer questions such as how likely a fault is, given a sensor reading. Exact calculations can become slow as a network grows, so practical systems often use approximate methods.
Uncertainty can also be handled with logic-based rules rather than numbers, a topic covered in symbolic reasoning under uncertainty in artificial intelligence.
Forward and backward chaining
Rule-based systems apply deduction in one of two directions.
- Forward chaining starts with known facts and applies rules to derive new facts. It repeats until no new facts follow or a goal is reached. It works from the data toward conclusions.
- Backward chaining starts with a goal and looks for rules that would establish it. It then checks the conditions of those rules, working back until it reaches facts it already has. It works from the goal back to the data.
Forward chaining suits systems that receive many new facts and need to react to them. Backward chaining suits a specific question with one target. Prolog, a logic programming language, uses backward chaining.
The facts and rules are kept in a knowledge base, and the part that applies the rules is the inference engine. Knowledge bases can be organized in several ways, as described in knowledge representation approaches in AI.
Non-monotonic inference
Most deduction is monotonic: adding a new fact never removes a conclusion already drawn. Non-monotonic inference allows a conclusion to be withdrawn when new information arrives. It is useful for default rules that hold most of the time.
Birds can usually fly. Tweety is a bird, so Tweety can fly. If the system then learns that Tweety is a penguin, it withdraws the earlier conclusion, because penguins cannot fly.
Inference in machine learning
In machine learning, inference is the step after training. The model’s learned parameters are fixed. The model receives new input, such as a photo or a sentence, and returns an output, such as a label or a prediction. Every time a deployed model is used, inference runs.
Training and inference have different costs. Training usually takes far more computing time, because the model adjusts its parameters over many passes through the data. Inference has to be fast enough for users, so response time and cost per prediction matter. For how the parameters are adjusted during training, see how do neural networks and machine learning actually learn.
Not every model learns in this way. An instance-based learner such as k-nearest neighbors stores its training examples and does most of its work when asked for a prediction, a pattern explained in instance-based learning in machine learning examples.
For a closer look at what happens each time a model runs, see what is inference in the context of AI models. Serving a model to many users needs software of its own, described in what is an inference server.
How the types compare
| Type | Direction of reasoning | Strength of conclusion | Simple example |
|---|---|---|---|
| Deductive | General rule to specific case | Certain, if the rules and facts are true | Socrates is mortal |
| Inductive | Specific cases to general rule | Probable, can be overturned | All observed swans are white |
| Abductive | Observation to likely explanation | Best guess, open to revision | The grass is wet, so it probably rained |
| Probabilistic | Evidence to updated probability | Degree of belief | Updating the chance of a fault after a sensor reading |
| Non-monotonic | Default rule, then withdrawal | Holds until new facts arrive | Tweety can fly, until Tweety is a penguin |
Which type fits a problem
No single type fits every problem. Rule-based expert systems rely on deduction and chaining. Statistical machine learning relies mostly on induction. Diagnostic and troubleshooting tasks often use abduction. Systems that work with noisy sensor data often use probabilistic methods. Many real systems combine several of these.