Start Building with Generative AI in Minutes

Unlock the full potential of Generative AI in your .NET applications with LM-Kit.NET.

Our free trial provides unlimited access to all featuresno time limits, no registration required. Start experimenting today and seamlessly integrate AI capabilities into your .NET ecosystem.

Prerequisites

Before getting started, ensure your environment meets the following requirements:

Unlimited, No Signup Trial

Made by developers for developers! Our trial gate lets you explore everything without time limits or the need to share personal data. Access all features and test our platform freely.

Installing LM-Kit.NET via NuGet

Follow these simple steps to install the LM-Kit.NET SDK using NuGet Package Manager:

Option 1: Install via Console

  • Open the NuGet Package Manager Console in Visual Studio.
  • Run the following command:
				
					Install-Package LM-Kit.NET
				
			

Option 2: Install via UI

  • Right-click on your project in the Solution Explorer.
  • Select Manage NuGet Packages….
  • Search for LM-Kit.NET in the Browse tab.
  • Click Install to add the package to your project.

Optional: Enable CUDA Support (GPU Acceleration)

For enhanced performance using Nvidia GPU acceleration, install the appropriate CUDA backend:

For Windows:
				
					Install-Package LM-Kit.NET.Backend.Cuda12.Windows

				
			
For Linux:
				
					Install-Package LM-Kit.NET.Backend.Cuda12.Linux

				
			

Example Use Cases

				
					using LMKit;
using LMKit.TextGeneration;

namespace YourNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Load the model
            var model = new LMKit.Model.LLM("my-model.gguf");

            // Create a multi-turn conversation instance
            var chat = new LMKit.TextGeneration.MultiTurnConversation(model);

            // Submit a prompt and get the response.
            var response = chat.Submit("Why are cats so cute?");

            // Output the generated text
            Console.WriteLine("Response: " + response.Completion);
        }
    }
}

				
			
				
					using LMKit.Extraction;
using LMKit.Model;
using System;
using System.Collections.Generic;

// Initialize the language model (LLM)
LLM languageModel = new LLM("https://huggingface.co/lm-kit/phi-3.5-mini-3.8b-instruct-gguf/resolve/main/Phi-3.5-mini-Instruct-Q4_K_M.gguf?download=true");

// Create an instance of TextExtraction using the LLM
TextExtraction textExtraction = new TextExtraction(languageModel);

// Define the elements to extract
textExtraction.Elements = new List<TextExtractionElement>
{
    new TextExtractionElement("Name", ElementType.String, "The person's full name"),
    new TextExtractionElement("Age", ElementType.Integer, "The person's age"),
    new TextExtractionElement("Birth Date", ElementType.Date, "The person's date of birth.")
};

// Set the content to extract data from
textExtraction.SetContent("Jane Smith, aged 28, born on 5 Nov of the year 1981");

// Perform the extraction synchronously
TextExtractionResult result = textExtraction.Parse();

// Access the extracted items
foreach (var item in result.Items)
{
    Console.WriteLine($"{item.TextExtractionElement.Name}: {item.Value}");
}

				
			
				
					using LMKit.TextGeneration;

namespace YourNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Load the model
            var model = new LMKit.Model.LLM("my-model.gguf");

            // Create a  TextTranslation  instance
            var textTranslation = new LMKit.Translation.TextTranslation(model);
            string text = "Allons boire une bière après le travail !";
            Language detectedLanguage = textTranslation.DetectLanguage(text);

            // Output the detected language
            Console.WriteLine($"Detected Language: {detectedLanguage}");
        }
    }
}
				
			
				
					using LMKit;

namespace YourNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Load the AI model, because language barriers are so last century.
            var model = new LMKit.Model.LLM("my-model.gguf");

            // Let the AI handle the translation, because Google Translate can't always save you.
            var translator = new LMKit.Translation.TextTranslation(model);

            // Translate something that sounds more philosophical in French than it probably is.
            string response = translator.Translate("Bonjour, comment vas-tu ? J'ai récemment lu un article fascinant sur l'impact de l'intelligence artificielle sur la littérature moderne. Qu'en penses-tu ?", LMKit.TextGeneration.Language.English);

            // Show off the AI's linguistic finesse with a dash of existential thought.
            Console.WriteLine("Translated version: " + response);
        }
    }
}

				
			
				
					using LMKit;

namespace YourNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Load the model
            var model = new LMKit.Model.LLM("https://huggingface.co/lm-kit/lm-kit-sentiment-analysis-2.0-1b-gguf/resolve/main/lm-kit-sentiment-analysis-2.0-1b-q4.gguf?download=true");

            // Create a classifier
            var classifier = new LMKit.TextAnalysis.SentimentAnalysis(model)
            {
                NeutralSupport = true
            };

            // Ask the model for its hot take on our brilliance
            var sentiment = classifier.GetSentimentCategory("LM-Kit is so convenient, it practically runs on sunshine and good karma!");

            // Drumroll, please... the model's about to flatter us
            Console.WriteLine($"Sentiment: {sentiment}"); // Positive! Just like our developer optimism after 10 cups of coffee.
        }
    }
}
				
			
				
					using LMKit;

namespace YourNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Load the model
            var model = new LMKit.Model.LLM("https://huggingface.co/lm-kit/phi-3.5-mini-3.8b-instruct-gguf/resolve/main/Phi-3.5-mini-Instruct-Q4_K_M.gguf?download=true");

            // Create a classifier
            var classifier = new LMKit.TextAnalysis.EmotionDetection(model)
            {
                NeutralSupport = true// Because sometimes you just feel "meh"
            };

            // Ask the model for its hot take on our brilliance
            var emotion = classifier.GetEmotionCategory("I just tried to make spaghetti, and somehow ended up with a culinary masterpiece!");

            Console.WriteLine($"Emotion: {emotion}"); 
        }
    }
}
				
			
				
					using LMKit;

namespace YourNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initialize the LLM model by providing the URL to the model file
            var model = new LMKit.Model.LLM("https://huggingface.co/lm-kit/phi-3.5-mini-3.8b-instruct-gguf/resolve/main/Phi-3.5-mini-Instruct-Q4_K_M.gguf?download=true");

            // Create a text classifier using the loaded model
            var classifier = new LMKit.TextAnalysis.Categorization(model);

            // Define a list of categories that the classifier can choose from
            var categories = new string[]
            {
                "sport", "finance", "technology", "entertainment",
                "health", "education", "science", "travel",
                "lifestyle", "food", "gaming"
            };

            // Input text for classification
            var inputText = "Physical activity helps build strength, endurance, and promotes a sense of camaraderie among participants";

            // Get the most appropriate category for the input text from the list of categories
            int category = classifier.GetBestCategory(categories, inputText);

            // Output the predicted category to the console
            if (category != -1)
            {
                Console.WriteLine($"Category: {categories[category]}");
            }
            else
            {
                Console.WriteLine("No match");
            }
        }
    }
}

				
			
				
					using LMKit;

namespace YourNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Load the model - because we need the brains behind this operation!
            var model = new LMKit.Model.LLM("my-model.gguf");

            // Create a TextRewriter instance - turning your casual thoughts into corporate gold.
            var rewriter = new LMKit.TextEnhancement.TextRewriter(model);

            // Submit a prompt and get a more professional response. 
            // Perfect for when you're trying to sound like you have your life together!
            string response = rewriter.Rewrite("I want to apply my candidature to LM-Kit as I would like to work with fancy people",
                                                LMKit.TextEnhancement.TextRewriter.CommunicationStyle.Professional);

            // Output the transformed text - hopefully making you sound like a polished professional, instead of a 'fancy people' fan.
            Console.WriteLine("Here’s a more professional style: " + response);
        }
    }
}

				
			
				
					using LMKit;

namespace YourNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Load the model like it's rocket science.
            var model = new LMKit.Model.LLM("my-model.gguf");

            // Call in the grammar rescue squad.
            var corrector = new LMKit.TextEnhancement.TextCorrection(model);

            // Fix the world's weirdest sentence.
            string response = corrector.Correct("My cat don't never flyed to the moon because he too much tired from baking a pizza in the bathtub last Tuesday");

            // Display the miracle correction.
            Console.WriteLine("Corrected version: " + response);
        }
    }
}

				
			
				
					using LMKit;
using LMKit.Configuration;

namespace YourNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Enable KV (key-value) cache recycling 
            LMKit.GlobalConfiguration.EnableKVCacheRecycling = true;
            
            // Disable model caching 
            LMKit.GlobalConfiguration.EnableModelCache = false;
            
            // Enable token healing 
            LMKit.GlobalConfiguration.EnableTokenHealing = true;
            
            // Discover more parameters in the LMKit.GlobalConfiguration static class.

            // Code to use LM-Kit.NET goes here
        }
    }
}

				
			

Ready to Deploy? Choose Our Free Community License!

🚀 Take Your App to the Next Level with LM-Kit.NET’s Community Edition 🚀

Whether you’re developing new AI-powered solutions or enhancing existing applications, our Community License offers powerful, cross-platform AI capabilities for free. Enjoy the full spectrum of Generative AI tools, from text generation and RAG to content retrieval and more—all packed in a single, easy-to-use SDK.

Deploy with confidence, no strings attached, and start transforming your ideas into reality today.

 

Send us Your Feedback

Stay anonymous if you prefer