Llama Guard
any_guardrail.guardrails.llama_guard.llama_guard
LlamaGuard
Bases: HuggingFace
Wrapper class for Llama Guard 3 & 4 implementations.
For more information about the implementations about either off topic model, please see the below model cards:
- Meta Llama Guard 3 Docs
- HuggingFace Llama Guard 3 Docs
- Meta Llama Guard 4 Docs
- HuggingFace Llama Guard 4 Docs
Source code in src/any_guardrail/guardrails/llama_guard/llama_guard.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
__init__(model_id=None)
Llama guard model. Either Llama Guard 3 or 4 depending on the model id. Defaults to Llama Guard 3.
Source code in src/any_guardrail/guardrails/llama_guard/llama_guard.py
validate(input_text, output_text=None, **kwargs)
Judge whether the input text or the input text, output text pair are unsafe based on the Llama taxonomy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_text
|
str
|
the prior text before hitting a system or model. |
required |
output_text
|
str | None
|
the succeeding text after hitting a system or model. |
None
|
**kwargs
|
Any
|
additional keyword arguments, specifically supporting 'excluded_category_keys' and 'categories'. Please see Llama Guard documentation for more details. |
{}
|
Returns:
Type | Description |
---|---|
GuardrailOutput
|
Provides an explanation that can be parsed to see whether the text is safe or not. |