Data model classes for serializing/deserializing a greedy generation reference document for an LLM proof-of-concept. Defines GreedyGenerationReferenceDocument with metadata, arrays of token ids and steps, plus GreedyGenerationReferenceStep and GreedyGenerationLogitReference types mapping JSON property names to C# properties.
using System.Text.Json.Serialization;
namespace LlmPoc.Llm;
public sealed class GreedyGenerationReferenceDocument
{
[JsonPropertyName( "model_id" )]
public string ModelId { get; set; }
[JsonPropertyName( "prompt" )]
public string Prompt { get; set; }
[JsonPropertyName( "input_token_ids" )]
public int[] InputTokenIds { get; set; }
[JsonPropertyName( "bos_token_id" )]
public int BosTokenId { get; set; }
[JsonPropertyName( "eos_token_id" )]
public int EosTokenId { get; set; }
[JsonPropertyName( "bos_automatically_added" )]
public bool BosAutomaticallyAdded { get; set; }
[JsonPropertyName( "eos_automatically_added" )]
public bool EosAutomaticallyAdded { get; set; }
[JsonPropertyName( "do_sample" )]
public bool DoSample { get; set; }
[JsonPropertyName( "argmax_tie_break" )]
public string ArgmaxTieBreak { get; set; }
[JsonPropertyName( "logits_processors" )]
public string[] LogitsProcessors { get; set; }
[JsonPropertyName( "raw_logits_used_for_argmax" )]
public bool RawLogitsUsedForArgmax { get; set; }
[JsonPropertyName( "cached_and_uncached_sequences_match" )]
public bool CachedAndUncachedSequencesMatch { get; set; }
[JsonPropertyName( "csharp_baseline_use_cache" )]
public bool CsharpBaselineUseCache { get; set; }
[JsonPropertyName( "max_new_tokens" )]
public int MaxNewTokens { get; set; }
[JsonPropertyName( "generated_token_ids" )]
public int[] GeneratedTokenIds { get; set; }
[JsonPropertyName( "generated_text" )]
public string GeneratedText { get; set; }
[JsonPropertyName( "full_sequence_token_ids" )]
public int[] FullSequenceTokenIds { get; set; }
[JsonPropertyName( "stop_reason" )]
public string StopReason { get; set; }
[JsonPropertyName( "eos_reached" )]
public bool EosReached { get; set; }
[JsonPropertyName( "minimum_top1_top2_margin" )]
public float MinimumTop1Top2Margin { get; set; }
[JsonPropertyName( "minimum_margin_step" )]
public int MinimumMarginStep { get; set; }
[JsonPropertyName( "steps" )]
public GreedyGenerationReferenceStep[] Steps { get; set; }
[JsonPropertyName( "later_full_logit_reference" )]
public GreedyGenerationLogitReference LaterFullLogitReference { get; set; }
}
public sealed class GreedyGenerationReferenceStep
{
[JsonPropertyName( "step" )]
public int Step { get; set; }
[JsonPropertyName( "input_sequence_length" )]
public int InputSequenceLength { get; set; }
[JsonPropertyName( "input_token_ids" )]
public int[] InputTokenIds { get; set; }
[JsonPropertyName( "new_token_position" )]
public int NewTokenPosition { get; set; }
[JsonPropertyName( "expected_next_token_id" )]
public int ExpectedNextTokenId { get; set; }
[JsonPropertyName( "decoded_token" )]
public string DecodedToken { get; set; }
[JsonPropertyName( "top1_logit" )]
public float Top1Logit { get; set; }
[JsonPropertyName( "top2_token_id" )]
public int Top2TokenId { get; set; }
[JsonPropertyName( "top2_logit" )]
public float Top2Logit { get; set; }
[JsonPropertyName( "top1_top2_margin" )]
public float Top1Top2Margin { get; set; }
[JsonPropertyName( "eos_reached" )]
public bool EosReached { get; set; }
[JsonPropertyName( "top5" )]
public ForwardReferenceTopLogit[] TopFive { get; set; }
}
public sealed class GreedyGenerationLogitReference
{
[JsonPropertyName( "step" )]
public int Step { get; set; }
[JsonPropertyName( "input_sequence_length" )]
public int InputSequenceLength { get; set; }
[JsonPropertyName( "file" )]
public string File { get; set; }
[JsonPropertyName( "elements" )]
public int Elements { get; set; }
[JsonPropertyName( "bytes" )]
public int Bytes { get; set; }
[JsonPropertyName( "sha256" )]
public string Sha256 { get; set; }
}