Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1f2a1b6
docs: initial Guardian documentation migration from deprecated Guardi…
planetf1 Apr 24, 2026
5c23088
docs: address review findings on Guardian migration PR
planetf1 Apr 24, 2026
9fce602
docs(metrics): mark GuardianCheck deprecated and document Intrinsics …
planetf1 Apr 24, 2026
0da3c0c
fix: address review findings from PR #935 code review
planetf1 May 1, 2026
2029b31
fix: delete deprecated GuardianCheck example files
planetf1 May 1, 2026
fce3854
fix: address second-pass review findings
planetf1 May 1, 2026
578c50f
docs: bump Guardian doc examples from granite-4.0-micro to granite-4.…
planetf1 May 5, 2026
81ce10b
docs: add canonical URL to safety-guardrails page
planetf1 May 5, 2026
bbd8743
docs(safety): fix examples that didn't match granite-4.1-3b behaviour
planetf1 May 5, 2026
1953372
docs: bump prose docs to granite-4.1-3b (incl. context_relevance)
planetf1 May 5, 2026
852891b
docs(safety): note OpenAI+GraniteSwitch alternative to LocalHFBackend
planetf1 May 13, 2026
97bc2f2
docs(safety): migrate target_role → scoring_schema after #1037
planetf1 May 19, 2026
8ca33f7
docs: address review WARNINGs — dead link and missing [hf] extra
planetf1 May 19, 2026
ebacaf4
docs: address review suggestions and fold in 2 follow-ups
planetf1 May 19, 2026
a6994c0
docs(safety): add Limitations section for Guardian Intrinsics gaps
planetf1 May 19, 2026
aafd5b1
docs(safety): correct "Full example" claim about guardian_core.py
planetf1 May 19, 2026
cae3b14
docs(safety): remove deprecated GuardianCheck docs and clean up revie…
planetf1 May 26, 2026
6f978b6
docs(safety): fix dead link in Limitations section after README deletion
planetf1 May 26, 2026
3b13315
docs(safety): address psschwei review comments on PR #935
planetf1 May 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Intrinsics are specialized LoRA adapters that add task-specific capabilities (RA
| `rag` | `rewrite_question(question, context, backend)` | Rewrite question into a retrieval query |
| `rag` | `clarify_query(question, documents, context, backend)` | Generate clarification or return "CLEAR" |
| `rag` | `find_citations(response, documents, context, backend)` | Document sentences supporting the response |
| `rag` | `check_context_relevance(question, document, context, backend)` | Whether a document is relevant (0–1); only supported for granite-4.0, not granite-4.1 |
| `rag` | `check_context_relevance(question, document, context, backend)` | Whether a document is relevant; returns a string label (e.g. `'relevant'`, `'partially relevant'`, `'irrelevant'`). **Granite 4.0 only — no adapter for Granite 4.1.** Use `ibm-granite/granite-4.0-micro` as the backend. |
| `rag` | `flag_hallucinated_content(response, documents, context, backend)` | Flag potentially hallucinated sentences |

```python
Expand Down
3 changes: 2 additions & 1 deletion docs/CONTRIBUTING_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ Terms that **must** be linked on first use wherever they appear in guide pages (
| `ReAct` | `#react` |
| `RichDocument` | `#richdocument` |
| `LiteLLM` / `LiteLLMBackend` | `#litellm--litellmbackend` |
| `GuardianCheck` / `GuardianRisk` | `#guardiancheck` |
| `guardian_check()` / `CRITERIA_BANK` | `#guardian_check` / `#criteria_bank` |
| `GuardianCheck` / `GuardianRisk` *(deprecated)* | `#guardiancheck` / `#guardianrisk` |
| `m decompose` | `#m-decompose` |

Linking within the **glossary page itself** is not required (the glossary is the definition source).
Expand Down
28 changes: 19 additions & 9 deletions docs/docs/advanced/intrinsics.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Set up the backend once and reuse it across intrinsic calls:
# Returns: LocalHFBackend
from mellea.backends.huggingface import LocalHFBackend

backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
backend = LocalHFBackend(model_id="ibm-granite/granite-4.1-3b")
```

Or, with a Granite Switch model via the OpenAI backend:
Expand Down Expand Up @@ -62,7 +62,7 @@ from mellea.stdlib.components import Document, Message
from mellea.stdlib.components.intrinsic import rag
from mellea.stdlib.context import ChatContext

backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
backend = LocalHFBackend(model_id="ibm-granite/granite-4.1-3b")
context = ChatContext().add(Message("assistant", "Hello! How can I help you?"))
question = "What is the square root of 4?"

Expand All @@ -79,12 +79,13 @@ Assess whether a document is relevant to a question:

```python
# Requires: mellea[hf]
# Returns: float
# Returns: str
from mellea.backends.huggingface import LocalHFBackend
from mellea.stdlib.components import Document
from mellea.stdlib.components.intrinsic import rag
from mellea.stdlib.context import ChatContext

# NOTE: no context_relevance adapter for Granite 4.1 — use granite-4.0-micro
backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
context = ChatContext()
question = "Who is the CEO of Microsoft?"
Expand All @@ -94,7 +95,7 @@ document = Document(
)

result = rag.check_context_relevance(question, document, context, backend)
print(result) # False — the document does not mention the CEO
print(result) # 'partially relevant' — doc is about Microsoft but not its CEO
```

## Hallucination detection
Expand All @@ -109,7 +110,7 @@ from mellea.stdlib.components import Document, Message
from mellea.stdlib.components.intrinsic import rag
from mellea.stdlib.context import ChatContext

backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
backend = LocalHFBackend(model_id="ibm-granite/granite-4.1-3b")
context = (
ChatContext()
.add(Message("assistant", "Hello! How can I help you?"))
Expand Down Expand Up @@ -138,7 +139,7 @@ from mellea.stdlib.components import Document, Message
from mellea.stdlib.components.intrinsic import rag
from mellea.stdlib.context import ChatContext

backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
backend = LocalHFBackend(model_id="ibm-granite/granite-4.1-3b")
context = ChatContext().add(Message("user", "Who attended the meeting?"))
documents = [
Document("Meeting attendees: Alice, Bob, Carol."),
Expand All @@ -163,7 +164,7 @@ from mellea.stdlib.components import Message
from mellea.stdlib.components.intrinsic import rag
from mellea.stdlib.context import ChatContext

backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
backend = LocalHFBackend(model_id="ibm-granite/granite-4.1-3b")
context = (
ChatContext()
.add(Message("assistant", "Welcome to pet questions!"))
Expand All @@ -190,7 +191,7 @@ from mellea.stdlib.components import Document, Message
from mellea.stdlib.components.intrinsic import rag
from mellea.stdlib.context import ChatContext

backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
backend = LocalHFBackend(model_id="ibm-granite/granite-4.1-3b")
context = ChatContext().add(
Message("user", "How did Murdoch expand in Australia versus New Zealand?")
)
Expand Down Expand Up @@ -223,7 +224,7 @@ from mellea.backends.huggingface import LocalHFBackend
from mellea.stdlib.components import Intrinsic, Message
from mellea.stdlib.context import ChatContext

backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
backend = LocalHFBackend(model_id="ibm-granite/granite-4.1-3b")

# Register an adapter by task name
req_adapter = CustomIntrinsicAdapter(
Expand Down Expand Up @@ -251,3 +252,12 @@ The `Intrinsic` component loads aLoRA adapters (falling back to LoRA) by task na
For OpenAI backends with Granite Switch, adapters are loaded from the model's
HuggingFace repository configuration instead of the intrinsic catalog.
Output format is task-specific — `requirement-check` returns a likelihood score.

---

## Guardian Intrinsics

Safety and factuality checks use a separate set of Guardian-specific intrinsics:
`guardian_check()`, `policy_guardrails()`, `factuality_detection()`, and
`factuality_correction()`. These are documented in the
[Safety Guardrails](../how-to/safety-guardrails) how-to guide.
173 changes: 0 additions & 173 deletions docs/docs/advanced/security-and-taint-tracking.md

This file was deleted.

6 changes: 3 additions & 3 deletions docs/docs/concepts/architecture-vs-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ orchestrator:
with [`ChatContext`](../reference/glossary#chatcontext) and the `@tool` decorator. See
[Tools and Agents](../how-to/tools-and-agents).
- **Guarded agents** — combine the ReACT pattern with `requirements` and
`GuardianCheck` to enforce safety constraints at every step. See
[Security and Taint Tracking](../advanced/security-and-taint-tracking).
[Guardian Intrinsics](../how-to/safety-guardrails) to enforce safety constraints
at every step.
- **Structured outputs** — use `@generative` with Pydantic models or `Literal` types
to enforce type-safe structured output at each step. See
[Generative Functions](../how-to/generative-functions).
Expand Down Expand Up @@ -213,4 +213,4 @@ tools or steps.
---

**See also:** [Tools and Agents](../how-to/tools-and-agents) |
[Security and Taint Tracking](../advanced/security-and-taint-tracking)
[Safety Guardrails](../how-to/safety-guardrails)
2 changes: 1 addition & 1 deletion docs/docs/concepts/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1049,4 +1049,4 @@ from mellea.plugins import (

---

**See also:** [Glossary](../reference/glossary), [Tools and Agents](../how-to/tools-and-agents), [Security and Taint Tracking](../advanced/security-and-taint-tracking), [OpenTelemetry Tracing](../observability/tracing)
**See also:** [Glossary](../reference/glossary), [Tools and Agents](../how-to/tools-and-agents), [Safety Guardrails](../how-to/safety-guardrails), [OpenTelemetry Tracing](../observability/tracing)
10 changes: 5 additions & 5 deletions docs/docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"how-to/configure-model-options",
"how-to/use-images-and-vision",
"how-to/build-a-rag-pipeline",
"how-to/safety-guardrails",
Comment thread
planetf1 marked this conversation as resolved.
"how-to/refactor-prompts-with-cli",
"how-to/unit-test-generative-code",
"how-to/handling-exceptions"
Expand Down Expand Up @@ -115,7 +116,6 @@
"advanced/lora-and-alora-adapters",
"advanced/prefix-caching-and-kv-blocks",
"advanced/inference-time-scaling",
"advanced/security-and-taint-tracking",
"advanced/mellea-core-internals",
"advanced/template-formatting",
"advanced/custom-components"
Expand Down Expand Up @@ -484,10 +484,6 @@
"source": "/integrations/langchain-and-smolagents",
"destination": "/integrations/langchain"
},
{
"source": "/how-to/safety-guardrails",
"destination": "/advanced/security-and-taint-tracking"
},
{
"source": "/dev/constrained-decoding",
"destination": "/advanced/mellea-core-internals"
Expand Down Expand Up @@ -631,6 +627,10 @@
{
"source": "/guide/m-decompose",
"destination": "/how-to/m-decompose"
},
{
"source": "/advanced/security-and-taint-tracking",
"destination": "/how-to/safety-guardrails"
}
]
}
5 changes: 3 additions & 2 deletions docs/docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ to run.

| Category | What it shows |
| -------- | ------------- |
| `safety/` | `GuardianCheck` for harm, jailbreak, profanity, social bias, violence, and groundedness; shared backend pattern |
| `intrinsics/` | [Guardian Intrinsics](../how-to/safety-guardrails): `guardian_check()` for harm, jailbreak, social bias, groundedness; `policy_guardrails()`; `factuality_detection()` / `factuality_correction()` |
| `safety/` | *(Examples removed — see [Guardian how-to guide](../how-to/safety-guardrails) for the current API. The `RepairTemplateStrategy` gap is tracked in [#1071](https://github.com/generative-computing/mellea/issues/1071).)* |

### Integration and deployment

Expand All @@ -79,7 +80,7 @@ to run.
| Category | What it shows |
| -------- | ------------- |
| `aLora/` | Training aLoRA adapters for fast constraint checking; performance optimisation |
| `intrinsics/` | Answer relevance, hallucination detection, citation validation, context relevance — specialised adapter-backed checks |
| `intrinsics/` | *(Non-Guardian)* Answer relevance, hallucination detection, citation validation, context relevance — specialised adapter-backed checks. For Guardian safety functions see [Safety and validation](#safety-and-validation) above |
| `granite-switch/` | Running intrinsics via OpenAI backend with Granite Switch embedded adapters |
| `sofai/` | Two-tier sampling: fast-model iteration with escalation to a slow model; cost optimisation |

Expand Down
Loading
Loading