Skip to contents

Grounding checks validate citation identifiers deterministically and may call an optional validator for unsupported claims or contradictions. Source support is evidence linkage; it does not prove that a source is true.

Usage

grounding_policy(
  require_citations = TRUE,
  citation_pattern = "\\[source:([A-Za-z0-9_.:-]+)\\]",
  validator = NULL,
  unsupported_action = c("block", "redact"),
  contradiction_action = c("block", "redact"),
  show_stats = FALSE
)

Arguments

require_citations

Whether at least one citation is required when sources are available.

citation_pattern

Regular expression with the citation identifier in capture group one.

validator

Optional function receiving (text, source_ids) and returning a list with unsupported_claims and/or contradictions.

unsupported_action

Action for absent or unsupported citations.

contradiction_action

Action for contradiction flags.

show_stats

Show construction time and available usage metrics.

Value

A shieldr_grounding_policy object.

Examples

grounding <- grounding_policy()
scan_grounding("Answer [source:doc-1]", "doc-1", grounding)
#> llmshieldr report
#> action: allow
#> risk_score: 0.000
#> findings: 0