Table of Contents

Class DocumentReference

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

Represents a reference to a specific location within a document, retrieved during a retrieval operation.

public sealed class DocumentReference
Inheritance
DocumentReference
Inherited Members

Examples

var result = await chat.SubmitAsync("What are the key findings?");

foreach (var reference in result.SourceReferences)
{
    Console.WriteLine($"[{reference.Name}, p.{reference.PageNumber}] " +
        $"(Score: {reference.SimilarityScore:P1})");
    Console.WriteLine($"  {reference.Excerpt}");
}

Properties

Excerpt

Gets the retrieved text excerpt.

Id

Gets the unique identifier of the source document, or an empty string if unavailable.

Metadata

Gets the complete metadata collection associated with this document reference.

Name

Gets the name of the source document.

PageNumber

Gets the page number within the document, or 0 if unavailable.

SimilarityScore

Gets the similarity score between the query and this partition (0.0 to 1.0).

SourceUri

Gets the source URI of the document, or an empty string if not specified during import.

Methods

FromPartitions(IEnumerable<PartitionSimilarity>)

Creates a list of DocumentReference instances from a collection of partition similarities.

FromRetrievalResults(IEnumerable<PartitionSimilarity>)

Builds user-facing source references from retrieval results: one reference per document page, ordered by descending score. Several chunks of the same page collapse into the page's best-scoring chunk, whose excerpt and score the reference carries, so a citation list never repeats a page. Context-window neighbors are skipped: they provide surrounding text for the model, not evidence, and carry no score of their own. Results without page metadata stay one reference per chunk.

Share