Skip to content

Commit

Permalink
SN-87 (Include additional annotations for LLM notebook) (#1319)
Browse files Browse the repository at this point in the history
Co-authored-by: ovalle15 <[email protected]>
  • Loading branch information
ovalle15 and ovalle15 authored Dec 11, 2023
1 parent f16da35 commit 7657524
Show file tree
Hide file tree
Showing 6 changed files with 1,968 additions and 790 deletions.
74 changes: 36 additions & 38 deletions examples/annotation_import/conversational.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@
" )\n",
")\n",
"\n",
"ner_annotation_ndjson = { \n",
"ner_annotation_ndjson = {\n",
" \"name\": \"ner\",\n",
" \"location\": { \n",
" \"start\": 0, \n",
" \"end\": 8 \n",
" \"location\": {\n",
" \"start\": 0,\n",
" \"end\": 8\n",
" },\n",
" \"messageId\": \"4\"\n",
" }"
Expand Down Expand Up @@ -178,15 +178,15 @@
{
"metadata": {},
"source": [
"##### Checklist Classification ####### \n",
"##### Checklist Classification #######\n",
"\n",
"checklist_annotation= lb_types.ClassificationAnnotation(\n",
" name=\"checklist_convo\", # must match your ontology feature\"s name\n",
" value=lb_types.Checklist(\n",
" answer = [\n",
" lb_types.ClassificationAnswer(\n",
" name = \"first_checklist_answer\"\n",
" ), \n",
" ),\n",
" lb_types.ClassificationAnswer(\n",
" name = \"second_checklist_answer\"\n",
" )\n",
Expand Down Expand Up @@ -215,7 +215,7 @@
"######## Radio Classification ######\n",
"\n",
"radio_annotation = lb_types.ClassificationAnnotation(\n",
" name=\"radio_convo\", \n",
" name=\"radio_convo\",\n",
" value=lb_types.Radio(answer = lb_types.ClassificationAnswer(name = \"first_radio_answer\")),\n",
" message_id=\"0\"\n",
")\n",
Expand Down Expand Up @@ -264,12 +264,12 @@
" \"name\": \"first_checklist_answer\",\n",
" \"classifications\" : [\n",
" {\n",
" \"name\": \"sub_checklist_question\", \n",
" \"name\": \"sub_checklist_question\",\n",
" \"answer\": {\n",
" \"name\": \"first_sub_checklist_answer\"\n",
" }\n",
" } \n",
" ] \n",
" }\n",
" ]\n",
" }]\n",
"}\n",
"# Global\n",
Expand Down Expand Up @@ -360,27 +360,27 @@
"metadata": {},
"source": [
"ontology_builder = lb.OntologyBuilder(\n",
" tools=[ \n",
" tools=[\n",
" lb.Tool(tool=lb.Tool.Type.NER,name=\"ner\"),\n",
" ], \n",
" classifications=[ \n",
" lb.Classification( \n",
" ],\n",
" classifications=[\n",
" lb.Classification(\n",
" class_type=lb.Classification.Type.TEXT,\n",
" scope=lb.Classification.Scope.INDEX, \n",
" name=\"text_convo\"), \n",
" lb.Classification( \n",
" class_type=lb.Classification.Type.CHECKLIST, \n",
" scope=lb.Classification.Scope.INDEX, \n",
" name=\"checklist_convo\", \n",
" scope=lb.Classification.Scope.INDEX,\n",
" name=\"text_convo\"),\n",
" lb.Classification(\n",
" class_type=lb.Classification.Type.CHECKLIST,\n",
" scope=lb.Classification.Scope.INDEX,\n",
" name=\"checklist_convo\",\n",
" options=[\n",
" lb.Option(value=\"first_checklist_answer\"),\n",
" lb.Option(value=\"second_checklist_answer\") \n",
" lb.Option(value=\"second_checklist_answer\")\n",
" ]\n",
" ), \n",
" lb.Classification( \n",
" class_type=lb.Classification.Type.RADIO, \n",
" name=\"radio_convo\", \n",
" scope=lb.Classification.Scope.INDEX, \n",
" ),\n",
" lb.Classification(\n",
" class_type=lb.Classification.Type.RADIO,\n",
" name=\"radio_convo\",\n",
" scope=lb.Classification.Scope.INDEX,\n",
" options=[\n",
" lb.Option(value=\"first_radio_answer\"),\n",
" lb.Option(value=\"second_radio_answer\")\n",
Expand All @@ -395,7 +395,7 @@
" options=[\n",
" lb.Classification(\n",
" class_type=lb.Classification.Type.CHECKLIST,\n",
" name=\"sub_checklist_question\", \n",
" name=\"sub_checklist_question\",\n",
" options=[lb.Option(\"first_sub_checklist_answer\")]\n",
" )\n",
" ])\n",
Expand Down Expand Up @@ -438,10 +438,10 @@
"metadata": {},
"source": [
"# Create Labelbox project\n",
"project = client.create_project(name=\"Conversational Text Annotation Import Demo\", \n",
"project = client.create_project(name=\"Conversational Text Annotation Import Demo\",\n",
" media_type=lb.MediaType.Conversational)\n",
"\n",
"# Setup your ontology \n",
"# Setup your ontology\n",
"project.setup_editor(ontology) # Connect your ontology and editor to your project"
],
"cell_type": "code",
Expand All @@ -458,8 +458,6 @@
{
"metadata": {},
"source": [
"# Setup Batches and Ontology\n",
"\n",
"# Create a batch to send to your MAL project\n",
"batch = project.create_batch(\n",
" \"first-batch-convo-demo\", # Each batch in a project must have a unique name\n",
Expand Down Expand Up @@ -566,9 +564,9 @@
"source": [
"# Upload our label using Model-Assisted Labeling\n",
"upload_job = lb.MALPredictionImport.create_from_objects(\n",
" client = client, \n",
" project_id = project.uid, \n",
" name=f\"mal_job-{str(uuid.uuid4())}\", \n",
" client = client,\n",
" project_id = project.uid,\n",
" name=f\"mal_job-{str(uuid.uuid4())}\",\n",
" predictions=label)\n",
"\n",
"upload_job.wait_until_done()\n",
Expand All @@ -589,11 +587,11 @@
{
"metadata": {},
"source": [
"# Upload label for this data row in project \n",
"# Upload label for this data row in project\n",
"upload_job = lb.LabelImport.create_from_objects(\n",
" client = client, \n",
" project_id = project.uid, \n",
" name=\"label_import_job\"+str(uuid.uuid4()), \n",
" client = client,\n",
" project_id = project.uid,\n",
" name=\"label_import_job\"+str(uuid.uuid4()),\n",
" labels=label)\n",
"\n",
"upload_job.wait_until_done()\n",
Expand Down
Loading

0 comments on commit 7657524

Please sign in to comment.