Set

Use Set for unordered membership in a bounded vocabulary. Use Category for one label and Branch when each item has attributes or position.

tags:
  - vip
  - international
  - vip
import relflow as rf

tags = rf.Set(size=2048, threshold=0.75)

Input and options

An Arrow list holds the labels; a scalar label is treated as a one-member set. Labels may be Boolean, integer, floating-point, string, or binary, with one compatible Arrow type family per field. Duplicate members collapse, and null members are ignored. An empty list is valued; a null list has state null.

Option Default Meaning
size 10000 Positive vocabulary capacity; capacity is also accepted.
p_unavailable 0.01 Training probability of dropping each known positive label, independently in input and target content.
threshold None Prediction filter in [0, 1]; retain labels whose probability meets it. None returns every populated label.

See shared leaf options for target and embedding configuration.

Vocabulary and learning

The shared Online Vocabulary contract covers admission order, capacity limits, worker synchronization, and checkpoint reuse.

Training grows a checkpointed vocabulary; validation, test, and prediction reuse it. For an application-supplied trained model:

labels = rf.Set.vocabulary(model, "record/tags")

This tuple snapshot lists populated labels in index order. It also accepts a preprocessor’s encoding_context; consult established vocabularies for inference preprocessing, not to decide which training labels may be learned.

Content is a capacity-wide multi-hot vector. Unknown members have no positive bit. A valued empty set, an all-unknown set, and a set whose members were all dropped therefore share zero content. Their valued state distinguishes them from nulls and padding. The encoder averages active label embeddings and adds the state embedding.

Reconstruction combines state loss with binary cross entropy for valued target sets. Content accuracy uses a fixed 0.5 cutoff. Unknown target labels cannot supply positive-label supervision.

Prediction

content is a list of value / probability structs, with string labels and independent membership probabilities. Only populated vocabulary entries appear. The configured threshold filters this list; it changes neither training metrics nor the capacity-wide decoder computation.

See the prediction envelope for shared state probabilities, inferred, and repeated shapes.