# Infer.NET: Bayesian Inference in Graphical Models for .NET

> Infer.NET is a Microsoft framework for running Bayesian inference over graphical models, distributed as four NuGet packages. It suits .NET developers who need probabilistic models with a compiler rather than a Python stack.

**dotnet/infer** — Infer.NET is a framework for running Bayesian inference in graphical models

- Repository: https://github.com/dotnet/infer
- Website: https://dotnet.github.io/infer/
- Stars: 1,614 · Forks: 241
- Language: C#
- License: MIT
- Published: 2026-09-10 · Updated: 2026-09-10 · Language: en
- Canonical page: https://hysenlabs.com/projects/dotnet-infer

## The problem Infer.NET solves, and who it is for

Probabilistic modelling usually means writing a model in one language and running inference in another. Infer.NET keeps both in .NET. The README describes it as "a framework for running Bayesian inference in graphical models" that "can also be used for probabilistic programming." The audience is a C# or F# developer who has a domain problem, not a machine learning researcher with a Python notebook.

The README lists the problem types it targets: classification, recommendation and clustering, plus "customised solutions to domain-specific problems." It names information retrieval, bioinformatics, epidemiology and vision as domains where it has been used. That range is the point. A model for click relevance and a model for nucleotide motifs look nothing alike, but both are expressed as factors over variables and both get the same inference machinery.

If your work already sits in .NET services, this removes a process boundary. There is no Python runtime to embed, no serialization layer between model and application. The cost is that you write the model in C# and accept the constraints of the Infer.NET API.

## How the compiler turns a model description into inference code

The architecture has two distinct halves, and the split matters more than any single feature.

The first half is the model description. You write variables and factors using the Infer.NET API. `src/Csoft` is an experimental feature that lets you express models in a subset of C# instead; its unit tests live in the Tests project under the `Category: CsoftModel` trait. The repository also carries an `FSharpWrapper` that "hides some of the generic constructs in the Infer.NET API allowing simpler calls" from F#.

The second half is the compiler. `Microsoft.ML.Probabilistic.Compiler` "takes model descriptions written using the Infer.NET API and converts them into inference code." This is the design decision that separates Infer.NET from libraries that interpret a model at runtime: inference is generated ahead of execution, and the compiler project also includes "utilities for the visualization of the generated code." You can read what your model became.

Around that core sit the learners. `Microsoft.ML.Probabilistic.Learners` contains "complete machine learning applications including a classifier and a recommender system," with the Bayes Point Machine classifier and the Matchbox recommender documented on the project site. If your problem is standard, you may not write a model at all.

The repository layout reflects this. `src/Compiler`, `src/Csoft`, `src/Examples`, `src/FSharpWrapper`, `src/IronPythonWrapper` and `src/Learners` are separate projects inside the single `Infer.sln` solution at the root.

## Installing Infer.NET and running a first model

You do not clone the repository to use the released binaries. The README states that binaries are on nuget.org and that "these binaries are cross-platform and work anywhere that .NET is supported, so there is no need to select your platform." The core packages target .NET Standard 2.0, which the README says makes them usable from projects targeting .NET Framework 4.6.2 or .NET Core 3.1.

Four packages are maintained. `Microsoft.ML.Probabilistic` holds the classes and methods needed to execute inference. `Microsoft.ML.Probabilistic.Compiler` holds the compiler and the generated-code visualization utilities. `Microsoft.ML.Probabilistic.Learners` holds the classifier and recommender. `Microsoft.ML.Probabilistic.Visualizers.Windows` is a Windows-specific set of visualization tools.

The README gives the command-line route for adding packages to an existing project file:

```bash
dotnet add package Microsoft.ML.Probabilistic
dotnet add package Microsoft.ML.Probabilistic.Compiler
dotnet add package Microsoft.ML.Probabilistic.Learners
```

After these run, the project file references the packages and the binaries are restored on build. In Visual Studio the README points to `Project -> Manage NuGet packages` instead.

For a first real use, the README points to the getting started guide on docs.microsoft.com and to the tutorials page on the Infer.NET website. The repository itself carries runnable samples under `src/Examples`: `InferNET101` for the basics, `ClinicalTrial` with an interactive interface, `MontyHall` with a graphical interface, plus `ClickThroughModel`, `ImageClassifier`, `LDA` and `MotifFinder`. The `LDA` sample is documented as paying "special attention to scalability with respect to vocabulary size, and with respect to the number of documents."

To build from source instead, the repository root holds `Infer.sln`, and `BUILDING.md` is the file that describes the build. The README does not reproduce those steps.

## Where Infer.NET is the wrong tool

The clearest limitation is the compiler itself. Because model descriptions are converted into inference code, the model must be expressible in the API before anything runs. A model that does not fit that shape is not a configuration problem; it is a rewrite.

The second limitation is language reach. The wrappers for F# and IronPython exist precisely because the native API is awkward outside C#. The F# wrapper is described as hiding "some of the generic constructs" in the API, which is an admission that those constructs are visible by default. If your team is not a .NET team, the wrappers do not change the underlying commitment.

The third is the boundary of the learners. `Microsoft.ML.Probabilistic.Learners` gives you a classifier and a recommender. The README does not present a deep learning stack, and nothing in the repository layout suggests one. If your problem needs neural components, this is not the framework for it.

Finally, the documentation surface is split. The README points outward to the project website and to docs.microsoft.com rather than carrying the material itself, and the README does not document rollback, versioning policy or upgrade procedures. Check those before you depend on a specific package version.

## How Infer.NET differs from probabilistic programming in Python

The obvious alternative is a Python probabilistic programming library, where the model is written in Python and inference runs in the same process. The difference is not only language. In a Python stack, inference is typically executed against the model at runtime by an interpreter. In Infer.NET, the compiler generates inference code from the model description before execution, and the compiler project ships utilities for visualizing that generated code.

That changes the debugging experience. You can inspect the artifact the compiler produced, which is not something an interpreted model offers. It also changes the failure mode: errors surface at compile time rather than partway through a sampling run.

A second alternative is to skip the framework and write the inference yourself. For a small conjugate model that is genuinely reasonable, and it removes the dependency entirely. Infer.NET earns its place when the model has enough structure that hand-written inference becomes error-prone, or when you need the standard learners and would otherwise reimplement a classifier.

A third path is to keep inference in Python and call it from .NET over a process or service boundary. That preserves the Python ecosystem at the cost of a runtime dependency and a serialization layer. Infer.NET exists to remove that layer.

## Maintenance, licensing and the cost of upgrading

The repository is not archived, and the last push was on 2026-07-14. The README shows nightly release builds for Windows, Linux and macOS, which indicates a continuous build process across the three platforms. It does not describe a release cadence, a support window or a deprecation policy.

Upgrade cost is shaped by the compiler. Since model descriptions are compiled into inference code, a package upgrade can change the generated code even when your model source is untouched. The README does not document rollback, so the practical safeguard is to keep the generated code under review as part of your build. The `Microsoft.ML.Probabilistic.Visualizers.Windows` package is the one component the README ties to a specific platform and framework, which makes it the piece most likely to constrain your target.

Licensing is MIT, per the repository metadata. That is permissive, and it is the kind of term that generally allows commercial use and modification, but the LICENSE.txt file in the repository root is the authoritative text and the README does not summarize its obligations. Nothing here is legal advice; read LICENSE.txt before you ship.

## Conclusion

Adopt Infer.NET when your model and its deployment both live in .NET, and when you want inference code generated from a model description rather than interpreted at runtime. Skip it if your team works in Python, if your model needs deep neural components, or if you cannot read C# model code. Before committing, verify that Microsoft.ML.Probabilistic, Microsoft.ML.Probabilistic.Compiler and Microsoft.ML.Probabilistic.Learners resolve for your target framework, and read the generated code for your first model to confirm the compiler produces what you expect.

## FAQ

### How do I install Infer.NET?

Add the NuGet packages to an existing project. The README gives the command-line form: dotnet add package Microsoft.ML.Probabilistic, followed by Microsoft.ML.Probabilistic.Compiler and Microsoft.ML.Probabilistic.Learners. In Visual Studio the README points to Project -> Manage NuGet packages.

### Do I need to clone the Infer.NET repository to use it?

No. The README states that binaries are located on nuget.org and that you do not need to clone the GitHub repository to use the pre-built binaries. The repository is needed only if you want to build Infer.NET from source, which BUILDING.md covers.

### Which .NET versions does Infer.NET support?

The core packages target .NET Standard 2.0, which the README says makes them usable from any project targeting .NET Framework version 4.6.2 or .NET Core 3.1. The binaries are described as cross-platform and working anywhere .NET is supported.

### What is the difference between the Infer.NET compiler and the runtime package?

Microsoft.ML.Probabilistic contains the classes and methods needed to execute inference code, while Microsoft.ML.Probabilistic.Compiler takes model descriptions written with the Infer.NET API and converts them into inference code. The compiler package also contains utilities for visualizing the generated code.

## Sources

- [dotnet/infer on GitHub](https://github.com/dotnet/infer)
- [Issues](https://github.com/dotnet/infer/issues)
- [License: MIT](https://github.com/dotnet/infer/blob/main/LICENSE)
- [Project website](https://dotnet.github.io/infer/)
- [README](https://github.com/dotnet/infer/blob/main/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/dotnet-infer
