Skip to content

Commit 7657524

Browse files
ovalle15ovalle15
andauthored
SN-87 (Include additional annotations for LLM notebook) (#1319)
Co-authored-by: ovalle15 <[email protected]>
1 parent f16da35 commit 7657524

File tree

6 files changed

+1968
-790
lines changed

6 files changed

+1968
-790
lines changed

examples/annotation_import/conversational.ipynb

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@
140140
" )\n",
141141
")\n",
142142
"\n",
143-
"ner_annotation_ndjson = { \n",
143+
"ner_annotation_ndjson = {\n",
144144
" \"name\": \"ner\",\n",
145-
" \"location\": { \n",
146-
" \"start\": 0, \n",
147-
" \"end\": 8 \n",
145+
" \"location\": {\n",
146+
" \"start\": 0,\n",
147+
" \"end\": 8\n",
148148
" },\n",
149149
" \"messageId\": \"4\"\n",
150150
" }"
@@ -178,15 +178,15 @@
178178
{
179179
"metadata": {},
180180
"source": [
181-
"##### Checklist Classification ####### \n",
181+
"##### Checklist Classification #######\n",
182182
"\n",
183183
"checklist_annotation= lb_types.ClassificationAnnotation(\n",
184184
" name=\"checklist_convo\", # must match your ontology feature\"s name\n",
185185
" value=lb_types.Checklist(\n",
186186
" answer = [\n",
187187
" lb_types.ClassificationAnswer(\n",
188188
" name = \"first_checklist_answer\"\n",
189-
" ), \n",
189+
" ),\n",
190190
" lb_types.ClassificationAnswer(\n",
191191
" name = \"second_checklist_answer\"\n",
192192
" )\n",
@@ -215,7 +215,7 @@
215215
"######## Radio Classification ######\n",
216216
"\n",
217217
"radio_annotation = lb_types.ClassificationAnnotation(\n",
218-
" name=\"radio_convo\", \n",
218+
" name=\"radio_convo\",\n",
219219
" value=lb_types.Radio(answer = lb_types.ClassificationAnswer(name = \"first_radio_answer\")),\n",
220220
" message_id=\"0\"\n",
221221
")\n",
@@ -264,12 +264,12 @@
264264
" \"name\": \"first_checklist_answer\",\n",
265265
" \"classifications\" : [\n",
266266
" {\n",
267-
" \"name\": \"sub_checklist_question\", \n",
267+
" \"name\": \"sub_checklist_question\",\n",
268268
" \"answer\": {\n",
269269
" \"name\": \"first_sub_checklist_answer\"\n",
270270
" }\n",
271-
" } \n",
272-
" ] \n",
271+
" }\n",
272+
" ]\n",
273273
" }]\n",
274274
"}\n",
275275
"# Global\n",
@@ -360,27 +360,27 @@
360360
"metadata": {},
361361
"source": [
362362
"ontology_builder = lb.OntologyBuilder(\n",
363-
" tools=[ \n",
363+
" tools=[\n",
364364
" lb.Tool(tool=lb.Tool.Type.NER,name=\"ner\"),\n",
365-
" ], \n",
366-
" classifications=[ \n",
367-
" lb.Classification( \n",
365+
" ],\n",
366+
" classifications=[\n",
367+
" lb.Classification(\n",
368368
" class_type=lb.Classification.Type.TEXT,\n",
369-
" scope=lb.Classification.Scope.INDEX, \n",
370-
" name=\"text_convo\"), \n",
371-
" lb.Classification( \n",
372-
" class_type=lb.Classification.Type.CHECKLIST, \n",
373-
" scope=lb.Classification.Scope.INDEX, \n",
374-
" name=\"checklist_convo\", \n",
369+
" scope=lb.Classification.Scope.INDEX,\n",
370+
" name=\"text_convo\"),\n",
371+
" lb.Classification(\n",
372+
" class_type=lb.Classification.Type.CHECKLIST,\n",
373+
" scope=lb.Classification.Scope.INDEX,\n",
374+
" name=\"checklist_convo\",\n",
375375
" options=[\n",
376376
" lb.Option(value=\"first_checklist_answer\"),\n",
377-
" lb.Option(value=\"second_checklist_answer\") \n",
377+
" lb.Option(value=\"second_checklist_answer\")\n",
378378
" ]\n",
379-
" ), \n",
380-
" lb.Classification( \n",
381-
" class_type=lb.Classification.Type.RADIO, \n",
382-
" name=\"radio_convo\", \n",
383-
" scope=lb.Classification.Scope.INDEX, \n",
379+
" ),\n",
380+
" lb.Classification(\n",
381+
" class_type=lb.Classification.Type.RADIO,\n",
382+
" name=\"radio_convo\",\n",
383+
" scope=lb.Classification.Scope.INDEX,\n",
384384
" options=[\n",
385385
" lb.Option(value=\"first_radio_answer\"),\n",
386386
" lb.Option(value=\"second_radio_answer\")\n",
@@ -395,7 +395,7 @@
395395
" options=[\n",
396396
" lb.Classification(\n",
397397
" class_type=lb.Classification.Type.CHECKLIST,\n",
398-
" name=\"sub_checklist_question\", \n",
398+
" name=\"sub_checklist_question\",\n",
399399
" options=[lb.Option(\"first_sub_checklist_answer\")]\n",
400400
" )\n",
401401
" ])\n",
@@ -438,10 +438,10 @@
438438
"metadata": {},
439439
"source": [
440440
"# Create Labelbox project\n",
441-
"project = client.create_project(name=\"Conversational Text Annotation Import Demo\", \n",
441+
"project = client.create_project(name=\"Conversational Text Annotation Import Demo\",\n",
442442
" media_type=lb.MediaType.Conversational)\n",
443443
"\n",
444-
"# Setup your ontology \n",
444+
"# Setup your ontology\n",
445445
"project.setup_editor(ontology) # Connect your ontology and editor to your project"
446446
],
447447
"cell_type": "code",
@@ -458,8 +458,6 @@
458458
{
459459
"metadata": {},
460460
"source": [
461-
"# Setup Batches and Ontology\n",
462-
"\n",
463461
"# Create a batch to send to your MAL project\n",
464462
"batch = project.create_batch(\n",
465463
" \"first-batch-convo-demo\", # Each batch in a project must have a unique name\n",
@@ -566,9 +564,9 @@
566564
"source": [
567565
"# Upload our label using Model-Assisted Labeling\n",
568566
"upload_job = lb.MALPredictionImport.create_from_objects(\n",
569-
" client = client, \n",
570-
" project_id = project.uid, \n",
571-
" name=f\"mal_job-{str(uuid.uuid4())}\", \n",
567+
" client = client,\n",
568+
" project_id = project.uid,\n",
569+
" name=f\"mal_job-{str(uuid.uuid4())}\",\n",
572570
" predictions=label)\n",
573571
"\n",
574572
"upload_job.wait_until_done()\n",
@@ -589,11 +587,11 @@
589587
{
590588
"metadata": {},
591589
"source": [
592-
"# Upload label for this data row in project \n",
590+
"# Upload label for this data row in project\n",
593591
"upload_job = lb.LabelImport.create_from_objects(\n",
594-
" client = client, \n",
595-
" project_id = project.uid, \n",
596-
" name=\"label_import_job\"+str(uuid.uuid4()), \n",
592+
" client = client,\n",
593+
" project_id = project.uid,\n",
594+
" name=\"label_import_job\"+str(uuid.uuid4()),\n",
597595
" labels=label)\n",
598596
"\n",
599597
"upload_job.wait_until_done()\n",

0 commit comments

Comments
 (0)