Quick Intro to Microsoft Semantic Kernel (AI Kitchen)

Mahmoud AmrMahmoud Amr
2 min read

Semantic Kernel is a tool that helps you easily integrate AI into your application. It can handle the process of converting your natural language prompt into a set of tool calls that can get your task done.

What is Semantic Kernel?

Semantic Kernel is a mix of two main components Semantic Completion + Semantic Memory

  • ๐Ÿช„ Semantic Completion: is using the power of the LLM to complete your prompts.

  • ๐Ÿ’พ Semantic Memory: is storing and retrieving data to help your model gain better context and give better replies.

๐Ÿ”Œ Plugins

Plugins are mainly the skills that you can add to the kernel to complete your tasks there are two types of plugins:

Native Plugin

Native code written in Python, C# or Java, where you provide a description of the function and its parameters.

Semantic Plugins

Plugins that are written in the form of a Prompt template and a Configuration file, the Config file has the LLM configuration and the description of the parameters.

How does the kernel work:

The following is a simple flow:

1- Define the kernel.

2- Register a Chat Completion Service, It might be OpenAI, AzureOpenAI, a Huggingface model,.. etc. 3- Register a Memory Service (optional), you need a text embedding model, and any memory solution that might be a set of files, a volatile memory,..etc

4- Import Plugins to the kernel, each plugin and its functions has a description.

5- The kernel takes the user input in the form of natural language.

6- The kernel combines the user input, the chat history, and the functions schemas (generated from function descriptions) along with your prompt.

7- A request is sent to the Completion service.

8- If the service model supports function calling, and the user prompt requires the invocation of one or more of the functions defined through the registered plugins, the model will return a schema of each function that should be called and its parameters (if available from the user input).

9- The kernel parses the response if: -- it has no tool calls: it is simply returned to the client and displayed to the user. -- it has a tool call: the function(s) schema is parsed and if all the required parameters are available and the kernel is set to Auto mode, the function is invoked and the result is passed back as context to the model.

10- The model receives the result of the function invocation and returns a natural language response.

More Resources

0
Subscribe to my newsletter

Read articles from Mahmoud Amr directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mahmoud Amr
Mahmoud Amr