| Title: | Inference and Fine-Tuning with 'ConfliBERT' Conflict Text Models |
|---|---|
| Description: | An interface to 'ConfliBERT', a pretrained language model for analyzing text about conflict and political violence (Hu et al. (2022) <doi:10.18653/v1/2022.naacl-main.400>). Provides functions for named entity recognition, binary and multilabel classification, and question answering, plus tools to fine-tune custom classifiers, compare several base model architectures, and run an interactive active-learning loop for efficiently labeling new data. Models are downloaded from 'Hugging Face' and run through the 'transformers' library for 'Python' via the 'reticulate' package. |
| Authors: | Shreyas Meher [aut, cre] (ORCID: <https://orcid.org/0000-0002-9656-4374>) |
| Maintainer: | Shreyas Meher <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.5.3 |
| Built: | 2026-07-11 08:06:07 UTC |
| Source: | https://github.com/shreyasmeher/conflibertr |
ggplot2 version of plot.conflibert_al_session: the
learning curve and the query-uncertainty trend across rounds.
## S3 method for class 'conflibert_al_session' autoplot(object, which = c("all", "metrics", "uncertainty"), ...)## S3 method for class 'conflibert_al_session' autoplot(object, which = c("all", "metrics", "uncertainty"), ...)
object |
A |
which |
|
... |
Ignored. |
A ggplot object.
Aggregated view of a conflibert_classify result: how
many texts landed in each class, annotated with the average
confidence.
## S3 method for class 'conflibert_classify' autoplot(object, ...)## S3 method for class 'conflibert_classify' autoplot(object, ...)
object |
A result from |
... |
Ignored. |
A ggplot object.
Dot chart of every metric for every model in a
conflibert_compare result, models ordered by their
primary metric.
## S3 method for class 'conflibert_comparison' autoplot(object, ...)## S3 method for class 'conflibert_comparison' autoplot(object, ...)
object |
A result from |
... |
Ignored. |
A ggplot object.
Test-set confusion matrix heatmap for a
conflibert_finetune result.
## S3 method for class 'conflibert_finetune' autoplot(object, ...)## S3 method for class 'conflibert_finetune' autoplot(object, ...)
object |
A |
... |
Ignored. |
A ggplot object.
Plots a conflibert_multilabel result. With several
texts it aggregates: the share of texts flagged for each event
category. With a single text it shows that text's category
probabilities against the 0.5 decision threshold.
## S3 method for class 'conflibert_multilabel' autoplot(object, ...)## S3 method for class 'conflibert_multilabel' autoplot(object, ...)
object |
A result from |
... |
Ignored. |
A ggplot object.
Aggregated view of a conflibert_ner result:
type = "types" (default) counts entities per entity type;
type = "entities" shows the most frequent individual
entities, colored by type.
## S3 method for class 'conflibert_ner' autoplot(object, type = c("types", "entities"), top_n = 12, ...)## S3 method for class 'conflibert_ner' autoplot(object, type = c("types", "entities"), top_n = 12, ...)
object |
A result from |
type |
|
top_n |
How many entities to show when
|
... |
Ignored. |
A ggplot object.
Opens a small Shiny gadget that shows each text in
session$query alongside radio buttons for each class. Click
Done to submit; the labels are returned as an integer vector ready
to pass to conflibert_active_next.
conflibert_active_label(session, classes = NULL)conflibert_active_label(session, classes = NULL)
session |
A |
classes |
Optional named integer vector mapping display names
to class values, e.g. |
Requires the shiny and miniUI packages. In RStudio the gadget opens as a modal dialog; elsewhere it opens in your browser.
An integer vector of labels (one per query row), or
NULL if the user cancels.
data <- conflibert_example("active") session <- conflibert_active_start( seed = data$seed, pool = data$pool, query_size = 5, epochs = 1 ) labels <- conflibert_active_label(session) session <- conflibert_active_next(session, labels)data <- conflibert_example("active") session <- conflibert_active_start( seed = data$seed, pool = data$pool, query_size = 5, epochs = 1 ) labels <- conflibert_active_label(session) session <- conflibert_active_next(session, labels)
Takes a session from conflibert_active_start (or a
previous call to this function), incorporates your labels for the
current query, retrains the model on the full labeled set, and
selects the next uncertain batch from the remaining pool.
conflibert_active_next(session, labels)conflibert_active_next(session, labels)
session |
A |
labels |
Integer (or coercible) vector of labels for
|
An updated conflibert_al_session. When the pool is
exhausted, session$done is TRUE and
session$query is empty.
data <- conflibert_example("active") session <- conflibert_active_start( seed = data$seed, pool = data$pool, query_size = 5, epochs = 1 ) # label the queried texts (here using the bundled oracle labels) labels <- unname(data$pool_labels[session$query$text]) session <- conflibert_active_next(session, labels) session$metricsdata <- conflibert_example("active") session <- conflibert_active_start( seed = data$seed, pool = data$pool, query_size = 5, epochs = 1 ) # label the queried texts (here using the bundled oracle labels) labels <- unname(data$pool_labels[session$query$text]) session <- conflibert_active_next(session, labels) session$metrics
Write the current session's model and tokenizer to disk. The result
is a standard HuggingFace checkpoint that can be reloaded with any
transformers tool.
conflibert_active_save(session, dir)conflibert_active_save(session, dir)
session |
A |
dir |
Directory to write the model into. Created if it does not exist. |
The directory path, invisibly.
data <- conflibert_example("active") session <- conflibert_active_start( seed = data$seed, pool = data$pool, query_size = 5, epochs = 1 ) dir <- file.path(tempdir(), "my_al_model") conflibert_active_save(session, dir)data <- conflibert_example("active") session <- conflibert_active_start( seed = data$seed, pool = data$pool, query_size = 5, epochs = 1 ) dir <- file.path(tempdir(), "my_al_model") conflibert_active_save(session, dir)
Train a classifier on a small labeled seed and select the most uncertain samples from an unlabeled pool for you to label. The returned session object tracks the labeled set, the pool, the current query, and metrics across rounds.
conflibert_active_start( seed, pool, dev = NULL, model = "ConfliBERT", task = c("binary", "multiclass"), strategy = c("entropy", "margin", "least_confidence"), diverse = FALSE, diversity_candidates = NULL, query_size = 10, epochs = 3, batch_size = 8, lr = 2e-05, max_seq_len = 512, use_lora = FALSE, lora_rank = 8, lora_alpha = 16, random_seed = 42 )conflibert_active_start( seed, pool, dev = NULL, model = "ConfliBERT", task = c("binary", "multiclass"), strategy = c("entropy", "margin", "least_confidence"), diverse = FALSE, diversity_candidates = NULL, query_size = 10, epochs = 3, batch_size = 8, lr = 2e-05, max_seq_len = 512, use_lora = FALSE, lora_rank = 8, lora_alpha = 16, random_seed = 42 )
seed |
Labeled starter set. A data.frame with |
pool |
Unlabeled pool. Either a character vector of texts, or a
data.frame with a |
dev |
Optional validation set with |
model |
Base model. See |
task |
|
strategy |
Uncertainty strategy: |
diverse |
If |
diversity_candidates |
How many top-scoring candidates to
cluster when |
query_size |
Samples queried per round. Default: 10. |
epochs |
Training epochs per round. Default: 3. |
batch_size |
Training batch size. Default: 8. |
lr |
Learning rate. Default: 2e-5. |
max_seq_len |
Max token sequence length. Default: 512. |
use_lora |
If |
lora_rank |
LoRA rank. Default: 8. |
lora_alpha |
LoRA alpha. Default: 16. |
random_seed |
Random seed for reproducibility (named to avoid a
clash with the labeled |
The typical workflow is:
Call conflibert_active_start() with your seed and pool.
Inspect session$query and assign labels.
Pass the labels to conflibert_active_next to
retrain and query the next batch.
Repeat until the pool is exhausted or metrics plateau.
Persist with conflibert_active_save.
An object of class "conflibert_al_session": a list
with query (tibble of texts to label), metrics
(tibble of metrics across rounds), round, labeled_n,
pool_n, done, and internal state.
data <- conflibert_example("active") session <- conflibert_active_start( seed = data$seed, pool = data$pool, query_size = 5, epochs = 1 ) session session$querydata <- conflibert_example("active") session <- conflibert_active_start( seed = data$seed, pool = data$pool, query_size = 5, epochs = 1 ) session session$query
Returns TRUE when the "conflibert" Python environment
exists and the core Python modules ('torch' and 'transformers') can
be imported. It never installs anything; environment discovery uses
filesystem checks only (it does not run the conda binary), and when
no environment is found it returns FALSE without initializing
Python, so it is cheap and safe to call on any system. It is used to
guard the package's examples on machines without the backend (such
as CRAN's check machines), and you can use it the same way in
scripts that should degrade gracefully.
conflibert_available()conflibert_available()
The detection result is cached for the R session (if you have just
run conflibert_install, restart R as its instructions
say). Set the environment variable CONFLIBERTR_AVAILABLE to
"true" or "false" to override the detection, e.g. to
skip the backend-dependent examples during R CMD check on a
machine that has the backend installed.
TRUE or FALSE.
conflibert_available()conflibert_available()
Evaluate the pretrained ConfliBERT binary classifier against labeled data and compute accuracy, precision, recall, and F1.
conflibert_benchmark(texts, labels)conflibert_benchmark(texts, labels)
texts |
Character vector of texts. |
labels |
Integer vector of true labels (0 or 1). |
A tibble with one row and columns: accuracy, precision, recall, f1, n.
conflibert_benchmark( texts = c("A bomb exploded.", "The weather was nice."), labels = c(1L, 0L) )conflibert_benchmark( texts = c("A bomb exploded.", "The weather was nice."), labels = c(1L, 0L) )
Classify text as conflict-related (Positive) or not (Negative) using the pretrained ConfliBERT binary classifier. Inference is batched, so long vectors are fast; a progress bar appears for large inputs.
conflibert_classify(text)conflibert_classify(text)
text |
A character vector of one or more texts. |
A tibble (with a themed print method) with columns:
The input text.
"Positive" or "Negative".
Integer (1 = positive, 0 = negative).
Probability of the predicted class.
Probability of the negative class.
Probability of the positive class.
conflibert_classify("A bomb exploded in the market.") conflibert_classify(c( "Government troops clashed with rebels.", "The weather was sunny and warm." ))conflibert_classify("A bomb exploded in the market.") conflibert_classify(c( "Government troops clashed with rebels.", "The weather was sunny and warm." ))
Fine-tune several base models on the same dataset and return a comparison table of test-set metrics. Useful for selecting the best architecture for your data.
conflibert_compare( train, dev, test, models = c("ConfliBERT", "BERT Base Uncased"), task = "binary", epochs = 3, batch_size = 8, lr = 2e-05, use_lora = FALSE, lora_rank = 8, lora_alpha = 16, seed = 42 )conflibert_compare( train, dev, test, models = c("ConfliBERT", "BERT Base Uncased"), task = "binary", epochs = 3, batch_size = 8, lr = 2e-05, use_lora = FALSE, lora_rank = 8, lora_alpha = 16, seed = 42 )
train |
A data.frame with |
dev |
A data.frame with |
test |
A data.frame with |
models |
Character vector of model names to compare.
See |
task |
|
epochs |
Number of training epochs. Default: 3. |
batch_size |
Training batch size. Default: 8. |
lr |
Learning rate. Default: 2e-5. |
use_lora |
If |
lora_rank |
LoRA rank. Default: 8. |
lora_alpha |
LoRA alpha. Default: 16. |
seed |
Random seed for reproducibility. Seeds the classifier-head initialization, data shuffling, and dropout so that two runs with the same seed on the same hardware and package versions give identical results. Change it to study run-to-run variability. Default: 42. |
A tibble with one row per model and columns for each metric
plus runtime. It has a themed print() method that
ranks models, and a plot() method comparing metrics.
data <- conflibert_example("binary") comparison <- conflibert_compare( train = data$train, dev = data$dev, test = data$test, models = c("ConfliBERT", "BERT Base Uncased"), task = "binary", epochs = 1 ) comparisondata <- conflibert_example("binary") comparison <- conflibert_compare( train = data$train, dev = data$dev, test = data$test, models = c("ConfliBERT", "BERT Base Uncased"), task = "binary", epochs = 1 ) comparison
Load one of the bundled example datasets for testing fine-tuning
and model comparison. Returns a list with train, dev, and test
data frames ready to pass to conflibert_finetune or
conflibert_compare.
conflibert_example(name = c("binary", "multiclass", "active"))conflibert_example(name = c("binary", "multiclass", "active"))
name |
One of:
|
A named list of data frames (and a character vector for the
active-learning pool). See name for the shape per dataset.
# Loading the bundled data is pure R and needs no Python backend: data <- conflibert_example("binary") data$train # Fine-tune with example data (needs the Python backend) data <- conflibert_example("binary") result <- conflibert_finetune( train = data$train, dev = data$dev, test = data$test, model = "ConfliBERT", task = "binary", epochs = 1 ) # Compare models with example data comparison <- conflibert_compare( train = data$train, dev = data$dev, test = data$test, models = c("ConfliBERT", "BERT Base Uncased"), task = "binary", epochs = 1 )# Loading the bundled data is pure R and needs no Python backend: data <- conflibert_example("binary") data$train # Fine-tune with example data (needs the Python backend) data <- conflibert_example("binary") result <- conflibert_finetune( train = data$train, dev = data$dev, test = data$test, model = "ConfliBERT", task = "binary", epochs = 1 ) # Compare models with example data comparison <- conflibert_compare( train = data$train, dev = data$dev, test = data$test, models = c("ConfliBERT", "BERT Base Uncased"), task = "binary", epochs = 1 )
Train a binary or multiclass text classifier on your own data using any of the supported base models (ConfliBERT, BERT, RoBERTa, ModernBERT, DeBERTa, DistilBERT).
conflibert_finetune( train, dev, test, model = "ConfliBERT", task = "binary", epochs = 3, batch_size = 8, lr = 2e-05, save_dir = NULL, use_lora = FALSE, lora_rank = 8, lora_alpha = 16, seed = 42 )conflibert_finetune( train, dev, test, model = "ConfliBERT", task = "binary", epochs = 3, batch_size = 8, lr = 2e-05, save_dir = NULL, use_lora = FALSE, lora_rank = 8, lora_alpha = 16, seed = 42 )
train |
A data.frame with |
dev |
A data.frame with |
test |
A data.frame with |
model |
Base model name. One of: |
task |
|
epochs |
Number of training epochs. Default: 3. |
batch_size |
Training batch size. Default: 8. |
lr |
Learning rate. Default: 2e-5. |
save_dir |
Optional directory to save the trained model. If provided,
the model and tokenizer are saved there and can be loaded later with
|
use_lora |
If |
lora_rank |
LoRA rank. Default: 8. |
lora_alpha |
LoRA alpha. Default: 16. |
seed |
Random seed for reproducibility. Seeds the classifier-head initialization, data shuffling, and dropout so that two runs with the same seed on the same hardware and package versions give identical results. Change it to study run-to-run variability. Default: 42. |
An object of class "conflibert_finetune" (a list, so all
existing $ access keeps working) with:
Tibble of test-set metrics.
Training time in seconds.
Integer vector of predicted class labels.
Matrix of class probabilities (rows = samples, columns = classes).
Integer vector of true labels.
Path where the model checkpoint was saved.
The base model name and task type.
It has a themed print() method and a plot() method
showing the test-set confusion matrix.
train <- data.frame( text = c("Troops advanced.", "Nice weather today."), label = c(1L, 0L) ) result <- conflibert_finetune(train, dev = train, test = train, epochs = 1) result$metricstrain <- data.frame( text = c("Troops advanced.", "Nice weather today."), label = c(1L, 0L) ) result <- conflibert_finetune(train, dev = train, test = train, epochs = 1) result$metrics
Creates a Python environment and installs the packages needed to run ConfliBERT models (torch, transformers, and friends). Only needs to be run once.
conflibert_install(envname = "conflibert", method = "auto", qa = FALSE)conflibert_install(envname = "conflibert", method = "auto", qa = FALSE)
envname |
Name of the environment. Default: |
method |
|
qa |
If |
As of conflibertR 0.5.0 the backend is PyTorch-only: TensorFlow is no
longer required, which makes installation considerably smaller and
more reliable. If you have issues with the default virtualenv method,
try method = "conda" instead.
Models downloaded from 'Hugging Face' are cached under
$HF_HOME (default ~/.cache/huggingface) and the converted
QA weights under ~/.cache/conflibertR (or $XDG_CACHE_HOME).
Set those environment variables to relocate the caches.
Invisible NULL. Called for its side effect.
## Not run: # Not run automatically anywhere: this installs software (it creates # a Python environment and downloads several GB of dependencies), so # it must only ever be run deliberately by the user. conflibert_install() # Include TensorFlow for the one-time QA weight conversion: conflibert_install(qa = TRUE) ## End(Not run)## Not run: # Not run automatically anywhere: this installs software (it creates # a Python environment and downloads several GB of dependencies), so # it must only ever be run deliberately by the user. conflibert_install() # Include TensorFlow for the one-time QA weight conversion: conflibert_install(qa = TRUE) ## End(Not run)
Load a classifier saved by conflibert_finetune
(when save_dir was specified) or
conflibert_active_save. Returns a reusable classifier
object you can pass to predict.
conflibert_load(dir)conflibert_load(dir)
dir |
Directory containing a HuggingFace checkpoint
( |
An object of class "conflibert_classifier": a list
with model, tokenizer, num_labels, and
dir.
# Fine-tune on the bundled example data, saving the model... data <- conflibert_example("binary") dir <- file.path(tempdir(), "my_model") conflibert_finetune( train = data$train, dev = data$dev, test = data$test, epochs = 1, save_dir = dir ) # ...then reload it later and predict clf <- conflibert_load(dir) predict(clf, c("Troops advanced on the capital.", "Nice weather."))# Fine-tune on the bundled example data, saving the model... data <- conflibert_example("binary") dir <- file.path(tempdir(), "my_model") conflibert_finetune( train = data$train, dev = data$dev, test = data$test, epochs = 1, save_dir = dir ) # ...then reload it later and predict clf <- conflibert_load(dir) predict(clf, c("Troops advanced on the capital.", "Nice weather."))
Returns the names of base models that can be used for fine-tuning and comparison.
conflibert_models()conflibert_models()
A character vector of model names.
conflibert_models()conflibert_models()
Score text against four event categories: Armed Assault, Bombing or Explosion, Kidnapping, and Other. Each category is scored independently. Inference is batched.
conflibert_multilabel(text)conflibert_multilabel(text)
text |
A character vector of one or more texts. |
A tibble (with themed print and plot methods) with columns:
Integer index of the input text
(only when length(text) > 1).
The input text.
Event category name.
Score between 0 and 1.
Logical, TRUE if probability >= 0.5.
conflibert_multilabel("Insurgents kidnapped two aid workers near the border.")conflibert_multilabel("Insurgents kidnapped two aid workers near the border.")
Identify persons, organizations, locations, weapons, and other entity types in text using the pretrained ConfliBERT NER model. Inference is batched, and printing highlights each entity in its source sentence.
conflibert_ner(text)conflibert_ner(text)
text |
A character vector of one or more texts to analyze. |
A tibble (with a themed print method) with columns:
Integer. Which input text this entity came from
(only present when length(text) > 1).
Character. The entity text.
Character. Entity type (Person, Organisation, Location, Weapon, etc.).
Numeric. Mean model confidence for the entity span.
Integer. 1-based inclusive character offsets of
the entity in the input text (use with substr()).
conflibert_ner("The soldiers attacked the village near Kabul.") conflibert_ner(c( "NATO forces were deployed to the region.", "The UN Security Council met in New York." ))conflibert_ner("The soldiers attacked the village near Kabul.") conflibert_ner(c( "NATO forces were deployed to the region.", "The UN Security Council met in New York." ))
Extract an answer from a context passage given a question. Both arguments are vectorized: pass equal-length vectors to answer many questions in one call, or a single context with several questions (scalars are recycled).
conflibert_qa(context, question, details = FALSE)conflibert_qa(context, question, details = FALSE)
context |
Character vector of passages. |
question |
Character vector of questions. |
details |
If |
The published question-answering checkpoint ships only 'TensorFlow'
weights. The first call converts them to 'PyTorch' once and caches the
result under ~/.cache/conflibertR (or $XDG_CACHE_HOME when
set); subsequent calls reuse the cache and never touch 'TensorFlow'
again. Downloaded 'Hugging Face' models are cached under $HF_HOME
(default ~/.cache/huggingface). Both caches are written only on
explicit, network-enabled calls, and can be relocated by setting those
environment variables.
With details = FALSE (default), a character vector of
answers (a single string when one question is asked, exactly as in
previous versions). With details = TRUE, a tibble with
columns question, answer, score, start,
end, and context.
conflibert_qa( context = "The ceasefire was signed in Geneva on March 15th.", question = "Where was the ceasefire signed?" ) # Several questions against one passage, with scores: conflibert_qa( context = "The ceasefire was signed in Geneva on March 15th.", question = c("Where was the ceasefire signed?", "When was the ceasefire signed?"), details = TRUE )conflibert_qa( context = "The ceasefire was signed in Geneva on March 15th.", question = "Where was the ceasefire signed?" ) # Several questions against one passage, with scores: conflibert_qa( context = "The ceasefire was signed in Geneva on March 15th.", question = c("Where was the ceasefire signed?", "When was the ceasefire signed?"), details = TRUE )
Run a quick diagnostic of the Python backend: whether the
"conflibert" environment exists, which Python is active, which
required packages are importable, and what compute device will be
used. Prints a checklist and gives specific advice when something is
missing.
conflibert_status()conflibert_status()
Invisibly, a list with env_found, python,
packages (named logical vector), device, and
ok.
conflibert_status()conflibert_status()
Visualize how the model is improving across rounds. The default view is a two-panel plot: the learning curve on top (metrics vs training set size) and the uncertainty trend on the bottom (mean uncertainty of each round's queries). The uncertainty trend is a useful signal: when it flattens, the model is no longer finding informative samples.
## S3 method for class 'conflibert_al_session' plot(x, which = c("all", "metrics", "uncertainty"), ...)## S3 method for class 'conflibert_al_session' plot(x, which = c("all", "metrics", "uncertainty"), ...)
x |
A |
which |
One of |
... |
Passed to the underlying plot call. |
The session, invisibly.
Base-graphics aggregated view of a conflibert_classify
result: texts per class with average confidence. For a ggplot2
version use ggplot2::autoplot().
## S3 method for class 'conflibert_classify' plot(x, ...)## S3 method for class 'conflibert_classify' plot(x, ...)
x |
A |
... |
Ignored. |
The object, invisibly.
Base-graphics dot chart of metrics per model for a
conflibert_compare result. For a ggplot2 version use
ggplot2::autoplot().
## S3 method for class 'conflibert_comparison' plot(x, ...)## S3 method for class 'conflibert_comparison' plot(x, ...)
x |
A |
... |
Ignored. |
The object, invisibly.
Base-graphics test-set confusion matrix for a
conflibert_finetune result. For a ggplot2 version use
ggplot2::autoplot().
## S3 method for class 'conflibert_finetune' plot(x, ...)## S3 method for class 'conflibert_finetune' plot(x, ...)
x |
A |
... |
Ignored. |
The object, invisibly.
Base-graphics version of the multilabel plot. With several texts it
aggregates (share of texts flagged per category); with a single text
it shows that text's category probabilities. For a ggplot2 version
use ggplot2::autoplot().
## S3 method for class 'conflibert_multilabel' plot(x, ...)## S3 method for class 'conflibert_multilabel' plot(x, ...)
x |
A |
... |
Ignored. |
The object, invisibly.
Base-graphics aggregated view of a conflibert_ner
result: entity counts per type. For a ggplot2 version (including a
top-entities view) use ggplot2::autoplot().
## S3 method for class 'conflibert_ner' plot(x, ...)## S3 method for class 'conflibert_ner' plot(x, ...)
x |
A |
... |
Ignored. |
The object, invisibly.
Run batched inference with a classifier loaded via
conflibert_load. Returns a tibble with predicted class,
confidence, and one prob_* column per class.
## S3 method for class 'conflibert_classifier' predict(object, text, batch_size = 32, max_seq_len = 512, ...)## S3 method for class 'conflibert_classifier' predict(object, text, batch_size = 32, max_seq_len = 512, ...)
object |
A |
text |
Character vector of texts to classify. |
batch_size |
Inference batch size. Default: 32. |
max_seq_len |
Max token sequence length. Default: 512. |
... |
Ignored. |
A tibble with text, class, confidence,
and prob_0..prob_{K-1} columns.
data <- conflibert_example("binary") dir <- file.path(tempdir(), "my_model") conflibert_finetune( train = data$train, dev = data$dev, test = data$test, epochs = 1, save_dir = dir ) clf <- conflibert_load(dir) predict(clf, c("Bomb exploded.", "Stock market rose."))data <- conflibert_example("binary") dir <- file.path(tempdir(), "my_model") conflibert_finetune( train = data$train, dev = data$dev, test = data$test, epochs = 1, save_dir = dir ) clf <- conflibert_load(dir) predict(clf, c("Bomb exploded.", "Stock market rose."))
A modern, flat ggplot2 theme used by all of the package's
autoplot() methods: no tick marks, no panel box, hairline
grid lines only along the data axis, bold left-aligned titles, and
generous whitespace. Use it on your own plots to match.
theme_conflibert( base_size = 12, base_family = "", grid = c("xy", "x", "y", "none") )theme_conflibert( base_size = 12, base_family = "", grid = c("xy", "x", "y", "none") )
base_size |
Base font size. Default: 12. |
base_family |
Base font family. Default: system sans. |
grid |
Which grid lines to keep: |
A ggplot2 theme object.
if (requireNamespace("ggplot2", quietly = TRUE)) { ggplot2::ggplot(mtcars, ggplot2::aes(wt, mpg)) + ggplot2::geom_point(colour = "#0ea5e9", size = 3) + theme_conflibert(grid = "y") }if (requireNamespace("ggplot2", quietly = TRUE)) { ggplot2::ggplot(mtcars, ggplot2::aes(wt, mpg)) + ggplot2::geom_point(colour = "#0ea5e9", size = 3) + theme_conflibert(grid = "y") }