April 22nd, 2025

Introducing the AI Dev Gallery: Your Gateway to Local AI Development with .NET

The world of AI development is evolving rapidly, with new models, techniques, and tools emerging every day.

For developers looking to incorporate AI into their applications, the landscape can be both exciting and overwhelming.

  • How do you experiment with different models?
  • How do you see working examples of AI patterns like RAG, chat, or object detection?
  • And most importantly, how do you bridge the gap between experimentation and production-ready code?

If you missed our initial announcement on the Azure Developer Community Blog, we’re excited to introduce you to the AI Dev Gallery. In this post, we’ll explore this Windows application in greater depth, showcasing how it simplifies AI development with .NET through interactive samples, easy model downloads, and exportable source code.

The AI Dev Gallery is a Windows application that serves as a comprehensive playground for AI development using .NET. It provides everything you need to explore, experiment with, and implement AI capabilities in your applications, all without requiring a connection to cloud services.

Features

Over 25 Interactive Local AI Samples

The AI Dev Gallery includes a diverse collection of interactive samples that demonstrate different AI capabilities:

  • RAG (Retrieval-Augmented Generation) implementations that combine search with generative AI
  • Chat interfaces powered by various local models
  • Object detection samples for identifying objects in images
  • Image generation using stable diffusion models
  • Text-to-speech and speech-to-text conversion
  • Semantic search for finding conceptually related content
  • Document summarization and analysis
  • And many more…

All these samples run entirely on your local machine, allowing you to experiment without cloud dependencies or API costs.

Easy Model Discovery and Download

Finding and setting up AI models is often a significant hurdle in development. The AI Dev Gallery simplifies this process by allowing you to:

  • Browse models from popular repositories like Hugging Face and GitHub
  • Download models with a single click, including:
    • Phi 4 and Phi Silica for efficient text generation
    • Stable Diffusion for image creation
    • Whisper for speech recognition
    • all-MiniLM (L6 and L12 versions) for text embeddings
    • Specialized models for various tasks like pose detection, street segmentation, and more

The gallery handles model compatibility, ensuring you get versions that work with the .NET ecosystem.

Tip

Models are cached locally after download, so you only need to download them once even if you use them across multiple samples.

View and Export Source Code

Key Feature

One of the most powerful features of the AI Dev Gallery is the ability to view the C# source code behind each sample and export it as a standalone Visual Studio project with a single click.

This feature bridges the gap between experimentation and implementation, allowing you to:

  1. Explore how each AI capability is implemented in C#
  2. Understand the patterns and best practices for AI integration
  3. Export the code as a complete, buildable project
  4. Use the exported code as a starting point for your own applications

AI Dev Gallery code view with export project button highlighted

Built using .NET AI Building Blocks

What makes the AI Dev Gallery particularly valuable for .NET developers is that it’s built entirely using the foundational pieces of the .NET AI ecosystem. This means that the code you see and export uses the same libraries and patterns you’ll use in production applications.

Microsoft.Extensions.AI for Model Integration

For chat and embedding generation, the AI Dev Gallery uses Microsoft.Extensions.AI – a unified set of abstractions for AI model integration in .NET applications.

// Example of Microsoft.Extensions.AI IChatClient
IChatClient chatClient = // ...Initialize your IChatClient

var chatOptions = new ChatOptions
{
    Temperature = 0.7f,
    MaxTokens = 800
};

var messages = new List<ChatMessage>()
{
    new ChatMessage(ChatRole.User, "What is AI?")
};

var response = await chatClient.GetResponseAsync(messages, chatOptions);

Microsoft.Extensions.AI provides a consistent programming model regardless of the underlying model implementation, whether it’s a local model or a cloud service. This allows you to swap models without changing your application code.

For generative language models specifically, the gallery leverages ONNX Runtime GenAI, which builds on top of Microsoft.Extensions.AI to provide optimized local model execution and an effective chat client implementation.

Learn more about Microsoft.Extensions.AI

Microsoft.ML.Tokenizers for Text Processing

To convert text into tokens (the numerical representations that models understand), the AI Dev Gallery uses Microsoft.ML.Tokenizers, which supports a wide range of tokenization schemes:

// Example of tokenization using Microsoft.ML.Tokenizers
var tokenizer = BertTokenizer.Create("vocab.txt");
var tokens = tokenizer.EncodeToIds("How does tokenization work?");

The tokenizer library in .NET 9 supports multiple tokenization schemes:

  • BERT for bidirectional encoding
  • BPE (Byte Pair Encoding) for efficient subword tokenization
  • SentencePiece (BPE and Unigram algorithms) for language-agnostic tokenization
  • Tiktoken for GPT models
  • Llama and Phi for their respective model families
  • DeepSeek and other specialized tokenizers

This flexibility ensures compatibility with virtually any text-based AI model.

Learn more about tokenizers in .NET

For semantic search and RAG scenarios, the AI Dev Gallery uses Microsoft.Extensions.VectorData, which provides abstractions for working with vector databases and embeddings:

// Example of vector search using Microsoft.Extensions.VectorData
// Create vector store with in-memory provider
var vectorStore = new InMemoryVectorStore<Document>();

// Add documents with embeddings
await vectorStore.UpsertAsync(
    [new Document { Id = "1", Text = "Example document", Vector = embeddings[0] }], 
    CancellationToken.None);

// Define a query embedding (example placeholder)
float[] queryEmbedding = new float[] { /* embedding values */ };

// Search for similar documents
var results = await vectorStore.SearchAsync(
    queryEmbedding, 
    new VectorSearchOptions { Limit = 5 }, 
    CancellationToken.None);

This library makes it easy to implement semantic search and RAG patterns without being tied to a specific vector database implementation.

Learn more about vector search in .NET or read our detailed blog post about semantic search with the AI Dev Gallery for a deeper dive into implementation details.

System.Numerics.Tensors for Efficient Computation

For post-processing model outputs and performing operations like cosine similarity, the AI Dev Gallery uses Tensor and TensorPrimitives provided by System.Numerics.Tensors:

// Example of using TensorPrimitives for cosine similarity
ReadOnlySpan<float> embedding1 = [...]; // First embedding
ReadOnlySpan<float> embedding2 = [...]; // Second embedding

// Calculate cosine similarity using TensorPrimitives
float similarity = TensorPrimitives.CosineSimilarity(embedding1, embedding2);

The Tensor types in .NET 9 provide high-performance numeric operations with minimal memory allocations, which is crucial for AI workloads that often involve large numeric arrays.

Learn more about Tensor and TensorPrimitives

Start Your AI Development Journey Today

The AI Dev Gallery represents a significant step forward in making AI development accessible to .NET developers. By providing interactive samples, easy model access, and exportable code, it removes many of the barriers that have traditionally made AI integration challenging.

Whether you’re new to AI or an experienced developer looking to explore new capabilities, the AI Dev Gallery provides a comprehensive environment for learning, experimentation, and implementation.

Open Source

The AI Dev Gallery is open source! If you want to contribute or explore how it’s built, check out the AI Dev Gallery GitHub repository.

We’re continuously adding new samples and features to the AI Dev Gallery. We’d love to hear your feedback and suggestions on what you’d like to see next.

Author

Jon Galloway
Principal Tech Program Manager

Jon is a Principal Program Manager on the DevDiv Community team, working on .NET and supporting .NET live streams and virtual events. He's the author of several programming books, tutorials and video courses on .NET development.

Luis Quintanilla
Program Manager

Luis Quintanilla is a program manager based out of the New York City area working on machine learning for .NET. He's passionate about helping others be successful developing machine learning applications.

3 comments

  • Nikita Prorekhin

    Great stuff, Microsoft Team!

    For anyone trying the examples. Please be aware, that CPU models take ages to perform the task, so prefer GPU version if possible. I would also recommend running the examples with local ollama running different models.

  • Tavi Cacina

    Nice, thank you. Please note that on a Windows 10 22H2 a message-box pops-up from time to time with a not found entry point “TryCreatePackageDependency” in “…/Microsoft.AIDevGallery_0.3.9.0_x64__8wekyb3d8bbwe/Microsoft.Windows.Workloads.dll”

  • M Shadman 2 days ago

    Thank you so much to make this wonderful tool.
    Are there any locations that I can download this application instead of GitHub or Microsoft store?