NET 9 is about to be released in RC1, and earlier this year the .NET team wrote a post on the release of the .NET 9 Preview 1 releaseOur Vision for .NET 9, which specifically mentions a vision for AI, we are committed to making it easier for .NET developers to integrate AI into their existing and new applications. Developers will find great libraries and documentation for working with OpenAI and OSS models (both hosted and native), and we'll continue to collaborate on the Semantic Kernel,, OpenAI, and Azure SDKs to ensure that .NET developers have a best-in-class experience building intelligent applications.
In .NET 9, the .NET community is pushing AI hard -- and it's pretty shocking ...... It's like AI is important right now. In the past big data and mobile internet era. NET missed out on both eras due to Microsoft's closedness and lack of openness, but in the era of cloud-native and AI, .NET has done a great job of stripping down and becoming open and powerful, and the upcoming .NET 9, in particular, has very big improvements in helping developers build smarter apps. Here's my roundup of what's new in the .NET community this year in terms of AI.
1. Upgrade
is being upgraded with high-performance C# bindings and automatic differentiation support. The full Keras API is now also in C#:
- New high-performance C# bindings generated with cppSharp
- Autodifferential support for custom C# operations
- The Keras API is implemented entirely in C#, allowing for seamless model definition and training.
2、OpenAI SDK Integration
The OpenAI SDK gives developers direct access to OpenAI's latest public AI models, including GPT-4 and its structured output capabilities. This means you'll have full API support, including synchronous and asynchronous APIs to suit your needs - even streaming completion for real-time processing.The SDK is extensible, so you can customize it even further. It is also integrated with Azure OpenAI for enterprise deployments and easy to interface with a variety of major OpenAI API-compatible models. This opens up a wealth of possibilities for building smarter .NET applications using conversational AI, dynamic content generation, and AI-driven features such as audio transcription and text-to-speech generation.
3. ONNX Runtime Native Support
There is no need to bother with separate package installations. We get a dedicated namespace () that contains an API to load and run ONNX models directly:
- Direct model loading: var session = new InferenceSession("");
- Efficient Memory Management of Input/Output Tensors with Span<T> and Memory<T>
- Support for hardware acceleration (CPU, GPU, DirectML) through a unified API
4、Developer-friendly 4.0
AutoML gets smarter with multi-metric optimization and time series prediction support:
- AutoML enhancements:
- Multi-metric optimization for equilibrium model selection
- Support for time series forecasting in AutoML
- New Infer<T> API for simplified model deployment
- Converting TensorFlow and ONNX Models to Formats to Improve Performance
- The new : GenAI package provides torchsharp implementations of a range of popular GenAI models, with the goal of loading the same weights from the corresponding Python regular models. The first models to be added include
、
、
cap (a poem)
as well as
。
5. AI-assisted code generation in .NET 9
AI-assisted code generation (code snippets, refactoring, unit testing) is integrated into the .NET 9 SDK via dotnet ai commands, which is great:
- Generating code snippets: dotnet ai snippet “mplement a binary search algorithm”
- Refactor existing code: dotnet ai refactor --file --description “Convert to LINQ query”
- Generate unit tests: dotnet ai test --file
6. NLP tools
NET 9 provides a rich set of NLP tools for tokenization, NER*, sentiment analysis, and text classification:
- Split words and sentence clauses:
var tokenizer = new Tokenizer(); var tokens = ("Hello, world!");
- Named Entity Recognition (NER):
var ner = new NamedEntityRecognizer(); var entities = ("Microsoft was founded by Bill Gates.");
- Perceptual analysis and text categorization using pre-trained models
7. GPU Acceleration in .NET 9
GPU acceleration in .NET 9 is more accessible than ever:
- New Tensor<T> Types for Efficient Multidimensional Array Arithmetic : Tensors are a fundamental part of many mathematical models, including deep learning algorithms. They are multidimensional arrays used to hold weights, biases, and intermediate computations in neural networks. This allows efficient processing of data and information flow for learning and prediction purposes. Whether it is image recognition, language understanding or trend prediction, tensors play a crucial role in all aspects of AI. In addition, they make it easier to share data between libraries such as ONNX Runtime, TorchSharp, or others, create your own math libraries, or develop applications using AI models.
- CUDA interoperability improvements:
- Integration with Nvidia's cuDNN library for deep learning primitives
8. Simplified AI model deployment
NET 9 simplifies AI model deployment with new Core integrations:
- New project template: dotnet new webapi --ai -model
- Automated OpenAPI/Swagger Documentation for Model End Nodes
- Built-in model version control and A/B testing support
- Scalable Modeling Services with gRPC Integration
9. New numerical API
NET 9 introduces a new numerical API for efficient tensor and matrix operations:
- <T> for efficient tensor operations
- <T> for matrix algebra
- SIMD Accelerated Linear Algebra Routines
10、Monitoring and observing your LLM applications
Large-scale language modeling (LLM) applications require reliable, high-performance, and high-quality results. Developers need to measure and track the results and behavior of LLM applications in both development and production environments, and identify and resolve any issues.
- Performance Monitoring: We want to know how fast our models run, how much memory they use, and how well they handle the load. This helps us identify bottlenecks and optimize things.
- Model Bias Detection: As the world changes, models become outdated over time. We need tools to capture when a model's performance starts to slip so we know it's time to retrain.
- Interpretability and transparency: AI should not be a black box. We must have a way to peer inside and understand how models make decisions. This builds trust and helps us catch any unintentional bias.
- Ethics and bias monitoring: AI should be fair and unbiased. We need tools to actively check and address any potential bias in the model.
11. Semantic kernel for .
Semantic kernelNET application to enable AI integration and business process capabilities. NET applications that use one or more AI services in conjunction with other APIs or web services, data stores, and custom code, this SDK is often the recommended AI orchestration tool. The Semantic Kernel benefits enterprise developers in the following ways:
- Simplify the process of integrating AI capabilities into existing applications to provide a unified solution for enterprise products.
- Minimize the learning curve of using different AI models or services with abstractions that reduce complexity.
- Improve reliability by reducing unpredictable behavior of AI model prompts and responses. Prompts can be fine-tuned and tasks scheduled to create a controlled and predictable user experience.
12. Stronger than ever .NET Community
NET is open source, including all the libraries, tools, and frameworks available on GitHub, so there has been a lot of collaboration going on. c# has grown and gained a strong foothold in AI, and the .NET community is hard at work building it. Below we list some of the resources in the community for your reference:
- Semantic kernel :/geffzhang/awesome-semantickernel/
- Autogen:/microsoft/autogen/tree/main/dotnet
- Botsharp:/en/latest/
AIDotNet:/AIDotNet
: /Senparc/
13, .NET 9 + Artificial Intelligence
Microsoft is making significant investments in AI, and they are driving the .NET and development community. The .NET ecosystem provides many powerful tools, libraries, and services for developing AI applications. NET supports cloud and local AI model connectivity, many different SDKs for various AI and vector database services, and other tools to help build intelligent applications of varying scope and complexity.