rg.Suggestion
¶
Class for interacting with Argilla Suggestions of records. Suggestions are typically created by a model prediction, unlike a Response
which is typically created by a user in the UI or consumed from a data source as a label.
Usage Examples¶
Adding records with suggestions¶
Suggestions can be added to a record directly or via a dictionary structure. The following examples demonstrate how to add suggestions to a record object and how to access suggestions from a record object:
Add a response from a dictionary where key is the question name and value is the response:
dataset.records.log(
[
{
"text": "Hello World, how are you?",
"label": "negative", # this will be used as a suggestion
},
]
)
If your data contains scores for suggestions you can add them as well via the mapping
parameter. The following example demonstrates how to add a suggestion with a score to a record object:
dataset.records.log(
[
{
"prompt": "Hello World, how are you?",
"label": "negative", # this will be used as a suggestion
"score": 0.9, # this will be used as the suggestion score
"model": "model_name", # this will be used as the suggestion agent
},
],
mapping={
"score": "label.suggestion.score",
"model": "label.suggestion.agent",
}, # `label` is the question name in the dataset settings
)
Or, instantiate the Record
and related Suggestions
objects directly, like this:
dataset.records.log(
[
rg.Record(
fields={"text": "Hello World, how are you?"},
suggestions=[rg.Suggestion("negative", "label", score=0.9, agent="model_name")],
)
]
)
Iterating over records with suggestions¶
Just like responses, suggestions can be accessed from a Record
via their question name as an attribute of the record. So if a question is named label
, the suggestion can be accessed as record.label
. The following example demonstrates how to access suggestions from a record object:
Class Reference¶
rg.Suggestion
¶
Bases: Resource
Class for interacting with Argilla Suggestions. Suggestions are typically model predictions for records. Suggestions are rendered in the user interfaces as 'hints' or 'suggestions' for the user to review and accept or reject.
Attributes:
Name | Type | Description |
---|---|---|
value |
str
|
The value of the suggestion.add() |
question_name |
str
|
The name of the question that the suggestion is for. |
type |
str
|
The type of suggestion, either 'model' or 'human'. |
score |
float
|
The score of the suggestion. For example, the probability of the model prediction. |
agent |
str
|
The agent that created the suggestion. For example, the model name. |
question_id |
UUID
|
The ID of the question that the suggestion is for. |
Source code in src/argilla_sdk/suggestions.py
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
agent: Optional[str]
property
writable
¶
The agent that created the suggestion.
question_id: Optional[UUID]
property
writable
¶
The ID of the question that the suggestion is for.
question_name: Optional[str]
property
writable
¶
The name of the question that the suggestion is for.
score: Optional[Union[float, List[float]]]
property
writable
¶
The score of the suggestion.
type: Optional[Literal['model', 'human']]
property
¶
The type of suggestion, either 'model' or 'human'.
value: Any
property
¶
The value of the suggestion.