Class TextGenerationResult
- Namespace
- LMKit.TextGeneration
- Assembly
- LM-Kit.NET.dll
Holds the result of a text completion operation.
public sealed class TextGenerationResult
- Inheritance
-
TextGenerationResult
- Inherited Members
Examples
Example: Inspect a text generation result
using LMKit.Model;
using LMKit.TextGeneration;
LM model = LM.LoadFromModelID("gemma3:4b");
var conversation = new MultiTurnConversation(model);
TextGenerationResult result = conversation.Submit("What is machine learning?");
Console.WriteLine(result.Completion);
Console.WriteLine($"Prompt tokens: {result.PromptTokenCount}");
Console.WriteLine($"Prompt rate: {result.PromptProcessingRate:F1} tok/s");
Console.WriteLine($"Generated tokens: {result.GeneratedTokenCount}");
Console.WriteLine($"Generation rate: {result.TokenGenerationRate:F1} tok/s");
Console.WriteLine($"Quality score: {result.QualityScore:F2}");
Console.WriteLine($"Stop reason: {result.TerminationReason}");
Console.WriteLine($"Context usage: {result.ContextTokens.Count}/{result.ContextSize} tokens");
Properties
- Completion
Gets the generated text in a human-readable format.
- ContextSize
Gets the context size in tokens.
- ContextTokens
Gets the tokens of the key-value cache context.
- GeneratedTokenCount
Gets the number of tokens generated during sampling.
- GeneratedTokens
Gets the tokens produced during the sampling operations.
- PromptProcessingRate
Gets the prompt processing rate in tokens per second.
- PromptTokenCount
Gets the number of prompt tokens processed during the prefill phase.
- QualityScore
Gets a quality score for the generated text.
This score ranges between 0 and 1, where 1 indicates higher reliability of the text generation.
The formula utilizes a custom-designed metric that comprehensively analyzes various metrics generated throughout the completion phase.
- TerminationReason
Gets the cause for the conclusion of the text completion process.
- TokenGenerationRate
Gets the token generation rate in tokens per second.