Embeddings addedtoken equals - CyrilB1531/lodestar GitHub Wiki

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

HomeEmbeddingsTokenization

AddedToken.Equals

Value equality over the content, the id and every flag.

public bool Equals(AddedToken other)

Parametersother is the token to compare against.

Returnsbool, true when the content, the id and all five flags agree.

Example — same content, different flag, not equal.

using Lodestar.Embeddings.Tokenization;

var strict = new AddedToken("[MASK]", 103) { SingleWord = true };
var loose = new AddedToken("[MASK]", 103) { SingleWord = false };

bool same = strict.Equals(loose);  // => False

Remarks — the flags are part of the identity because they change what the token matches, not merely how it is described. Two tokens with the same content and different Lstrip produce different ids for the same text, so treating them as equal would make a vocabulary comparison say "identical" about two models that tokenize differently.

Applies to — net10.0, netstandard2.0.

See alsoAddedToken, AddedToken.GetHashCode.