Skip to content

Embeddings specialtokentemplate gethashcode

github-actions[bot] edited this page Aug 26, 2026 · 24 revisions

Development build. This page describes main, not a released package. The latest published Lodestar.Embeddings is 0.4.0 — read its documentation.

SpecialTokenTemplate.GetHashCode

A hash consistent with that equality.

public int GetHashCode()

Returnsint, over the prefix tokens, the suffix tokens and the pad token.

Example — the same template hashes alike.

using Lodestar.Embeddings.Tokenization;

SpecialTokenTemplate template = SpecialTokenTemplate.Bert;

bool equal = template.Equals(SpecialTokenTemplate.Bert);  // => True
bool hashesAlike = template.GetHashCode() == SpecialTokenTemplate.Bert.GetHashCode();  // => True

Remarks — the token contents contribute, not the list identities, so a template rebuilt from the same strings hashes to what the ready-made one does. That is what makes a template usable as a dictionary key when caching encoders per model.

Applies to — net10.0, netstandard2.0.

See alsoSpecialTokenTemplate.Equals.

Lodestar

Project

Clone this wiki locally