Microsoft’s Open-Source Semantic Kernel: Bridging AI and Programming

Hello Learners…

Welcome to the blog…

Table Of Contents

  • Introduction
  • What is Semantic Kernel?
  • What is Kernel?
  • What makes Semantic Kernel special?
  • Microsoft’s Open-Source Semantic Kernel: Bridging AI and Programming
  • What’s possible with Semantic Kernel?
  • Visual Studio Code extension Of Semantic Kernel
  • Summary
  • References

Introduction

In this post, we talk about Microsoft’s Open-Source Semantic Kernel: Bridging AI and Programming. we can use it as an alternative to the LangChain.

In the world of programming advancements, Microsoft introduces a groundbreaking advancement – the Open-Source Semantic Kernel (SK).

This innovative SDK stands as a pivotal bridge that unites the prowess of Large Language Models (LLMs) AI with the conventional might of programming languages.

With Semantic Kernel (SK), developers are empowered to seamlessly open doors to a new era of possibilities.

What is Semantic Kernel?

Semantic Kernel is an SDK that integrates Large Language Models (LLMs) like OpenAIAzure OpenAI, and Hugging Face with conventional programming languages like C#, Python, and Java. Semantic Kernel achieves this by allowing you to define plugins that can be chained together in just a few lines of code.

What is Kernel?

The term “kernel” can have different meanings in different contexts, but in the case of the Semantic Kernel, the kernel refers to an instance of the processing engine that fulfills a user’s request with a collection of plugins.

Microsoft's Open-Source Semantic Kernel: Bridging AI and Programming

What makes Semantic Kernel special?

It is special because of its ability to automatically orchestrate plugins with AI. With Semantic Kernel planners, you can ask an LLM to generate a plan that achieves a user’s unique goal. Afterward, Semantic Kernel will execute the plan for the user.

Microsoft’s Open-Source Semantic Kernel: Bridging AI and Programming

The Semantic Kernel SDK is available in C#, Python, and Java.

The quickest way to get started with the basics is to get an API key from either OpenAI or Azure OpenAI and to run one of the C#, Python, and Java console applications/scripts below.

Microsoft’s Open-Source Semantic Kernel: Connecting AI and Programming

C#:

  1. Create a new console app.
  2. Add the semantic kernel nuget Microsoft.SemanticKernel.
  3. Copy the code from here into the app Program.cs file.
  4. Replace the configuration placeholders for the API key and other parameters with your key and settings.
  5. Run with F5 or dotnet run

Python:

Install the pip package: 

python -m pip install semantic-kernel

Create a new script e.g. 

hello-world.py

Store your API key and settings in an .env file as described here.

Copy the code from here into the hello-world.py script.

Run the python script.

Java:

  1. Clone and checkout the experimental Java branch: 
git clone -b experimental-java https://github.com/microsoft/semantic-kernel.git
  1. Follow the instructions here

What’s possible with Semantic Kernel?

If you’re interested in seeing a full end-to-end example of how to use Semantic Kernel, check out their Chat Copilot reference application.

Chat Copilot is a chatbot that demonstrates the power of Semantic Kernel. By combining plugins, planners, and personas, we demonstrate how you can build a chatbot that can maintain long-running conversations with users while also leveraging plugins to integrate with other services.

We can run the app yourself by downloading it from its GitHub repo.

Visual Studio Code extension Of Semantic Kernel

The Semantic Kernel extension for Visual Studio Code makes it easy to design and test semantic functions. The extension provides an interface for designing semantic functions and allows us to test them with a push of a button with our existing models and data.

semantic kernel extension for vscode

Other Repository Of Microsoft’s Open-Source Semantic Kernel

There are some other repos of the Semantic Kernel that the team supports:

RepoDescription
Chat CopilotA reference application that demonstrates how to build a chatbot with Semantic Kernel.
Semantic Kernel DocsThe home for Semantic Kernel documentation that appears on the Microsoft learn site.
Semantic Kernel StartersStarter projects for Semantic Kernel to make it easier to get started.
Semantic MemoryA service that allows you to create pipelines for ingesting, storing, and querying knowledge.

Summary

This is a simple introduction to Microsoft’s Open-Source Semantic Kernel. Here we understand that now we can use any programming language to integrate Large language model agents like OpenAI with the help of the Semantic Kernel.

Also, you can refer,

References

Leave a Comment