๐ 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
๐ Clone the repository:
git clone https://github.com/LM-Kit/lm-kit-net-samples๐ Navigate to the project directory:
cd lm-kit-net-samples/console_net/text-generation/conversations/multi_turn_chat_with_custom_sampling๐จ Build and run the application:
dotnet build dotnet run๐ Follow the on-screen prompts to select a model and start the multi-turn chat.
๐ก Example Usage
- Select a Model: Choose from the available models or enter a custom model URI.
- Initiate Conversation: Start by entering a prompt, such as "Hello!".
- Receive Custom Responses: The chatbot will generate responses influenced by the custom sampling strategies and biases.
- Continue Interaction: Enter another prompt or use the special commands (/reset or /regenerate) to manage the conversation.
- 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.
๐ Related Content
- How-To: Control Token Sampling with Dynamic Strategies: Learn how to configure temperature, top-k, top-p, and other sampling parameters.
- How-To: Enforce Structured Output with Grammar: Guide to constraining LLM output format using grammar-based sampling.
- Glossary: Sampling: Core concepts behind token sampling strategies and their effect on response quality.
- Glossary: Dynamic Sampling: Understanding adaptive sampling techniques that adjust parameters during generation.
- Glossary: Temperature: How temperature controls randomness and creativity in LLM output.