| sfa_semk | R Documentation |
Estimates the number of semantic factors in an item set from its embeddings using sem-k: a learned retention rule trained on a planted-truth corpus of LLM-written item sets with known structure, embedded in realistic encoder geometry. Unlike null-referenced eigenvalue rules, sem-k is a calibrated estimator: its error rates are measured on held-out planted configurations (65.7% exact, 73.9% within 25% on the v1–v4 corpus under Qwen3-Embedding-8B), and every verdict carries a 90% split-conformal interval.
sfa_semk(
sim_matrix = NULL,
embeddings = NULL,
floor = NULL,
seed = 42L,
download = interactive(),
quiet = FALSE
)
sim_matrix |
A fitted |
embeddings |
Numeric embedding matrix (n_items x embedding_dim).
Required unless |
floor |
Register-floor calibration for the encoder that produced
the embeddings (mean off-diagonal similarity of construct-dead
survey-register items). |
seed |
Random seed for the feature-extraction bootstrap (verdicts are seed-invariant on 41 of 42 benchmark scales, max spread 1). |
download |
Permission to download the model artifact if not yet
cached. Defaults to |
quiet |
Suppress download progress messages. |
The estimand is semantic dimensionality: the number of
distinguishable meaning clusters the items' embedding geometry
supports. Across 35 scales with large response archives, semantic
verdicts track empirical human-data dimensionality far better than
documented textbook counts do; where the two diverge (for example,
single-construct symptom inventories carrying real symptom-cluster
structure), human response data typically diverges the same way.
Treat sem-k as one voice alongside the granularity evidence in
sfa_dimselect() when the interval is wide.
The rule generalizes across encoders: retrained and evaluated on nine
encoders from six providers (Qwen 0.6B–8B, e5-mistral, NVIDIA
llama-embed-nemotron, Microsoft harrier, OpenAI text-embedding-3
small/large, Google gemini-embedding-2), exact accuracy stays within
61.6–69.0% and real-scale verdicts agree across providers at mean
pairwise Spearman .89. The shipped artifact is the Qwen3-Embedding-8B
model; for other encoders pass the encoder's register floor via
floor (see the calibration files distributed with the sem-k
release).
Requires Python with numpy, scipy, scikit-learn
(pinned to the 1.8 series, matching the artifact's training version),
and joblib (all declared automatically via
reticulate::py_require() on first use), and a one-time ~17 MB
artifact download (cached under
tools::R_user_dir("semanticfa", "cache")).
A list of class "sfa_semk" with components:
Integer: the sem-k point estimate of semantic k.
Integer bounds of the 90% split-conformal interval (calibrated coverage 91–96% across encoders).
The register floor used.
Named integer vector: the classical battery votes (kaiser, pa_iso, ekc, map) consumed as features, for reference.
Artifact identifier and training-corpus tag.
Yanitski, D., & Westbury, C. (in preparation). How many factors does a questionnaire mean? Validated factor retention for language-model embedding similarity matrices.
Goretzko, D., & Buhner, M. (2020). One model to rule them all? Using machine learning algorithms to determine the number of factors in exploratory factor analysis. Psychological Methods, 25(6), 776–786. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1037/met0000262")}
## Not run:
data(big5)
sim <- sfa_similarity(big5$embeddings, "mean_centered_pearson")
sfa_semk(sim, big5$embeddings) # 5 [2, 13]
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.