Introduction to Microsoft Semantic Kernel

Welcome to a new series of articles dedicated to Semantic Kernel — an innovative solution developed by Microsoft aimed at facilitating the integration of generative artificial intelligence into applications for developers. In today's post, I will provide an overview of Semantic Kernel and a review of the possibilities this solution offers. You'll learn how SK can revolutionize your approach to creating intelligent systems and the benefits it brings.

Throughout this series on Microsoft Semantic Kernel, we will explore the practical use of OpenAI services. It is worth noting that developing and training large language models (LLM) requires significant resources, so using these advanced technologies comes with certain costs. Language models such as ChatGPT offer incredible capabilities in natural language processing, which can be extremely useful in various applications, from customer service automation to content creation. Using these services is not free, but the benefits often outweigh the costs.

Recently, OpenAI introduced a new model, GPT-4o Mini, which is even cheaper than GPT-3.5 Turbo. GPT-4o Mini is an intelligent and affordable model that surpasses GPT-3.5 Turbo in text intelligence (achieving 82% in MMLU compared to 69.8% for GPT-3.5 Turbo). The price of GPT-4o Mini is over 60% lower than GPT-3.5 Turbo, at $0.15 per 1 million input tokens and $0.60 per 1 million output tokens (equivalent to about 2500 pages of a standard book). GPT-4o Mini currently supports text and visual capabilities, with plans to support audio and video inputs and outputs. This model also has better multilingual understanding compared to GPT-3.5 Turbo, covering a wide range of non-English languages. Due to its low costs and latency, GPT-4o Mini is ideal for tasks requiring large amounts of data (e.g., passing an entire codebase or conversation history to the model), cost-sensitive tasks (e.g., summarizing large documents), and tasks requiring quick responses (e.g., customer service chatbots).

To use OpenAI services, we will need an API key. This is a unique code that allows your application to access OpenAI resources. To generate a key, create an account on OpenAI or log into an existing one. Then, go to the API keys page and select "Create new secret key," optionally giving it a name. Make sure to save this key in a secure place and do not share it with anyone.

Currently, OpenAI recommends using project-based API keys for more detailed resource control. The documentation link can be found here.

What is Microsoft Semantic Kernel?

Microsoft Semantic Kernel is an open-source software development kit (SDK) designed to facilitate the integration of applications written in C#, Python, and Java with artificial intelligence services such as those provided by OpenAI, Azure OpenAI, and Hugging Face. With SK, it is possible to receive requests from applications and forward them to various AI services. Moreover, by extending SK functionality with your own functions, it is possible to automatically detect which functions need to be used and in what order to fulfill a given request.

Semantic Kernel was originally designed to power various versions of Microsoft Copilot, such as Microsoft 365 Copilot and Bing Copilot, and was later made available to the developer community as an open-source package. Developers can use SK to create plugins that perform complex actions using AI services and combine these plugins with just a few lines of code.

One of the unique features of Semantic Kernel is its ability to automatically orchestrate different plugins using a planner. With the planner, the user can request the application to achieve a complex goal. For example, if you have a function that translates text into different languages and another function that sends emails, the user can say, "Translate this text into Spanish and email my Spanish-speaking client," and the planner will automatically understand that the translation function needs to be called first, followed by the email-sending function. SK will automatically find and connect the plugins to achieve this goal and create a plan.

What does Microsoft Semantic Kernel offer?

One of the most important aspects of Semantic Kernel is its ability to integrate with large language models such as GPT-4. Additionally, SK enables connections with other models available within Azure OpenAI, Hugging Face, and local models. With implementations of these abstractions for OpenAI, Azure OpenAI, Hugging Face services, and various vector databases like Chroma, Qdrant, Milvus, and Azure, developers can easily incorporate advanced natural language processing features into their applications. This opens the door to a wide range of applications, from chatbots and recommendation systems to text analysis tools.

Semantic Kernel introduces a distinction between native and semantic functions. Native functions are standard functions written in the application language, while semantic functions integrate with external AI services. This distinction allows for the creation of more modular and flexible applications.

Key strength of Semantic Kernel is the ability to create semantic plugins. These plugins are language-independent and consist of a collection of semantic functions. This allows developers to separate their code from AI functions, making application maintenance easier and enabling better collaboration on prompts.

Semantic Kernel is equipped with advanced planning tools that enable dynamic action plan creation based on user goals. Planners can use both native and semantic functions to achieve tasks most efficiently.

Practical Applications

Due to its flexibility, Semantic Kernel can be used in a variety of practical applications. Examples include:

  • Chatbots: Creating intelligent assistants that can conduct natural conversations with users.
  • Recommendation systems: Analyzing user preferences and suggesting products or content.
  • Text analysis: Processing and analyzing large text datasets to extract valuable insights.
  • Task automation: Creating scripts and tools that automate daily administrative tasks.

Semantic Kernel is a great tool that opens new possibilities for integrating advanced language models into applications. With its flexibility, modularity, and advanced planning features, SK provides a solid foundation for creating intelligent systems of the future. In further articles, we will delve into specific use cases, configure semantic functions, and provide practical tips for implementing SK in your projects.

We invite you to read the following parts of our series, where we will step-by-step explore how to fully leverage the potential of Microsoft Semantic Kernel.

See you in the next posts!