π Granite Guardian Context RelevanceΒΆ
metrics.rag.granite_guardian_context_relevance
type: MetricPipeline
main_score: granite_guardian_context_relevance
metric:
type: GraniteGuardianWMLMetric
main_score: granite_guardian_context_relevance
risk_name: context_relevance
preprocess_steps:
- type: Copy
field_to_field:
ground_truths: task_data/ground_truths
answer: task_data/answer
contexts: task_data/contexts
question: task_data/question
not_exist_do_nothing: True
- type: Copy
field_to_field:
prediction: task_data/question
not_exist_do_nothing: True
- type: Set
fields:
prediction: 0.0
references:
- 0.0
[source]Explanation about CopyΒΆ
Copies values from specified fields to specified fields.
- Args (of parent class):
field_to_field (Union[List[List], Dict[str, str]]): A list of lists, where each sublist contains the source field and the destination field, or a dictionary mapping source fields to destination fields.
- Examples:
An input instance {βaβ: 2, βbβ: 3}, when processed by
Copy(field_to_field={"a": "b"})would yield {βaβ: 2, βbβ: 2}, and when processed byCopy(field_to_field={"a": "c"})would yield {βaβ: 2, βbβ: 3, βcβ: 2}with field names containing / , we can also copy inside the field:
Copy(field="a/0",to_field="a")would process instance {βaβ: [1, 3]} into {βaβ: 1}
Explanation about GraniteGuardianWMLMetricΒΆ
Return metric for different kinds of βriskβ from the Granite-3.0 Guardian model.
Explanation about SetΒΆ
Sets specified fields in each instance, in a given stream or all streams (default), with specified values. If fields exist, updates them, if do not exist β adds them.
- Args:
fields (Dict[str, object]): The fields to add to each instance. Use β/β to access inner fields
use_deepcopy (bool) : Deep copy the input value to avoid later modifications
- Examples:
# Set a value of a list consisting of βpositiveβ and βnegativeβ do field βclassesβ to each and every instance of all streams
Set(fields={"classes": ["positive","negatives"]})# In each and every instance of all streams, field βspanβ is to become a dictionary containing a field βstartβ, in which the value 0 is to be set
Set(fields={"span/start": 0}# In all instances of stream βtrainβ only, Set field βclassesβ to have the value of a list consisting of βpositiveβ and βnegativeβ
Set(fields={"classes": ["positive","negatives"], apply_to_stream=["train"]})# Set field βclassesβ to have the value of a given list, preventing modification of original list from changing the instance.
Set(fields={"classes": alist}), use_deepcopy=True)if now alist is modified, still the instances remain intact.
Read more about catalog usage here.