Unlock the Potential of AI in Your Apps with Semantic Kernel: A Lightweight SDK for LLMs
Published Mar 22 2023 12:00 AM 9,171 Views
Microsoft

Semantic Kernel (SK) is an innovative and lightweight Software Development Kit (SDK) designed to integrate Artificial Intelligence (AI) Large Language Models (LLMs) with conventional programming languages. With SK, developers can easily infuse their applications with complex skills such as prompt chaining, summarization, recursive reasoning, embeddings-based memory, zero/few-shot learning, and more. SK supports prompt templating, function chaining, vectorized memory, and intelligent planning capabilities out of the box.

Join the SK community and build AI-first apps faster with a front-row seat on the future of computing.

 

The SK extensible programming model combines natural language semantic functions, traditional code native functions,
and embeddings-based memory unlocking new potential and adding value to applications with AI.

SK supports prompt templating, function chaining, vectorized memory, and intelligent planning capabilities out of the box.

 

Semantic Kernel is designed to support and encapsulate several design patterns from the latest in AI research, such that developers can infuse their applications with complex skills like prompt chaining, recursive reasoning, summarization, zero/few-shot learning, contextual memory, long-term memory, embeddings, semantic indexing, planning, and accessing external knowledge stores as well as your own data.
Semantic KernelSemantic Kernel

Join the SK community! You can build AI-first apps faster and have a front-row peek at how the SDK is being built. SK has been released as open-source so that more pioneering developers can join us in crafting the future of this landmark moment in the history of computing. 


Samples

If you would like a quick overview about how Semantic Kernel can integrate with your app

git clone https://github.com/microsoft/semantic-kernel.git

and try these examples:

   
Simple chat summary Use ready-to-use skills and get those skills into your app easily.
Book creator Use planner to deconstruct a complex goal and envision using the planner in your app.
Authentication and APIs Use a basic connector pattern to authenticate and connect to an API and imagine integrating external data into your app's LLM AI.

 

For a more hands-on overview, you can also run the Getting Started notebook, looking into the syntax, creating Semantic Functions, working with Memory, and see how the kernel works and more details at the Semantic Kernel documentation | Microsoft Learn


Please note:


Get Started with Semantic Kernel 

Here is a quick example of how to use Semantic Kernel from a C# console app. More details at Semantic Kernel documentation | Microsoft Learn

  1. Create a new project, targeting .NET 6 or newer, and add the Microsoft.SemanticKernel nuget package:

    dotnet add package Microsoft.SemanticKernel --prerelease
    

    See nuget.org for the latest version and more instructions.

  2. Copy and paste the following code into your project, with your Azure OpenAI key in hand (you can create one here).

using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.KernelExtensions;

var kernel = Kernel.Builder.Build();

// For Azure Open AI service endpoint and keys please see
// https://learn.microsoft.com/azure/cognitive-services/openai/quickstart?pivots=rest-api
kernel.Config.AddAzureOpenAICompletionBackend(
    "davinci-backend",                   // Alias used by the kernel
    "text-davinci-003",                  // Azure OpenAI *Deployment ID*
    "https://contoso.openai.azure.com/", // Azure OpenAI *Endpoint*
    "...your Azure OpenAI Key..."        // Azure OpenAI *Key*
);

string skPrompt = @"
{{$input}}

Give me the TLDR in 5 words.
";

string textToSummarize = @"
1) A robot may not injure a human being or, through inaction,
allow a human being to come to harm.

2) A robot must obey orders given it by human beings except where
such orders would conflict with the First Law.

3) A robot must protect its own existence as long as such protection
does not conflict with the First or Second Law.
";

var tldrFunction = kernel.CreateSemanticFunction(skPrompt);

var summary = await kernel.RunAsync(textToSummarize, tldrFunction);

Console.WriteLine(summary);

// Output => Protect humans, follow orders, survive.


Contributing and Community

We welcome your contributions and suggestions to SK community! One of the easiest ways to participate is to engage in discussions in the GitHub repository. Bug reports and fixes are welcome!


For new features, components, or extensions, please open an issue and discuss with us before sending a PR. This is to avoid rejection as we might be taking the core in a different direction, but also to consider the impact on the larger ecosystem.

To learn more and get started:

 

 

Co-Authors
Version history
Last update:
‎Mar 22 2023 02:24 AM
Updated by: