Table of Contents

Method Summarize

Namespace
LMKit.TextGeneration
Assembly
LM-Kit.NET.dll

Summarize(string, CancellationToken)

Generates a summary from the provided content synchronously.

public Summarizer.SummarizerResult Summarize(string content, CancellationToken cancellationToken = default)

Parameters

content string

The input text to be summarized.

cancellationToken CancellationToken

An optional cancellation token for asynchronous operations.

Returns

Summarizer.SummarizerResult

An instance of Summarizer.SummarizerResult containing the title and/or content summary.

Examples

// Summarizing user input from the console.
var model = new LMKit.Model.LM("user-input-model.gguf");
var summarizer = new LMKit.TextGeneration.Summarizer(model)
{
    GenerateTitle = true,
    GenerateContent = true
};

Console.WriteLine("Please enter text to summarize:");
string userInput = Console.ReadLine();

var summaryResult = summarizer.Summarize(userInput);
Console.WriteLine("Title: " + summaryResult.Title);
Console.WriteLine("Summary: " + summaryResult.Content);

Exceptions

ArgumentException

Thrown if the provided content is null or empty.

Exception

Passes through any exceptions that occur during summarization.