Embeddings addedtoken gethashcode - 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.
Home › Embeddings › Tokenization
AddedToken.GetHashCode
A hash consistent with that equality.
public int GetHashCode()
Returns — int, over the content, the id and the flags.
Example — equal tokens hash alike.
using Lodestar.Embeddings.Tokenization;
var first = new AddedToken("[MASK]", 103) { Special = true };
var second = new AddedToken("[MASK]", 103) { Special = true };
bool consistent = first.Equals(second) && first.GetHashCode() == second.GetHashCode(); // => True
Remarks — every field that Equals reads contributes, which is what
the contract requires and what makes an AddedToken safe as a dictionary key or in a set — the
shape a vocabulary's added-token list is usually searched as.
Applies to — net10.0, netstandard2.0.
See also — AddedToken.Equals.