ContentHash

Helpers & Utilities · AiDotNet.RetrievalAugmentedGeneration.Embeddings

Provides stable, content-based hashing utilities used for caching and de-duplicating text.

For Beginners

A content hash is a short “fingerprint” of a piece of text.

  • The same text always produces the same fingerprint.
  • Different text (almost) always produces a different fingerprint.
  • It lets us recognize “we have already seen this exact text” without storing the whole text.

We use it so that repeated pieces of text are only embedded once and then reused.

How It Works

The hashes produced here are deterministic across processes and platforms (unlike GetHashCode, which is randomized per process on modern .NET runtimes). This makes them suitable as cache keys and for ingestion de-duplication where the same content must always map to the same key.

Methods

Method Summary
string ComputeHash(string text) Computes a stable SHA-256 hash of the supplied text and returns it as a lowercase hex string.