Chatbots
Large Language Models are good for chatbots because they can understand natural language and generate human-like responses. With the ability to analyze and learn from vast amounts of data, these models can quickly adapt to different types of conversations and provide relevant and personalized responses.
Few-shots learning example
By using a ModelChain
with history of previous messages you could construct chatbot capable to talk and remember previous discussion.
var suffix = new PromptTemplate("{human_phrase}");
var examples = new List<(string, string)>()
{
new("Hello nice to meet you.", "Nice to meet you too."),
new("How is it going today?", "Not so bad, thank you! How about you?"),
new("I am ok, but I am a bit sad...", "Oh? Why that?")
};
var prompt = new ChatMLPromptTemplate(suffix, "This is a discussion between a human and a robot. The robot is very nice and empathetic.", examples);
var llm = new ChatGptModel(Constants.OpenAIKey, ChatGptModelConfiguration.Default with { Temperature = 0.9f, MaxTokens = 100 });
var llmChain = new ModelChain(prompt, llm);
var executor = llmChain.GetExecutor();
var answer1 = await executor.PromptAsync("I broke up with my girlfriend...");
Console.WriteLine(answer1);
var answer2 = await executor.PromptAsync("I won a lot of money today");
Console.WriteLine(answer2);
Conversational Chain
When we combine Chain, Memory and ChatML model we could construct ultimative chatbot that could talk on any topics.
ConversationalChain - Coming Soon