| Title: | Automatic Item Generation and Validation via Network-Integrated Evaluation |
|---|---|
| Description: | Automated psychological scale development and structural validation using large language models (LLMs) and network psychometric methods. Implements the AI-GENIE framework (Automatic Item Generation and Validation via Network-Integrated Evaluation) to generate candidate items, compute embedding representations, and estimate dimensional structure using Exploratory Graph Analysis (EGA). Item quality is evaluated using Unique Variable Analysis to identify redundant items and Bootstrap EGA to assess item and dimension stability. Supports both fully automated item generation and analysis of user-provided item sets, facilitating efficient, theory-informed measurement development prior to empirical data collection. |
| Authors: | Lara Russell-Lasalandra [aut, cph] (ORCID: <https://orcid.org/0009-0000-3014-1937>), Alexander Christensen [aut, cph] (ORCID: <https://orcid.org/0000-0002-9798-7037>), Hudson Golino [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-1601-1447>) |
| Maintainer: | Hudson Golino <[email protected]> |
| License: | AGPL (>= 3) |
| Version: | 2.1.2 |
| Built: | 2026-11-06 10:08:58 UTC |
| Source: | https://github.com/laralee/AIGENIE |
Generate, validate, and check your items for quality and redundancy using AI-GENIE (Generative Psychometrics via AI-GENIE: Automatic Item Generation and Validation via Network-Integrated Evaluation). AI-GENIE is a methodology that combines the latest open-source LLMs and generative artificial intelligence with advances in network psychometrics to facilitate scale generation, selection, and validation. The pipeline eliminates the need to generate hundreds of items by content experts, recruit diverse and experienced researchers, administer items to thousands of participants, and employ modern psychometric methods in the collected data.
AIGENIE( item.attributes, openai.API = NULL, hf.token = NULL, main.prompts = NULL, groq.API = NULL, anthropic.API = NULL, jina.API = NULL, model = "gpt4o", temperature = NULL, top.p = NULL, embedding.model = "text-embedding-3-small", target.N = NULL, domain = NULL, scale.title = NULL, item.examples = NULL, audience = NULL, item.type.definitions = NULL, item.attribute.definitions = NULL, response.options = NULL, prompt.notes = NULL, system.role = NULL, EGA.model = NULL, EGA.algorithm = NULL, EGA.uni.method = NULL, uva.cut.off = 0.2, boot.iter = 500, ncores = NULL, keep.org = FALSE, items.only = FALSE, embeddings.only = FALSE, adaptive = TRUE, run.overall = FALSE, all.together = FALSE, plot = TRUE, silently = FALSE )AIGENIE( item.attributes, openai.API = NULL, hf.token = NULL, main.prompts = NULL, groq.API = NULL, anthropic.API = NULL, jina.API = NULL, model = "gpt4o", temperature = NULL, top.p = NULL, embedding.model = "text-embedding-3-small", target.N = NULL, domain = NULL, scale.title = NULL, item.examples = NULL, audience = NULL, item.type.definitions = NULL, item.attribute.definitions = NULL, response.options = NULL, prompt.notes = NULL, system.role = NULL, EGA.model = NULL, EGA.algorithm = NULL, EGA.uni.method = NULL, uva.cut.off = 0.2, boot.iter = 500, ncores = NULL, keep.org = FALSE, items.only = FALSE, embeddings.only = FALSE, adaptive = TRUE, run.overall = FALSE, all.together = FALSE, plot = TRUE, silently = FALSE )
item.attributes |
A named list of atomic character vectors (required). Describes the attributes or characteristics that each item type should encompass. These are not necessarily lower-order dimensions, but can be if the item types represent appropriate hierarchical constructs. Each nested list must have at least two unique attributes. Repeated attributes within the same nested list are not allowed, but attributes can be repeated across nested lists. Each name of the list must be unique, and all elements within sublists must be strings. For example, attributes of the personality trait "neuroticism" might include "anxious", "depressed", "insecure", or "emotional" since these characteristics encompass aspects of neuroticism that the item pool should address. |
openai.API |
A character string or NULL (optional, default: NULL). The OpenAI API
key for authentication with OpenAI's services. Required when using OpenAI's platform
for either item generation or embedding. If NULL, item generation must use another
provider ( |
hf.token |
A character string or NULL (optional, default: NULL). The Hugging Face
API token for authentication with Hugging Face services. Used when embedding with
Hugging Face models; recommended for better rate limits and required for gated models
(e.g., |
main.prompts |
A named list of character strings or NULL (optional, default: NULL).
Custom prompts for item generation. If provided, this must be a named list where
|
groq.API |
A character string or NULL (optional, default: NULL). The Groq API
key for authentication with Groq's LLM services. Required when users want to generate
items via Groq's API platform using open-source models. Commonly used in combination
with |
anthropic.API |
A character string or NULL (optional, default: NULL). The Anthropic API key for authentication with Anthropic's Claude models. Required when using Claude models (e.g., "sonnet", "opus", "haiku") for item generation. Get a key at https://platform.claude.com/docs/en/manage-claude/authentication. |
jina.API |
A character string or NULL (optional, default: NULL). The Jina AI API key for authentication with Jina's embedding services. Required when using Jina embedding models (e.g., "jina-embeddings-v3", "jina-embeddings-v4"). Free tier available at https://jina.ai/. |
model |
A character string (optional, default: "gpt4o"). Specifies which large language model to use for item generation. Supports models from multiple providers:
Aliases such as |
temperature |
A numeric value or NULL (optional, default: NULL). Controls the
randomness and creativity of the LLM's item generation. Must be between 0-2, where
lower values produce more deterministic outputs and higher values increase creativity
and variability. When NULL, no |
top.p |
A numeric value or NULL (optional, default: NULL). Controls nucleus
sampling for the LLM's text generation. Must be between 0-1, where lower values make
the model more focused and higher values allow more diverse outputs. When NULL, no
|
embedding.model |
A character string (optional, default: "text-embedding-3-small"). Specifies which model to use for generating embeddings of items. Supports multiple providers:
The provider is automatically detected based on the model name. Jina models support task adapters and Matryoshka dimension truncation for optimized embeddings. |
target.N |
An integer, named list of integers, or NULL (optional, default: NULL).
Specifies the number of items to generate for each item type. Can be a single integer
(applies to all item types) or a named list of integers where |
domain |
A character string or NULL (optional, default: NULL). Specifies the
psychological or research domain for context in item generation. Should be specific
(e.g., "personality", "child development") rather than general. If supplied, it will
be used to construct appropriate prompts and system roles unless |
scale.title |
A character string or NULL (optional, default: NULL). Specifies
the name or title of the scale being developed. Can be formal or descriptive, but
more specific titles generally produce better results. If supplied, it will be used
to construct appropriate prompts and system roles unless |
item.examples |
A data frame or NULL (optional, default: NULL). Provides example
items to guide the LLM's generation style and format. Must be a data frame with
columns: |
audience |
A character string or NULL (optional, default: NULL). Specifies the
target population for the scale being developed. Should be as specific as possible
(e.g., "educated adults in rural America", "children with ASD in second grade")
rather than general demographic categories. If supplied, it will be used to construct
appropriate prompts and system roles unless |
item.type.definitions |
A named list of character strings or NULL (optional,
default: NULL). Provides definitions or descriptions of each item type for the LLM.
Must be a named list where |
item.attribute.definitions |
A named list of character strings or NULL (optional,
default: NULL). Provides definitions or descriptions of individual attributes for the
LLM. Each name must match an attribute listed within the |
response.options |
A character vector or NULL (optional, default: NULL). Specifies
the response scale labels for the generated items (e.g., c("agree", "neither agree
nor disagree", "disagree")). These labels provide context for item writing but do
not appear in the actual items themselves. If supplied, it will be used to construct
appropriate system roles unless |
prompt.notes |
A named list of character strings, character string, or NULL
(optional, default: NULL). Allows users to add custom instructions or context to
the prompts. Can be a named list where |
system.role |
A character string or NULL (optional, default: NULL). Defines the system role/persona for the LLM during item generation. If not provided, one is built automatically based on prompt-building parameters. Should be as specific as possible (e.g., "You are an expert scale developer and psychometrician with extensive expertise in drafting Likert-type items for children with ASD. Today, you will focus on developing robust, single-statement items that assess linguistic ability."). Applies to all LLM interactions. |
EGA.model |
A character string or NULL (optional, default: NULL). Specifies which model to use for Exploratory Graph Analysis network construction. Valid options are "tmfg" or "glasso". If NULL, AIGENIE will test both "tmfg" and "glasso" models and automatically return the model that maximizes NMI (normalized mutual information). TMFG is a greedy but speedy network-building algorithm that works well for many applications, especially text. EBICglasso is slower but non-greedy and may capture more nuanced relationships. |
EGA.algorithm |
A character string or NULL (optional, default: NULL, which uses
"walktrap"). Specifies
which community detection algorithm to use within the EGA framework. Valid options
are "louvain", "walktrap", or "leiden". The algorithm operates separately from the
network building specified by |
EGA.uni.method |
A character string (optional, default: "louvain"). Specifies
the method for handling unidimensional structures in EGA. Valid options are: "expand"
(expands correlation matrix with four variables correlated 0.50; if dimensions |
uva.cut.off |
A numeric value in |
boot.iter |
A positive integer (optional, default: 500). Number of
bootstrap iterations used by |
ncores |
A positive integer or |
keep.org |
A logical value (optional, default: FALSE). Controls whether the pre-reduced items generated by the model are returned to the user. If TRUE, returns the full item pool before psychometric reduction. Does not affect the reduction process. |
items.only |
A logical value (optional, default: FALSE). Controls whether the
function only generates items without running the full psychometric pipeline. If TRUE,
skips embedding, EGA, and reduction steps, returning only a data frame with columns
|
embeddings.only |
A logical value (optional, default: FALSE). Controls whether
the function generates items and embeddings but skips psychometric reduction. If TRUE,
returns a named list with |
adaptive |
A logical value (optional, default: TRUE). Controls whether previously generated items are incorporated into subsequent prompts to reduce redundancy. Items are generated in batches to avoid context window limitations, potentially requiring multiple API calls. When TRUE, appends previously generated items so the model knows what has been generated to avoid repetition. Should always be enabled unless context limitations are a concern. |
run.overall |
A logical value (optional, default: FALSE). Controls whether a fit analysis
on the complete item pool is run post-reduction.
By default, only type-level reduction analyses are run (i.e., items of like-type go through
the pipeline independent of the other items in the pool). When this flag is |
all.together |
A logical value (optional, default: FALSE). Controls whether the reduction analysis
on the complete item pool is run.
By default, only type-level reduction analyses are run (i.e., items of like-type go through
the pipeline independent of the other items in the pool). When this flag is |
plot |
A logical value (optional, default: TRUE). Controls whether visualizations
are generated and displayed. When TRUE, generates EGA network comparison plots (before
vs after reduction) for each item type and, when |
silently |
A logical value (optional, default: FALSE). Controls console output
and messaging during function execution. When TRUE, suppresses progress statements
about item generation, embedding, and pipeline reduction. Does not affect warnings
or errors, only informational messages. Operates independently of the |
The structure of the return value depends on the function flags.
When items.only = TRUE:
Returns a data.frame of generated items with columns
type, attribute, statement, and ID.
When embeddings.only = TRUE:
Returns a named list with two elements:
embeddings — a numeric embedding matrix (rows are embedding dimensions; columns are items, named by item ID).
items — the items data.frame described above.
Default behaviour (items.only = FALSE, embeddings.only = FALSE,
run.overall = FALSE, keep.org = FALSE, all.together = FALSE):
Returns a named list with two top-level elements:
item_type_levelA named list where each name is an item type and each element is a per-type named list containing:
final_NMINumeric: normalized mutual information (NMI) of the final EGA solution after reduction.
initial_NMINumeric: NMI of the pre-reduction item pool, estimated on the full (dense) embeddings with the selected EGA model.
embeddingsList containing selected ("full" or "sparse", the embedding representation chosen for reduction), selection_log (a data.frame of the NMI for each candidate EGA model and representation), and full and sparse (embedding matrices for the final items).
UVAList from Unique Variable Analysis containing n_removed, n_sweeps, redundant_pairs (a data.frame of redundant item groups), and removal_log (a data.frame with one row per removed item, its retained redundant partner, and the wTO statistic).
bootEGAList containing post_uva_initial_boot and post_uva_final_boot (bootEGA objects before and after stability filtering), n_removed, items_removed (a data.frame of removed items with their item stability), and initial_boot_with_redundancies (a bootEGA object for the pre-reduction pool, used in stability_plot).
EGA.model_selectedCharacter: the chosen EGA model ("glasso" or "TMFG").
final_itemsdata.frame: final items after reduction (columns ID, type, attribute, statement, and EGA_com, the final EGA community).
final_EGAEGA.fit object (from EGAnet) for the final items.
initial_EGAEGA.fit object for the pre-reduction item pool.
start_NInteger: initial number of items in this type.
final_NInteger: final number of items in this type.
network_plotpatchwork object comparing networks before vs after reduction.
stability_plotpatchwork object showing networks and item stability before vs after reduction.
filtering_auditdata.frame with one row per removed item, giving the removal stage ("UVA", "EGA_selection", "bootEGA", or "final_EGA"), the reason, the filtering statistic and cutoff, redundancy partner(s), item stability, and pre-reduction network-loading diagnostics. Network loadings are descriptive only; they are not used as removal criteria.
reduction_summarydata.frame giving the number of items (N), NMI, n_removed_at_stage, and delta_NMI (change from initial_NMI) at each stage of the reduction.
filtering_auditdata.frame combining the per-type filtering_audit tables across all item types.
When keep.org = TRUE (in addition to the defaults above):
each per-type sublist also contains initial_items (the pre-reduction items, with
their EGA_com from the initial EGA), and its embeddings list also contains
full_org and sparse_org (the full and sparse embedding matrices for the
pre-reduction item pool).
When run.overall = TRUE (and more than one item type is present):
the list additionally contains overall, a pooled post-reduction fit of all items
retained by the type-level reductions. No further items are removed at this level.
overall contains final_NMI, initial_NMI, embeddings (selected, full, and
sparse), EGA.model_selected, final_items, final_EGA, initial_EGA, start_N,
final_N, network_plot, stability_plot (always NULL), filtering_audit, and
reduction_summary. Pooled NMI values compare EGA communities against
type-by-attribute labels. With keep.org = TRUE, overall also contains
initial_items, and overall$embeddings also contains full_org and sparse_org. The
top-level filtering_audit then reports pooled (rather than within-type)
pre-reduction network-loading diagnostics.
When all.together = TRUE (and more than one item type is present):
results are not split by item type. The function returns a single per-type
named list (as described under item_type_level above) for the pooled analysis, in
which EGA communities are compared against type-by-attribute labels. Here,
final_items (and initial_items, when keep.org = TRUE) contain the original item
rows (with their original type and attribute labels) plus the EGA_com column.
On failure: if item generation or embedding fails, the items generated so far are returned. If the reduction pipeline fails, the partial per-type results list is returned.
Golino, H. F., & Epskamp, S. (2017). Exploratory graph analysis: A new approach for estimating the number of dimensions in psychological research. PLOS ONE, 12(6), e0174035. doi:10.1371/journal.pone.0174035
Christensen, A. P., Garrido, L. E., & Golino, H. (2023). Unique variable analysis: A network psychometrics method to detect local dependence. Multivariate Behavioral Research, 58(6), 1165–1182. doi:10.1080/00273171.2023.2194606
Christensen, A. P., & Golino, H. (2021). Estimating the stability of psychological dimensions via bootstrap exploratory graph analysis: A Monte Carlo simulation and tutorial. Psych, 3(3), 479–500. doi:10.3390/psych3030032
Danon, L., Díaz-Guilera, A., Duch, J., & Arenas, A. (2005). Comparing community structure identification. Journal of Statistical Mechanics: Theory and Experiment, 2005(9), P09008. doi:10.1088/1742-5468/2005/09/P09008
Russell-Lasalandra, L. L., Christensen, A. P., & Golino, H. F. (2026). Generative psychometrics via AI-GENIE: Automatic item generation and validation with network-integrated evaluation. Behavior Research Methods, 58(8), 217. doi:10.3758/s13428-026-03082-1
## Not run: ######################################################## #### Example 1: Using AI-GENIE with Default Prompts #### ######################################################## # Add an OpenAI API key key <- "INSERT YOUR KEY HERE" # Item type definitions trait.definitions <- list( neuroticism = paste0( "Neuroticism is a personality trait that describes one's ", "tendency to experience negative emotions like anxiety, ", "depression, irritability, anger, and self-consciousness." ), openness = paste0( "Openness is a personality trait that describes how ", "open-minded, creative, and imaginative a person is." ), extraversion = paste0( "Extraversion is a personality trait that describes people ", "who are more focused on the external world than their ", "internal experience." ) ) # Item attributes aspects.of.personality.traits <- list( neuroticism = c("anxious", "depressed", "insecure", "emotional"), openness = c("creative", "perceptual", "curious", "philosophical"), extraversion = c("friendly", "positive", "assertive", "energetic") ) # Name the field or specialty domain <- "Personality Measurement" # Name the Inventory being created scale.title <- "Three of 'Big Five:' A Streamlined Personality Inventory" # Run AI-GENIE to generate, validate, and redundancy-check an item pool for your new scale. personality.inventory.results <- AIGENIE( item.attributes = aspects.of.personality.traits, openai.API = key, domain = domain, scale.title = scale.title, item.type.definitions = trait.definitions ) # View the final item pool View(personality.inventory.results) ####################################################### #### Example 2: Using AI-GENIE with Custom Prompts #### ####################################################### # Define a custom system role system.role <- paste0( "You are an expert methodologist who specializes in scale ", "development for personality measurement. You are especially ", "equipped to create novel personality items that mimic the ", "style of popular 'Big Five' assessments." ) # Define custom prompts for each personality trait custom.personality.prompts <- list( # Prompt for generating neuroticism traits neuroticism = paste0( "Generate unique, psychometrically robust single-statement items designed to assess ", "the Big Five personality trait neuroticism.", paste0( "Neuroticism has the following characteristics: anxious, ", "depressed, insecure, and emotional. " ) ), # Prompt for generating openness traits openness = paste0( "Generate unique, psychometrically robust single-statement items designed to assess ", "the Big Five personality trait openness.", paste0( "Openness has the following characteristics: creative, ", "perceptual, curious, and philosophical" ) ), # Prompt for generating extraversion traits extraversion = paste0( "Generate unique, psychometrically robust single-statement items designed to assess ", "the Big Five personality trait extraversion.", paste0( "Extraversion has the following characteristics: friendly, ", "positive, assertive, and energetic." ) ) ) # Run AI-GENIE to generate, validate, and redundancy-check an item pool for your new scale. personality.inventory.results.custom <- AIGENIE( item.attributes = aspects.of.personality.traits, # created in example 1 main.prompts = custom.personality.prompts, system.role = system.role, openai.API = key, # created in example 1 scale.title = scale.title # created in example 1 ) # View the final item pool View(personality.inventory.results.custom) ################################################################ ###### Or, Run AIGENIE with an Open Source Model via Groq ###### ################################################################ # Add your API Key from Groq groq.key <- "INSERT YOUR KEY HERE" # Chose an open-source model like 'DeepSeek' or 'GPT oss' open.source.model <- "GPT oss 120b" # Use AIGENIE with an open source model via Groq personality.inventory.results.gptoss <- AIGENIE( item.attributes = aspects.of.personality.traits, # created in example 1 openai.API = key, # Created in example 1 domain = domain, # Created in example 1 scale.title = scale.title, # Created in example 1 model = open.source.model, # Select a model available on Groq's API groq.API = groq.key ) # View the final item pool View(personality.inventory.results.gptoss) ################################################################ ###### Or, Run AIGENIE with a Hugging Face Embedding Model ##### ################################################################ # Chose a BAAI/bge series OR thenlper/gte series model hf.embedding.model <- "BAAI/bge-large-en-v1.5" # Create a HF Token to access the best models. Moderate useage will still be FREE hf.token <- "INSERT YOUR KEY HERE" # Use AIGENIE with an open source model via Groq personality.inventory.results.hf <- AIGENIE( item.attributes = aspects.of.personality.traits, # created in example 1 # OpenAI API key is not needed for this example # domain = domain, # Created in example 1 scale.title = scale.title, # Created in example 1 model = open.source.model, # Select a model available on Groq's API groq.API = groq.key, embedding.model = hf.embedding.model, hf.token = hf.token ) # View the final item pool View(personality.inventory.results.hf) ################################################################ #### Example 4: Using Anthropic Claude for Item Generation #### ################################################################ # Add your Anthropic API key anthropic.key <- "INSERT YOUR KEY HERE" # Use Claude Sonnet (or "opus", "haiku", or full model names) personality.inventory.claude <- AIGENIE( item.attributes = aspects.of.personality.traits, anthropic.API = anthropic.key, openai.API = key, # Still needed for embeddings model = "sonnet", # Alias for claude-sonnet-4-5-20250929 domain = domain, scale.title = scale.title, item.type.definitions = trait.definitions ) # View the final item pool View(personality.inventory.claude) ################################################################ #### Example 5: Using Jina AI Embeddings #### ################################################################ # Add your Jina API key (free tier available) jina.key <- "INSERT YOUR KEY HERE" # Use Jina embeddings with Groq for generation personality.inventory.jina <- AIGENIE( item.attributes = aspects.of.personality.traits, groq.API = groq.key, jina.API = jina.key, model = "llama-3.3-70b-versatile", embedding.model = "jina-embeddings-v3", domain = domain, scale.title = scale.title, item.type.definitions = trait.definitions ) # View the final item pool View(personality.inventory.jina) ################################################################ #### Example 6: Anthropic + Jina (No OpenAI Required) #### ################################################################ # Full pipeline without OpenAI personality.inventory.no.openai <- AIGENIE( item.attributes = aspects.of.personality.traits, anthropic.API = anthropic.key, jina.API = jina.key, model = "sonnet", embedding.model = "jina-embeddings-v3", domain = domain, scale.title = scale.title, item.type.definitions = trait.definitions ) # View the final item pool View(personality.inventory.no.openai) ## End(Not run)## Not run: ######################################################## #### Example 1: Using AI-GENIE with Default Prompts #### ######################################################## # Add an OpenAI API key key <- "INSERT YOUR KEY HERE" # Item type definitions trait.definitions <- list( neuroticism = paste0( "Neuroticism is a personality trait that describes one's ", "tendency to experience negative emotions like anxiety, ", "depression, irritability, anger, and self-consciousness." ), openness = paste0( "Openness is a personality trait that describes how ", "open-minded, creative, and imaginative a person is." ), extraversion = paste0( "Extraversion is a personality trait that describes people ", "who are more focused on the external world than their ", "internal experience." ) ) # Item attributes aspects.of.personality.traits <- list( neuroticism = c("anxious", "depressed", "insecure", "emotional"), openness = c("creative", "perceptual", "curious", "philosophical"), extraversion = c("friendly", "positive", "assertive", "energetic") ) # Name the field or specialty domain <- "Personality Measurement" # Name the Inventory being created scale.title <- "Three of 'Big Five:' A Streamlined Personality Inventory" # Run AI-GENIE to generate, validate, and redundancy-check an item pool for your new scale. personality.inventory.results <- AIGENIE( item.attributes = aspects.of.personality.traits, openai.API = key, domain = domain, scale.title = scale.title, item.type.definitions = trait.definitions ) # View the final item pool View(personality.inventory.results) ####################################################### #### Example 2: Using AI-GENIE with Custom Prompts #### ####################################################### # Define a custom system role system.role <- paste0( "You are an expert methodologist who specializes in scale ", "development for personality measurement. You are especially ", "equipped to create novel personality items that mimic the ", "style of popular 'Big Five' assessments." ) # Define custom prompts for each personality trait custom.personality.prompts <- list( # Prompt for generating neuroticism traits neuroticism = paste0( "Generate unique, psychometrically robust single-statement items designed to assess ", "the Big Five personality trait neuroticism.", paste0( "Neuroticism has the following characteristics: anxious, ", "depressed, insecure, and emotional. " ) ), # Prompt for generating openness traits openness = paste0( "Generate unique, psychometrically robust single-statement items designed to assess ", "the Big Five personality trait openness.", paste0( "Openness has the following characteristics: creative, ", "perceptual, curious, and philosophical" ) ), # Prompt for generating extraversion traits extraversion = paste0( "Generate unique, psychometrically robust single-statement items designed to assess ", "the Big Five personality trait extraversion.", paste0( "Extraversion has the following characteristics: friendly, ", "positive, assertive, and energetic." ) ) ) # Run AI-GENIE to generate, validate, and redundancy-check an item pool for your new scale. personality.inventory.results.custom <- AIGENIE( item.attributes = aspects.of.personality.traits, # created in example 1 main.prompts = custom.personality.prompts, system.role = system.role, openai.API = key, # created in example 1 scale.title = scale.title # created in example 1 ) # View the final item pool View(personality.inventory.results.custom) ################################################################ ###### Or, Run AIGENIE with an Open Source Model via Groq ###### ################################################################ # Add your API Key from Groq groq.key <- "INSERT YOUR KEY HERE" # Chose an open-source model like 'DeepSeek' or 'GPT oss' open.source.model <- "GPT oss 120b" # Use AIGENIE with an open source model via Groq personality.inventory.results.gptoss <- AIGENIE( item.attributes = aspects.of.personality.traits, # created in example 1 openai.API = key, # Created in example 1 domain = domain, # Created in example 1 scale.title = scale.title, # Created in example 1 model = open.source.model, # Select a model available on Groq's API groq.API = groq.key ) # View the final item pool View(personality.inventory.results.gptoss) ################################################################ ###### Or, Run AIGENIE with a Hugging Face Embedding Model ##### ################################################################ # Chose a BAAI/bge series OR thenlper/gte series model hf.embedding.model <- "BAAI/bge-large-en-v1.5" # Create a HF Token to access the best models. Moderate useage will still be FREE hf.token <- "INSERT YOUR KEY HERE" # Use AIGENIE with an open source model via Groq personality.inventory.results.hf <- AIGENIE( item.attributes = aspects.of.personality.traits, # created in example 1 # OpenAI API key is not needed for this example # domain = domain, # Created in example 1 scale.title = scale.title, # Created in example 1 model = open.source.model, # Select a model available on Groq's API groq.API = groq.key, embedding.model = hf.embedding.model, hf.token = hf.token ) # View the final item pool View(personality.inventory.results.hf) ################################################################ #### Example 4: Using Anthropic Claude for Item Generation #### ################################################################ # Add your Anthropic API key anthropic.key <- "INSERT YOUR KEY HERE" # Use Claude Sonnet (or "opus", "haiku", or full model names) personality.inventory.claude <- AIGENIE( item.attributes = aspects.of.personality.traits, anthropic.API = anthropic.key, openai.API = key, # Still needed for embeddings model = "sonnet", # Alias for claude-sonnet-4-5-20250929 domain = domain, scale.title = scale.title, item.type.definitions = trait.definitions ) # View the final item pool View(personality.inventory.claude) ################################################################ #### Example 5: Using Jina AI Embeddings #### ################################################################ # Add your Jina API key (free tier available) jina.key <- "INSERT YOUR KEY HERE" # Use Jina embeddings with Groq for generation personality.inventory.jina <- AIGENIE( item.attributes = aspects.of.personality.traits, groq.API = groq.key, jina.API = jina.key, model = "llama-3.3-70b-versatile", embedding.model = "jina-embeddings-v3", domain = domain, scale.title = scale.title, item.type.definitions = trait.definitions ) # View the final item pool View(personality.inventory.jina) ################################################################ #### Example 6: Anthropic + Jina (No OpenAI Required) #### ################################################################ # Full pipeline without OpenAI personality.inventory.no.openai <- AIGENIE( item.attributes = aspects.of.personality.traits, anthropic.API = anthropic.key, jina.API = jina.key, model = "sonnet", embedding.model = "jina-embeddings-v3", domain = domain, scale.title = scale.title, item.type.definitions = trait.definitions ) # View the final item pool View(personality.inventory.no.openai) ## End(Not run)
Send one or more prompts to a remote large-language model (LLM) using the
appropriate provider API (OpenAI, Groq, or Anthropic). A valid
API key for at least one provider is required. To use a local model
(no API call), see local_chat().
chat( prompts, model, system.role = NULL, openai.API = NULL, hf.token = NULL, groq.API = NULL, anthropic.API = NULL, reps = 1, top.p = NULL, temperature = NULL, max.tokens = 2048L, silently = FALSE )chat( prompts, model, system.role = NULL, openai.API = NULL, hf.token = NULL, groq.API = NULL, anthropic.API = NULL, reps = 1, top.p = NULL, temperature = NULL, max.tokens = 2048L, silently = FALSE )
prompts |
A character string or character vector. The main prompt(s) given to the model. If multiple prompts are supplied, each will be sent separately to the model. |
model |
A character string specifying the LLM model name (e.g.,
|
system.role |
A character string or character vector, default |
openai.API |
A character string, default |
hf.token |
A character string, default |
groq.API |
A character string, default |
anthropic.API |
A character string, default |
reps |
Integer, default |
top.p |
Numeric or |
temperature |
Numeric or |
max.tokens |
Integer, default |
silently |
Logical, default |
The function includes a retry mechanism (up to 5 attempts) for transient API
failures. If all attempts fail, the function stops with an informative error.
Errors that mention temperature or top_p are not retried, since the model
is likely rejecting those parameters.
A data.frame with one row per API call (i.e., per prompt × repetition)
containing:
rep — repetition index
prompt — the prompt text sent to the model
response — the raw text response returned by the model
This function requires a valid API key corresponding to the selected model.
Network access is required. For local (non-API) models, use local_chat().
## Not run: ################################################# ### Example 1: Writing a Very Basic Prompt ##### ################################################# # First, define your API key key <- "INSERT YOUR KEY HERE" # Then, define your LLM model. This model should correspond to your API key. model <- "gpt4o" # in this example, you would need an OpenAI API key. # Then, write your prompt. This will be given to the model directly. prompt <- "Why does the planet Saturn have rings? Give a 100 word explanation." # Optionally, add a system role (a model persona) system.role <- "You specialize in tutoring astronomy for high school students." # Add the number of prompt repetitions. By default, this is set to 1. But it # may be useful to increase the number of repetitions to get a sense of how # consistent your output might be. reps <- 3 # Now you are ready to chat with an LLM first_chat <- chat( # Set your own API key. If you are not using OpenAI, change the 1st # argument to match your API key. Choices are `groq.API`, # `anthropic.API`, and `openai.API`. In this example, I'm using # `openai.API` since I want to chat with a GPT model. openai.API = key, model = model, # Ensure your model corresponds to your API key. prompts = prompt, system.role = system.role, reps = reps ) # Check how the output changes from iteration to iteration first_chat$response[[1]] # first iteration output first_chat$response[[2]] # second iteration output first_chat$response[[3]] # third iteration output #################################################################### ### Example 2: Send multiple prompts in a single function call ##### #################################################################### # You are also able to send more than one prompt in a single call # Let's pull the first prompt from Example 1: prompt1 <- "Why does the planet Saturn have rings? Give a 100 word explanation." prompt2 <- "Which planet is the hottest in our solar system? How do we know?" # Aggregate the prompts in a single object prompts <- c(prompt1, prompt2) # Ask the model the questions second_chat <- chat( openai.API = key, # defined in Example 1 model = model, # defined in Example 1 prompts = prompts, # NEW system.role = system.role, # defined in Example 1 reps = reps # defined in Example 1 ) # The outputted data frame for this example will have 6 rows # since the number of prompts (2) times the number of reps (3) # gives a total of 6 API calls. second_chat$response[second_chat$prompt==prompt1] # the responses from prompt 1 second_chat$response[second_chat$prompt==prompt2] # the responses from prompt 2 #################################################################### ### Example 3: Send multiple prompts with different System Roles ### #################################################################### # Perhaps your prompts are not related. In that case, you would probably want # to set a different system role for each prompt. # Let's change `prompt 2` to be entirely unrelated to astronomy. prompt2 <- "What is the difference between eukaryotes and prokaryotes? Why?" # This new second prompt does not fit with the astronomy tutor persona. Let's # write a persona to match this new prompt topic. system.role2 <- "You specialize in tutoring biology for middle school students." # Now, let's combine the system roles into a single object system.role <- c(system.role, # defined in Example 1: the astronomy tutor system.role2 # defined above: the biology tutor ) # Aggregate our prompts in a single object again prompts <- c(prompt1, # Asks about Saturn's rings (needs astronomy tutor) prompt2 # Asks about types of cells (needs biology tutor) ) # Ask the model the questions third_chat <- chat( openai.API = key, # defined in Example 1 model = model, # defined in Example 1 prompts = prompts, # NEW system.role = system.role, # NEW reps = reps # defined in Example 1 ) # View the outputted data frame to examine the responses View(third_chat) ## End(Not run)## Not run: ################################################# ### Example 1: Writing a Very Basic Prompt ##### ################################################# # First, define your API key key <- "INSERT YOUR KEY HERE" # Then, define your LLM model. This model should correspond to your API key. model <- "gpt4o" # in this example, you would need an OpenAI API key. # Then, write your prompt. This will be given to the model directly. prompt <- "Why does the planet Saturn have rings? Give a 100 word explanation." # Optionally, add a system role (a model persona) system.role <- "You specialize in tutoring astronomy for high school students." # Add the number of prompt repetitions. By default, this is set to 1. But it # may be useful to increase the number of repetitions to get a sense of how # consistent your output might be. reps <- 3 # Now you are ready to chat with an LLM first_chat <- chat( # Set your own API key. If you are not using OpenAI, change the 1st # argument to match your API key. Choices are `groq.API`, # `anthropic.API`, and `openai.API`. In this example, I'm using # `openai.API` since I want to chat with a GPT model. openai.API = key, model = model, # Ensure your model corresponds to your API key. prompts = prompt, system.role = system.role, reps = reps ) # Check how the output changes from iteration to iteration first_chat$response[[1]] # first iteration output first_chat$response[[2]] # second iteration output first_chat$response[[3]] # third iteration output #################################################################### ### Example 2: Send multiple prompts in a single function call ##### #################################################################### # You are also able to send more than one prompt in a single call # Let's pull the first prompt from Example 1: prompt1 <- "Why does the planet Saturn have rings? Give a 100 word explanation." prompt2 <- "Which planet is the hottest in our solar system? How do we know?" # Aggregate the prompts in a single object prompts <- c(prompt1, prompt2) # Ask the model the questions second_chat <- chat( openai.API = key, # defined in Example 1 model = model, # defined in Example 1 prompts = prompts, # NEW system.role = system.role, # defined in Example 1 reps = reps # defined in Example 1 ) # The outputted data frame for this example will have 6 rows # since the number of prompts (2) times the number of reps (3) # gives a total of 6 API calls. second_chat$response[second_chat$prompt==prompt1] # the responses from prompt 1 second_chat$response[second_chat$prompt==prompt2] # the responses from prompt 2 #################################################################### ### Example 3: Send multiple prompts with different System Roles ### #################################################################### # Perhaps your prompts are not related. In that case, you would probably want # to set a different system role for each prompt. # Let's change `prompt 2` to be entirely unrelated to astronomy. prompt2 <- "What is the difference between eukaryotes and prokaryotes? Why?" # This new second prompt does not fit with the astronomy tutor persona. Let's # write a persona to match this new prompt topic. system.role2 <- "You specialize in tutoring biology for middle school students." # Now, let's combine the system roles into a single object system.role <- c(system.role, # defined in Example 1: the astronomy tutor system.role2 # defined above: the biology tutor ) # Aggregate our prompts in a single object again prompts <- c(prompt1, # Asks about Saturn's rings (needs astronomy tutor) prompt2 # Asks about types of cells (needs biology tutor) ) # Ask the model the questions third_chat <- chat( openai.API = key, # defined in Example 1 model = model, # defined in Example 1 prompts = prompts, # NEW system.role = system.role, # NEW reps = reps # defined in Example 1 ) # View the outputted data frame to examine the responses View(third_chat) ## End(Not run)
Verifies that all requirements for local LLM inference are met, including Python environment, llama-cpp-python installation, and model file accessibility.
check_local_llm_setup(model.path, silently = FALSE)check_local_llm_setup(model.path, silently = FALSE)
model.path |
Path to the GGUF model file |
silently |
Logical. Suppress progress messages? |
Logical. TRUE if setup is complete, FALSE otherwise.
A numeric embedding matrix corresponding to
items.gpt5.4.example, provided for demonstrating
GENIE without requiring an external embedding API call.
data("embeddings.gpt5.4.example")data("embeddings.gpt5.4.example")
A 1536 x 180 numeric matrix. Rows are embedding dimensions and columns
are items. Column names correspond to the item IDs in
items.gpt5.4.example.
The embeddings were generated from the GPT-5.4 example item pool using
OpenAI's text-embedding-3-small embedding model. The matrix is
oriented in the format expected by GENIE: embedding
dimensions in rows and items in columns.
The corresponding item metadata are available as
items.gpt5.4.example.
data("embeddings.gpt5.4.example") dim(embeddings.gpt5.4.example) data("items.gpt5.4.example") all( colnames(embeddings.gpt5.4.example) %in% as.character(items.gpt5.4.example$ID) )data("embeddings.gpt5.4.example") dim(embeddings.gpt5.4.example) data("items.gpt5.4.example") all( colnames(embeddings.gpt5.4.example) %in% as.character(items.gpt5.4.example$ID) )
Sets up the Python environment with all required dependencies for AI-GENIE. Uses UV for fast, reliable package management. This function is called automatically when needed, but can also be called directly.
ensure_aigenie_python( force_reinstall = FALSE, include_huggingface = TRUE, include_local_llm = FALSE, gpu = FALSE )ensure_aigenie_python( force_reinstall = FALSE, include_huggingface = TRUE, include_local_llm = FALSE, gpu = FALSE )
force_reinstall |
Logical. Force complete reinstallation? |
include_huggingface |
Logical. Include HuggingFace packages? Default TRUE. |
include_local_llm |
Logical. Include local LLM support? Default FALSE. |
gpu |
Logical. Install GPU-enabled PyTorch? Default FALSE. |
TRUE invisibly on success
GENIE applies the psychometric reduction steps present in AIGENIE on user-supplied
items. Users provide their own items and optionally their own
embeddings, then GENIE performs redundancy reduction and
structural validation to assess item quality and dimensionality.
GENIE( items, embedding.matrix = NULL, openai.API = NULL, hf.token = NULL, jina.API = NULL, embedding.model = "text-embedding-3-small", EGA.model = NULL, EGA.algorithm = NULL, EGA.uni.method = NULL, uva.cut.off = 0.2, boot.iter = 500, ncores = NULL, embeddings.only = FALSE, run.overall = FALSE, all.together = FALSE, plot = TRUE, silently = FALSE )GENIE( items, embedding.matrix = NULL, openai.API = NULL, hf.token = NULL, jina.API = NULL, embedding.model = "text-embedding-3-small", EGA.model = NULL, EGA.algorithm = NULL, EGA.uni.method = NULL, uva.cut.off = 0.2, boot.iter = 500, ncores = NULL, embeddings.only = FALSE, run.overall = FALSE, all.together = FALSE, plot = TRUE, silently = FALSE )
items |
Data frame with columns: statement, attribute, type, ID.
|
embedding.matrix |
Optional numeric matrix or data frame where:
|
openai.API |
OpenAI API key (required if using OpenAI embedding models) |
hf.token |
HuggingFace token (optional, improves rate limits for HF models) |
jina.API |
Jina AI API key for using Jina embedding models (e.g., "jina-embeddings-v3"). Free tier available at https://jina.ai/. |
embedding.model |
Embedding model to use if embedding.matrix not provided:
|
EGA.model |
EGA network estimation model ("glasso", "TMFG", or NULL for auto-selection) |
EGA.algorithm |
EGA community detection algorithm ("walktrap", "leiden", "louvain"; NULL uses "walktrap") |
EGA.uni.method |
Unidimensionality assessment method ("louvain", "expand", "LE"; NULL uses "louvain") |
uva.cut.off |
Numeric in |
boot.iter |
A positive integer (optional, default: 500). Number of
bootstrap iterations used by |
ncores |
A positive integer or |
embeddings.only |
If |
run.overall |
A logical value (optional, default: FALSE). Controls whether a fit analysis
on the complete item pool is run post-reduction.
By default, only type-level reduction analyses are run (i.e., items of like-type go through
the pipeline independent of the other items in the pool). When this flag is |
all.together |
A logical value (optional, default: FALSE). Controls whether the reduction analysis
on the complete item pool is run.
By default, only type-level reduction analyses are run (i.e., items of like-type go through
the pipeline independent of the other items in the pool). When this flag is |
plot |
If |
silently |
If |
The structure of the return value depends on the function flags.
When embeddings.only = TRUE:
Returns the numeric embedding matrix only (rows are embedding dimensions; columns are items, named by item ID).
Default behaviour (embeddings.only = FALSE, run.overall = FALSE,
all.together = FALSE):
Returns a named list with two top-level elements:
item_type_levelA named list where each name is an item type and each element is a per-type named list containing:
final_NMINumeric: normalized mutual information (NMI) of the final EGA solution after reduction.
initial_NMINumeric: NMI of the pre-reduction item pool, estimated on the full (dense) embeddings with the selected EGA model.
embeddingsList containing selected ("full" or "sparse", the embedding representation chosen for reduction), selection_log (a data.frame of the NMI for each candidate EGA model and representation), and full and sparse (embedding matrices for the final items).
UVAList from Unique Variable Analysis containing n_removed, n_sweeps, redundant_pairs (a data.frame of redundant item groups), and removal_log (a data.frame with one row per removed item, its retained redundant partner, and the wTO statistic).
bootEGAList containing post_uva_initial_boot and post_uva_final_boot (bootEGA objects before and after stability filtering), n_removed, items_removed (a data.frame of removed items with their item stability), and initial_boot_with_redundancies (a bootEGA object for the pre-reduction pool, used in stability_plot).
EGA.model_selectedCharacter: the chosen EGA model ("glasso" or "TMFG").
final_itemsdata.frame: final items after reduction (columns ID, statement, attribute, type, and EGA_com, the final EGA community).
final_EGAEGA.fit object (from EGAnet) for the final items.
initial_EGAEGA.fit object for the pre-reduction item pool.
start_NInteger: initial number of items in this type.
final_NInteger: final number of items in this type.
network_plotpatchwork object comparing networks before vs after reduction.
stability_plotpatchwork object showing networks and item stability before vs after reduction.
filtering_auditdata.frame with one row per removed item, giving the removal stage ("UVA", "EGA_selection", "bootEGA", or "final_EGA"), the reason, the filtering statistic and cutoff, redundancy partner(s), item stability, and pre-reduction network-loading diagnostics. Network loadings are descriptive only; they are not used as removal criteria.
reduction_summarydata.frame giving the number of items (N), NMI, n_removed_at_stage, and delta_NMI (change from initial_NMI) at each stage of the reduction.
filtering_auditdata.frame combining the per-type filtering_audit tables across all item types.
When run.overall = TRUE (and more than one item type is present):
the list additionally contains overall, a pooled post-reduction fit of all items
retained by the type-level reductions. No further items are removed at this level.
overall contains final_NMI, initial_NMI, embeddings (selected, full, and
sparse), EGA.model_selected, final_items, final_EGA, initial_EGA, start_N,
final_N, network_plot, stability_plot (always NULL), filtering_audit, and
reduction_summary. Pooled NMI values compare EGA communities against
type-by-attribute labels. The top-level filtering_audit then reports pooled (rather
than within-type) pre-reduction network-loading diagnostics.
When all.together = TRUE (and more than one item type is present):
results are not split by item type. The function returns a single per-type
named list (as described under item_type_level above) for the pooled analysis, in
which EGA communities are compared against type-by-attribute labels. Here,
final_items contains the original item rows (with their original type and
attribute labels) plus the EGA_com column.
On failure: if the reduction pipeline fails, the partial per-type results list is returned.
Golino, H. F., & Epskamp, S. (2017). Exploratory graph analysis: A new approach for estimating the number of dimensions in psychological research. PLOS ONE, 12(6), e0174035. doi:10.1371/journal.pone.0174035
Christensen, A. P., Garrido, L. E., & Golino, H. (2023). Unique variable analysis: A network psychometrics method to detect local dependence. Multivariate Behavioral Research, 58(6), 1165–1182. doi:10.1080/00273171.2023.2194606
Christensen, A. P., & Golino, H. (2021). Estimating the stability of psychological dimensions via bootstrap exploratory graph analysis: A Monte Carlo simulation and tutorial. Psych, 3(3), 479–500. doi:10.3390/psych3030032
Danon, L., Díaz-Guilera, A., Duch, J., & Arenas, A. (2005). Comparing community structure identification. Journal of Statistical Mechanics: Theory and Experiment, 2005(9), P09008. doi:10.1088/1742-5468/2005/09/P09008
Russell-Lasalandra, L. L., Christensen, A. P., & Golino, H. F. (2026). Generative psychometrics via AI-GENIE: Automatic item generation and validation with network-integrated evaluation. Behavior Research Methods, 58(8), 217. doi:10.3758/s13428-026-03082-1
## Not run: ##################################################################### #### GENIE with Bundled GPT-5.4 Items and Frozen Embeddings #### ##################################################################### # Load the example item pool and its matching embedding matrix. # No API key is required. data("items.gpt5.4.example") data("embeddings.gpt5.4.example") # Run GENIE using the pre-computed embeddings. gpt5.4.example.results <- GENIE( items = items.gpt5.4.example, embedding.matrix = embeddings.gpt5.4.example, EGA.model = "glasso", EGA.algorithm = "walktrap", EGA.uni.method = "louvain", uva.cut.off = 0.20, run.overall = TRUE, plot = FALSE, silently = FALSE ) # Final retained items gpt5.4.example.results$item_type_level$conscientiousness$final_items gpt5.4.example.results$item_type_level$openness$final_items # Publication-ready audit of every filtered item: # what was removed, why, the filtering statistic and cutoff, # redundancy partner(s), item stability, and pre-reduction # network-loading diagnostics. gpt5.4.example.results$filtering_audit # Stage-by-stage NMI trajectories gpt5.4.example.results$item_type_level$conscientiousness$reduction_summary gpt5.4.example.results$item_type_level$openness$reduction_summary # Pooled post-reduction fit, when run.overall = TRUE gpt5.4.example.results$overall ############################################################ #### Using GENIE with OpenAI's Embeddings (Recommended) #### ############################################################ # Add an OpenAI API Key key <- "INSERT YOUR KEY HERE" # Specify item statements that you already have written statements <- c( "I find myself naturally initiating conversations with strangers at social gatherings.", "I enjoy creating a welcoming atmosphere for people I meet for the first time.", "I generally maintain a hopeful outlook, even when faced with challenges.", "I frequently find myself in a good mood, spreading cheer to those around me.", "I often have the drive to engage in exciting activities, even after a long day.", "I tend to tackle projects with enthusiasm and high energy from start to finish.", paste0( "I actively seek to include others in group activities, ", "making them feel part of the team." ), "I frequently reach out to new acquaintances to foster connections and friendships.", paste0( "I habitually focus on the silver lining in difficult ", "situations, maintaining an optimistic perspective." ), paste0( "I often express gratitude for the positive aspects of my ", "life, which enhances my overall mood." ), "I find joy in taking on new challenges that require a burst of energy and enthusiasm.", "I thrive in dynamic environments that keep me on my toes and invigorate my spirit.", "I take pleasure in introducing people to one another, acting as a social connector.", "I enjoy making others comfortable by engaging them in light-hearted conversation.", "I often set a positive tone in group settings with my upbeat demeanor.", "I approach each day with a sense of excitement and a positive mindset.", "I am drawn to fast-paced environments where I can express my high energy levels.", "I feel invigorated when working on multiple projects that demand my full attention.", "I take delight in meeting new people and quickly making them feel at ease.", paste0( "I find it rewarding to help shy or reserved individuals ", "become involved in group discussions." ), "I have a natural tendency to uplift others with my positive remarks and outlook.", paste0( "I find happiness in highlighting the successes of others, ", "contributing to a cheerful environment." ), "I eagerly immerse myself in activities that demand stamina and sustained energy.", "I often channel my vitality into hobbies and sports that require physical exertion.", "I feel rejuvenated when I bring people together to collaborate and share ideas.", "I often extend a genuine greeting to others, creating an inviting atmosphere.", "I regularly see challenges as opportunities for growth and learning.", "I commonly radiate positivity, influencing the mood of those around me.", "I approach mornings with anticipation and vigor, ready to embrace the day.", paste0( "I consistently infuse enthusiasm into group activities, ", "boosting collective energy levels." ), "I make an effort to connect with people by remembering details about their lives.", "I genuinely enjoy learning about people's diverse experiences and viewpoints.", "I have a habit of encouraging others to see the bright side of their situations.", "I believe in celebrating small victories, finding joy in daily accomplishments.", "I often find myself eager to start the day with ambitious plans and goals.", paste0( "I am known for sustaining high levels of energy during ", "extended work sessions or projects." ), "I make an effort to engage those around me in meaningful and enjoyable conversations.", "I often seek opportunities to bring people together, fostering a sense of community.", "I naturally inspire others with my optimistic outlook, even in uncertain times.", paste0( "I frequently look for the positive aspects in challenging ", "situations and share them with others." ), "I approach new experiences with an eagerness and fervor that motivates those around me.", "I thrive on maintaining high energy levels throughout demanding and fast-paced days.", paste0( "I take pleasure in initiating warm interactions in group ", "settings to make everyone comfortable." ), "I enjoy hosting gatherings that connect friends and encourage social bonding.", paste0( "I am skilled at turning setbacks into learning experiences ", "to maintain a positive outlook." ), "I always try to highlight the benefits in situations, enhancing a cheerful atmosphere.", "I find excitement in starting the day with a list of activities to energize my routine.", paste0( "I relish the challenge of keeping up with dynamic schedules ", "that require sustained energy." ), "I often find joy in making newcomers feel welcome and appreciated in group settings.", "I genuinely enjoy striking up conversations to learn more about the people I encounter.", "I have a knack for seeing potential in situations that others might overlook.", paste0( "I consistently try to uplift the mood in my surroundings ", "with hopeful and encouraging words." ), paste0( "I frequently harness my energy to inspire and motivate those ", "around me in team environments." ), "I often feel invigorated by challenges that require sustained focus and dynamic thinking.", "I often create environments where people feel encouraged to share their thoughts freely.", "I find it fulfilling to engage deeply with people, building lasting connections.", "I see potential in every day, believing it holds opportunities for something good.", "I actively focus on the pleasures of life, which naturally enhances my mood.", "I am invigorated by opportunities to engage in lively and spirited events.", "I tend to maintain momentum throughout the day, sustaining my energy levels.", paste0( "I frequently experience sudden shifts in my emotions even ", "when there is no apparent reason." ), "People often find it difficult to predict my emotional reactions to different situations.", "I often doubt my abilities and worry about whether I am meeting expectations.", "I frequently question my self-worth and tend to seek reassurance from others.", "I become annoyed easily over small inconveniences or delays.", paste0( "I often find myself feeling agitated or frustrated in ", "situations that don't bother most people." ), "My mood can change drastically over the course of a day, often without any clear reason.", "I tend to experience emotional highs and lows more intensely than those around me.", "I sometimes avoid taking on new challenges because I fear not being good enough.", "I often feel uncertain about my social standing and worry about being accepted by others.", "I find myself getting irritated quickly when things don't go my way.", "Minor annoyances often cause my patience to wear thin unusually fast.", "I frequently struggle to maintain a stable emotional state throughout the day.", "Unexpected events can cause me to experience drastic emotional swings.", "I often feel inadequate in comparison to others around me.", "I tend to second-guess my choices due to a lack of confidence in myself.", "I tend to become frustrated when things do not proceed as I have planned.", "I am prone to irritation when faced with unexpected changes to my routine.", paste0( "My emotional state is often unpredictable, shifting from ", "contentment to sadness with little warning." ), "People have commented that my emotions seem to fluctuate more than those of others.", "I frequently feel self-conscious about my achievements compared to those of my peers.", paste0( "I often worry excessively about making mistakes, even in ", "situations where it might be inconsequential." ), "Small disruptions in my daily routine can trigger strong feelings of annoyance.", "I find myself becoming irritated more quickly than others when under stress or pressure.", paste0( "I often find my emotional responses to be unpredictable, ", "feeling fine one moment and unsettled the next." ), "I experience strong emotions that can shift unexpectedly, often catching me off guard.", "I regularly feel uncertain about my ability to manage new responsibilities effectively.", "I often question my decisions, fearing they might not lead to the best outcomes.", paste0( "I frequently find myself reacting with impatience to ", "situations perceived as minor interruptions." ), "Even minor provocations can sometimes lead to an exaggerated sense of annoyance for me.", paste0( "My emotional state is often inconsistent, and I can feel ", "ecstatic or despondent within short timeframes." ), paste0( "I notice that my feelings can be quite volatile and intense, ", "affecting how I interact with others throughout the day." ), "I regularly doubt whether I am capable of achieving my personal or professional goals.", "I often seek validation from others to feel reassured about my self-worth.", paste0( "I am sensitive to disturbances and find my patience wearing ", "thin quickly when things aren't orderly." ), paste0( "I occasionally struggle to contain my annoyance over trivial ", "issues that disrupt my sense of calm." ), "I can go from feeling upbeat to being downcast without an obvious cause.", "My emotional responses can sometimes be unpredictable, shifting with little notice.", "I often feel the need for affirmation about my abilities from friends or colleagues.", "I tend to compare myself to others and feel uncertain about my achievements.", "I find myself easily bothered by noises or disturbances in my environment.", "I get easily flustered by situations that interrupt my planned activities.", paste0( "I find it challenging to maintain a consistent emotional ", "state, regardless of external situations." ), "My emotional reactions can be intense and differ significantly from moment to moment.", "I have a persistent fear of not measuring up to the expectations placed on me.", "I often feel anxious about others' perceptions of my capabilities and appearance.", "I am quick to express frustration at minor inconveniences in my daily routine.", paste0( "I find that small, unforeseen events often disrupt my sense ", "of calm and lead to irritation." ), paste0( "My emotional reactions can be strong and relentless, ", "impacting my behavior throughout the day." ), paste0( "I often find myself emotionally labile, with an inner ", "turbulence that others rarely perceive." ), "I frequently worry about my competence in areas where others seem confident.", paste0( "I have a tendency to second-guess myself and require ", "affirmation to feel reassured about my choices." ), "Small disruptions can ignite a lingering sense of agitation within me.", "I often catch myself feeling irritable even in relatively calm settings.", paste0( "I find myself swinging from happy to melancholic in a short ", "span of time, often surprising even myself." ), paste0( "Others often comment on how quickly my mood can change in ", "response to seemingly minor events." ), paste0( "I tend to feel apprehensive about presenting my opinions, ", "fearing they may be judged harshly." ), "I often require reassurance from peers to feel confident in my decisions and ideas.", "Interruptions during focused tasks often lead to an outpour of irritation from me.", "I struggle to keep my frustration in check when things do not unfold as expected." ) # Create the item type and attribute labels item.attributes <- c( rep(c("friendly", "positive", "energetic"), each = 2, times = 10), rep(c("moody", "insecure", "irritable"), each = 2, times = 10) ) item.types <- c( rep("extraversion", 60), rep("neuroticism", 60) ) # Build your data frame with the required columns: ID, statement, attribute, and type items_df <- data.frame( ID = rep(as.factor(1:length(statements))), statement = statements, attribute = item.attributes, type = item.types ) # Run GENIE with items you provide (embedding items via OpenAI) example_reduction <- GENIE(items = items_df, openai.API = key) # View the results View(example_reduction) ################################################################ ###### Or, Run GENIE with a Hugging Face Embedding Model ####### ################################################################ # Chose a BAAI/bge series OR thenlper/gte series model hf.embedding.model <- "BAAI/bge-large-en-v1.5" # Create a HF Token to access the best models. Moderate useage will still be FREE hf.token <- "INSERT YOUR KEY HERE" # Run GENIE using the Hugging Face Embedding model example_reduction_HF <- GENIE(items = items_df, embedding.model = hf.embedding.model, hf.token = hf.token) ## End(Not run)## Not run: ##################################################################### #### GENIE with Bundled GPT-5.4 Items and Frozen Embeddings #### ##################################################################### # Load the example item pool and its matching embedding matrix. # No API key is required. data("items.gpt5.4.example") data("embeddings.gpt5.4.example") # Run GENIE using the pre-computed embeddings. gpt5.4.example.results <- GENIE( items = items.gpt5.4.example, embedding.matrix = embeddings.gpt5.4.example, EGA.model = "glasso", EGA.algorithm = "walktrap", EGA.uni.method = "louvain", uva.cut.off = 0.20, run.overall = TRUE, plot = FALSE, silently = FALSE ) # Final retained items gpt5.4.example.results$item_type_level$conscientiousness$final_items gpt5.4.example.results$item_type_level$openness$final_items # Publication-ready audit of every filtered item: # what was removed, why, the filtering statistic and cutoff, # redundancy partner(s), item stability, and pre-reduction # network-loading diagnostics. gpt5.4.example.results$filtering_audit # Stage-by-stage NMI trajectories gpt5.4.example.results$item_type_level$conscientiousness$reduction_summary gpt5.4.example.results$item_type_level$openness$reduction_summary # Pooled post-reduction fit, when run.overall = TRUE gpt5.4.example.results$overall ############################################################ #### Using GENIE with OpenAI's Embeddings (Recommended) #### ############################################################ # Add an OpenAI API Key key <- "INSERT YOUR KEY HERE" # Specify item statements that you already have written statements <- c( "I find myself naturally initiating conversations with strangers at social gatherings.", "I enjoy creating a welcoming atmosphere for people I meet for the first time.", "I generally maintain a hopeful outlook, even when faced with challenges.", "I frequently find myself in a good mood, spreading cheer to those around me.", "I often have the drive to engage in exciting activities, even after a long day.", "I tend to tackle projects with enthusiasm and high energy from start to finish.", paste0( "I actively seek to include others in group activities, ", "making them feel part of the team." ), "I frequently reach out to new acquaintances to foster connections and friendships.", paste0( "I habitually focus on the silver lining in difficult ", "situations, maintaining an optimistic perspective." ), paste0( "I often express gratitude for the positive aspects of my ", "life, which enhances my overall mood." ), "I find joy in taking on new challenges that require a burst of energy and enthusiasm.", "I thrive in dynamic environments that keep me on my toes and invigorate my spirit.", "I take pleasure in introducing people to one another, acting as a social connector.", "I enjoy making others comfortable by engaging them in light-hearted conversation.", "I often set a positive tone in group settings with my upbeat demeanor.", "I approach each day with a sense of excitement and a positive mindset.", "I am drawn to fast-paced environments where I can express my high energy levels.", "I feel invigorated when working on multiple projects that demand my full attention.", "I take delight in meeting new people and quickly making them feel at ease.", paste0( "I find it rewarding to help shy or reserved individuals ", "become involved in group discussions." ), "I have a natural tendency to uplift others with my positive remarks and outlook.", paste0( "I find happiness in highlighting the successes of others, ", "contributing to a cheerful environment." ), "I eagerly immerse myself in activities that demand stamina and sustained energy.", "I often channel my vitality into hobbies and sports that require physical exertion.", "I feel rejuvenated when I bring people together to collaborate and share ideas.", "I often extend a genuine greeting to others, creating an inviting atmosphere.", "I regularly see challenges as opportunities for growth and learning.", "I commonly radiate positivity, influencing the mood of those around me.", "I approach mornings with anticipation and vigor, ready to embrace the day.", paste0( "I consistently infuse enthusiasm into group activities, ", "boosting collective energy levels." ), "I make an effort to connect with people by remembering details about their lives.", "I genuinely enjoy learning about people's diverse experiences and viewpoints.", "I have a habit of encouraging others to see the bright side of their situations.", "I believe in celebrating small victories, finding joy in daily accomplishments.", "I often find myself eager to start the day with ambitious plans and goals.", paste0( "I am known for sustaining high levels of energy during ", "extended work sessions or projects." ), "I make an effort to engage those around me in meaningful and enjoyable conversations.", "I often seek opportunities to bring people together, fostering a sense of community.", "I naturally inspire others with my optimistic outlook, even in uncertain times.", paste0( "I frequently look for the positive aspects in challenging ", "situations and share them with others." ), "I approach new experiences with an eagerness and fervor that motivates those around me.", "I thrive on maintaining high energy levels throughout demanding and fast-paced days.", paste0( "I take pleasure in initiating warm interactions in group ", "settings to make everyone comfortable." ), "I enjoy hosting gatherings that connect friends and encourage social bonding.", paste0( "I am skilled at turning setbacks into learning experiences ", "to maintain a positive outlook." ), "I always try to highlight the benefits in situations, enhancing a cheerful atmosphere.", "I find excitement in starting the day with a list of activities to energize my routine.", paste0( "I relish the challenge of keeping up with dynamic schedules ", "that require sustained energy." ), "I often find joy in making newcomers feel welcome and appreciated in group settings.", "I genuinely enjoy striking up conversations to learn more about the people I encounter.", "I have a knack for seeing potential in situations that others might overlook.", paste0( "I consistently try to uplift the mood in my surroundings ", "with hopeful and encouraging words." ), paste0( "I frequently harness my energy to inspire and motivate those ", "around me in team environments." ), "I often feel invigorated by challenges that require sustained focus and dynamic thinking.", "I often create environments where people feel encouraged to share their thoughts freely.", "I find it fulfilling to engage deeply with people, building lasting connections.", "I see potential in every day, believing it holds opportunities for something good.", "I actively focus on the pleasures of life, which naturally enhances my mood.", "I am invigorated by opportunities to engage in lively and spirited events.", "I tend to maintain momentum throughout the day, sustaining my energy levels.", paste0( "I frequently experience sudden shifts in my emotions even ", "when there is no apparent reason." ), "People often find it difficult to predict my emotional reactions to different situations.", "I often doubt my abilities and worry about whether I am meeting expectations.", "I frequently question my self-worth and tend to seek reassurance from others.", "I become annoyed easily over small inconveniences or delays.", paste0( "I often find myself feeling agitated or frustrated in ", "situations that don't bother most people." ), "My mood can change drastically over the course of a day, often without any clear reason.", "I tend to experience emotional highs and lows more intensely than those around me.", "I sometimes avoid taking on new challenges because I fear not being good enough.", "I often feel uncertain about my social standing and worry about being accepted by others.", "I find myself getting irritated quickly when things don't go my way.", "Minor annoyances often cause my patience to wear thin unusually fast.", "I frequently struggle to maintain a stable emotional state throughout the day.", "Unexpected events can cause me to experience drastic emotional swings.", "I often feel inadequate in comparison to others around me.", "I tend to second-guess my choices due to a lack of confidence in myself.", "I tend to become frustrated when things do not proceed as I have planned.", "I am prone to irritation when faced with unexpected changes to my routine.", paste0( "My emotional state is often unpredictable, shifting from ", "contentment to sadness with little warning." ), "People have commented that my emotions seem to fluctuate more than those of others.", "I frequently feel self-conscious about my achievements compared to those of my peers.", paste0( "I often worry excessively about making mistakes, even in ", "situations where it might be inconsequential." ), "Small disruptions in my daily routine can trigger strong feelings of annoyance.", "I find myself becoming irritated more quickly than others when under stress or pressure.", paste0( "I often find my emotional responses to be unpredictable, ", "feeling fine one moment and unsettled the next." ), "I experience strong emotions that can shift unexpectedly, often catching me off guard.", "I regularly feel uncertain about my ability to manage new responsibilities effectively.", "I often question my decisions, fearing they might not lead to the best outcomes.", paste0( "I frequently find myself reacting with impatience to ", "situations perceived as minor interruptions." ), "Even minor provocations can sometimes lead to an exaggerated sense of annoyance for me.", paste0( "My emotional state is often inconsistent, and I can feel ", "ecstatic or despondent within short timeframes." ), paste0( "I notice that my feelings can be quite volatile and intense, ", "affecting how I interact with others throughout the day." ), "I regularly doubt whether I am capable of achieving my personal or professional goals.", "I often seek validation from others to feel reassured about my self-worth.", paste0( "I am sensitive to disturbances and find my patience wearing ", "thin quickly when things aren't orderly." ), paste0( "I occasionally struggle to contain my annoyance over trivial ", "issues that disrupt my sense of calm." ), "I can go from feeling upbeat to being downcast without an obvious cause.", "My emotional responses can sometimes be unpredictable, shifting with little notice.", "I often feel the need for affirmation about my abilities from friends or colleagues.", "I tend to compare myself to others and feel uncertain about my achievements.", "I find myself easily bothered by noises or disturbances in my environment.", "I get easily flustered by situations that interrupt my planned activities.", paste0( "I find it challenging to maintain a consistent emotional ", "state, regardless of external situations." ), "My emotional reactions can be intense and differ significantly from moment to moment.", "I have a persistent fear of not measuring up to the expectations placed on me.", "I often feel anxious about others' perceptions of my capabilities and appearance.", "I am quick to express frustration at minor inconveniences in my daily routine.", paste0( "I find that small, unforeseen events often disrupt my sense ", "of calm and lead to irritation." ), paste0( "My emotional reactions can be strong and relentless, ", "impacting my behavior throughout the day." ), paste0( "I often find myself emotionally labile, with an inner ", "turbulence that others rarely perceive." ), "I frequently worry about my competence in areas where others seem confident.", paste0( "I have a tendency to second-guess myself and require ", "affirmation to feel reassured about my choices." ), "Small disruptions can ignite a lingering sense of agitation within me.", "I often catch myself feeling irritable even in relatively calm settings.", paste0( "I find myself swinging from happy to melancholic in a short ", "span of time, often surprising even myself." ), paste0( "Others often comment on how quickly my mood can change in ", "response to seemingly minor events." ), paste0( "I tend to feel apprehensive about presenting my opinions, ", "fearing they may be judged harshly." ), "I often require reassurance from peers to feel confident in my decisions and ideas.", "Interruptions during focused tasks often lead to an outpour of irritation from me.", "I struggle to keep my frustration in check when things do not unfold as expected." ) # Create the item type and attribute labels item.attributes <- c( rep(c("friendly", "positive", "energetic"), each = 2, times = 10), rep(c("moody", "insecure", "irritable"), each = 2, times = 10) ) item.types <- c( rep("extraversion", 60), rep("neuroticism", 60) ) # Build your data frame with the required columns: ID, statement, attribute, and type items_df <- data.frame( ID = rep(as.factor(1:length(statements))), statement = statements, attribute = item.attributes, type = item.types ) # Run GENIE with items you provide (embedding items via OpenAI) example_reduction <- GENIE(items = items_df, openai.API = key) # View the results View(example_reduction) ################################################################ ###### Or, Run GENIE with a Hugging Face Embedding Model ####### ################################################################ # Chose a BAAI/bge series OR thenlper/gte series model hf.embedding.model <- "BAAI/bge-large-en-v1.5" # Create a HF Token to access the best models. Moderate useage will still be FREE hf.token <- "INSERT YOUR KEY HERE" # Run GENIE using the Hugging Face Embedding model example_reduction_HF <- GENIE(items = items_df, embedding.model = hf.embedding.model, hf.token = hf.token) ## End(Not run)
Downloads a GGUF model from HuggingFace for use with local_AIGENIE. Models are saved to a user-specified directory or the default AIGENIE models directory.
get_local_llm(repo_id, filename, save_dir = NULL, hf.token = NULL)get_local_llm(repo_id, filename, save_dir = NULL, hf.token = NULL)
repo_id |
HuggingFace repository ID (e.g., "TheBloke/Mistral-7B-Instruct-v0.2-GGUF") |
filename |
Specific GGUF filename to download (e.g., "mistral-7b-instruct-v0.2.Q4_K_M.gguf") |
save_dir |
Directory to save the model. If NULL, uses the default AIGENIE models directory. |
hf.token |
Optional HuggingFace token for gated models |
Character string with the full path to the downloaded model file.
## Not run: # Download a Mistral 7B model model_path <- get_local_llm( repo_id = "TheBloke/Mistral-7B-Instruct-v0.2-GGUF", filename = "mistral-7b-instruct-v0.2.Q4_K_M.gguf" ) # Use it with local_AIGENIE results <- local_AIGENIE( item.attributes = my_attributes, model.path = model_path ) ## End(Not run)## Not run: # Download a Mistral 7B model model_path <- get_local_llm( repo_id = "TheBloke/Mistral-7B-Instruct-v0.2-GGUF", filename = "mistral-7b-instruct-v0.2.Q4_K_M.gguf" ) # Use it with local_AIGENIE results <- local_AIGENIE( item.attributes = my_attributes, model.path = model_path ) ## End(Not run)
Reinstalls the Python environment with GPU-enabled PyTorch for faster inference with local embedding models. Requires a CUDA-compatible NVIDIA GPU and proper driver installation.
install_gpu_support()install_gpu_support()
This function:
Removes the existing Python environment
Creates a new environment with GPU-enabled PyTorch
Installs all HuggingFace dependencies
On Apple Silicon Macs, MPS (Metal Performance Shaders) acceleration is used automatically without needing this function.
Invisible TRUE on success.
reinstall_python_env,
python_env_info.
## Not run: # Enable GPU acceleration (requires NVIDIA GPU + CUDA) install_gpu_support() ## End(Not run)## Not run: # Enable GPU acceleration (requires NVIDIA GPU + CUDA) install_gpu_support() ## End(Not run)
Installs llama-cpp-python for running local GGUF models with
local_AIGENIE. On Apple Silicon Macs, this includes
Metal acceleration support for fast inference.
install_local_llm_support()install_local_llm_support()
After installation, you can use any GGUF model file with local_AIGENIE().
Download GGUF models from HuggingFace (search for "GGUF" format).
Popular model recommendations:
Llama 3 8B: Good balance of quality and speed
Mistral 7B: Fast with good quality
Qwen 2.5: Strong multilingual support
Invisible TRUE on success.
local_AIGENIE,
reinstall_python_env.
## Not run: # Install local LLM support install_local_llm_support() # Then download a GGUF model and use with local_AIGENIE results <- local_AIGENIE( item.attributes = my_traits, model.path = "~/models/llama-3-8b.Q4_K_M.gguf", embedding.model = "bert-base-uncased" ) ## End(Not run)## Not run: # Install local LLM support install_local_llm_support() # Then download a GGUF model and use with local_AIGENIE results <- local_AIGENIE( item.attributes = my_traits, model.path = "~/models/llama-3-8b.Q4_K_M.gguf", embedding.model = "bert-base-uncased" ) ## End(Not run)
An example item pool generated with GPT-5.4 for demonstrating the
psychometric reduction workflow implemented in GENIE.
The data contain 180 personality items: 90 conscientiousness items
and 90 openness items.
data("items.gpt5.4.example")data("items.gpt5.4.example")
A data frame with 180 rows and 4 variables:
IDUnique item identifier.
statementThe generated item statement.
typeHigher-order item type: conscientiousness or openness.
attributeTarget attribute represented by the item.
The item pool is the GPT-5.4 example used to illustrate AI-GENIE/GENIE item reduction. Conscientiousness items represent self-efficacy, achievement-striving, and perseverance. Openness items represent introspection, aesthetics, and abstract-thinking.
The corresponding embedding matrix is available as
embeddings.gpt5.4.example.
embeddings.gpt5.4.example, GENIE
data("items.gpt5.4.example") dim(items.gpt5.4.example) head(items.gpt5.4.example) table(items.gpt5.4.example$type) table(items.gpt5.4.example$attribute)data("items.gpt5.4.example") dim(items.gpt5.4.example) head(items.gpt5.4.example) table(items.gpt5.4.example$type) table(items.gpt5.4.example$attribute)
Queries the OpenAI, Groq, Anthropic, and/or Jina AI APIs to retrieve currently available models. Requires API keys for live provider queries. Jina AI models are returned from a curated static list (no list endpoint).
list_available_models( provider = NULL, openai.API = NULL, groq.API = NULL, anthropic.API = NULL, type = NULL )list_available_models( provider = NULL, openai.API = NULL, groq.API = NULL, anthropic.API = NULL, type = NULL )
provider |
Optional. Filter by provider: "openai", "groq", "anthropic", "jina", or NULL for all. |
openai.API |
Optional OpenAI API key. If NULL, checks OPENAI_API_KEY env var. |
groq.API |
Optional Groq API key. If NULL, checks GROQ_API_KEY env var. |
anthropic.API |
Optional Anthropic API key. If NULL, checks ANTHROPIC_API_KEY env var. |
type |
Filter by model type: "chat", "embedding", or NULL for all. Default is NULL (show everything). |
A data frame with columns: provider, model, type, display_name, created
Local version of AI-GENIE that uses locally installed language models and embeddings for complete privacy and offline operation. Generates items, creates embeddings, and performs network psychometric reduction entirely on the user's machine.
local_AIGENIE( item.attributes, model.path, embedding.model = "bert-base-uncased", main.prompts = NULL, temperature = NULL, top.p = NULL, target.N = NULL, domain = NULL, scale.title = NULL, item.examples = NULL, audience = NULL, item.type.definitions = NULL, item.attribute.definitions = NULL, response.options = NULL, prompt.notes = NULL, system.role = NULL, EGA.model = NULL, EGA.algorithm = NULL, EGA.uni.method = NULL, uva.cut.off = 0.2, boot.iter = 500, ncores = NULL, n.ctx = 4096, n.gpu.layers = -1, max.tokens = 1024, device = "auto", batch.size = 32, pooling.strategy = "mean", max.length = 512L, keep.org = FALSE, items.only = FALSE, embeddings.only = FALSE, adaptive = TRUE, run.overall = FALSE, all.together = FALSE, plot = TRUE, silently = FALSE )local_AIGENIE( item.attributes, model.path, embedding.model = "bert-base-uncased", main.prompts = NULL, temperature = NULL, top.p = NULL, target.N = NULL, domain = NULL, scale.title = NULL, item.examples = NULL, audience = NULL, item.type.definitions = NULL, item.attribute.definitions = NULL, response.options = NULL, prompt.notes = NULL, system.role = NULL, EGA.model = NULL, EGA.algorithm = NULL, EGA.uni.method = NULL, uva.cut.off = 0.2, boot.iter = 500, ncores = NULL, n.ctx = 4096, n.gpu.layers = -1, max.tokens = 1024, device = "auto", batch.size = 32, pooling.strategy = "mean", max.length = 512L, keep.org = FALSE, items.only = FALSE, embeddings.only = FALSE, adaptive = TRUE, run.overall = FALSE, all.together = FALSE, plot = TRUE, silently = FALSE )
item.attributes |
Named list of item types and their attributes (required) |
model.path |
Path to local GGUF model file (required) |
embedding.model |
Name or path to local embedding model (default: "bert-base-uncased") |
main.prompts |
Custom prompts for item generation (optional) |
temperature |
LLM temperature for randomness (0-2). Default NULL uses the local model's (llama.cpp) default. |
top.p |
Top-p nucleus sampling parameter (0-1). Default NULL uses the local model's (llama.cpp) default. |
target.N |
Number of items to generate per type (default: 60) |
domain |
Content domain (e.g., "psychological") |
scale.title |
Name of the scale |
item.examples |
Data frame of example items |
audience |
Target population |
item.type.definitions |
Definitions for item types |
item.attribute.definitions |
Named list of definitions for some or all attributes
(names must match attributes within the |
response.options |
Response scale labels |
prompt.notes |
Additional instructions for generation |
system.role |
Custom system prompt |
EGA.model |
Network model ("glasso", "TMFG", or NULL for auto) |
EGA.algorithm |
Community detection algorithm ("walktrap", "leiden", "louvain"; NULL uses "walktrap") |
EGA.uni.method |
Unidimensionality method ("louvain", "expand", "LE"; NULL uses "louvain") |
uva.cut.off |
Numeric in |
boot.iter |
A positive integer (optional, default: 500). Number of
bootstrap iterations used by |
ncores |
A positive integer or |
n.ctx |
Context window size (default: 4096) |
n.gpu.layers |
GPU layers to use (-1 for all, default: -1) |
max.tokens |
Maximum tokens per generation (default: 1024) |
device |
Device for embeddings ("auto", "cpu", "cuda", "mps") |
batch.size |
Batch size for embeddings (default: 32) |
pooling.strategy |
Pooling for embeddings ("mean", "cls", "max") |
max.length |
Max sequence length for embeddings (default: 512) |
keep.org |
Keep original items and embeddings (default: FALSE) |
items.only |
Generate items only, skip reduction (default: FALSE) |
embeddings.only |
Generate embeddings only (default: FALSE) |
adaptive |
Use adaptive generation (default: TRUE) |
run.overall |
A logical value (optional, default: FALSE). Controls whether a fit analysis
on the complete item pool is run post-reduction.
By default, only type-level reduction analyses are run (i.e., items of like-type go through
the pipeline independent of the other items in the pool). When this flag is |
all.together |
A logical value (optional, default: FALSE). Controls whether the reduction analysis
on the complete item pool is run.
By default, only type-level reduction analyses are run (i.e., items of like-type go through
the pipeline independent of the other items in the pool). When this flag is |
plot |
Display network plots (default: TRUE) |
silently |
Suppress progress messages (default: FALSE) |
The structure of the return value depends on the function flags.
When items.only = TRUE:
Returns a data.frame of generated items with columns
type, attribute, statement, and ID.
When embeddings.only = TRUE:
Returns a named list with two elements:
embeddings — a numeric embedding matrix (rows are embedding dimensions; columns are items, named by item ID).
items — the items data.frame described above.
Default behaviour (items.only = FALSE, embeddings.only = FALSE,
run.overall = FALSE, keep.org = FALSE, all.together = FALSE):
Returns a named list with two top-level elements:
item_type_levelA named list where each name is an item type and each element is a per-type named list containing:
final_NMINumeric: normalized mutual information (NMI) of the final EGA solution after reduction.
initial_NMINumeric: NMI of the pre-reduction item pool, estimated on the full (dense) embeddings with the selected EGA model.
embeddingsList containing selected ("full" or "sparse", the embedding representation chosen for reduction), selection_log (a data.frame of the NMI for each candidate EGA model and representation), and full and sparse (embedding matrices for the final items).
UVAList from Unique Variable Analysis containing n_removed, n_sweeps, redundant_pairs (a data.frame of redundant item groups), and removal_log (a data.frame with one row per removed item, its retained redundant partner, and the wTO statistic).
bootEGAList containing post_uva_initial_boot and post_uva_final_boot (bootEGA objects before and after stability filtering), n_removed, items_removed (a data.frame of removed items with their item stability), and initial_boot_with_redundancies (a bootEGA object for the pre-reduction pool, used in stability_plot).
EGA.model_selectedCharacter: the chosen EGA model ("glasso" or "TMFG").
final_itemsdata.frame: final items after reduction (columns ID, type, attribute, statement, and EGA_com, the final EGA community).
final_EGAEGA.fit object (from EGAnet) for the final items.
initial_EGAEGA.fit object for the pre-reduction item pool.
start_NInteger: initial number of items in this type.
final_NInteger: final number of items in this type.
network_plotpatchwork object comparing networks before vs after reduction.
stability_plotpatchwork object showing networks and item stability before vs after reduction.
filtering_auditdata.frame with one row per removed item, giving the removal stage ("UVA", "EGA_selection", "bootEGA", or "final_EGA"), the reason, the filtering statistic and cutoff, redundancy partner(s), item stability, and pre-reduction network-loading diagnostics. Network loadings are descriptive only; they are not used as removal criteria.
reduction_summarydata.frame giving the number of items (N), NMI, n_removed_at_stage, and delta_NMI (change from initial_NMI) at each stage of the reduction.
filtering_auditdata.frame combining the per-type filtering_audit tables across all item types.
When keep.org = TRUE (in addition to the defaults above):
each per-type sublist also contains initial_items (the pre-reduction items, with
their EGA_com from the initial EGA), and its embeddings list also contains
full_org and sparse_org (the full and sparse embedding matrices for the
pre-reduction item pool).
When run.overall = TRUE (and more than one item type is present):
the list additionally contains overall, a pooled post-reduction fit of all items
retained by the type-level reductions. No further items are removed at this level.
overall contains final_NMI, initial_NMI, embeddings (selected, full, and
sparse), EGA.model_selected, final_items, final_EGA, initial_EGA, start_N,
final_N, network_plot, stability_plot (always NULL), filtering_audit, and
reduction_summary. Pooled NMI values compare EGA communities against
type-by-attribute labels. With keep.org = TRUE, overall also contains
initial_items, and overall$embeddings also contains full_org and sparse_org. The
top-level filtering_audit then reports pooled (rather than within-type)
pre-reduction network-loading diagnostics.
When all.together = TRUE (and more than one item type is present):
results are not split by item type. The function returns a single per-type
named list (as described under item_type_level above) for the pooled analysis, in
which EGA communities are compared against type-by-attribute labels. Here,
final_items (and initial_items, when keep.org = TRUE) contain the original item
rows (with their original type and attribute labels) plus the EGA_com column.
On failure: if item generation or embedding fails, the items generated so far are returned. If the reduction pipeline fails, the partial per-type results list is returned.
Golino, H. F., & Epskamp, S. (2017). Exploratory graph analysis: A new approach for estimating the number of dimensions in psychological research. PLOS ONE, 12(6), e0174035. doi:10.1371/journal.pone.0174035
Christensen, A. P., Garrido, L. E., & Golino, H. (2023). Unique variable analysis: A network psychometrics method to detect local dependence. Multivariate Behavioral Research, 58(6), 1165–1182. doi:10.1080/00273171.2023.2194606
Christensen, A. P., & Golino, H. (2021). Estimating the stability of psychological dimensions via bootstrap exploratory graph analysis: A Monte Carlo simulation and tutorial. Psych, 3(3), 479–500. doi:10.3390/psych3030032
Danon, L., Díaz-Guilera, A., Duch, J., & Arenas, A. (2005). Comparing community structure identification. Journal of Statistical Mechanics: Theory and Experiment, 2005(9), P09008. doi:10.1088/1742-5468/2005/09/P09008
Russell-Lasalandra, L. L., Christensen, A. P., & Golino, H. F. (2026). Generative psychometrics via AI-GENIE: Automatic item generation and validation with network-integrated evaluation. Behavior Research Methods, 58(8), 217. doi:10.3758/s13428-026-03082-1
## Not run: ######################################################## #### Running AIGENIE with a downloaded LLM model ###### ######################################################## # Item type definitions trait.definitions <- list( neuroticism = paste0( "Neuroticism is a personality trait that describes one's ", "tendency to experience negative emotions like anxiety, ", "depression, irritability, anger, and self-consciousness." ), extraversion = paste0( "Extraversion is a personality trait that describes people ", "who are more focused on the external world than their ", "internal experience." ) ) # Item attributes aspects.of.personality.traits <- list( neuroticism = c("anxious", "depressed", "insecure", "emotional"), extraversion = c("friendly", "positive", "assertive", "energetic") ) # Name the field or specialty domain <- "Personality Measurement" # Name the Inventory being created scale.title <- "Two of 'Big Five:' A Streamlined Personality Inventory" # Add a file path name to a local text generation model downloaded on your computer model.path <- "ADD FILE PATH TO DOWNLOADED MODEL HERE" # Generate and validate items using a model installed on your machine local_example <- local_AIGENIE( item.attributes = aspects.of.personality.traits, item.type.definitions = trait.definitions, domain = domain, model.path = model.path ) ## End(Not run)## Not run: ######################################################## #### Running AIGENIE with a downloaded LLM model ###### ######################################################## # Item type definitions trait.definitions <- list( neuroticism = paste0( "Neuroticism is a personality trait that describes one's ", "tendency to experience negative emotions like anxiety, ", "depression, irritability, anger, and self-consciousness." ), extraversion = paste0( "Extraversion is a personality trait that describes people ", "who are more focused on the external world than their ", "internal experience." ) ) # Item attributes aspects.of.personality.traits <- list( neuroticism = c("anxious", "depressed", "insecure", "emotional"), extraversion = c("friendly", "positive", "assertive", "energetic") ) # Name the field or specialty domain <- "Personality Measurement" # Name the Inventory being created scale.title <- "Two of 'Big Five:' A Streamlined Personality Inventory" # Add a file path name to a local text generation model downloaded on your computer model.path <- "ADD FILE PATH TO DOWNLOADED MODEL HERE" # Generate and validate items using a model installed on your machine local_example <- local_AIGENIE( item.attributes = aspects.of.personality.traits, item.type.definitions = trait.definitions, domain = domain, model.path = model.path ) ## End(Not run)
Send one or more prompts to a locally available large-language model (LLM) without making remote API calls. The local model must be available on the machine as a GGUF model file (run via llama-cpp-python). This function is intended for fully local inference (no API key required).
local_chat( prompts, model.path, n.ctx = 4096, n.gpu.layers = -1, max.tokens = 1024, system.role = NULL, reps = 1, temperature = NULL, top.p = NULL, silently = FALSE )local_chat( prompts, model.path, n.ctx = 4096, n.gpu.layers = -1, max.tokens = 1024, system.role = NULL, reps = 1, temperature = NULL, top.p = NULL, silently = FALSE )
prompts |
A character string or character vector. The main prompt(s) given to the model. If multiple prompts are supplied, each will be sent separately to the model. |
model.path |
A character string. Path to the local GGUF model file. The function does not download models; ensure the model is present locally before using this function. |
n.ctx |
Integer, default |
n.gpu.layers |
Integer, default |
max.tokens |
Integer, default |
system.role |
A character string or character vector, default |
reps |
Integer, default |
temperature |
Numeric or |
top.p |
Numeric or |
silently |
Logical, default |
Before running this function check that you are able to run the local
environment via check_local_llm_setup().
For each prompt × repetition the function constructs a full_prompt that
includes the system.role and the user prompt, sets a deterministic
generation seed per generation, and calls the local model. A retry loop
(up to 5 attempts, with brief waits) handles transient failures; if all
attempts fail the function aborts with an informative error.
A data.frame with one row per generation (i.e., per prompt × repetition)
containing:
rep — repetition index
prompt — the prompt text sent to the model
response — the raw text response returned by the model
Local model inference can be resource intensive. Large models may require substantial disk space, RAM, and (optionally) GPU support. Performance and feasibility depend on model size and hardware.
model.path must point to a model already present; this function will not
download remote models.
## Not run: ################################################# ### Example 1: Writing a Very Basic Prompt ##### ################################################# # For local_chat you do NOT need an API key, but you DO need a text generation # model available locally. model <- "path/to/local-model" # replace with your local model path # Then, write your prompt. This will be given to the model directly. prompt <- "Why does the planet Saturn have rings? Give a 100 word explanation." # Optionally, add a system role (a model persona) system.role <- "You specialize in tutoring astronomy for high school students." # Add the number of prompt repetitions. By default, this is set to 1. But it # may be useful to increase the number of repetitions to get a sense of how # consistent your output might be. reps <- 3 # Now you are ready to chat with the local model first_chat <- local_chat( model.path = model, # local model identifier or path prompts = prompt, system.role = system.role, reps = reps ) # Check how the output changes from iteration to iteration first_chat$response[[1]] # first iteration output first_chat$response[[2]] # second iteration output first_chat$response[[3]] # third iteration output #################################################################### ### Example 2: Send multiple prompts in a single function call ##### #################################################################### # You are able to send more than one prompt in a single call prompt1 <- "Why does the planet Saturn have rings? Give a 100 word explanation." prompt2 <- "Which planet is the hottest in our solar system? How do we know?" # Aggregate the prompts in a single object prompts <- c(prompt1, prompt2) # Ask the model the questions second_chat <- local_chat( model.path = model, # defined above prompts = prompts, # NEW system.role = system.role, # defined above reps = reps # defined above ) # The outputted data frame for this example will have 6 rows # since the number of prompts (2) times the number of reps (3) # gives a total of 6 generations. second_chat$response[second_chat$prompt == prompt1] # the responses from prompt 1 second_chat$response[second_chat$prompt == prompt2] # the responses from prompt 2 #################################################################### ### Example 3: Send multiple prompts with different System Roles ### #################################################################### # Perhaps your prompts are not related. In that case, you would probably want # to set a different system role for each prompt. prompt2 <- "What is the difference between eukaryotes and prokaryotes? Why?" # This new second prompt does not fit with the astronomy tutor persona. Let's # write a persona to match this new prompt topic. system.role2 <- "You specialize in tutoring biology for middle school students." # Now, let's combine the system roles into a single object system.role <- c(system.role, # defined earlier: the astronomy tutor system.role2 # defined above: the biology tutor ) # Aggregate our prompts in a single object again prompts <- c(prompt1, # Asks about Saturn's rings (needs astronomy tutor) prompt2 # Asks about types of cells (needs biology tutor) ) # Ask the model the questions third_chat <- local_chat( model.path = model, prompts = prompts, system.role = system.role, reps = reps ) # View the outputted data frame to examine the responses View(third_chat) ## End(Not run)## Not run: ################################################# ### Example 1: Writing a Very Basic Prompt ##### ################################################# # For local_chat you do NOT need an API key, but you DO need a text generation # model available locally. model <- "path/to/local-model" # replace with your local model path # Then, write your prompt. This will be given to the model directly. prompt <- "Why does the planet Saturn have rings? Give a 100 word explanation." # Optionally, add a system role (a model persona) system.role <- "You specialize in tutoring astronomy for high school students." # Add the number of prompt repetitions. By default, this is set to 1. But it # may be useful to increase the number of repetitions to get a sense of how # consistent your output might be. reps <- 3 # Now you are ready to chat with the local model first_chat <- local_chat( model.path = model, # local model identifier or path prompts = prompt, system.role = system.role, reps = reps ) # Check how the output changes from iteration to iteration first_chat$response[[1]] # first iteration output first_chat$response[[2]] # second iteration output first_chat$response[[3]] # third iteration output #################################################################### ### Example 2: Send multiple prompts in a single function call ##### #################################################################### # You are able to send more than one prompt in a single call prompt1 <- "Why does the planet Saturn have rings? Give a 100 word explanation." prompt2 <- "Which planet is the hottest in our solar system? How do we know?" # Aggregate the prompts in a single object prompts <- c(prompt1, prompt2) # Ask the model the questions second_chat <- local_chat( model.path = model, # defined above prompts = prompts, # NEW system.role = system.role, # defined above reps = reps # defined above ) # The outputted data frame for this example will have 6 rows # since the number of prompts (2) times the number of reps (3) # gives a total of 6 generations. second_chat$response[second_chat$prompt == prompt1] # the responses from prompt 1 second_chat$response[second_chat$prompt == prompt2] # the responses from prompt 2 #################################################################### ### Example 3: Send multiple prompts with different System Roles ### #################################################################### # Perhaps your prompts are not related. In that case, you would probably want # to set a different system role for each prompt. prompt2 <- "What is the difference between eukaryotes and prokaryotes? Why?" # This new second prompt does not fit with the astronomy tutor persona. Let's # write a persona to match this new prompt topic. system.role2 <- "You specialize in tutoring biology for middle school students." # Now, let's combine the system roles into a single object system.role <- c(system.role, # defined earlier: the astronomy tutor system.role2 # defined above: the biology tutor ) # Aggregate our prompts in a single object again prompts <- c(prompt1, # Asks about Saturn's rings (needs astronomy tutor) prompt2 # Asks about types of cells (needs biology tutor) ) # Ask the model the questions third_chat <- local_chat( model.path = model, prompts = prompts, system.role = system.role, reps = reps ) # View the outputted data frame to examine the responses View(third_chat) ## End(Not run)
Local version of GENIE that uses locally installed embedding models for complete privacy and offline operation. Provides the same psychometric validation and quality assessment for user-supplied items as GENIE, but generates embeddings locally using transformer models instead of API calls.
local_GENIE( items, embedding.matrix = NULL, embedding.model = "bert-base-uncased", device = "auto", batch.size = 32, pooling.strategy = "mean", max.length = 512, EGA.model = NULL, EGA.algorithm = NULL, EGA.uni.method = NULL, uva.cut.off = 0.2, boot.iter = 500, ncores = NULL, embeddings.only = FALSE, run.overall = FALSE, all.together = FALSE, plot = TRUE, silently = FALSE )local_GENIE( items, embedding.matrix = NULL, embedding.model = "bert-base-uncased", device = "auto", batch.size = 32, pooling.strategy = "mean", max.length = 512, EGA.model = NULL, EGA.algorithm = NULL, EGA.uni.method = NULL, uva.cut.off = 0.2, boot.iter = 500, ncores = NULL, embeddings.only = FALSE, run.overall = FALSE, all.together = FALSE, plot = TRUE, silently = FALSE )
items |
Data frame with columns: statement, attribute, type, ID.
|
embedding.matrix |
Optional numeric matrix or data frame where:
|
embedding.model |
Local embedding model identifier or path. Compatible models:
|
device |
Device for embedding computation:
|
batch.size |
Number of items to process simultaneously (default: 32) |
pooling.strategy |
Method for pooling token embeddings:
|
max.length |
Maximum sequence length for tokenization (default: 512) |
EGA.model |
Network estimation model ("glasso", "TMFG", or NULL for auto-selection) |
EGA.algorithm |
Community detection algorithm ("walktrap", "leiden", "louvain"; NULL uses "walktrap") |
EGA.uni.method |
Unidimensionality assessment method ("louvain", "expand", "LE"; NULL uses "louvain") |
uva.cut.off |
Numeric in |
boot.iter |
A positive integer (optional, default: 500). Number of
bootstrap iterations used by |
ncores |
A positive integer or |
embeddings.only |
If |
run.overall |
A logical value (optional, default: FALSE). Controls whether a fit analysis
on the complete item pool is run post-reduction.
By default, only type-level reduction analyses are run (i.e., items of like-type go through
the pipeline independent of the other items in the pool). When this flag is |
all.together |
A logical value (optional, default: FALSE). Controls whether the reduction analysis
on the complete item pool is run.
By default, only type-level reduction analyses are run (i.e., items of like-type go through
the pipeline independent of the other items in the pool). When this flag is |
plot |
If |
silently |
If |
The structure of the return value depends on the function flags.
When embeddings.only = TRUE:
Returns a named list with embeddings (a numeric matrix with embedding dimensions in rows and items in columns, named by item ID) and items (the validated items data.frame).
Default behaviour (embeddings.only = FALSE, run.overall = FALSE,
all.together = FALSE):
Returns a named list with two top-level elements:
item_type_levelA named list where each name is an item type and each element is a per-type named list containing:
final_NMINumeric: normalized mutual information (NMI) of the final EGA solution after reduction.
initial_NMINumeric: NMI of the pre-reduction item pool, estimated on the full (dense) embeddings with the selected EGA model.
embeddingsList containing selected ("full" or "sparse", the embedding representation chosen for reduction), selection_log (a data.frame of the NMI for each candidate EGA model and representation), and full and sparse (embedding matrices for the final items).
UVAList from Unique Variable Analysis containing n_removed, n_sweeps, redundant_pairs (a data.frame of redundant item groups), and removal_log (a data.frame with one row per removed item, its retained redundant partner, and the wTO statistic).
bootEGAList containing post_uva_initial_boot and post_uva_final_boot (bootEGA objects before and after stability filtering), n_removed, items_removed (a data.frame of removed items with their item stability), and initial_boot_with_redundancies (a bootEGA object for the pre-reduction pool, used in stability_plot).
EGA.model_selectedCharacter: the chosen EGA model ("glasso" or "TMFG").
final_itemsdata.frame: final items after reduction (columns ID, statement, attribute, type, and EGA_com, the final EGA community).
final_EGAEGA.fit object (from EGAnet) for the final items.
initial_EGAEGA.fit object for the pre-reduction item pool.
start_NInteger: initial number of items in this type.
final_NInteger: final number of items in this type.
network_plotpatchwork object comparing networks before vs after reduction.
stability_plotpatchwork object showing networks and item stability before vs after reduction.
filtering_auditdata.frame with one row per removed item, giving the removal stage ("UVA", "EGA_selection", "bootEGA", or "final_EGA"), the reason, the filtering statistic and cutoff, redundancy partner(s), item stability, and pre-reduction network-loading diagnostics. Network loadings are descriptive only; they are not used as removal criteria.
reduction_summarydata.frame giving the number of items (N), NMI, n_removed_at_stage, and delta_NMI (change from initial_NMI) at each stage of the reduction.
filtering_auditdata.frame combining the per-type filtering_audit tables across all item types.
When run.overall = TRUE (and more than one item type is present):
the list additionally contains overall, a pooled post-reduction fit of all items
retained by the type-level reductions. No further items are removed at this level.
overall contains final_NMI, initial_NMI, embeddings (selected, full, and
sparse), EGA.model_selected, final_items, final_EGA, initial_EGA, start_N,
final_N, network_plot, stability_plot (always NULL), filtering_audit, and
reduction_summary. Pooled NMI values compare EGA communities against
type-by-attribute labels. The top-level filtering_audit then reports pooled (rather
than within-type) pre-reduction network-loading diagnostics.
When all.together = TRUE (and more than one item type is present):
results are not split by item type. The function returns a single per-type
named list (as described under item_type_level above) for the pooled analysis, in
which EGA communities are compared against type-by-attribute labels. Here,
final_items contains the original item rows (with their original type and
attribute labels) plus the EGA_com column.
On failure: if the reduction pipeline fails, the partial per-type results list is returned.
Golino, H. F., & Epskamp, S. (2017). Exploratory graph analysis: A new approach for estimating the number of dimensions in psychological research. PLOS ONE, 12(6), e0174035. doi:10.1371/journal.pone.0174035
Christensen, A. P., Garrido, L. E., & Golino, H. (2023). Unique variable analysis: A network psychometrics method to detect local dependence. Multivariate Behavioral Research, 58(6), 1165–1182. doi:10.1080/00273171.2023.2194606
Christensen, A. P., & Golino, H. (2021). Estimating the stability of psychological dimensions via bootstrap exploratory graph analysis: A Monte Carlo simulation and tutorial. Psych, 3(3), 479–500. doi:10.3390/psych3030032
Danon, L., Díaz-Guilera, A., Duch, J., & Arenas, A. (2005). Comparing community structure identification. Journal of Statistical Mechanics: Theory and Experiment, 2005(9), P09008. doi:10.1088/1742-5468/2005/09/P09008
Russell-Lasalandra, L. L., Christensen, A. P., & Golino, H. F. (2026). Generative psychometrics via AI-GENIE: Automatic item generation and validation with network-integrated evaluation. Behavior Research Methods, 58(8), 217. doi:10.3758/s13428-026-03082-1
## Not run: ################################################### #### Using GENIE with a Local Embedding Model #### ################################################### # First, ensure that your machine is configured to compute local generation install_local_llm_support() # Once ready, continue to run GENIE on your data frame # Specify item statements that you already have written statements <- c( "I find myself naturally initiating conversations with strangers at social gatherings.", "I enjoy creating a welcoming atmosphere for people I meet for the first time.", "I generally maintain a hopeful outlook, even when faced with challenges.", "I frequently find myself in a good mood, spreading cheer to those around me.", "I often have the drive to engage in exciting activities, even after a long day.", "I tend to tackle projects with enthusiasm and high energy from start to finish.", paste0( "I actively seek to include others in group activities, ", "making them feel part of the team." ), "I frequently reach out to new acquaintances to foster connections and friendships.", paste0( "I habitually focus on the silver lining in difficult ", "situations, maintaining an optimistic perspective." ), paste0( "I often express gratitude for the positive aspects of my ", "life, which enhances my overall mood." ), "I find joy in taking on new challenges that require a burst of energy and enthusiasm.", "I thrive in dynamic environments that keep me on my toes and invigorate my spirit.", "I take pleasure in introducing people to one another, acting as a social connector.", "I enjoy making others comfortable by engaging them in light-hearted conversation.", "I often set a positive tone in group settings with my upbeat demeanor.", "I approach each day with a sense of excitement and a positive mindset.", "I am drawn to fast-paced environments where I can express my high energy levels.", "I feel invigorated when working on multiple projects that demand my full attention.", "I take delight in meeting new people and quickly making them feel at ease.", paste0( "I find it rewarding to help shy or reserved individuals ", "become involved in group discussions." ), "I have a natural tendency to uplift others with my positive remarks and outlook.", paste0( "I find happiness in highlighting the successes of others, ", "contributing to a cheerful environment." ), "I eagerly immerse myself in activities that demand stamina and sustained energy.", "I often channel my vitality into hobbies and sports that require physical exertion.", "I feel rejuvenated when I bring people together to collaborate and share ideas.", "I often extend a genuine greeting to others, creating an inviting atmosphere.", "I regularly see challenges as opportunities for growth and learning.", "I commonly radiate positivity, influencing the mood of those around me.", "I approach mornings with anticipation and vigor, ready to embrace the day.", paste0( "I consistently infuse enthusiasm into group activities, ", "boosting collective energy levels." ), "I make an effort to connect with people by remembering details about their lives.", "I genuinely enjoy learning about people's diverse experiences and viewpoints.", "I have a habit of encouraging others to see the bright side of their situations.", "I believe in celebrating small victories, finding joy in daily accomplishments.", "I often find myself eager to start the day with ambitious plans and goals.", paste0( "I am known for sustaining high levels of energy during ", "extended work sessions or projects." ), "I make an effort to engage those around me in meaningful and enjoyable conversations.", "I often seek opportunities to bring people together, fostering a sense of community.", "I naturally inspire others with my optimistic outlook, even in uncertain times.", paste0( "I frequently look for the positive aspects in challenging ", "situations and share them with others." ), "I approach new experiences with an eagerness and fervor that motivates those around me.", "I thrive on maintaining high energy levels throughout demanding and fast-paced days.", paste0( "I take pleasure in initiating warm interactions in group ", "settings to make everyone comfortable." ), "I enjoy hosting gatherings that connect friends and encourage social bonding.", paste0( "I am skilled at turning setbacks into learning experiences ", "to maintain a positive outlook." ), "I always try to highlight the benefits in situations, enhancing a cheerful atmosphere.", "I find excitement in starting the day with a list of activities to energize my routine.", paste0( "I relish the challenge of keeping up with dynamic schedules ", "that require sustained energy." ), "I often find joy in making newcomers feel welcome and appreciated in group settings.", "I genuinely enjoy striking up conversations to learn more about the people I encounter.", "I have a knack for seeing potential in situations that others might overlook.", paste0( "I consistently try to uplift the mood in my surroundings ", "with hopeful and encouraging words." ), paste0( "I frequently harness my energy to inspire and motivate those ", "around me in team environments." ), paste0( "I often feel invigorated by challenges that require ", "sustained focus and dynamic thinking." ), "I often create environments where people feel encouraged to share their thoughts freely.", "I find it fulfilling to engage deeply with people, building lasting connections.", "I see potential in every day, believing it holds opportunities for something good.", "I actively focus on the pleasures of life, which naturally enhances my mood.", "I am invigorated by opportunities to engage in lively and spirited events.", "I tend to maintain momentum throughout the day, sustaining my energy levels.", paste0( "I frequently experience sudden shifts in my emotions even ", "when there is no apparent reason." ), paste0( "People often find it difficult to predict my emotional ", "reactions to different situations." ), "I often doubt my abilities and worry about whether I am meeting expectations.", "I frequently question my self-worth and tend to seek reassurance from others.", "I become annoyed easily over small inconveniences or delays.", paste0( "I often find myself feeling agitated or frustrated in ", "situations that don't bother most people." ), "My mood can change drastically over the course of a day, often without any clear reason.", "I tend to experience emotional highs and lows more intensely than those around me.", "I sometimes avoid taking on new challenges because I fear not being good enough.", paste0( "I often feel uncertain about my social standing and worry ", "about being accepted by others." ), "I find myself getting irritated quickly when things don't go my way.", "Minor annoyances often cause my patience to wear thin unusually fast.", "I frequently struggle to maintain a stable emotional state throughout the day.", "Unexpected events can cause me to experience drastic emotional swings.", "I often feel inadequate in comparison to others around me.", "I tend to second-guess my choices due to a lack of confidence in myself.", "I tend to become frustrated when things do not proceed as I have planned.", "I am prone to irritation when faced with unexpected changes to my routine.", paste0( "My emotional state is often unpredictable, shifting from ", "contentment to sadness with little warning." ), "People have commented that my emotions seem to fluctuate more than those of others.", "I frequently feel self-conscious about my achievements compared to those of my peers.", paste0( "I often worry excessively about making mistakes, even in ", "situations where it might be inconsequential." ), "Small disruptions in my daily routine can trigger strong feelings of annoyance.", "I find myself becoming irritated more quickly than others when under stress or pressure.", paste0( "I often find my emotional responses to be unpredictable, ", "feeling fine one moment and unsettled the next." ), "I experience strong emotions that can shift unexpectedly, often catching me off guard.", "I regularly feel uncertain about my ability to manage new responsibilities effectively.", "I often question my decisions, fearing they might not lead to the best outcomes.", paste0( "I frequently find myself reacting with impatience to ", "situations perceived as minor interruptions." ), "Even minor provocations can sometimes lead to an exaggerated sense of annoyance for me.", paste0( "My emotional state is often inconsistent, and I can feel ", "ecstatic or despondent within short timeframes." ), paste0( "I notice that my feelings can be quite volatile and intense, ", "affecting how I interact with others throughout the day." ), "I regularly doubt whether I am capable of achieving my personal or professional goals.", "I often seek validation from others to feel reassured about my self-worth.", paste0( "I am sensitive to disturbances and find my patience wearing ", "thin quickly when things aren't orderly." ), paste0( "I occasionally struggle to contain my annoyance over trivial ", "issues that disrupt my sense of calm." ), "I can go from feeling upbeat to being downcast without an obvious cause.", "My emotional responses can sometimes be unpredictable, shifting with little notice.", "I often feel the need for affirmation about my abilities from friends or colleagues.", "I tend to compare myself to others and feel uncertain about my achievements.", "I find myself easily bothered by noises or disturbances in my environment.", "I get easily flustered by situations that interrupt my planned activities.", paste0( "I find it challenging to maintain a consistent emotional ", "state, regardless of external situations." ), "My emotional reactions can be intense and differ significantly from moment to moment.", "I have a persistent fear of not measuring up to the expectations placed on me.", "I often feel anxious about others' perceptions of my capabilities and appearance.", "I am quick to express frustration at minor inconveniences in my daily routine.", paste0( "I find that small, unforeseen events often disrupt my sense ", "of calm and lead to irritation." ), paste0( "My emotional reactions can be strong and relentless, ", "impacting my behavior throughout the day." ), paste0( "I often find myself emotionally labile, with an inner ", "turbulence that others rarely perceive." ), "I frequently worry about my competence in areas where others seem confident.", paste0( "I have a tendency to second-guess myself and require ", "affirmation to feel reassured about my choices." ), "Small disruptions can ignite a lingering sense of agitation within me.", "I often catch myself feeling irritable even in relatively calm settings.", paste0( "I find myself swinging from happy to melancholic in a short ", "span of time, often surprising even myself." ), paste0( "Others often comment on how quickly my mood can change in ", "response to seemingly minor events." ), paste0( "I tend to feel apprehensive about presenting my opinions, ", "fearing they may be judged harshly." ), "I often require reassurance from peers to feel confident in my decisions and ideas.", "Interruptions during focused tasks often lead to an outpour of irritation from me.", "I struggle to keep my frustration in check when things do not unfold as expected." ) # Create the item type and attribute labels item.attributes <- c( rep(c("friendly", "positive", "energetic"), each = 2, times = 10), rep(c("moody", "insecure", "irritable"), each = 2, times = 10) ) item.types <- c( rep("extraversion", 60), rep("neuroticism", 60) ) # Build your data frame with the required columns: ID, statement, attribute, and type items_df <- data.frame( ID = rep(as.factor(1:length(statements))), statement = statements, attribute = item.attributes, type = item.types ) # Run GENIE with items you provide with the default local embedding model ("bert-base-uncased") example_reduction <- local_GENIE(items = items_df) # View the results View(example_reduction) ######################################################################################## ###### Or, Run local_GENIE with a locally-install Embedding Model of your Choice ####### ####################################################################################### # Provide the path to a compatible locally installed embedding model # Note that this package will not install the model for you, it should already be # installed and ready to go embedding.model <- "ADD YOUR PATH HERE" # Run GENIE using the Hugging Face Embedding model example_reduction_your_model <- local_GENIE(items = items_df, embedding.model = embedding.model) ## End(Not run)## Not run: ################################################### #### Using GENIE with a Local Embedding Model #### ################################################### # First, ensure that your machine is configured to compute local generation install_local_llm_support() # Once ready, continue to run GENIE on your data frame # Specify item statements that you already have written statements <- c( "I find myself naturally initiating conversations with strangers at social gatherings.", "I enjoy creating a welcoming atmosphere for people I meet for the first time.", "I generally maintain a hopeful outlook, even when faced with challenges.", "I frequently find myself in a good mood, spreading cheer to those around me.", "I often have the drive to engage in exciting activities, even after a long day.", "I tend to tackle projects with enthusiasm and high energy from start to finish.", paste0( "I actively seek to include others in group activities, ", "making them feel part of the team." ), "I frequently reach out to new acquaintances to foster connections and friendships.", paste0( "I habitually focus on the silver lining in difficult ", "situations, maintaining an optimistic perspective." ), paste0( "I often express gratitude for the positive aspects of my ", "life, which enhances my overall mood." ), "I find joy in taking on new challenges that require a burst of energy and enthusiasm.", "I thrive in dynamic environments that keep me on my toes and invigorate my spirit.", "I take pleasure in introducing people to one another, acting as a social connector.", "I enjoy making others comfortable by engaging them in light-hearted conversation.", "I often set a positive tone in group settings with my upbeat demeanor.", "I approach each day with a sense of excitement and a positive mindset.", "I am drawn to fast-paced environments where I can express my high energy levels.", "I feel invigorated when working on multiple projects that demand my full attention.", "I take delight in meeting new people and quickly making them feel at ease.", paste0( "I find it rewarding to help shy or reserved individuals ", "become involved in group discussions." ), "I have a natural tendency to uplift others with my positive remarks and outlook.", paste0( "I find happiness in highlighting the successes of others, ", "contributing to a cheerful environment." ), "I eagerly immerse myself in activities that demand stamina and sustained energy.", "I often channel my vitality into hobbies and sports that require physical exertion.", "I feel rejuvenated when I bring people together to collaborate and share ideas.", "I often extend a genuine greeting to others, creating an inviting atmosphere.", "I regularly see challenges as opportunities for growth and learning.", "I commonly radiate positivity, influencing the mood of those around me.", "I approach mornings with anticipation and vigor, ready to embrace the day.", paste0( "I consistently infuse enthusiasm into group activities, ", "boosting collective energy levels." ), "I make an effort to connect with people by remembering details about their lives.", "I genuinely enjoy learning about people's diverse experiences and viewpoints.", "I have a habit of encouraging others to see the bright side of their situations.", "I believe in celebrating small victories, finding joy in daily accomplishments.", "I often find myself eager to start the day with ambitious plans and goals.", paste0( "I am known for sustaining high levels of energy during ", "extended work sessions or projects." ), "I make an effort to engage those around me in meaningful and enjoyable conversations.", "I often seek opportunities to bring people together, fostering a sense of community.", "I naturally inspire others with my optimistic outlook, even in uncertain times.", paste0( "I frequently look for the positive aspects in challenging ", "situations and share them with others." ), "I approach new experiences with an eagerness and fervor that motivates those around me.", "I thrive on maintaining high energy levels throughout demanding and fast-paced days.", paste0( "I take pleasure in initiating warm interactions in group ", "settings to make everyone comfortable." ), "I enjoy hosting gatherings that connect friends and encourage social bonding.", paste0( "I am skilled at turning setbacks into learning experiences ", "to maintain a positive outlook." ), "I always try to highlight the benefits in situations, enhancing a cheerful atmosphere.", "I find excitement in starting the day with a list of activities to energize my routine.", paste0( "I relish the challenge of keeping up with dynamic schedules ", "that require sustained energy." ), "I often find joy in making newcomers feel welcome and appreciated in group settings.", "I genuinely enjoy striking up conversations to learn more about the people I encounter.", "I have a knack for seeing potential in situations that others might overlook.", paste0( "I consistently try to uplift the mood in my surroundings ", "with hopeful and encouraging words." ), paste0( "I frequently harness my energy to inspire and motivate those ", "around me in team environments." ), paste0( "I often feel invigorated by challenges that require ", "sustained focus and dynamic thinking." ), "I often create environments where people feel encouraged to share their thoughts freely.", "I find it fulfilling to engage deeply with people, building lasting connections.", "I see potential in every day, believing it holds opportunities for something good.", "I actively focus on the pleasures of life, which naturally enhances my mood.", "I am invigorated by opportunities to engage in lively and spirited events.", "I tend to maintain momentum throughout the day, sustaining my energy levels.", paste0( "I frequently experience sudden shifts in my emotions even ", "when there is no apparent reason." ), paste0( "People often find it difficult to predict my emotional ", "reactions to different situations." ), "I often doubt my abilities and worry about whether I am meeting expectations.", "I frequently question my self-worth and tend to seek reassurance from others.", "I become annoyed easily over small inconveniences or delays.", paste0( "I often find myself feeling agitated or frustrated in ", "situations that don't bother most people." ), "My mood can change drastically over the course of a day, often without any clear reason.", "I tend to experience emotional highs and lows more intensely than those around me.", "I sometimes avoid taking on new challenges because I fear not being good enough.", paste0( "I often feel uncertain about my social standing and worry ", "about being accepted by others." ), "I find myself getting irritated quickly when things don't go my way.", "Minor annoyances often cause my patience to wear thin unusually fast.", "I frequently struggle to maintain a stable emotional state throughout the day.", "Unexpected events can cause me to experience drastic emotional swings.", "I often feel inadequate in comparison to others around me.", "I tend to second-guess my choices due to a lack of confidence in myself.", "I tend to become frustrated when things do not proceed as I have planned.", "I am prone to irritation when faced with unexpected changes to my routine.", paste0( "My emotional state is often unpredictable, shifting from ", "contentment to sadness with little warning." ), "People have commented that my emotions seem to fluctuate more than those of others.", "I frequently feel self-conscious about my achievements compared to those of my peers.", paste0( "I often worry excessively about making mistakes, even in ", "situations where it might be inconsequential." ), "Small disruptions in my daily routine can trigger strong feelings of annoyance.", "I find myself becoming irritated more quickly than others when under stress or pressure.", paste0( "I often find my emotional responses to be unpredictable, ", "feeling fine one moment and unsettled the next." ), "I experience strong emotions that can shift unexpectedly, often catching me off guard.", "I regularly feel uncertain about my ability to manage new responsibilities effectively.", "I often question my decisions, fearing they might not lead to the best outcomes.", paste0( "I frequently find myself reacting with impatience to ", "situations perceived as minor interruptions." ), "Even minor provocations can sometimes lead to an exaggerated sense of annoyance for me.", paste0( "My emotional state is often inconsistent, and I can feel ", "ecstatic or despondent within short timeframes." ), paste0( "I notice that my feelings can be quite volatile and intense, ", "affecting how I interact with others throughout the day." ), "I regularly doubt whether I am capable of achieving my personal or professional goals.", "I often seek validation from others to feel reassured about my self-worth.", paste0( "I am sensitive to disturbances and find my patience wearing ", "thin quickly when things aren't orderly." ), paste0( "I occasionally struggle to contain my annoyance over trivial ", "issues that disrupt my sense of calm." ), "I can go from feeling upbeat to being downcast without an obvious cause.", "My emotional responses can sometimes be unpredictable, shifting with little notice.", "I often feel the need for affirmation about my abilities from friends or colleagues.", "I tend to compare myself to others and feel uncertain about my achievements.", "I find myself easily bothered by noises or disturbances in my environment.", "I get easily flustered by situations that interrupt my planned activities.", paste0( "I find it challenging to maintain a consistent emotional ", "state, regardless of external situations." ), "My emotional reactions can be intense and differ significantly from moment to moment.", "I have a persistent fear of not measuring up to the expectations placed on me.", "I often feel anxious about others' perceptions of my capabilities and appearance.", "I am quick to express frustration at minor inconveniences in my daily routine.", paste0( "I find that small, unforeseen events often disrupt my sense ", "of calm and lead to irritation." ), paste0( "My emotional reactions can be strong and relentless, ", "impacting my behavior throughout the day." ), paste0( "I often find myself emotionally labile, with an inner ", "turbulence that others rarely perceive." ), "I frequently worry about my competence in areas where others seem confident.", paste0( "I have a tendency to second-guess myself and require ", "affirmation to feel reassured about my choices." ), "Small disruptions can ignite a lingering sense of agitation within me.", "I often catch myself feeling irritable even in relatively calm settings.", paste0( "I find myself swinging from happy to melancholic in a short ", "span of time, often surprising even myself." ), paste0( "Others often comment on how quickly my mood can change in ", "response to seemingly minor events." ), paste0( "I tend to feel apprehensive about presenting my opinions, ", "fearing they may be judged harshly." ), "I often require reassurance from peers to feel confident in my decisions and ideas.", "Interruptions during focused tasks often lead to an outpour of irritation from me.", "I struggle to keep my frustration in check when things do not unfold as expected." ) # Create the item type and attribute labels item.attributes <- c( rep(c("friendly", "positive", "energetic"), each = 2, times = 10), rep(c("moody", "insecure", "irritable"), each = 2, times = 10) ) item.types <- c( rep("extraversion", 60), rep("neuroticism", 60) ) # Build your data frame with the required columns: ID, statement, attribute, and type items_df <- data.frame( ID = rep(as.factor(1:length(statements))), statement = statements, attribute = item.attributes, type = item.types ) # Run GENIE with items you provide with the default local embedding model ("bert-base-uncased") example_reduction <- local_GENIE(items = items_df) # View the results View(example_reduction) ######################################################################################## ###### Or, Run local_GENIE with a locally-install Embedding Model of your Choice ####### ####################################################################################### # Provide the path to a compatible locally installed embedding model # Note that this package will not install the model for you, it should already be # installed and ready to go embedding.model <- "ADD YOUR PATH HERE" # Run GENIE using the Hugging Face Embedding model example_reduction_your_model <- local_GENIE(items = items_df, embedding.model = embedding.model) ## End(Not run)
Returns diagnostic information about the AIGENIE Python environment, including paths, installation status, and installed packages. Useful for troubleshooting Python-related issues.
python_env_info()python_env_info()
A list with the following elements:
env_path |
Path to the virtual environment directory. |
python_path |
Path to the Python executable. |
env_exists |
Logical. Whether the environment directory exists. |
python_exists |
Logical. Whether the Python executable exists. |
initialized |
Logical. Whether Python has been initialized this session. |
uv_available |
Logical. Whether UV is installed and accessible. |
installed_packages |
Character vector of installed packages (if environment exists). |
reinstall_python_env to fix environment issues.
## Not run: # Check environment status info <- python_env_info() # Is the environment set up? info$env_exists # What packages are installed? cat(info$installed_packages, sep = "\n") # Is UV available? info$uv_available ## End(Not run)## Not run: # Check environment status info <- python_env_info() # Is the environment set up? info$env_exists # What packages are installed? cat(info$installed_packages, sep = "\n") # Is UV available? info$uv_available ## End(Not run)
Removes and recreates the Python virtual environment with all required dependencies. Use this function if you encounter Python-related errors, want to update Python packages, or need to change the environment configuration.
AIGENIE uses UV (https://docs.astral.sh/uv/) for fast, reliable Python environment management.
reinstall_python_env( include_huggingface = TRUE, include_local_llm = FALSE, gpu = FALSE )reinstall_python_env( include_huggingface = TRUE, include_local_llm = FALSE, gpu = FALSE )
include_huggingface |
Logical. Include HuggingFace packages (transformers,
sentence-transformers, torch). Required for local embeddings with HuggingFace
models. Default |
include_local_llm |
Logical. Include llama-cpp-python for running local
GGUF models with |
gpu |
Logical. Install GPU-enabled PyTorch. Requires CUDA-compatible
NVIDIA GPU and proper driver installation. Default |
Invisible TRUE on success.
python_env_info to check environment status,
install_gpu_support for GPU setup,
install_local_llm_support for local model setup.
## Not run: # Fix Python environment issues reinstall_python_env() # Reinstall with GPU support reinstall_python_env(gpu = TRUE) # Minimal install (API-only, no HuggingFace - faster) reinstall_python_env(include_huggingface = FALSE) # Full install with local LLM support reinstall_python_env(include_huggingface = TRUE, include_local_llm = TRUE) ## End(Not run)## Not run: # Fix Python environment issues reinstall_python_env() # Reinstall with GPU support reinstall_python_env(gpu = TRUE) # Minimal install (API-only, no HuggingFace - faster) reinstall_python_env(include_huggingface = FALSE) # Full install with local LLM support reinstall_python_env(include_huggingface = TRUE, include_local_llm = TRUE) ## End(Not run)
Configure your HuggingFace API token for accessing gated models like Google's EmbeddingGemma or other restricted models.
set_huggingface_token(token, save = TRUE)set_huggingface_token(token, save = TRUE)
token |
Character. Your HuggingFace API token from https://huggingface.co/settings/tokens. |
save |
Logical. If |
Some embedding models on HuggingFace require authentication:
google/embeddinggemma-300m
Other gated models
Before using these models, you must:
Create an account at https://huggingface.co
Accept the model's license on its model page
Generate an access token at https://huggingface.co/settings/tokens
Call this function with your token
Invisible TRUE on success.
## Not run: # Set token (saved permanently for future sessions) set_huggingface_token("hf_xxxxxxxxxxxxxxxxx") # Set token for this session only (not saved) set_huggingface_token("hf_xxxxxxxxxxxxxxxxx", save = FALSE) # Now you can use gated HuggingFace models results <- GENIE( items = my_items, embedding.model = "BAAI/bge-large-en-v1.5", hf.token = "hf_xxxxxxxxxxxxxxxxx" ) ## End(Not run)## Not run: # Set token (saved permanently for future sessions) set_huggingface_token("hf_xxxxxxxxxxxxxxxxx") # Set token for this session only (not saved) set_huggingface_token("hf_xxxxxxxxxxxxxxxxx", save = FALSE) # Now you can use gated HuggingFace models results <- GENIE( items = my_items, embedding.model = "BAAI/bge-large-en-v1.5", hf.token = "hf_xxxxxxxxxxxxxxxxx" ) ## End(Not run)