Table of Contents

๐Ÿ‘‰ Try the demo:
https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/text-generation/conversations/multi_turn_chat_with_custom_sampling

๐Ÿ’ฌ Multi-Turn Chat with Custom Sampling Demo Overview


๐ŸŽฏ Purpose of the Demo

The Multi-Turn Chat with Custom Sampling Demo demonstrates how to use the LM-Kit.NET SDK to create an interactive chatbot with customized sampling strategies. This sample showcases the integration of large language models (LLMs) into a .NET application to facilitate multi-turn conversations with advanced sampling techniques to influence the chatbot's responses.


๐Ÿ‘ฅ Industry Target Audience

This sample is particularly beneficial for developers and organizations in the following sectors:

  • ๐Ÿ› ๏ธ Customer Support: Provide tailored responses based on specific customer needs and preferences.
  • ๐Ÿ“š Education: Develop interactive learning assistants that can adapt to different educational contexts and styles.
  • ๐Ÿฉบ Healthcare: Create chatbots that can respond appropriately to patient inquiries by adjusting the language model's output dynamically.
  • ๐Ÿ›’ E-commerce: Enhance customer engagement by delivering personalized and context-aware responses.

๐Ÿš€ Problem Solved

Generating responses that are contextually relevant and stylistically appropriate can be challenging, especially when dealing with diverse conversational contexts. The Multi-Turn Chat with Custom Sampling Demo addresses this problem by leveraging advanced sampling techniques to customize the chatbot's responses, ensuring that they are both relevant and engaging.


๐Ÿ’ป Sample Application Description

The Multi-Turn Chat with Custom Sampling Demo is a console application that allows users to interact with a chatbot designed to adapt its responses using various sampling strategies and biases.

โœจ Key Features

  • ๐Ÿ“ฆ Model Selection: Users can choose from predefined models or provide a custom model URI.
  • ๐Ÿ“Š Progress Tracking: The application displays download and loading progress for the selected model.
  • ๐ŸŽฒ Custom Sampling: The application uses advanced sampling strategies such as top-k, top-p, temperature, and others to influence the chatbot's responses.
  • โš–๏ธ Bias Adjustment: Adjusts the logit biases to encourage or discourage specific topics in the chatbot's responses.
  • ๐Ÿ“ˆ Performance Metrics: Displays generated tokens, stop reasons, quality score, and speed of response for each interaction.
  • ๐Ÿ”ง Special Commands: Users can reset the conversation using the /reset command or regenerate responses with the /regenerate command.

๐Ÿง  Supported Models

The sample supports several state-of-the-art models:

  • Alibaba Qwen 3.5 9B (~7 GB VRAM)
  • Google Gemma 4 E4B (~6 GB VRAM)
  • Microsoft Phi-4 14.7B (~11 GB VRAM)
  • OpenAI GPT OSS 20B (~16 GB VRAM)
  • Z.ai GLM 4.7 Flash 30B (~18 GB VRAM)
  • Alibaba Qwen 3.8 27B (~18 GB VRAM)
  • Alibaba Qwen 3.6 35B-A3B (~22 GB VRAM)

๐Ÿ› ๏ธ Getting Started

๐Ÿ“‹ Prerequisites

  • .NET 8.0 or later

๐Ÿ“ฅ Download the Project

โ–ถ๏ธ Running the Application

  1. ๐Ÿ“‚ Clone the repository:

    git clone https://github.com/LM-Kit/lm-kit-net-samples
    
  2. ๐Ÿ“ Navigate to the project directory:

    cd lm-kit-net-samples/console_net/text-generation/conversations/multi_turn_chat_with_custom_sampling
    
  3. ๐Ÿ”จ Build and run the application:

    dotnet build
    dotnet run
    
  4. ๐Ÿ“œ Follow the on-screen prompts to select a model and start the multi-turn chat.

๐Ÿ’ก Example Usage

  1. Select a Model: Choose from the available models or enter a custom model URI.
  2. Initiate Conversation: Start by entering a prompt, such as "Hello!".
  3. Receive Custom Responses: The chatbot will generate responses influenced by the custom sampling strategies and biases.
  4. Continue Interaction: Enter another prompt or use the special commands (/reset or /regenerate) to manage the conversation.
  5. End the Chat: Submit an empty input to end the program.

By following these steps, developers can explore the functionalities of LM-Kit.NET and integrate advanced sampling strategies into their chatbot applications, enhancing the relevance and engagement of automated responses through a multi-turn conversational AI.

Share