detect_emotions() for emotion analysis with checked
preset models: "ekman" (six basic emotions + neutral),
"goemotions" (28 emotions, several per text) and
"vad" (valence, arousal, dominance on EmoBank’s 1-5 scale).
It returns a tidy data frame, records which model was used, and keeps
loaded models in memory for the session. Any HuggingFace emotion model
also works. emotion_models() lists the presets.set_topic_labels() gives topics custom names, from
a named vector or a filled-in spreadsheet (data frame with
Topic and Label). The names appear in all
accessors and plots.visualize_topics_over_time() gains a fit
argument and then shows topic names in the legend instead of “Topic 0”,
“Topic 1”, … (its documented example already used
fit = fit, which failed before).load_hf_bert() and
load_hf_classifier() (sequence and token classification).
DistilBERT was listed as supported before but failed to load. This opens
up many emotion, sentiment and NER models, e.g.
bhadresh-savani/distilbert-base-uncased-emotion.build_dtm(), and so the c-TF-IDF step of
fit_bertopic() and zero_shot_topics(), took
time quadratic in the number of documents: the sparse-matrix triplets
were grown document by document. It is now built in one pass, with
identical output: 30,000 documents take about 1 s instead of 2 minutes,
and 150,000 no longer take hours.
classify_texts() on NER / token-classification
models returned no tokens: the token strings were read from a field the
tokenizer does not provide. Output now matches Python
transformers.
embed_texts(chunk_strategy = "mean" / "first")
treated padding as real text: short documents were padded to the longest
document in the batch, the padding was attended to, and a pad token was
used as [SEP]. Chunked embeddings change as a result and
now match embedding each document on its own. Re-run any chunked
embeddings made with earlier versions.
hdbscan_clustering() with the default
allow_single_cluster = FALSE returned all documents as one
cluster when the cluster tree never split into groups of at least
min_pts. It now returns all documents as noise, as Python
hdbscan and dbscan::hdbscan() do.
embed_texts() uses far less memory on large corpora. On
3,000 documents (MiniLM, batch 64 x 256 tokens) peak memory fell from
17.6 GB to 4.4 GB, and to 1.9-2.4 GB with max_tokens,
without slowing down. Peak memory now depends on the largest batch, not
on corpus size. Default output is unchanged.
gc_every
(default 1; 0 turns all cleanup off).max_tokens caps padded tokens per batch,
so long texts get smaller batches and short texts can use a large
batch_size.classify_texts() uses the same memory strategy as
embed_texts() (block tokenization, longest-first batching,
memory freed after every batch and layer) and gains the
max_tokens and gc_every arguments. Its
text column now shows the input texts without the model
prefix.\dontrun{} example blocks replaced with
\donttest{} (examples require a model download and cannot
run in < 5 s; \dontrun{} retained only for
rhobots_install() which installs the torch backend).load_specter2() now correctly injects adapter
weights into all transformer layers. The previous code used a nested
replacement chain
(enc$model$encoder$layer[[i]]$adapter <- adp) which R
desugars into a [[<- write-back that can reinitialise
the submodule; weights from earlier layers were silently overwritten by
each successive iteration. Fixed by pre-fetching direct layer references
(lapply(seq_len(n_layers), \(i) ...)). SPECTER2 embeddings
now match the Python reference (cosine similarity > 0.9999).
load_hf_bert() / load_specter2() now
correctly read safetensors files named
pytorch_model.safetensors in addition to
model.safetensors.
weight_loading.R now detects ZIP-archive
.bin files (PyTorch 1.6+ format, magic bytes
PK) and emits a clear error message with conversion
instructions, in addition to the pre-existing guard for legacy pickle
format (0x80).
torch::torch_load() call updated from deprecated
map_location argument to device (renamed in
torch 0.16.3).
Default repositories for load_specter2() updated to
NetworkIsLife/specter2_base and
NetworkIsLife/specter2, which host safetensors versions of
the original allenai/specter2_base and
allenai/specter2 (the AllenAI repos only provide
.bin files that R torch cannot read directly).
hdbscan_clustering() gains
allow_single_cluster (default FALSE, matching
Python hdbscan’s default). When FALSE, EOM
never returns a single root cluster when sub-structure is present in the
condensed tree. This fixes cases where diffuse embedding spaces
(continuous sentiment data, overlapping topics) collapsed to 1 cluster.
On the validation suite, datasets that previously returned 1 cluster
(Emotion, Yelp Reviews, IMDB, Rotten Tomatoes) now match Python’s
cluster counts within ±1.
topic_quality() gains a space argument
("original" / "reduced"). When
"reduced", cohesion, separation, and silhouette are
measured in the UMAP-reduced space rather than the full encoder
embedding. This makes quality metrics much more sensitive to different
UMAP/HDBSCAN parameter choices and is the recommended setting when using
sweep_topics().
sweep_topics() gains a corresponding
quality_space argument that is forwarded to
topic_quality() (default "reduced").
hdbscan_clustering() gains a knn argument
that selects the tree data structure used during Borůvka MST
construction:
"balltree" (default) — dual-tree Borůvka with a
Ball-tree index (bounding hyperspheres; effective pruning in ≥3-D)."kdtree" — dual-tree Borůvka with a KD-tree index
(axis-aligned bounding boxes; faster to build, pruning degrades above
three dimensions)."adaptive" — pre-computed kNN graph via
dbscan::kNN(), growing k until the MST is
fully connected (guaranteed connectivity, no cap)."fixed" — same as "adaptive" but caps
k at 200 (faster)."balltree" default replaces the previous fixed-kNN
approach and matches the algorithm used by the Python
hdbscan package’s boruvka_balltree mode.
Validation on two scientific-abstract corpora (n = 3,328 and n = 9,035)
confirms Adjusted Rand Index > 0.97 and Normalised Mutual Information
> 0.98 against the Python reference.gutenbergr and plotly in
rhobots_demo().useDynLib being overwritten by roxygen2
regeneration.rhobots_demo() — Gutenberg pipeline
walkthrough.