@@ -162,104 +162,6 @@ def load_feedback_dataset_from_huggingface(repo_id: str, split: str = "train", s
162
162
163
163
dataset .push_to_argilla (name = repo_id .split ("/" )[- 1 ])
164
164
165
- @staticmethod
166
- def build_error_analysis_record (
167
- row : pd .Series , legacy : bool = False
168
- ) -> Union [rg .FeedbackRecord , rg .TextClassificationRecord ]:
169
- fields = {
170
- "user-message-1" : row ["HumanMessage1" ],
171
- "llm-output" : row ["llm_output" ]
172
- if not row ["llm_output" ].__contains__ ("```json" )
173
- else row ["llm_output" ].replace ("'" , '"' ),
174
- "ai-message" : (f"```json\n { row ['AIMessage' ]} \n ```" if not legacy else row ["AIMessage" ]).replace ("'" , '"' ),
175
- "function-message" : (f"```json\n { row ['FunctionMessage' ]} \n ```" if not legacy else row ["AIMessage" ]).replace (
176
- "'" , '"'
177
- ),
178
- "system-message" : "You are an AI assistant name ACME" ,
179
- "langsmith-url" : f"https://smith.langchain.com/o/{ row ['parent_id' ]} " ,
180
- }
181
- metadata = {
182
- "correctness-langsmith" : row ["correctness_langsmith" ],
183
- "model-name" : row ["model_name" ],
184
- "temperature" : row ["temperature" ],
185
- "max-tokens" : int (row ["max_tokens" ]),
186
- "cpu-user" : row ["cpu_time_user" ],
187
- "cpu-system" : row ["cpu_time_system" ],
188
- "library-version" : row ["library_version" ],
189
- }
190
-
191
- if legacy :
192
- return rg .TextClassificationRecord (
193
- inputs = fields , metadata = metadata , vectors = eval (row ["vectors" ]), multi_label = True
194
- )
195
- return rg .FeedbackRecord (fields = fields , metadata = metadata )
196
-
197
- @staticmethod
198
- def load_error_analysis (with_metadata_property_options : bool = True ):
199
- print ("Loading Error Analysis dataset as a `FeedbackDataset` (Alpha)" )
200
- df = pd .read_csv ("https://raw.githubusercontent.com/argilla-io/dataset_examples/main/synthetic_data_v2.csv" )
201
-
202
- fields = [
203
- rg .TextField (name = "user-message-1" , use_markdown = True ),
204
- rg .TextField (name = "llm-output" , use_markdown = True ),
205
- rg .TextField (name = "ai-message" , use_markdown = True , required = False ),
206
- rg .TextField (name = "function-message" , use_markdown = True , required = False ),
207
- rg .TextField (name = "system-message" , use_markdown = True , required = False ),
208
- rg .TextField (name = "langsmith-url" , use_markdown = True , required = False ),
209
- ]
210
-
211
- questions = [
212
- rg .MultiLabelQuestion (
213
- name = "issue" ,
214
- title = "Please categorize the record:" ,
215
- labels = ["follow-up needed" , "reviewed" , "no-repro" , "not-helpful" , "empty-response" , "critical" ],
216
- ),
217
- rg .TextQuestion (name = "note" , title = "Leave a note to describe the issue:" , required = False ),
218
- ]
219
-
220
- dataset_name = "error-analysis-with-feedback"
221
-
222
- if with_metadata_property_options :
223
- metadata = [
224
- rg .TermsMetadataProperty (
225
- name = "correctness-langsmith" , values = df .correctness_langsmith .unique ().tolist ()
226
- ),
227
- rg .TermsMetadataProperty (name = "model-name" , values = df .model_name .unique ().tolist ()),
228
- rg .FloatMetadataProperty (name = "temperature" , min = df .temperature .min (), max = df .temperature .max ()),
229
- rg .FloatMetadataProperty (name = "cpu-user" , min = df .cpu_time_user .min (), max = df .cpu_time_user .max ()),
230
- rg .FloatMetadataProperty (name = "cpu-system" , min = df .cpu_time_system .min (), max = df .cpu_time_system .max ()),
231
- rg .TermsMetadataProperty (name = "library-version" , values = df .library_version .unique ().tolist ()),
232
- ]
233
- else :
234
- dataset_name += "-no-settings"
235
-
236
- metadata = [
237
- rg .TermsMetadataProperty (name = "correctness-langsmith" ),
238
- rg .TermsMetadataProperty (name = "model-name" ),
239
- rg .FloatMetadataProperty (name = "temperature" ),
240
- rg .FloatMetadataProperty (name = "cpu-user" ),
241
- rg .FloatMetadataProperty (name = "cpu-system" ),
242
- rg .TermsMetadataProperty (name = "library-version" ),
243
- ]
244
-
245
- dataset = rg .FeedbackDataset (fields = fields , questions = questions , metadata_properties = metadata )
246
- dataset .add_records (records = [LoadDatasets .build_error_analysis_record (row ) for _ , row in df .iterrows ()])
247
- dataset .push_to_argilla (name = dataset_name )
248
-
249
- @staticmethod
250
- def load_error_analysis_textcat_version ():
251
- print ("Loading Error Analysis dataset as a `DatasetForTextClassification`" )
252
- df = pd .read_csv (
253
- "https://raw.githubusercontent.com/argilla-io/dataset_examples/main/synthetic_data_v2_with_vectors.csv"
254
- )
255
-
256
- labels = ["follow-up needed" , "reviewed" , "no-repro" , "not-helpful" , "empty-response" , "critical" ]
257
- settings = rg .TextClassificationSettings (label_schema = labels )
258
- rg .configure_dataset_settings (name = "error-analysis-with-text-classification" , settings = settings )
259
-
260
- records = [LoadDatasets .build_error_analysis_record (row , legacy = True ) for _ , row in df .iterrows ()]
261
- rg .log (name = "error-analysis-with-text-classification" , records = records , batch_size = 25 )
262
-
263
165
264
166
if __name__ == "__main__" :
265
167
API_KEY = sys .argv [1 ]
@@ -274,9 +176,6 @@ def load_error_analysis_textcat_version():
274
176
response = requests .get ("http://0.0.0.0:6900" )
275
177
if response .status_code == 200 :
276
178
ld = LoadDatasets (API_KEY )
277
- ld .load_error_analysis (with_metadata_property_options = False )
278
- ld .load_error_analysis ()
279
- ld .load_error_analysis_textcat_version ()
280
179
ld .load_feedback_dataset_from_huggingface (
281
180
repo_id = "argilla/databricks-dolly-15k-curated-en" , split = "train" , samples = 100
282
181
)
@@ -296,6 +195,9 @@ def load_error_analysis_textcat_version():
296
195
ld .load_feedback_dataset_from_huggingface (
297
196
repo_id = "argilla/oasst_response_comparison" , split = "train" , samples = 100
298
197
)
198
+ ld .load_feedback_dataset_from_huggingface (
199
+ repo_id = "argilla/text-descriptives-metadata" , split = "train" , samples = 100
200
+ )
299
201
except requests .exceptions .ConnectionError :
300
202
pass
301
203
except Exception as e :
0 commit comments