Document<T>

Models & Types · AiDotNet.RetrievalAugmentedGeneration.Models

Represents a document with content, metadata, and optional relevance scoring.

For Beginners

A document is like a file or article in your system.

Think of it like a book entry in a library catalog:

  • Id: The unique catalog number
  • Content: The actual text from the book
  • Metadata: Information about the book (author, date, category, etc.)
  • RelevanceScore: How well this book matches what you’re looking for

For example, when you search for “climate change”, documents about environmental science get high relevance scores, while documents about sports get low scores.

How It Works

A document is the fundamental unit of information in a retrieval-augmented generation system. It contains the actual text content, metadata for filtering and tracking, and optional relevance scores assigned during retrieval or reranking processes.

Constructors

Constructor Summary
Document() Initializes a new instance of the Document class.
Document(string id, string content) Initializes a new instance of the Document class with specified content.
Document(string id, string content, Dictionary<string, object> metadata) Initializes a new instance of the Document class with content and metadata.

Properties

Property Summary
Dictionary<string, object> Metadata { get; set; } Gets or sets metadata associated with this document.
T RelevanceScore { get; set; } Gets or sets the relevance score assigned to this document by a retriever or reranker.
Vector<T> Embedding { get; set; } Gets or sets the embedding vector for this document.
bool HasRelevanceScore { get; set; } Gets or sets whether this document has a relevance score assigned.
string Content { get; set; } Gets or sets the text content of the document.
string Id { get; set; } Gets or sets the unique identifier for this document.