# embeddings_queue

created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 0f2da6d2-6a43-4ccf-ac27-21359ae64502
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"0f2da6d2-6a43-4ccf-ac27-21359ae64502\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b7cf020a-5bac-4c3d-b345-b5c09465413e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"7ecc94fcd9460094a5c15af65a820f189f6e7749cb6255e3ee7144242cf1b8fb\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"3578168c-2670-4e5e-96d4-96bf9b7a277e\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"fc4422e9985a27da2d43965fa2621a509b4205d33347f809f243518a1552106f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 26507, \"end_char_idx\": 28219, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "056000</td>\n      <td>0.062200</td>\n      <td>0.111900</td>\n      <td>0.053500</td>\n      <td>0.447300</td>\n      <td>0.010600</td>\n      <td>0.100000</td>\n      <td>0.000200</td>\n      <td>0.022800</td>\n      <td>0.000100</td>\n      <td>0.015400</td>\n      <td>0.009700</td>\n      <td>0.064400</td>\n    </tr>\n    <tr>\n      <td>3</td>\n      <td>No log</td>\n      <td>2.107622</td>\n      <td>0.041700</td>\n      <td>0.094000</td>\n      <td>0.034300</td>\n      <td>0.024100</td>\n      <td>0.026400</td>\n      <td>0.047400</td>\n      <td>0.091500</td>\n      <td>0.182800</td>\n      <td>0.225800</td>\n      <td>0.087200</td>\n      <td>0.199400</td>\n      <td>0.210600</td>\n      <td>0.150900</td>\n      <td>0.571200</td>\n      <td>0.017300</td>\n      <td>0.101300</td>\n      <td>0.007300</td>\n      <td>0.180400</td>\n      <td>0.002100</td>\n      <td>0.026200</td>\n      <td>0.031000</td>\n      <td>0.250200</td>\n    </tr>\n    <tr>\n      <td>4</td>\n      <td>No log</td>\n      <td>2.031242</td>\n      <td>0.055900</td>\n      <td>0.120600</td>\n      <td>0.046900</td>\n      <td>0.013800</td>\n      <td>0.038100</td>\n      <td>0.090300</td>\n      <td>0.105900</td>\n      <td>0.225600</td>\n      <td>0.266100</td>\n      <td>0.130200</td>\n      <td>0.228100</td>\n      <td>0.330000</td>\n      <td>0.191000</td>\n      <td>0.572100</td>\n      <td>0.010600</td>\n      <td>0.157000</td>\n      <td>0.014600</td>\n      <td>0.235300</td>\n      <td>0.001700</td>\n      <td>0.052300</td>\n      <td>0.061800</td>\n      <td>0.313800</td>\n    </tr>\n    <tr>\n      <td>5</td>\n      <td>3.889400</td>\n      <td>1.883433</td>\n      <td>0.089700</td>\n      <td>0.201800</td>\n      <td>0.067300</td>\n      <td>0.022800</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 3578168c-2670-4e5e-96d4-96bf9b7a277e
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"3578168c-2670-4e5e-96d4-96bf9b7a277e\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"0f2da6d2-6a43-4ccf-ac27-21359ae64502\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"f8a645dd9d35f31e40672c9f0ff20692d0fb2269dc047f8fd523fcae681f48ae\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"944fe527-82e7-4f59-9e87-9202be212db9\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"eb4318405ff3b14377badcb4ae9417f008f8e2b1828339a774c5351b74e5dc58\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 27357, \"end_char_idx\": 29071, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "026200</td>\n      <td>0.031000</td>\n      <td>0.250200</td>\n    </tr>\n    <tr>\n      <td>4</td>\n      <td>No log</td>\n      <td>2.031242</td>\n      <td>0.055900</td>\n      <td>0.120600</td>\n      <td>0.046900</td>\n      <td>0.013800</td>\n      <td>0.038100</td>\n      <td>0.090300</td>\n      <td>0.105900</td>\n      <td>0.225600</td>\n      <td>0.266100</td>\n      <td>0.130200</td>\n      <td>0.228100</td>\n      <td>0.330000</td>\n      <td>0.191000</td>\n      <td>0.572100</td>\n      <td>0.010600</td>\n      <td>0.157000</td>\n      <td>0.014600</td>\n      <td>0.235300</td>\n      <td>0.001700</td>\n      <td>0.052300</td>\n      <td>0.061800</td>\n      <td>0.313800</td>\n    </tr>\n    <tr>\n      <td>5</td>\n      <td>3.889400</td>\n      <td>1.883433</td>\n      <td>0.089700</td>\n      <td>0.201800</td>\n      <td>0.067300</td>\n      <td>0.022800</td>\n      <td>0.065300</td>\n      <td>0.129500</td>\n      <td>0.136000</td>\n      <td>0.272200</td>\n      <td>0.303700</td>\n      <td>0.112900</td>\n      <td>0.312500</td>\n      <td>0.424600</td>\n      <td>0.300200</td>\n      <td>0.585100</td>\n      <td>0.032700</td>\n      <td>0.202500</td>\n      <td>0.031300</td>\n      <td>0.271000</td>\n      <td>0.008700</td>\n      <td>0.126200</td>\n      <td>0.075500</td>\n      <td>0.333800</td>\n    </tr>\n    <tr>\n      <td>6</td>\n      <td>3.889400</td>\n      <td>1.807503</td>\n      <td>0.118500</td>\n      <td>0.270900</td>\n      <td>0.090200</td>\n      <td>0.034900</td>\n      <td>0.076700</td>\n      <td>0.152500</td>\n      <td>0.146100</td>\n      <td>0.297800</td>\n      <td>0.325400</td>\n      <td>0.171700</td>\n      <td>0.283700</td>\n      <td>0.545900</td>\n      <td>0.396900</td>\n      <td>0.554500</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 944fe527-82e7-4f59-9e87-9202be212db9
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"944fe527-82e7-4f59-9e87-9202be212db9\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"3578168c-2670-4e5e-96d4-96bf9b7a277e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"6586ea3cc7637c9ab7e2d02ff475a2d700cc946b3eb7378d3e283ef73d165b48\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"cca2048b-99a2-4713-beee-1cb7e316f37b\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e7a715484b69a165f548bd7622a287d74ab1d22ef8ff711aba00d1860da097e2\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 28219, \"end_char_idx\": 29935, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "065300</td>\n      <td>0.129500</td>\n      <td>0.136000</td>\n      <td>0.272200</td>\n      <td>0.303700</td>\n      <td>0.112900</td>\n      <td>0.312500</td>\n      <td>0.424600</td>\n      <td>0.300200</td>\n      <td>0.585100</td>\n      <td>0.032700</td>\n      <td>0.202500</td>\n      <td>0.031300</td>\n      <td>0.271000</td>\n      <td>0.008700</td>\n      <td>0.126200</td>\n      <td>0.075500</td>\n      <td>0.333800</td>\n    </tr>\n    <tr>\n      <td>6</td>\n      <td>3.889400</td>\n      <td>1.807503</td>\n      <td>0.118500</td>\n      <td>0.270900</td>\n      <td>0.090200</td>\n      <td>0.034900</td>\n      <td>0.076700</td>\n      <td>0.152500</td>\n      <td>0.146100</td>\n      <td>0.297800</td>\n      <td>0.325400</td>\n      <td>0.171700</td>\n      <td>0.283700</td>\n      <td>0.545900</td>\n      <td>0.396900</td>\n      <td>0.554500</td>\n      <td>0.043000</td>\n      <td>0.262000</td>\n      <td>0.054500</td>\n      <td>0.271900</td>\n      <td>0.020300</td>\n      <td>0.230800</td>\n      <td>0.077600</td>\n      <td>0.308000</td>\n    </tr>\n    <tr>\n      <td>7</td>\n      <td>3.889400</td>\n      <td>1.716169</td>\n      <td>0.143500</td>\n      <td>0.307700</td>\n      <td>0.123200</td>\n      <td>0.045800</td>\n      <td>0.097800</td>\n      <td>0.258300</td>\n      <td>0.165300</td>\n      <td>0.327700</td>\n      <td>0.352600</td>\n      <td>0.140900</td>\n      <td>0.336700</td>\n      <td>0.599400</td>\n      <td>0.442900</td>\n      <td>0.620700</td>\n      <td>0.069400</td>\n      <td>0.301300</td>\n      <td>0.081600</td>\n      <td>0.292000</td>\n      <td>0.011000</td>\n      <td>0.230800</td>\n      <td>0.112700</td>\n      <td>0.318200</td>\n    </tr>\n    <tr>\n      <td>8</td>\n      <td>3.889400</td>\n      <td>1."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: cca2048b-99a2-4713-beee-1cb7e316f37b
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"cca2048b-99a2-4713-beee-1cb7e316f37b\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"944fe527-82e7-4f59-9e87-9202be212db9\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"425cad898c31c38f09ee2f2bb7c27bfa1403b5f4f27df15c126a209f92817fe9\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"e8242a0e-91e6-4551-8317-6e89b48cbd7e\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e32bf384f8ca4d2ff6407564725c87abc278c324dfdc34dd44ad639f3b7dba9a\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 29071, \"end_char_idx\": 30787, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "043000</td>\n      <td>0.262000</td>\n      <td>0.054500</td>\n      <td>0.271900</td>\n      <td>0.020300</td>\n      <td>0.230800</td>\n      <td>0.077600</td>\n      <td>0.308000</td>\n    </tr>\n    <tr>\n      <td>7</td>\n      <td>3.889400</td>\n      <td>1.716169</td>\n      <td>0.143500</td>\n      <td>0.307700</td>\n      <td>0.123200</td>\n      <td>0.045800</td>\n      <td>0.097800</td>\n      <td>0.258300</td>\n      <td>0.165300</td>\n      <td>0.327700</td>\n      <td>0.352600</td>\n      <td>0.140900</td>\n      <td>0.336700</td>\n      <td>0.599400</td>\n      <td>0.442900</td>\n      <td>0.620700</td>\n      <td>0.069400</td>\n      <td>0.301300</td>\n      <td>0.081600</td>\n      <td>0.292000</td>\n      <td>0.011000</td>\n      <td>0.230800</td>\n      <td>0.112700</td>\n      <td>0.318200</td>\n    </tr>\n    <tr>\n      <td>8</td>\n      <td>3.889400</td>\n      <td>1.679014</td>\n      <td>0.153000</td>\n      <td>0.355800</td>\n      <td>0.127900</td>\n      <td>0.038700</td>\n      <td>0.115600</td>\n      <td>0.291600</td>\n      <td>0.176000</td>\n      <td>0.322500</td>\n      <td>0.349700</td>\n      <td>0.135600</td>\n      <td>0.326100</td>\n      <td>0.643700</td>\n      <td>0.431700</td>\n      <td>0.582900</td>\n      <td>0.069800</td>\n      <td>0.265800</td>\n      <td>0.088600</td>\n      <td>0.274600</td>\n      <td>0.028300</td>\n      <td>0.280000</td>\n      <td>0.146700</td>\n      <td>0.345300</td>\n    </tr>\n    <tr>\n      <td>9</td>\n      <td>3.889400</td>\n      <td>1.618239</td>\n      <td>0.172100</td>\n      <td>0.375300</td>\n      <td>0.137600</td>\n      <td>0.046100</td>\n      <td>0.141700</td>\n      <td>0.308500</td>\n      <td>0.194000</td>\n      <td>0.356200</td>\n      <td>0.386200</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: e8242a0e-91e6-4551-8317-6e89b48cbd7e
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"e8242a0e-91e6-4551-8317-6e89b48cbd7e\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"cca2048b-99a2-4713-beee-1cb7e316f37b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"f8b5cdf6200e1e523386d947330720ddec93937dd77ec3c71ebf20abaac03d8d\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"5139a966-bcff-4638-a848-723a85a17b35\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"bbbcf3788fd8f7266a224ac316f989ff78479d775dbae48d943664fd1418b997\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 29935, \"end_char_idx\": 31640, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "679014</td>\n      <td>0.153000</td>\n      <td>0.355800</td>\n      <td>0.127900</td>\n      <td>0.038700</td>\n      <td>0.115600</td>\n      <td>0.291600</td>\n      <td>0.176000</td>\n      <td>0.322500</td>\n      <td>0.349700</td>\n      <td>0.135600</td>\n      <td>0.326100</td>\n      <td>0.643700</td>\n      <td>0.431700</td>\n      <td>0.582900</td>\n      <td>0.069800</td>\n      <td>0.265800</td>\n      <td>0.088600</td>\n      <td>0.274600</td>\n      <td>0.028300</td>\n      <td>0.280000</td>\n      <td>0.146700</td>\n      <td>0.345300</td>\n    </tr>\n    <tr>\n      <td>9</td>\n      <td>3.889400</td>\n      <td>1.618239</td>\n      <td>0.172100</td>\n      <td>0.375300</td>\n      <td>0.137600</td>\n      <td>0.046100</td>\n      <td>0.141700</td>\n      <td>0.308500</td>\n      <td>0.194000</td>\n      <td>0.356200</td>\n      <td>0.386200</td>\n      <td>0.162400</td>\n      <td>0.359200</td>\n      <td>0.677700</td>\n      <td>0.469800</td>\n      <td>0.623900</td>\n      <td>0.102100</td>\n      <td>0.317700</td>\n      <td>0.099100</td>\n      <td>0.290200</td>\n      <td>0.029300</td>\n      <td>0.335400</td>\n      <td>0.160200</td>\n      <td>0.364000</td>\n    </tr>\n    <tr>\n      <td>10</td>\n      <td>1.599700</td>\n      <td>1.572512</td>\n      <td>0.179500</td>\n      <td>0.400400</td>\n      <td>0.147200</td>\n      <td>0.056500</td>\n      <td>0.141700</td>\n      <td>0.316700</td>\n      <td>0.213100</td>\n      <td>0.357600</td>\n      <td>0.381300</td>\n      <td>0.197900</td>\n      <td>0.344300</td>\n      <td>0.638500</td>\n      <td>0.466900</td>\n      <td>0.623900</td>\n      <td>0.101300</td>\n      <td>0.311400</td>\n      <td>0.104700</td>\n      <td>0.279500</td>\n      <td>0.051600</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 5139a966-bcff-4638-a848-723a85a17b35
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"5139a966-bcff-4638-a848-723a85a17b35\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"e8242a0e-91e6-4551-8317-6e89b48cbd7e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"5d7ff6def374f467033c6de4a09e366aeaf661e2fc6cc1abcbe6465696ffed1e\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"9b99d7b2-f95f-4adb-80f1-077ad8f5c75d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"939d090f4a93794149c0061a726581a0762304442ea1b3e64071ab9ec56bb0ba\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 30787, \"end_char_idx\": 32506, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "162400</td>\n      <td>0.359200</td>\n      <td>0.677700</td>\n      <td>0.469800</td>\n      <td>0.623900</td>\n      <td>0.102100</td>\n      <td>0.317700</td>\n      <td>0.099100</td>\n      <td>0.290200</td>\n      <td>0.029300</td>\n      <td>0.335400</td>\n      <td>0.160200</td>\n      <td>0.364000</td>\n    </tr>\n    <tr>\n      <td>10</td>\n      <td>1.599700</td>\n      <td>1.572512</td>\n      <td>0.179500</td>\n      <td>0.400400</td>\n      <td>0.147200</td>\n      <td>0.056500</td>\n      <td>0.141700</td>\n      <td>0.316700</td>\n      <td>0.213100</td>\n      <td>0.357600</td>\n      <td>0.381300</td>\n      <td>0.197900</td>\n      <td>0.344300</td>\n      <td>0.638500</td>\n      <td>0.466900</td>\n      <td>0.623900</td>\n      <td>0.101300</td>\n      <td>0.311400</td>\n      <td>0.104700</td>\n      <td>0.279500</td>\n      <td>0.051600</td>\n      <td>0.338500</td>\n      <td>0.173000</td>\n      <td>0.353300</td>\n    </tr>\n    <tr>\n      <td>11</td>\n      <td>1.599700</td>\n      <td>1.528889</td>\n      <td>0.192200</td>\n      <td>0.415000</td>\n      <td>0.160800</td>\n      <td>0.053700</td>\n      <td>0.150500</td>\n      <td>0.378000</td>\n      <td>0.211500</td>\n      <td>0.371700</td>\n      <td>0.397800</td>\n      <td>0.204900</td>\n      <td>0.374600</td>\n      <td>0.684800</td>\n      <td>0.491900</td>\n      <td>0.632400</td>\n      <td>0.131200</td>\n      <td>0.346800</td>\n      <td>0.122000</td>\n      <td>0.300900</td>\n      <td>0.038400</td>\n      <td>0.344600</td>\n      <td>0.177500</td>\n      <td>0.364400</td>\n    </tr>\n    <tr>\n      <td>12</td>\n      <td>1.599700</td>\n      <td>1.517532</td>\n      <td>0.198300</td>\n      <td>0.429800</td>\n      <td>0.159800</td>\n      <td>0.066400</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 9b99d7b2-f95f-4adb-80f1-077ad8f5c75d
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"9b99d7b2-f95f-4adb-80f1-077ad8f5c75d\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"5139a966-bcff-4638-a848-723a85a17b35\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"e12902a74f2ec1caecd348c00e69df5cab942ac197bae3967d92f2a91a494b3b\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"15a9d3b0-e041-4419-9698-29f063b94b5d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"2b8b833c8606730771ccb0e973478e78a34ee844a105af9d063206d9bb2ff453\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 31640, \"end_char_idx\": 33359, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "338500</td>\n      <td>0.173000</td>\n      <td>0.353300</td>\n    </tr>\n    <tr>\n      <td>11</td>\n      <td>1.599700</td>\n      <td>1.528889</td>\n      <td>0.192200</td>\n      <td>0.415000</td>\n      <td>0.160800</td>\n      <td>0.053700</td>\n      <td>0.150500</td>\n      <td>0.378000</td>\n      <td>0.211500</td>\n      <td>0.371700</td>\n      <td>0.397800</td>\n      <td>0.204900</td>\n      <td>0.374600</td>\n      <td>0.684800</td>\n      <td>0.491900</td>\n      <td>0.632400</td>\n      <td>0.131200</td>\n      <td>0.346800</td>\n      <td>0.122000</td>\n      <td>0.300900</td>\n      <td>0.038400</td>\n      <td>0.344600</td>\n      <td>0.177500</td>\n      <td>0.364400</td>\n    </tr>\n    <tr>\n      <td>12</td>\n      <td>1.599700</td>\n      <td>1.517532</td>\n      <td>0.198300</td>\n      <td>0.429800</td>\n      <td>0.159800</td>\n      <td>0.066400</td>\n      <td>0.162900</td>\n      <td>0.383300</td>\n      <td>0.220700</td>\n      <td>0.382100</td>\n      <td>0.405400</td>\n      <td>0.214800</td>\n      <td>0.383200</td>\n      <td>0.672900</td>\n      <td>0.469000</td>\n      <td>0.610400</td>\n      <td>0.167800</td>\n      <td>0.379700</td>\n      <td>0.119700</td>\n      <td>0.307100</td>\n      <td>0.038100</td>\n      <td>0.335400</td>\n      <td>0.196800</td>\n      <td>0.394200</td>\n    </tr>\n    <tr>\n      <td>13</td>\n      <td>1.599700</td>\n      <td>1.488849</td>\n      <td>0.209800</td>\n      <td>0.452300</td>\n      <td>0.172300</td>\n      <td>0.094900</td>\n      <td>0.171100</td>\n      <td>0.437800</td>\n      <td>0.222000</td>\n      <td>0.379800</td>\n      <td>0.411500</td>\n      <td>0.203800</td>\n      <td>0.397300</td>\n      <td>0.707500</td>\n      <td>0.470700</td>\n      <td>0.620700</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 15a9d3b0-e041-4419-9698-29f063b94b5d
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"15a9d3b0-e041-4419-9698-29f063b94b5d\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"9b99d7b2-f95f-4adb-80f1-077ad8f5c75d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d6dd8db7830b29a1c00df414b4142ea804e01820af5b1d78cf18c4ed3df79928\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"5d53a123-fccb-475c-906d-b2c3be134d66\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"681df8a3bdec3ada79e24e702726a5f7b23eea3db9c4584c55c2c40b49957d62\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 32506, \"end_char_idx\": 34225, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "162900</td>\n      <td>0.383300</td>\n      <td>0.220700</td>\n      <td>0.382100</td>\n      <td>0.405400</td>\n      <td>0.214800</td>\n      <td>0.383200</td>\n      <td>0.672900</td>\n      <td>0.469000</td>\n      <td>0.610400</td>\n      <td>0.167800</td>\n      <td>0.379700</td>\n      <td>0.119700</td>\n      <td>0.307100</td>\n      <td>0.038100</td>\n      <td>0.335400</td>\n      <td>0.196800</td>\n      <td>0.394200</td>\n    </tr>\n    <tr>\n      <td>13</td>\n      <td>1.599700</td>\n      <td>1.488849</td>\n      <td>0.209800</td>\n      <td>0.452300</td>\n      <td>0.172300</td>\n      <td>0.094900</td>\n      <td>0.171100</td>\n      <td>0.437800</td>\n      <td>0.222000</td>\n      <td>0.379800</td>\n      <td>0.411500</td>\n      <td>0.203800</td>\n      <td>0.397300</td>\n      <td>0.707500</td>\n      <td>0.470700</td>\n      <td>0.620700</td>\n      <td>0.186900</td>\n      <td>0.407600</td>\n      <td>0.124200</td>\n      <td>0.306700</td>\n      <td>0.059300</td>\n      <td>0.355400</td>\n      <td>0.207700</td>\n      <td>0.367100</td>\n    </tr>\n    <tr>\n      <td>14</td>\n      <td>1.599700</td>\n      <td>1.482210</td>\n      <td>0.228900</td>\n      <td>0.482600</td>\n      <td>0.187800</td>\n      <td>0.083600</td>\n      <td>0.191800</td>\n      <td>0.444100</td>\n      <td>0.225900</td>\n      <td>0.376900</td>\n      <td>0.407400</td>\n      <td>0.182500</td>\n      <td>0.384800</td>\n      <td>0.700600</td>\n      <td>0.512100</td>\n      <td>0.640100</td>\n      <td>0.175000</td>\n      <td>0.363300</td>\n      <td>0.144300</td>\n      <td>0.300000</td>\n      <td>0.083100</td>\n      <td>0.363100</td>\n      <td>0.229900</td>\n      <td>0.370700</td>\n    </tr>\n    <tr>\n      <td>15</td>\n      <td>1.326800</td>\n      <td>1."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 5d53a123-fccb-475c-906d-b2c3be134d66
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"5d53a123-fccb-475c-906d-b2c3be134d66\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"15a9d3b0-e041-4419-9698-29f063b94b5d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"7e76842df688ee38d98d8435e99e2edc7bb2ffe61a0d30e4a9268d5c9e44198e\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"bb831dd5-b3cd-4c68-8173-9b9a3fd76f6e\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"50120ce80d54abad8b1b009e80b1e2af3143afb5c900b75966952e9dd1a78067\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 33359, \"end_char_idx\": 35078, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "186900</td>\n      <td>0.407600</td>\n      <td>0.124200</td>\n      <td>0.306700</td>\n      <td>0.059300</td>\n      <td>0.355400</td>\n      <td>0.207700</td>\n      <td>0.367100</td>\n    </tr>\n    <tr>\n      <td>14</td>\n      <td>1.599700</td>\n      <td>1.482210</td>\n      <td>0.228900</td>\n      <td>0.482600</td>\n      <td>0.187800</td>\n      <td>0.083600</td>\n      <td>0.191800</td>\n      <td>0.444100</td>\n      <td>0.225900</td>\n      <td>0.376900</td>\n      <td>0.407400</td>\n      <td>0.182500</td>\n      <td>0.384800</td>\n      <td>0.700600</td>\n      <td>0.512100</td>\n      <td>0.640100</td>\n      <td>0.175000</td>\n      <td>0.363300</td>\n      <td>0.144300</td>\n      <td>0.300000</td>\n      <td>0.083100</td>\n      <td>0.363100</td>\n      <td>0.229900</td>\n      <td>0.370700</td>\n    </tr>\n    <tr>\n      <td>15</td>\n      <td>1.326800</td>\n      <td>1.475198</td>\n      <td>0.216300</td>\n      <td>0.455600</td>\n      <td>0.174900</td>\n      <td>0.088500</td>\n      <td>0.183500</td>\n      <td>0.424400</td>\n      <td>0.226900</td>\n      <td>0.373400</td>\n      <td>0.404300</td>\n      <td>0.199200</td>\n      <td>0.396400</td>\n      <td>0.677800</td>\n      <td>0.496300</td>\n      <td>0.633800</td>\n      <td>0.166300</td>\n      <td>0.392400</td>\n      <td>0.128900</td>\n      <td>0.312900</td>\n      <td>0.085200</td>\n      <td>0.312300</td>\n      <td>0.205000</td>\n      <td>0.370200</td>\n    </tr>\n    <tr>\n      <td>16</td>\n      <td>1.326800</td>\n      <td>1.459697</td>\n      <td>0.233200</td>\n      <td>0.504200</td>\n      <td>0.192200</td>\n      <td>0.096000</td>\n      <td>0.202000</td>\n      <td>0.430800</td>\n      <td>0.239100</td>\n      <td>0.382400</td>\n      <td>0.412600</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: bb831dd5-b3cd-4c68-8173-9b9a3fd76f6e
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"bb831dd5-b3cd-4c68-8173-9b9a3fd76f6e\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"5d53a123-fccb-475c-906d-b2c3be134d66\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d9d9a93ee46df656774d68d037c47f113ce64c4da171378663fe30631847dd55\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"8c803e35-32d6-4356-aac6-a81cc44f8d63\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"884bb5e26c6e24aa4a56f35a3f1cdd9b23675715e65229abf6f9129d97122a8e\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 34225, \"end_char_idx\": 35931, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "475198</td>\n      <td>0.216300</td>\n      <td>0.455600</td>\n      <td>0.174900</td>\n      <td>0.088500</td>\n      <td>0.183500</td>\n      <td>0.424400</td>\n      <td>0.226900</td>\n      <td>0.373400</td>\n      <td>0.404300</td>\n      <td>0.199200</td>\n      <td>0.396400</td>\n      <td>0.677800</td>\n      <td>0.496300</td>\n      <td>0.633800</td>\n      <td>0.166300</td>\n      <td>0.392400</td>\n      <td>0.128900</td>\n      <td>0.312900</td>\n      <td>0.085200</td>\n      <td>0.312300</td>\n      <td>0.205000</td>\n      <td>0.370200</td>\n    </tr>\n    <tr>\n      <td>16</td>\n      <td>1.326800</td>\n      <td>1.459697</td>\n      <td>0.233200</td>\n      <td>0.504200</td>\n      <td>0.192200</td>\n      <td>0.096000</td>\n      <td>0.202000</td>\n      <td>0.430800</td>\n      <td>0.239100</td>\n      <td>0.382400</td>\n      <td>0.412600</td>\n      <td>0.219500</td>\n      <td>0.403100</td>\n      <td>0.670400</td>\n      <td>0.485200</td>\n      <td>0.625200</td>\n      <td>0.196500</td>\n      <td>0.410100</td>\n      <td>0.135700</td>\n      <td>0.299600</td>\n      <td>0.123100</td>\n      <td>0.356900</td>\n      <td>0.225300</td>\n      <td>0.371100</td>\n    </tr>\n    <tr>\n      <td>17</td>\n      <td>1.326800</td>\n      <td>1.407340</td>\n      <td>0.243400</td>\n      <td>0.511900</td>\n      <td>0.204500</td>\n      <td>0.121000</td>\n      <td>0.215700</td>\n      <td>0.468000</td>\n      <td>0.246200</td>\n      <td>0.394600</td>\n      <td>0.424200</td>\n      <td>0.225900</td>\n      <td>0.416100</td>\n      <td>0.705200</td>\n      <td>0.494900</td>\n      <td>0.638300</td>\n      <td>0.224900</td>\n      <td>0.430400</td>\n      <td>0.157200</td>\n      <td>0.317900</td>\n      <td>0.115700</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 8c803e35-32d6-4356-aac6-a81cc44f8d63
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"8c803e35-32d6-4356-aac6-a81cc44f8d63\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"bb831dd5-b3cd-4c68-8173-9b9a3fd76f6e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"a7ba4a519846a974aaaf5ac4735e172f61ac665b886d0007c5b27635ff13ce3a\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"6f26c907-5b60-486b-8540-b379c09abc2e\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"f5e2ed09e692af5f24b4ab4ac43a5967511e83d14a34b0d9c5badb2179327433\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 35078, \"end_char_idx\": 36797, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "219500</td>\n      <td>0.403100</td>\n      <td>0.670400</td>\n      <td>0.485200</td>\n      <td>0.625200</td>\n      <td>0.196500</td>\n      <td>0.410100</td>\n      <td>0.135700</td>\n      <td>0.299600</td>\n      <td>0.123100</td>\n      <td>0.356900</td>\n      <td>0.225300</td>\n      <td>0.371100</td>\n    </tr>\n    <tr>\n      <td>17</td>\n      <td>1.326800</td>\n      <td>1.407340</td>\n      <td>0.243400</td>\n      <td>0.511900</td>\n      <td>0.204500</td>\n      <td>0.121000</td>\n      <td>0.215700</td>\n      <td>0.468000</td>\n      <td>0.246200</td>\n      <td>0.394600</td>\n      <td>0.424200</td>\n      <td>0.225900</td>\n      <td>0.416100</td>\n      <td>0.705200</td>\n      <td>0.494900</td>\n      <td>0.638300</td>\n      <td>0.224900</td>\n      <td>0.430400</td>\n      <td>0.157200</td>\n      <td>0.317900</td>\n      <td>0.115700</td>\n      <td>0.369200</td>\n      <td>0.224200</td>\n      <td>0.365300</td>\n    </tr>\n    <tr>\n      <td>18</td>\n      <td>1.326800</td>\n      <td>1.419522</td>\n      <td>0.245100</td>\n      <td>0.521500</td>\n      <td>0.210000</td>\n      <td>0.116100</td>\n      <td>0.211500</td>\n      <td>0.489900</td>\n      <td>0.255400</td>\n      <td>0.391600</td>\n      <td>0.419700</td>\n      <td>0.198800</td>\n      <td>0.421200</td>\n      <td>0.701400</td>\n      <td>0.501800</td>\n      <td>0.634200</td>\n      <td>0.226700</td>\n      <td>0.410100</td>\n      <td>0.154400</td>\n      <td>0.321400</td>\n      <td>0.105900</td>\n      <td>0.352300</td>\n      <td>0.236700</td>\n      <td>0.380400</td>\n    </tr>\n    <tr>\n      <td>19</td>\n      <td>1.158600</td>\n      <td>1.398764</td>\n      <td>0.253600</td>\n      <td>0.519200</td>\n      <td>0.213600</td>\n      <td>0.135200</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 6f26c907-5b60-486b-8540-b379c09abc2e
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"6f26c907-5b60-486b-8540-b379c09abc2e\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"8c803e35-32d6-4356-aac6-a81cc44f8d63\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"98d410a89045fb493d4637349eaedc3477fb644feef5629736e3b1a5ef818b68\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"d9a42c1f-d60b-453f-ba10-dadd1e4fe59f\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"092fa7f1d5b14d0cc6a0e83453021b2e9a7d89626975ee1f414c66738f01bcae\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 35931, \"end_char_idx\": 37650, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "369200</td>\n      <td>0.224200</td>\n      <td>0.365300</td>\n    </tr>\n    <tr>\n      <td>18</td>\n      <td>1.326800</td>\n      <td>1.419522</td>\n      <td>0.245100</td>\n      <td>0.521500</td>\n      <td>0.210000</td>\n      <td>0.116100</td>\n      <td>0.211500</td>\n      <td>0.489900</td>\n      <td>0.255400</td>\n      <td>0.391600</td>\n      <td>0.419700</td>\n      <td>0.198800</td>\n      <td>0.421200</td>\n      <td>0.701400</td>\n      <td>0.501800</td>\n      <td>0.634200</td>\n      <td>0.226700</td>\n      <td>0.410100</td>\n      <td>0.154400</td>\n      <td>0.321400</td>\n      <td>0.105900</td>\n      <td>0.352300</td>\n      <td>0.236700</td>\n      <td>0.380400</td>\n    </tr>\n    <tr>\n      <td>19</td>\n      <td>1.158600</td>\n      <td>1.398764</td>\n      <td>0.253600</td>\n      <td>0.519200</td>\n      <td>0.213600</td>\n      <td>0.135200</td>\n      <td>0.207700</td>\n      <td>0.491900</td>\n      <td>0.257300</td>\n      <td>0.397300</td>\n      <td>0.428000</td>\n      <td>0.241400</td>\n      <td>0.401800</td>\n      <td>0.703500</td>\n      <td>0.509700</td>\n      <td>0.631100</td>\n      <td>0.236700</td>\n      <td>0.441800</td>\n      <td>0.155900</td>\n      <td>0.330800</td>\n      <td>0.128100</td>\n      <td>0.352300</td>\n      <td>0.237500</td>\n      <td>0.384000</td>\n    </tr>\n    <tr>\n      <td>20</td>\n      <td>1.158600</td>\n      <td>1.390591</td>\n      <td>0.248800</td>\n      <td>0.520200</td>\n      <td>0.216600</td>\n      <td>0.127500</td>\n      <td>0.211400</td>\n      <td>0.471900</td>\n      <td>0.258300</td>\n      <td>0.407000</td>\n      <td>0.429100</td>\n      <td>0.240300</td>\n      <td>0.407600</td>\n      <td>0.708500</td>\n      <td>0.505800</td>\n      <td>0.623400</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: d9a42c1f-d60b-453f-ba10-dadd1e4fe59f
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"d9a42c1f-d60b-453f-ba10-dadd1e4fe59f\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"6f26c907-5b60-486b-8540-b379c09abc2e\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"b9806917656863919ffcb2502f15697d67ad987f093f5e502df2a609752a3c1d\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"0cc62b0a-741b-42f4-9780-7cf5deb4ba96\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"c206e2aba1c2e2db8e5ed8f34faceb2af3c9591ce2587612691b81e43049eeb6\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 36797, \"end_char_idx\": 38516, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "207700</td>\n      <td>0.491900</td>\n      <td>0.257300</td>\n      <td>0.397300</td>\n      <td>0.428000</td>\n      <td>0.241400</td>\n      <td>0.401800</td>\n      <td>0.703500</td>\n      <td>0.509700</td>\n      <td>0.631100</td>\n      <td>0.236700</td>\n      <td>0.441800</td>\n      <td>0.155900</td>\n      <td>0.330800</td>\n      <td>0.128100</td>\n      <td>0.352300</td>\n      <td>0.237500</td>\n      <td>0.384000</td>\n    </tr>\n    <tr>\n      <td>20</td>\n      <td>1.158600</td>\n      <td>1.390591</td>\n      <td>0.248800</td>\n      <td>0.520200</td>\n      <td>0.216600</td>\n      <td>0.127500</td>\n      <td>0.211400</td>\n      <td>0.471900</td>\n      <td>0.258300</td>\n      <td>0.407000</td>\n      <td>0.429100</td>\n      <td>0.240300</td>\n      <td>0.407600</td>\n      <td>0.708500</td>\n      <td>0.505800</td>\n      <td>0.623400</td>\n      <td>0.235500</td>\n      <td>0.431600</td>\n      <td>0.150000</td>\n      <td>0.325000</td>\n      <td>0.125700</td>\n      <td>0.375400</td>\n      <td>0.227200</td>\n      <td>0.390200</td>\n    </tr>\n    <tr>\n      <td>21</td>\n      <td>1.158600</td>\n      <td>1.360608</td>\n      <td>0.262700</td>\n      <td>0.544800</td>\n      <td>0.222100</td>\n      <td>0.134700</td>\n      <td>0.230000</td>\n      <td>0.487500</td>\n      <td>0.269500</td>\n      <td>0.413300</td>\n      <td>0.436300</td>\n      <td>0.236200</td>\n      <td>0.419100</td>\n      <td>0.709300</td>\n      <td>0.514100</td>\n      <td>0.637400</td>\n      <td>0.257200</td>\n      <td>0.450600</td>\n      <td>0.165100</td>\n      <td>0.338400</td>\n      <td>0.139400</td>\n      <td>0.372300</td>\n      <td>0.237700</td>\n      <td>0.382700</td>\n    </tr>\n    <tr>\n      <td>22</td>\n      <td>1.158600</td>\n      <td>1."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 0cc62b0a-741b-42f4-9780-7cf5deb4ba96
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"0cc62b0a-741b-42f4-9780-7cf5deb4ba96\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"d9a42c1f-d60b-453f-ba10-dadd1e4fe59f\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"75efab553a388d89495a58cfd25bc7a64ecdd9fba4e52092b5204803b1220211\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"8a42d618-dd15-4e93-a637-4ee372a7bb08\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"cb90b7d5f837b23c2bb070ff668090694bd9b4d301e1303d948b919f0020fe66\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 37650, \"end_char_idx\": 39369, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "235500</td>\n      <td>0.431600</td>\n      <td>0.150000</td>\n      <td>0.325000</td>\n      <td>0.125700</td>\n      <td>0.375400</td>\n      <td>0.227200</td>\n      <td>0.390200</td>\n    </tr>\n    <tr>\n      <td>21</td>\n      <td>1.158600</td>\n      <td>1.360608</td>\n      <td>0.262700</td>\n      <td>0.544800</td>\n      <td>0.222100</td>\n      <td>0.134700</td>\n      <td>0.230000</td>\n      <td>0.487500</td>\n      <td>0.269500</td>\n      <td>0.413300</td>\n      <td>0.436300</td>\n      <td>0.236200</td>\n      <td>0.419100</td>\n      <td>0.709300</td>\n      <td>0.514100</td>\n      <td>0.637400</td>\n      <td>0.257200</td>\n      <td>0.450600</td>\n      <td>0.165100</td>\n      <td>0.338400</td>\n      <td>0.139400</td>\n      <td>0.372300</td>\n      <td>0.237700</td>\n      <td>0.382700</td>\n    </tr>\n    <tr>\n      <td>22</td>\n      <td>1.158600</td>\n      <td>1.368296</td>\n      <td>0.262800</td>\n      <td>0.542400</td>\n      <td>0.236400</td>\n      <td>0.137400</td>\n      <td>0.228100</td>\n      <td>0.498500</td>\n      <td>0.266500</td>\n      <td>0.409000</td>\n      <td>0.433000</td>\n      <td>0.239900</td>\n      <td>0.418500</td>\n      <td>0.697500</td>\n      <td>0.520500</td>\n      <td>0.641000</td>\n      <td>0.257500</td>\n      <td>0.455700</td>\n      <td>0.162600</td>\n      <td>0.334800</td>\n      <td>0.140200</td>\n      <td>0.353800</td>\n      <td>0.233200</td>\n      <td>0.379600</td>\n    </tr>\n    <tr>\n      <td>23</td>\n      <td>1.158600</td>\n      <td>1.368176</td>\n      <td>0.264800</td>\n      <td>0.541100</td>\n      <td>0.233100</td>\n      <td>0.138200</td>\n      <td>0.223900</td>\n      <td>0.498700</td>\n      <td>0.272300</td>\n      <td>0.407400</td>\n      <td>0.434400</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 8a42d618-dd15-4e93-a637-4ee372a7bb08
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"8a42d618-dd15-4e93-a637-4ee372a7bb08\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"0cc62b0a-741b-42f4-9780-7cf5deb4ba96\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"a42eb577bc6d183070b970ab98fa77e015c695c7921dbcf8a3b59d47f2ba8f03\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"7f36e50f-f559-4088-81ef-46a9a65ea10a\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"108fb5b15066664482823b60bab61e4ec9e696ddca62cf0ada2baeb41f2d74d1\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 38516, \"end_char_idx\": 40222, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "368296</td>\n      <td>0.262800</td>\n      <td>0.542400</td>\n      <td>0.236400</td>\n      <td>0.137400</td>\n      <td>0.228100</td>\n      <td>0.498500</td>\n      <td>0.266500</td>\n      <td>0.409000</td>\n      <td>0.433000</td>\n      <td>0.239900</td>\n      <td>0.418500</td>\n      <td>0.697500</td>\n      <td>0.520500</td>\n      <td>0.641000</td>\n      <td>0.257500</td>\n      <td>0.455700</td>\n      <td>0.162600</td>\n      <td>0.334800</td>\n      <td>0.140200</td>\n      <td>0.353800</td>\n      <td>0.233200</td>\n      <td>0.379600</td>\n    </tr>\n    <tr>\n      <td>23</td>\n      <td>1.158600</td>\n      <td>1.368176</td>\n      <td>0.264800</td>\n      <td>0.541100</td>\n      <td>0.233100</td>\n      <td>0.138200</td>\n      <td>0.223900</td>\n      <td>0.498700</td>\n      <td>0.272300</td>\n      <td>0.407400</td>\n      <td>0.434400</td>\n      <td>0.233100</td>\n      <td>0.418300</td>\n      <td>0.702000</td>\n      <td>0.524400</td>\n      <td>0.642300</td>\n      <td>0.262300</td>\n      <td>0.444300</td>\n      <td>0.159700</td>\n      <td>0.335300</td>\n      <td>0.140500</td>\n      <td>0.366200</td>\n      <td>0.236900</td>\n      <td>0.384000</td>\n    </tr>\n    <tr>\n      <td>24</td>\n      <td>1.049700</td>\n      <td>1.355271</td>\n      <td>0.269700</td>\n      <td>0.549200</td>\n      <td>0.239100</td>\n      <td>0.134700</td>\n      <td>0.229900</td>\n      <td>0.519200</td>\n      <td>0.274800</td>\n      <td>0.412700</td>\n      <td>0.437600</td>\n      <td>0.245400</td>\n      <td>0.417200</td>\n      <td>0.711200</td>\n      <td>0.523200</td>\n      <td>0.644100</td>\n      <td>0.272100</td>\n      <td>0.440500</td>\n      <td>0.166700</td>\n      <td>0.341500</td>\n      <td>0.137700</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 7f36e50f-f559-4088-81ef-46a9a65ea10a
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"7f36e50f-f559-4088-81ef-46a9a65ea10a\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"8a42d618-dd15-4e93-a637-4ee372a7bb08\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"be68388591b61172fc6ecc2482a4b4f4c523047752a76d84ad7ad153acb94f97\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"6deb91b0-b583-4939-b904-bdd996693dd0\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"1ce097a499811ccd2fac259ac29813066670c0cb078fa4b1ea3c1ae03e3b3481\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 39369, \"end_char_idx\": 41088, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "233100</td>\n      <td>0.418300</td>\n      <td>0.702000</td>\n      <td>0.524400</td>\n      <td>0.642300</td>\n      <td>0.262300</td>\n      <td>0.444300</td>\n      <td>0.159700</td>\n      <td>0.335300</td>\n      <td>0.140500</td>\n      <td>0.366200</td>\n      <td>0.236900</td>\n      <td>0.384000</td>\n    </tr>\n    <tr>\n      <td>24</td>\n      <td>1.049700</td>\n      <td>1.355271</td>\n      <td>0.269700</td>\n      <td>0.549200</td>\n      <td>0.239100</td>\n      <td>0.134700</td>\n      <td>0.229900</td>\n      <td>0.519200</td>\n      <td>0.274800</td>\n      <td>0.412700</td>\n      <td>0.437600</td>\n      <td>0.245400</td>\n      <td>0.417200</td>\n      <td>0.711200</td>\n      <td>0.523200</td>\n      <td>0.644100</td>\n      <td>0.272100</td>\n      <td>0.440500</td>\n      <td>0.166700</td>\n      <td>0.341500</td>\n      <td>0.137700</td>\n      <td>0.373800</td>\n      <td>0.249000</td>\n      <td>0.388000</td>\n    </tr>\n    <tr>\n      <td>25</td>\n      <td>1.049700</td>\n      <td>1.355180</td>\n      <td>0.272500</td>\n      <td>0.547900</td>\n      <td>0.243800</td>\n      <td>0.149700</td>\n      <td>0.229900</td>\n      <td>0.523100</td>\n      <td>0.272500</td>\n      <td>0.415700</td>\n      <td>0.442200</td>\n      <td>0.256200</td>\n      <td>0.420200</td>\n      <td>0.705800</td>\n      <td>0.523900</td>\n      <td>0.639600</td>\n      <td>0.271700</td>\n      <td>0.451900</td>\n      <td>0.166300</td>\n      <td>0.346900</td>\n      <td>0.153700</td>\n      <td>0.383100</td>\n      <td>0.247000</td>\n      <td>0.389300</td>\n    </tr>\n    <tr>\n      <td>26</td>\n      <td>1.049700</td>\n      <td>1.349337</td>\n      <td>0.275600</td>\n      <td>0.556300</td>\n      <td>0.246400</td>\n      <td>0.146700</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 6deb91b0-b583-4939-b904-bdd996693dd0
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"6deb91b0-b583-4939-b904-bdd996693dd0\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"7f36e50f-f559-4088-81ef-46a9a65ea10a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"b0329d896ab3f41a34e08c4b03f53cb615ca454e8be37b4d25933fdf47ba0dd7\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b84aa76e-91e9-44ce-887c-bdabc8e0d1f4\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"0ea5fcc2bf037a653b27fc45f254faee0670dedad78e4a966a3041d471cde9a4\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 40222, \"end_char_idx\": 41941, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "373800</td>\n      <td>0.249000</td>\n      <td>0.388000</td>\n    </tr>\n    <tr>\n      <td>25</td>\n      <td>1.049700</td>\n      <td>1.355180</td>\n      <td>0.272500</td>\n      <td>0.547900</td>\n      <td>0.243800</td>\n      <td>0.149700</td>\n      <td>0.229900</td>\n      <td>0.523100</td>\n      <td>0.272500</td>\n      <td>0.415700</td>\n      <td>0.442200</td>\n      <td>0.256200</td>\n      <td>0.420200</td>\n      <td>0.705800</td>\n      <td>0.523900</td>\n      <td>0.639600</td>\n      <td>0.271700</td>\n      <td>0.451900</td>\n      <td>0.166300</td>\n      <td>0.346900</td>\n      <td>0.153700</td>\n      <td>0.383100</td>\n      <td>0.247000</td>\n      <td>0.389300</td>\n    </tr>\n    <tr>\n      <td>26</td>\n      <td>1.049700</td>\n      <td>1.349337</td>\n      <td>0.275600</td>\n      <td>0.556300</td>\n      <td>0.246400</td>\n      <td>0.146700</td>\n      <td>0.234800</td>\n      <td>0.516300</td>\n      <td>0.274200</td>\n      <td>0.418300</td>\n      <td>0.440900</td>\n      <td>0.248700</td>\n      <td>0.418900</td>\n      <td>0.705800</td>\n      <td>0.523200</td>\n      <td>0.636500</td>\n      <td>0.274700</td>\n      <td>0.440500</td>\n      <td>0.172400</td>\n      <td>0.349100</td>\n      <td>0.155600</td>\n      <td>0.384600</td>\n      <td>0.252300</td>\n      <td>0.393800</td>\n    </tr>\n    <tr>\n      <td>27</td>\n      <td>1.049700</td>\n      <td>1.350782</td>\n      <td>0.275200</td>\n      <td>0.548700</td>\n      <td>0.246800</td>\n      <td>0.147300</td>\n      <td>0.236400</td>\n      <td>0.527200</td>\n      <td>0.280100</td>\n      <td>0.416200</td>\n      <td>0.442600</td>\n      <td>0.253400</td>\n      <td>0.424000</td>\n      <td>0.710300</td>\n      <td>0.526600</td>\n      <td>0.640100</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: b84aa76e-91e9-44ce-887c-bdabc8e0d1f4
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"b84aa76e-91e9-44ce-887c-bdabc8e0d1f4\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"6deb91b0-b583-4939-b904-bdd996693dd0\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"eea4576c6d6873529cc3bea66ea1778f283e2678101b921b93587b016d3cd8aa\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"e3be1cac-cb30-4ddf-9c10-ffebd53de173\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"b3ce0a443be5ab2466ca0c64fd00fabf3259ec1ecc365afdb2c7639f161401bf\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 41088, \"end_char_idx\": 42807, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "234800</td>\n      <td>0.516300</td>\n      <td>0.274200</td>\n      <td>0.418300</td>\n      <td>0.440900</td>\n      <td>0.248700</td>\n      <td>0.418900</td>\n      <td>0.705800</td>\n      <td>0.523200</td>\n      <td>0.636500</td>\n      <td>0.274700</td>\n      <td>0.440500</td>\n      <td>0.172400</td>\n      <td>0.349100</td>\n      <td>0.155600</td>\n      <td>0.384600</td>\n      <td>0.252300</td>\n      <td>0.393800</td>\n    </tr>\n    <tr>\n      <td>27</td>\n      <td>1.049700</td>\n      <td>1.350782</td>\n      <td>0.275200</td>\n      <td>0.548700</td>\n      <td>0.246800</td>\n      <td>0.147300</td>\n      <td>0.236400</td>\n      <td>0.527200</td>\n      <td>0.280100</td>\n      <td>0.416200</td>\n      <td>0.442600</td>\n      <td>0.253400</td>\n      <td>0.424000</td>\n      <td>0.710300</td>\n      <td>0.526600</td>\n      <td>0.640100</td>\n      <td>0.273200</td>\n      <td>0.445600</td>\n      <td>0.167000</td>\n      <td>0.346900</td>\n      <td>0.160100</td>\n      <td>0.387700</td>\n      <td>0.249200</td>\n      <td>0.392900</td>\n    </tr>\n    <tr>\n      <td>28</td>\n      <td>1.049700</td>\n      <td>1.346533</td>\n      <td>0.277000</td>\n      <td>0.552800</td>\n      <td>0.252900</td>\n      <td>0.147400</td>\n      <td>0.240000</td>\n      <td>0.527600</td>\n      <td>0.280900</td>\n      <td>0.420900</td>\n      <td>0.444100</td>\n      <td>0.255500</td>\n      <td>0.424500</td>\n      <td>0.711200</td>\n      <td>0.530200</td>\n      <td>0.646800</td>\n      <td>0.277400</td>\n      <td>0.441800</td>\n      <td>0.170900</td>\n      <td>0.346900</td>\n      <td>0.156600</td>\n      <td>0.389200</td>\n      <td>0.249600</td>\n      <td>0.396000</td>\n    </tr>\n    <tr>\n      <td>29</td>\n      <td>0.993700</td>\n      <td>1."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: e3be1cac-cb30-4ddf-9c10-ffebd53de173
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"e3be1cac-cb30-4ddf-9c10-ffebd53de173\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b84aa76e-91e9-44ce-887c-bdabc8e0d1f4\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"5b33e1d2e1d5d67dba5584bb5d11b6244c552e10c848f8be320d7b97b46991ff\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"92f15471-ed88-4dc4-930c-f5a8d39c9bbd\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"59982fcea0cccdb244a5f5733c581b0f3199be6ada77b32787c79b333e2706c8\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 41941, \"end_char_idx\": 43660, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "273200</td>\n      <td>0.445600</td>\n      <td>0.167000</td>\n      <td>0.346900</td>\n      <td>0.160100</td>\n      <td>0.387700</td>\n      <td>0.249200</td>\n      <td>0.392900</td>\n    </tr>\n    <tr>\n      <td>28</td>\n      <td>1.049700</td>\n      <td>1.346533</td>\n      <td>0.277000</td>\n      <td>0.552800</td>\n      <td>0.252900</td>\n      <td>0.147400</td>\n      <td>0.240000</td>\n      <td>0.527600</td>\n      <td>0.280900</td>\n      <td>0.420900</td>\n      <td>0.444100</td>\n      <td>0.255500</td>\n      <td>0.424500</td>\n      <td>0.711200</td>\n      <td>0.530200</td>\n      <td>0.646800</td>\n      <td>0.277400</td>\n      <td>0.441800</td>\n      <td>0.170900</td>\n      <td>0.346900</td>\n      <td>0.156600</td>\n      <td>0.389200</td>\n      <td>0.249600</td>\n      <td>0.396000</td>\n    </tr>\n    <tr>\n      <td>29</td>\n      <td>0.993700</td>\n      <td>1.346575</td>\n      <td>0.277100</td>\n      <td>0.554800</td>\n      <td>0.252900</td>\n      <td>0.148400</td>\n      <td>0.239700</td>\n      <td>0.523600</td>\n      <td>0.278400</td>\n      <td>0.420000</td>\n      <td>0.443300</td>\n      <td>0.256300</td>\n      <td>0.424000</td>\n      <td>0.705600</td>\n      <td>0.529600</td>\n      <td>0.647300</td>\n      <td>0.273900</td>\n      <td>0.439200</td>\n      <td>0.174300</td>\n      <td>0.348700</td>\n      <td>0.157600</td>\n      <td>0.386200</td>\n      <td>0.250100</td>\n      <td>0.395100</td>\n    </tr>\n    <tr>\n      <td>30</td>\n      <td>0.993700</td>\n      <td>1.346446</td>\n      <td>0.277400</td>\n      <td>0.554700</td>\n      <td>0.252700</td>\n      <td>0.147900</td>\n      <td>0.240800</td>\n      <td>0.523600</td>\n      <td>0.278800</td>\n      <td>0.420400</td>\n      <td>0.443300</td>\n      <td>0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 92f15471-ed88-4dc4-930c-f5a8d39c9bbd
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"92f15471-ed88-4dc4-930c-f5a8d39c9bbd\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"e3be1cac-cb30-4ddf-9c10-ffebd53de173\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"75cf3b74e03b2f1bbc7c5ad2b5e71d5ffca6cc15caa636cdcaec6b267f83b0e3\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"4036b18f-940a-4455-a59f-5db3aa14ea79\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"1ef026ef0d3a9ed9437da9b2d6b1a80a19cc4383f0da115e2f1842ad9d53c285\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 42807, \"end_char_idx\": 44245, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "346575</td>\n      <td>0.277100</td>\n      <td>0.554800</td>\n      <td>0.252900</td>\n      <td>0.148400</td>\n      <td>0.239700</td>\n      <td>0.523600</td>\n      <td>0.278400</td>\n      <td>0.420000</td>\n      <td>0.443300</td>\n      <td>0.256300</td>\n      <td>0.424000</td>\n      <td>0.705600</td>\n      <td>0.529600</td>\n      <td>0.647300</td>\n      <td>0.273900</td>\n      <td>0.439200</td>\n      <td>0.174300</td>\n      <td>0.348700</td>\n      <td>0.157600</td>\n      <td>0.386200</td>\n      <td>0.250100</td>\n      <td>0.395100</td>\n    </tr>\n    <tr>\n      <td>30</td>\n      <td>0.993700</td>\n      <td>1.346446</td>\n      <td>0.277400</td>\n      <td>0.554700</td>\n      <td>0.252700</td>\n      <td>0.147900</td>\n      <td>0.240800</td>\n      <td>0.523600</td>\n      <td>0.278800</td>\n      <td>0.420400</td>\n      <td>0.443300</td>\n      <td>0.256100</td>\n      <td>0.424200</td>\n      <td>0.705500</td>\n      <td>0.530100</td>\n      <td>0.646800</td>\n      <td>0.275600</td>\n      <td>0.440500</td>\n      <td>0.174500</td>\n      <td>0.348700</td>\n      <td>0.157300</td>\n      <td>0.386200</td>\n      <td>0.249200</td>\n      <td>0.394200</td>\n    </tr>\n  </tbody>\n</table><p>\n\nIf you have set `push_to_hub` to `True` in the `training_args`, the training checkpoints are pushed to the\nHugging Face Hub. Upon training completion, push the final model to the Hub as well by calling the [`~transformers.Trainer.push_to_hub`] method."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 4036b18f-940a-4455-a59f-5db3aa14ea79
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"4036b18f-940a-4455-a59f-5db3aa14ea79\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"92f15471-ed88-4dc4-930c-f5a8d39c9bbd\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"294c0852c60673f20a356f1c2b0c66012ff79f920b63c9bfdb007db94b486adb\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"3bba897a-7994-472c-b3f4-2d1bafe612f8\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"fef76698782cd924dfa6d083953b9935fd0dc238a9ff8043046ec52647f20817\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 43263, \"end_char_idx\": 45324, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "157600</td>\n      <td>0.386200</td>\n      <td>0.250100</td>\n      <td>0.395100</td>\n    </tr>\n    <tr>\n      <td>30</td>\n      <td>0.993700</td>\n      <td>1.346446</td>\n      <td>0.277400</td>\n      <td>0.554700</td>\n      <td>0.252700</td>\n      <td>0.147900</td>\n      <td>0.240800</td>\n      <td>0.523600</td>\n      <td>0.278800</td>\n      <td>0.420400</td>\n      <td>0.443300</td>\n      <td>0.256100</td>\n      <td>0.424200</td>\n      <td>0.705500</td>\n      <td>0.530100</td>\n      <td>0.646800</td>\n      <td>0.275600</td>\n      <td>0.440500</td>\n      <td>0.174500</td>\n      <td>0.348700</td>\n      <td>0.157300</td>\n      <td>0.386200</td>\n      <td>0.249200</td>\n      <td>0.394200</td>\n    </tr>\n  </tbody>\n</table><p>\n\nIf you have set `push_to_hub` to `True` in the `training_args`, the training checkpoints are pushed to the\nHugging Face Hub. Upon training completion, push the final model to the Hub as well by calling the [`~transformers.Trainer.push_to_hub`] method.\n\n```py\n>>> trainer.push_to_hub()\n```\n\n## Evaluate\n\n```py\n>>> from pprint import pprint\n\n>>> metrics = trainer.evaluate(eval_dataset=cppe5[\"test\"], metric_key_prefix=\"test\")\n>>> pprint(metrics)\n{'epoch': 30.0,\n  'test_loss': 1.0877351760864258,\n  'test_map': 0.4116,\n  'test_map_50': 0.741,\n  'test_map_75': 0.3663,\n  'test_map_Coverall': 0.5937,\n  'test_map_Face_Shield': 0.5863,\n  'test_map_Gloves': 0.3416,\n  'test_map_Goggles': 0.1468,\n  'test_map_Mask': 0.3894,\n  'test_map_large': 0.5637,\n  'test_map_medium': 0.3257,\n  'test_map_small': 0.3589,\n  'test_mar_1': 0.323,\n  'test_mar_10': 0.5237,\n  'test_mar_100': 0.5587,\n  'test_mar_100_Coverall': 0.6756,\n  'test_mar_100_Face_Shield': 0.7294,\n  'test_mar_100_Gloves': 0.4721,\n  'test_mar_100_Goggles': 0.4125,\n  'test_mar_100_Mask': 0.5038,\n  'test_mar_large': 0.7283,\n  'test_mar_medium': 0.4901,\n  'test_mar_small': 0.4469,\n  'test_runtime': 1.6526,\n  'test_samples_per_second': 17.548,\n  'test_steps_per_second': 2.42}\n```\n\nThese results can be further improved by adjusting the hyperparameters in [`TrainingArguments`]."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 3bba897a-7994-472c-b3f4-2d1bafe612f8
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/object_detection", "title": "Object detection", "tokens": 16536, "retrieve_doc": false, "source": "transformers", "_node_content": "{\"id_\": \"3bba897a-7994-472c-b3f4-2d1bafe612f8\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"c67b77e2-0310-4df5-8659-cf6d0618167d\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"d49b6ae8ff266cc10e090c1ef796434af536b844319b2f94a799eb913f650fc6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"4036b18f-940a-4455-a59f-5db3aa14ea79\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/object_detection\", \"title\": \"Object detection\", \"tokens\": 16536, \"retrieve_doc\": false, \"source\": \"transformers\"}, \"hash\": \"c01bfcedcc9708bb38549065936edfbcf3b16f93579ee0683ee90102e00dc845\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 45325, \"end_char_idx\": 47788, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "ref_doc_id": "c67b77e2-0310-4df5-8659-cf6d0618167d", "chroma:document": "Give it a go!\n\n## Inference\n\nNow that you have finetuned a model, evaluated it, and uploaded it to the Hugging Face Hub, you can use it for inference.\n\n```py\n>>> import torch\n>>> import requests\n\n>>> from PIL import Image, ImageDraw\n>>> from transformers import AutoImageProcessor, AutoModelForObjectDetection\n\n>>> url = \"https://images.pexels.com/photos/8413299/pexels-photo-8413299.jpeg?auto=compress&cs=tinysrgb&w=630&h=375&dpr=2\"\n>>> image = Image.open(requests.get(url, stream=True).raw)\n```\n\nLoad model and image processor from the Hugging Face Hub (skip to use already trained in this session):\n```py\n>>> device = \"cuda\"\n>>> model_repo = \"qubvel-hf/detr_finetuned_cppe5\"\n\n>>> image_processor = AutoImageProcessor.from_pretrained(model_repo)\n>>> model = AutoModelForObjectDetection.from_pretrained(model_repo)\n>>> model = model.to(device)\n```\n\nAnd detect bounding boxes:\n\n```py\n\n>>> with torch.no_grad():\n...     inputs = image_processor(images=[image], return_tensors=\"pt\")\n...     outputs = model(**inputs.to(device))\n...     target_sizes = torch.tensor([[image.size[1], image.size[0]]])\n...     results = image_processor.post_process_object_detection(outputs, threshold=0.3, target_sizes=target_sizes)[0]\n\n>>> for score, label, box in zip(results[\"scores\"], results[\"labels\"], results[\"boxes\"]):\n...     box = [round(i, 2) for i in box.tolist()]\n...     print(\n...         f\"Detected {model.config.id2label[label.item()]} with confidence \"\n...         f\"{round(score.item(), 3)} at location {box}\"\n...     )\nDetected Gloves with confidence 0.683 at location [244.58, 124.33, 300.35, 185.13]\nDetected Mask with confidence 0.517 at location [143.73, 64.58, 219.57, 125.89]\nDetected Gloves with confidence 0.425 at location [179.15, 155.57, 262.4, 226.35]\nDetected Coverall with confidence 0.407 at location [307.13, -1.18, 477.82, 318.06]\nDetected Coverall with confidence 0.391 at location [68.61, 126.66, 309.03, 318.89]\n```\n\nLet's plot the result:\n\n```py\n>>> draw = ImageDraw.Draw(image)\n\n>>> for score, label, box in zip(results[\"scores\"], results[\"labels\"], results[\"boxes\"]):\n...     box = [round(i, 2) for i in box.tolist()]\n...     x, y, x2, y2 = tuple(box)\n...     draw.rectangle((x, y, x2, y2), outline=\"red\", width=1)\n...     draw.text((x, y), model.config.id2label[label.item()], fill=\"white\")\n\n>>> image\n```\n\n<div class=\"flex justify-center\">\n    <img src=\"https://i.imgur.com/oDUqD0K.png\" alt=\"Object detection result on a new image\"/>\n</div>"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 691da99c-3f64-45c7-9de9-ef70575bbfdc
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"691da99c-3f64-45c7-9de9-ef70575bbfdc\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"827f035b-0e63-4c14-b8c1-1da0fc0c446a\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"7fad541e01f49fb3c14c95628ab35eaf9915dee7237b3c7b3e8f2e6bf913debd\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 2505, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "# Token classification\n\n[[open-in-colab]]\n\n<Youtube id=\"wVHdVlPScxA\"/>\n\nToken classification assigns a label to individual tokens in a sentence. One of the most common token classification tasks is Named Entity Recognition (NER). NER attempts to find a label for each entity in a sentence, such as a person, location, or organization.\n\nThis guide will show you how to:\n\n1. Finetune [DistilBERT](https://huggingface.co/distilbert/distilbert-base-uncased) on the [WNUT 17](https://huggingface.co/datasets/wnut_17) dataset to detect new entities.\n2. Use your finetuned model for inference.\n\n<Tip>\n\nTo see all architectures and checkpoints compatible with this task, we recommend checking the [task-page](https://huggingface.co/tasks/token-classification).\n\n</Tip>\n\nBefore you begin, make sure you have all the necessary libraries installed:\n\n```bash\npip install transformers datasets evaluate seqeval\n```\n\nWe encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:\n\n```py\n>>> from huggingface_hub import notebook_login\n\n>>> notebook_login()\n```\n\n## Load WNUT 17 dataset\n\nStart by loading the WNUT 17 dataset from the \ud83e\udd17 Datasets library:\n\n```py\n>>> from datasets import load_dataset\n\n>>> wnut = load_dataset(\"wnut_17\")\n```\n\nThen take a look at an example:\n\n```py\n>>> wnut[\"train\"][0]\n{'id': '0',\n 'ner_tags': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0],\n 'tokens': ['@paulwalk', 'It', \"'s\", 'the', 'view', 'from', 'where', 'I', \"'m\", 'living', 'for', 'two', 'weeks', '.', 'Empire', 'State', 'Building', '=', 'ESB', '.', 'Pretty', 'bad', 'storm', 'here', 'last', 'evening', '.']\n}\n```\n\nEach number in `ner_tags` represents an entity. Convert the numbers to their label names to find out what the entities are:\n\n```py\n>>> label_list = wnut[\"train\"].features[f\"ner_tags\"].feature.names\n>>> label_list\n[\n    \"O\",\n    \"B-corporation\",\n    \"I-corporation\",\n    \"B-creative-work\",\n    \"I-creative-work\",\n    \"B-group\",\n    \"I-group\",\n    \"B-location\",\n    \"I-location\",\n    \"B-person\",\n    \"I-person\",\n    \"B-product\",\n    \"I-product\",\n]\n```\n\nThe letter that prefixes each `ner_tag` indicates the token position of the entity:\n\n- `B-` indicates the beginning of an entity.\n- `I-` indicates a token is contained inside the same entity (for example, the `State` token is a part of an entity like\n  `Empire State Building`).\n- `0` indicates the token doesn't correspond to any entity."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 827f035b-0e63-4c14-b8c1-1da0fc0c446a
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"827f035b-0e63-4c14-b8c1-1da0fc0c446a\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"691da99c-3f64-45c7-9de9-ef70575bbfdc\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4ce66b9f8a5303f783742c32261bd29bd6a7778e5aad92469187666fa05c7771\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"08733de2-ad5c-4c3b-96bd-fe351c359e80\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e24a3259e936aa3c545d1ab2fdad9f602f66c385b824ec4ef84154749c1c20b4\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 1600, \"end_char_idx\": 4255, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "', 'Empire', 'State', 'Building', '=', 'ESB', '.', 'Pretty', 'bad', 'storm', 'here', 'last', 'evening', '.']\n}\n```\n\nEach number in `ner_tags` represents an entity. Convert the numbers to their label names to find out what the entities are:\n\n```py\n>>> label_list = wnut[\"train\"].features[f\"ner_tags\"].feature.names\n>>> label_list\n[\n    \"O\",\n    \"B-corporation\",\n    \"I-corporation\",\n    \"B-creative-work\",\n    \"I-creative-work\",\n    \"B-group\",\n    \"I-group\",\n    \"B-location\",\n    \"I-location\",\n    \"B-person\",\n    \"I-person\",\n    \"B-product\",\n    \"I-product\",\n]\n```\n\nThe letter that prefixes each `ner_tag` indicates the token position of the entity:\n\n- `B-` indicates the beginning of an entity.\n- `I-` indicates a token is contained inside the same entity (for example, the `State` token is a part of an entity like\n  `Empire State Building`).\n- `0` indicates the token doesn't correspond to any entity.\n\n## Preprocess\n\n<Youtube id=\"iY2AZYdZAr0\"/>\n\nThe next step is to load a DistilBERT tokenizer to preprocess the `tokens` field:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"distilbert/distilbert-base-uncased\")\n```\n\nAs you saw in the example `tokens` field above, it looks like the input has already been tokenized. But the input actually hasn't been tokenized yet and you'll need to set `is_split_into_words=True` to tokenize the words into subwords. For example:\n\n```py\n>>> example = wnut[\"train\"][0]\n>>> tokenized_input = tokenizer(example[\"tokens\"], is_split_into_words=True)\n>>> tokens = tokenizer.convert_ids_to_tokens(tokenized_input[\"input_ids\"])\n>>> tokens\n['[CLS]', '@', 'paul', '##walk', 'it', \"'\", 's', 'the', 'view', 'from', 'where', 'i', \"'\", 'm', 'living', 'for', 'two', 'weeks', '.', 'empire', 'state', 'building', '=', 'es', '##b', '.', 'pretty', 'bad', 'storm', 'here', 'last', 'evening', '.', '[SEP]']\n```\n\nHowever, this adds some special tokens `[CLS]` and `[SEP]` and the subword tokenization creates a mismatch between the input and labels. A single word corresponding to a single label may now be split into two subwords. You'll need to realign the tokens and labels by:\n\n1. Mapping all tokens to their corresponding word with the [`word_ids`](https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.BatchEncoding.word_ids) method.\n2. Assigning the label `-100` to the special tokens `[CLS]` and `[SEP]` so they're ignored by the PyTorch loss function (see [CrossEntropyLoss](https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html)).\n3. Only labeling the first token of a given word. Assign `-100` to other subtokens from the same word."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 08733de2-ad5c-4c3b-96bd-fe351c359e80
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"08733de2-ad5c-4c3b-96bd-fe351c359e80\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"827f035b-0e63-4c14-b8c1-1da0fc0c446a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"27c61547823b6dade56a4b83b332b2e84f6e9837ecaa4036bc851501359a1b35\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"e2f3809c-9493-42fb-af0c-f2e533ce9c6d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"8b40dc6404aa43958b99d6dba236aab721b1780867b9fbaff0852f08e6ba03de\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2873, \"end_char_idx\": 5883, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "But the input actually hasn't been tokenized yet and you'll need to set `is_split_into_words=True` to tokenize the words into subwords. For example:\n\n```py\n>>> example = wnut[\"train\"][0]\n>>> tokenized_input = tokenizer(example[\"tokens\"], is_split_into_words=True)\n>>> tokens = tokenizer.convert_ids_to_tokens(tokenized_input[\"input_ids\"])\n>>> tokens\n['[CLS]', '@', 'paul', '##walk', 'it', \"'\", 's', 'the', 'view', 'from', 'where', 'i', \"'\", 'm', 'living', 'for', 'two', 'weeks', '.', 'empire', 'state', 'building', '=', 'es', '##b', '.', 'pretty', 'bad', 'storm', 'here', 'last', 'evening', '.', '[SEP]']\n```\n\nHowever, this adds some special tokens `[CLS]` and `[SEP]` and the subword tokenization creates a mismatch between the input and labels. A single word corresponding to a single label may now be split into two subwords. You'll need to realign the tokens and labels by:\n\n1. Mapping all tokens to their corresponding word with the [`word_ids`](https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.BatchEncoding.word_ids) method.\n2. Assigning the label `-100` to the special tokens `[CLS]` and `[SEP]` so they're ignored by the PyTorch loss function (see [CrossEntropyLoss](https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html)).\n3. Only labeling the first token of a given word. Assign `-100` to other subtokens from the same word.\n\nHere is how you can create a function to realign the tokens and labels, and truncate sequences to be no longer than DistilBERT's maximum input length:\n\n```py\n>>> def tokenize_and_align_labels(examples):\n...     tokenized_inputs = tokenizer(examples[\"tokens\"], truncation=True, is_split_into_words=True)\n\n...     labels = []\n...     for i, label in enumerate(examples[f\"ner_tags\"]):\n...         word_ids = tokenized_inputs.word_ids(batch_index=i)  # Map tokens to their respective word.\n...         previous_word_idx = None\n...         label_ids = []\n...         for word_idx in word_ids:  # Set the special tokens to -100.\n...             if word_idx is None:\n...                 label_ids.append(-100)\n...             elif word_idx != previous_word_idx:  # Only label the first token of a given word.\n...                 label_ids.append(label[word_idx])\n...             else:\n...                 label_ids.append(-100)\n...             previous_word_idx = word_idx\n...         labels.append(label_ids)\n\n...     tokenized_inputs[\"labels\"] = labels\n...     return tokenized_inputs\n```\n\nTo apply the preprocessing function over the entire dataset, use \ud83e\udd17 Datasets [`~datasets.Dataset.map`] function. You can speed up the `map` function by setting `batched=True` to process multiple elements of the dataset at once:\n\n```py\n>>> tokenized_wnut = wnut.map(tokenize_and_align_labels, batched=True)\n```\n\nNow create a batch of examples using [`DataCollatorWithPadding`]. It's more efficient to *dynamically pad* the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: e2f3809c-9493-42fb-af0c-f2e533ce9c6d
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"e2f3809c-9493-42fb-af0c-f2e533ce9c6d\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"08733de2-ad5c-4c3b-96bd-fe351c359e80\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"ae7a759a0092c922744e5f5a3cd4cf4bb140daef03781c949842b6117c94eef4\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"6efde9e8-ae4c-4e95-a872-f827b56372c9\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"c48f8e218afc02521019a541ca338e311e5413d985d6935bb41b53308401feca\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4153, \"end_char_idx\": 7140, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "3. Only labeling the first token of a given word. Assign `-100` to other subtokens from the same word.\n\nHere is how you can create a function to realign the tokens and labels, and truncate sequences to be no longer than DistilBERT's maximum input length:\n\n```py\n>>> def tokenize_and_align_labels(examples):\n...     tokenized_inputs = tokenizer(examples[\"tokens\"], truncation=True, is_split_into_words=True)\n\n...     labels = []\n...     for i, label in enumerate(examples[f\"ner_tags\"]):\n...         word_ids = tokenized_inputs.word_ids(batch_index=i)  # Map tokens to their respective word.\n...         previous_word_idx = None\n...         label_ids = []\n...         for word_idx in word_ids:  # Set the special tokens to -100.\n...             if word_idx is None:\n...                 label_ids.append(-100)\n...             elif word_idx != previous_word_idx:  # Only label the first token of a given word.\n...                 label_ids.append(label[word_idx])\n...             else:\n...                 label_ids.append(-100)\n...             previous_word_idx = word_idx\n...         labels.append(label_ids)\n\n...     tokenized_inputs[\"labels\"] = labels\n...     return tokenized_inputs\n```\n\nTo apply the preprocessing function over the entire dataset, use \ud83e\udd17 Datasets [`~datasets.Dataset.map`] function. You can speed up the `map` function by setting `batched=True` to process multiple elements of the dataset at once:\n\n```py\n>>> tokenized_wnut = wnut.map(tokenize_and_align_labels, batched=True)\n```\n\nNow create a batch of examples using [`DataCollatorWithPadding`]. It's more efficient to *dynamically pad* the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length.\n\n<frameworkcontent>\n<pt>\n```py\n>>> from transformers import DataCollatorForTokenClassification\n\n>>> data_collator = DataCollatorForTokenClassification(tokenizer=tokenizer)\n```\n</pt>\n<tf>\n```py\n>>> from transformers import DataCollatorForTokenClassification\n\n>>> data_collator = DataCollatorForTokenClassification(tokenizer=tokenizer, return_tensors=\"tf\")\n```\n</tf>\n</frameworkcontent>\n\n## Evaluate\n\nIncluding a metric during training is often helpful for evaluating your model's performance. You can quickly load a evaluation method with the \ud83e\udd17 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [seqeval](https://huggingface.co/spaces/evaluate-metric/seqeval) framework (see the \ud83e\udd17 Evaluate [quick tour](https://huggingface.co/docs/evaluate/a_quick_tour) to learn more about how to load and compute a metric). Seqeval actually produces several scores: precision, recall, F1, and accuracy.\n\n```py\n>>> import evaluate\n\n>>> seqeval = evaluate.load(\"seqeval\")\n```\n\nGet the NER labels first, and then create a function that passes your true predictions and true labels to [`~evaluate.EvaluationModule.compute`] to calculate the scores:\n\n```py\n>>> import numpy as np\n\n>>> labels = [label_list[i] for i in example[f\"ner_tags\"]]"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 6efde9e8-ae4c-4e95-a872-f827b56372c9
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"6efde9e8-ae4c-4e95-a872-f827b56372c9\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"e2f3809c-9493-42fb-af0c-f2e533ce9c6d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"725395a4524e9155d3cd49543a87e29c340894bbf88935f95cc92383a96dca3a\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"f87b2342-4377-41cb-bd3d-a70adfb9b5ff\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"2785ed4cda887f25cbbfdbf7f11d1469fc8fb6cbc35dc7fd9c5fb56868f7f0ff\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5454, \"end_char_idx\": 8034, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "You can speed up the `map` function by setting `batched=True` to process multiple elements of the dataset at once:\n\n```py\n>>> tokenized_wnut = wnut.map(tokenize_and_align_labels, batched=True)\n```\n\nNow create a batch of examples using [`DataCollatorWithPadding`]. It's more efficient to *dynamically pad* the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length.\n\n<frameworkcontent>\n<pt>\n```py\n>>> from transformers import DataCollatorForTokenClassification\n\n>>> data_collator = DataCollatorForTokenClassification(tokenizer=tokenizer)\n```\n</pt>\n<tf>\n```py\n>>> from transformers import DataCollatorForTokenClassification\n\n>>> data_collator = DataCollatorForTokenClassification(tokenizer=tokenizer, return_tensors=\"tf\")\n```\n</tf>\n</frameworkcontent>\n\n## Evaluate\n\nIncluding a metric during training is often helpful for evaluating your model's performance. You can quickly load a evaluation method with the \ud83e\udd17 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [seqeval](https://huggingface.co/spaces/evaluate-metric/seqeval) framework (see the \ud83e\udd17 Evaluate [quick tour](https://huggingface.co/docs/evaluate/a_quick_tour) to learn more about how to load and compute a metric). Seqeval actually produces several scores: precision, recall, F1, and accuracy.\n\n```py\n>>> import evaluate\n\n>>> seqeval = evaluate.load(\"seqeval\")\n```\n\nGet the NER labels first, and then create a function that passes your true predictions and true labels to [`~evaluate.EvaluationModule.compute`] to calculate the scores:\n\n```py\n>>> import numpy as np\n\n>>> labels = [label_list[i] for i in example[f\"ner_tags\"]]\n\n\n>>> def compute_metrics(p):\n...     predictions, labels = p\n...     predictions = np.argmax(predictions, axis=2)\n\n...     true_predictions = [\n...         [label_list[p] for (p, l) in zip(prediction, label) if l != -100]\n...         for prediction, label in zip(predictions, labels)\n...     ]\n...     true_labels = [\n...         [label_list[l] for (p, l) in zip(prediction, label) if l != -100]\n...         for prediction, label in zip(predictions, labels)\n...     ]\n\n...     results = seqeval.compute(predictions=true_predictions, references=true_labels)\n...     return {\n...         \"precision\": results[\"overall_precision\"],\n...         \"recall\": results[\"overall_recall\"],\n...         \"f1\": results[\"overall_f1\"],\n...         \"accuracy\": results[\"overall_accuracy\"],\n...     }\n```\n\nYour `compute_metrics` function is ready to go now, and you'll return to it when you setup your training."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: f87b2342-4377-41cb-bd3d-a70adfb9b5ff
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"f87b2342-4377-41cb-bd3d-a70adfb9b5ff\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"6efde9e8-ae4c-4e95-a872-f827b56372c9\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"519ea7b6fd7abbda59d6c6d09cf6639fe2d3698a44a4dd745447b64ea88bf7c8\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b5891f24-a444-4f5b-b6f4-b30550bade31\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"361ddae4d20d8a9763a0df4fb87d8f3d209da7e2a76e44dc9857432d305f8b1b\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6376, \"end_char_idx\": 9106, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "You can quickly load a evaluation method with the \ud83e\udd17 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [seqeval](https://huggingface.co/spaces/evaluate-metric/seqeval) framework (see the \ud83e\udd17 Evaluate [quick tour](https://huggingface.co/docs/evaluate/a_quick_tour) to learn more about how to load and compute a metric). Seqeval actually produces several scores: precision, recall, F1, and accuracy.\n\n```py\n>>> import evaluate\n\n>>> seqeval = evaluate.load(\"seqeval\")\n```\n\nGet the NER labels first, and then create a function that passes your true predictions and true labels to [`~evaluate.EvaluationModule.compute`] to calculate the scores:\n\n```py\n>>> import numpy as np\n\n>>> labels = [label_list[i] for i in example[f\"ner_tags\"]]\n\n\n>>> def compute_metrics(p):\n...     predictions, labels = p\n...     predictions = np.argmax(predictions, axis=2)\n\n...     true_predictions = [\n...         [label_list[p] for (p, l) in zip(prediction, label) if l != -100]\n...         for prediction, label in zip(predictions, labels)\n...     ]\n...     true_labels = [\n...         [label_list[l] for (p, l) in zip(prediction, label) if l != -100]\n...         for prediction, label in zip(predictions, labels)\n...     ]\n\n...     results = seqeval.compute(predictions=true_predictions, references=true_labels)\n...     return {\n...         \"precision\": results[\"overall_precision\"],\n...         \"recall\": results[\"overall_recall\"],\n...         \"f1\": results[\"overall_f1\"],\n...         \"accuracy\": results[\"overall_accuracy\"],\n...     }\n```\n\nYour `compute_metrics` function is ready to go now, and you'll return to it when you setup your training.\n\n## Train\n\nBefore you start training your model, create a map of the expected ids to their labels with `id2label` and `label2id`:\n\n```py\n>>> id2label = {\n...     0: \"O\",\n...     1: \"B-corporation\",\n...     2: \"I-corporation\",\n...     3: \"B-creative-work\",\n...     4: \"I-creative-work\",\n...     5: \"B-group\",\n...     6: \"I-group\",\n...     7: \"B-location\",\n...     8: \"I-location\",\n...     9: \"B-person\",\n...     10: \"I-person\",\n...     11: \"B-product\",\n...     12: \"I-product\",\n... }\n>>> label2id = {\n...     \"O\": 0,\n...     \"B-corporation\": 1,\n...     \"I-corporation\": 2,\n...     \"B-creative-work\": 3,\n...     \"I-creative-work\": 4,\n...     \"B-group\": 5,\n...     \"I-group\": 6,\n...     \"B-location\": 7,\n...     \"I-location\": 8,\n...     \"B-person\": 9,\n...     \"I-person\": 10,\n...     \"B-product\": 11,\n...     \"I-product\": 12,\n... }\n```\n\n<frameworkcontent>\n<pt>\n<Tip>\n\nIf you aren't familiar with finetuning a model with the [`Trainer`], take a look at the basic tutorial [here](../training#train-with-pytorch-trainer)!\n\n</Tip>\n\nYou're ready to start training your model now!"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: b5891f24-a444-4f5b-b6f4-b30550bade31
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"b5891f24-a444-4f5b-b6f4-b30550bade31\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"f87b2342-4377-41cb-bd3d-a70adfb9b5ff\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"aa6683ba18182c25b2cc055d59626c3ba351e1089d431ef5cb3ff9e85823405b\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"65581ac0-b114-49c8-bd80-b1d6c811d3e4\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"d14c6500bb75218c36c18dc1c412f9c3e9419f26650964188997e7522391b8ba\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8036, \"end_char_idx\": 10113, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "## Train\n\nBefore you start training your model, create a map of the expected ids to their labels with `id2label` and `label2id`:\n\n```py\n>>> id2label = {\n...     0: \"O\",\n...     1: \"B-corporation\",\n...     2: \"I-corporation\",\n...     3: \"B-creative-work\",\n...     4: \"I-creative-work\",\n...     5: \"B-group\",\n...     6: \"I-group\",\n...     7: \"B-location\",\n...     8: \"I-location\",\n...     9: \"B-person\",\n...     10: \"I-person\",\n...     11: \"B-product\",\n...     12: \"I-product\",\n... }\n>>> label2id = {\n...     \"O\": 0,\n...     \"B-corporation\": 1,\n...     \"I-corporation\": 2,\n...     \"B-creative-work\": 3,\n...     \"I-creative-work\": 4,\n...     \"B-group\": 5,\n...     \"I-group\": 6,\n...     \"B-location\": 7,\n...     \"I-location\": 8,\n...     \"B-person\": 9,\n...     \"I-person\": 10,\n...     \"B-product\": 11,\n...     \"I-product\": 12,\n... }\n```\n\n<frameworkcontent>\n<pt>\n<Tip>\n\nIf you aren't familiar with finetuning a model with the [`Trainer`], take a look at the basic tutorial [here](../training#train-with-pytorch-trainer)!\n\n</Tip>\n\nYou're ready to start training your model now! Load DistilBERT with [`AutoModelForTokenClassification`] along with the number of expected labels, and the label mappings:\n\n```py\n>>> from transformers import AutoModelForTokenClassification, TrainingArguments, Trainer\n\n>>> model = AutoModelForTokenClassification.from_pretrained(\n...     \"distilbert/distilbert-base-uncased\", num_labels=13, id2label=id2label, label2id=label2id\n... )\n```\n\nAt this point, only three steps remain:\n\n1. Define your training hyperparameters in [`TrainingArguments`]. The only required parameter is `output_dir` which specifies where to save your model. You'll push this model to the Hub by setting `push_to_hub=True` (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the [`Trainer`] will evaluate the seqeval scores and save the training checkpoint.\n2. Pass the training arguments to [`Trainer`] along with the model, dataset, tokenizer, data collator, and `compute_metrics` function.\n3. Call [`~Trainer.train`] to finetune your model."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 65581ac0-b114-49c8-bd80-b1d6c811d3e4
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"65581ac0-b114-49c8-bd80-b1d6c811d3e4\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b5891f24-a444-4f5b-b6f4-b30550bade31\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"0280928dc6375ed54195f5e586abad9f19bdd956c0fddefa486a5009e7614840\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b62ea455-6a06-4089-bca3-89bee4790041\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"884fdc423f1ee4a412f40282735107c2af27bc154c7ad28ac3141014acd96396\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9052, \"end_char_idx\": 11147, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "</Tip>\n\nYou're ready to start training your model now! Load DistilBERT with [`AutoModelForTokenClassification`] along with the number of expected labels, and the label mappings:\n\n```py\n>>> from transformers import AutoModelForTokenClassification, TrainingArguments, Trainer\n\n>>> model = AutoModelForTokenClassification.from_pretrained(\n...     \"distilbert/distilbert-base-uncased\", num_labels=13, id2label=id2label, label2id=label2id\n... )\n```\n\nAt this point, only three steps remain:\n\n1. Define your training hyperparameters in [`TrainingArguments`]. The only required parameter is `output_dir` which specifies where to save your model. You'll push this model to the Hub by setting `push_to_hub=True` (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the [`Trainer`] will evaluate the seqeval scores and save the training checkpoint.\n2. Pass the training arguments to [`Trainer`] along with the model, dataset, tokenizer, data collator, and `compute_metrics` function.\n3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> training_args = TrainingArguments(\n...     output_dir=\"my_awesome_wnut_model\",\n...     learning_rate=2e-5,\n...     per_device_train_batch_size=16,\n...     per_device_eval_batch_size=16,\n...     num_train_epochs=2,\n...     weight_decay=0.01,\n...     eval_strategy=\"epoch\",\n...     save_strategy=\"epoch\",\n...     load_best_model_at_end=True,\n...     push_to_hub=True,\n... )\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     train_dataset=tokenized_wnut[\"train\"],\n...     eval_dataset=tokenized_wnut[\"test\"],\n...     tokenizer=tokenizer,\n...     data_collator=data_collator,\n...     compute_metrics=compute_metrics,\n... )\n\n>>> trainer.train()\n```\n\nOnce training is completed, share your model to the Hub with the [`~transformers.Trainer.push_to_hub`] method so everyone can use your model:\n\n```py\n>>> trainer.push_to_hub()\n```\n</pt>\n<tf>\n<Tip>\n\nIf you aren't familiar with finetuning a model with Keras, take a look at the basic tutorial [here](../training#train-a-tensorflow-model-with-keras)!"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: b62ea455-6a06-4089-bca3-89bee4790041
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"b62ea455-6a06-4089-bca3-89bee4790041\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"65581ac0-b114-49c8-bd80-b1d6c811d3e4\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"1e3540831ef652f7e28c47514b8ae6dde357e23e02a614c4c4819e7113757a7e\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"82a6dd4b-3511-4537-8d78-45a672761ef5\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e02c7d35bf0351340539f9131f6e3d953747f6cec2f229514f303db3b2a22b5c\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9604, \"end_char_idx\": 12620, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "The only required parameter is `output_dir` which specifies where to save your model. You'll push this model to the Hub by setting `push_to_hub=True` (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the [`Trainer`] will evaluate the seqeval scores and save the training checkpoint.\n2. Pass the training arguments to [`Trainer`] along with the model, dataset, tokenizer, data collator, and `compute_metrics` function.\n3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> training_args = TrainingArguments(\n...     output_dir=\"my_awesome_wnut_model\",\n...     learning_rate=2e-5,\n...     per_device_train_batch_size=16,\n...     per_device_eval_batch_size=16,\n...     num_train_epochs=2,\n...     weight_decay=0.01,\n...     eval_strategy=\"epoch\",\n...     save_strategy=\"epoch\",\n...     load_best_model_at_end=True,\n...     push_to_hub=True,\n... )\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     train_dataset=tokenized_wnut[\"train\"],\n...     eval_dataset=tokenized_wnut[\"test\"],\n...     tokenizer=tokenizer,\n...     data_collator=data_collator,\n...     compute_metrics=compute_metrics,\n... )\n\n>>> trainer.train()\n```\n\nOnce training is completed, share your model to the Hub with the [`~transformers.Trainer.push_to_hub`] method so everyone can use your model:\n\n```py\n>>> trainer.push_to_hub()\n```\n</pt>\n<tf>\n<Tip>\n\nIf you aren't familiar with finetuning a model with Keras, take a look at the basic tutorial [here](../training#train-a-tensorflow-model-with-keras)!\n\n</Tip>\nTo finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:\n\n```py\n>>> from transformers import create_optimizer\n\n>>> batch_size = 16\n>>> num_train_epochs = 3\n>>> num_train_steps = (len(tokenized_wnut[\"train\"]) // batch_size) * num_train_epochs\n>>> optimizer, lr_schedule = create_optimizer(\n...     init_lr=2e-5,\n...     num_train_steps=num_train_steps,\n...     weight_decay_rate=0.01,\n...     num_warmup_steps=0,\n... )\n```\n\nThen you can load DistilBERT with [`TFAutoModelForTokenClassification`] along with the number of expected labels, and the label mappings:\n\n```py\n>>> from transformers import TFAutoModelForTokenClassification\n\n>>> model = TFAutoModelForTokenClassification.from_pretrained(\n...     \"distilbert/distilbert-base-uncased\", num_labels=13, id2label=id2label, label2id=label2id\n... )\n```\n\nConvert your datasets to the `tf.data.Dataset` format with [`~transformers.TFPreTrainedModel.prepare_tf_dataset`]:\n\n```py\n>>> tf_train_set = model.prepare_tf_dataset(\n...     tokenized_wnut[\"train\"],\n...     shuffle=True,\n...     batch_size=16,\n...     collate_fn=data_collator,\n... )\n\n>>> tf_validation_set = model.prepare_tf_dataset(\n...     tokenized_wnut[\"validation\"],\n...     shuffle=False,\n...     batch_size=16,\n...     collate_fn=data_collator,\n... )\n```\n\nConfigure the model for training with [`compile`](https://keras.io/api/models/model_training_apis/#compile-method)."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 82a6dd4b-3511-4537-8d78-45a672761ef5
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"82a6dd4b-3511-4537-8d78-45a672761ef5\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b62ea455-6a06-4089-bca3-89bee4790041\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"8f7b9e3ebc53bd897cc806d4985a52f9eae694c152746df6f358dca135c247ad\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"87783408-116d-44b3-8676-77022bd716fd\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"567448bec4c7d17bccd228fbf7f802103157af75729277c11b04a956639fbdb3\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 11149, \"end_char_idx\": 14184, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "</Tip>\nTo finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:\n\n```py\n>>> from transformers import create_optimizer\n\n>>> batch_size = 16\n>>> num_train_epochs = 3\n>>> num_train_steps = (len(tokenized_wnut[\"train\"]) // batch_size) * num_train_epochs\n>>> optimizer, lr_schedule = create_optimizer(\n...     init_lr=2e-5,\n...     num_train_steps=num_train_steps,\n...     weight_decay_rate=0.01,\n...     num_warmup_steps=0,\n... )\n```\n\nThen you can load DistilBERT with [`TFAutoModelForTokenClassification`] along with the number of expected labels, and the label mappings:\n\n```py\n>>> from transformers import TFAutoModelForTokenClassification\n\n>>> model = TFAutoModelForTokenClassification.from_pretrained(\n...     \"distilbert/distilbert-base-uncased\", num_labels=13, id2label=id2label, label2id=label2id\n... )\n```\n\nConvert your datasets to the `tf.data.Dataset` format with [`~transformers.TFPreTrainedModel.prepare_tf_dataset`]:\n\n```py\n>>> tf_train_set = model.prepare_tf_dataset(\n...     tokenized_wnut[\"train\"],\n...     shuffle=True,\n...     batch_size=16,\n...     collate_fn=data_collator,\n... )\n\n>>> tf_validation_set = model.prepare_tf_dataset(\n...     tokenized_wnut[\"validation\"],\n...     shuffle=False,\n...     batch_size=16,\n...     collate_fn=data_collator,\n... )\n```\n\nConfigure the model for training with [`compile`](https://keras.io/api/models/model_training_apis/#compile-method). Note that Transformers models all have a default task-relevant loss function, so you don't need to specify one unless you want to:\n\n```py\n>>> import tensorflow as tf\n\n>>> model.compile(optimizer=optimizer)  # No loss argument!\n```\n\nThe last two things to setup before you start training is to compute the seqeval scores from the predictions, and provide a way to push your model to the Hub. Both are done by using [Keras callbacks](../main_classes/keras_callbacks).\n\nPass your `compute_metrics` function to [`~transformers.KerasMetricCallback`]:\n\n```py\n>>> from transformers.keras_callbacks import KerasMetricCallback\n\n>>> metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_validation_set)\n```\n\nSpecify where to push your model and tokenizer in the [`~transformers.PushToHubCallback`]:\n\n```py\n>>> from transformers.keras_callbacks import PushToHubCallback\n\n>>> push_to_hub_callback = PushToHubCallback(\n...     output_dir=\"my_awesome_wnut_model\",\n...     tokenizer=tokenizer,\n... )\n```\n\nThen bundle your callbacks together:\n\n```py\n>>> callbacks = [metric_callback, push_to_hub_callback]\n```\n\nFinally, you're ready to start training your model! Call [`fit`](https://keras.io/api/models/model_training_apis/#fit-method) with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:\n\n```py\n>>> model.fit(x=tf_train_set, validation_data=tf_validation_set, epochs=3, callbacks=callbacks)\n```\n\nOnce training is completed, your model is automatically uploaded to the Hub so everyone can use it!"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 87783408-116d-44b3-8676-77022bd716fd
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"87783408-116d-44b3-8676-77022bd716fd\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"82a6dd4b-3511-4537-8d78-45a672761ef5\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"d6e9a66da3063064646fd7581ad2822293186d82314458af983ec75bcb306465\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b1e6bf2e-fbbd-489c-8254-1b83eea3a9f7\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"43649f7ea7aa46f7b0026a055f23fdf5a41ddb27921fa2d7f9bbbb0eb0c58095\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 12621, \"end_char_idx\": 15602, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "Note that Transformers models all have a default task-relevant loss function, so you don't need to specify one unless you want to:\n\n```py\n>>> import tensorflow as tf\n\n>>> model.compile(optimizer=optimizer)  # No loss argument!\n```\n\nThe last two things to setup before you start training is to compute the seqeval scores from the predictions, and provide a way to push your model to the Hub. Both are done by using [Keras callbacks](../main_classes/keras_callbacks).\n\nPass your `compute_metrics` function to [`~transformers.KerasMetricCallback`]:\n\n```py\n>>> from transformers.keras_callbacks import KerasMetricCallback\n\n>>> metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_validation_set)\n```\n\nSpecify where to push your model and tokenizer in the [`~transformers.PushToHubCallback`]:\n\n```py\n>>> from transformers.keras_callbacks import PushToHubCallback\n\n>>> push_to_hub_callback = PushToHubCallback(\n...     output_dir=\"my_awesome_wnut_model\",\n...     tokenizer=tokenizer,\n... )\n```\n\nThen bundle your callbacks together:\n\n```py\n>>> callbacks = [metric_callback, push_to_hub_callback]\n```\n\nFinally, you're ready to start training your model! Call [`fit`](https://keras.io/api/models/model_training_apis/#fit-method) with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:\n\n```py\n>>> model.fit(x=tf_train_set, validation_data=tf_validation_set, epochs=3, callbacks=callbacks)\n```\n\nOnce training is completed, your model is automatically uploaded to the Hub so everyone can use it!\n</tf>\n</frameworkcontent>\n\n<Tip>\n\nFor a more in-depth example of how to finetune a model for token classification, take a look at the corresponding\n[PyTorch notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/token_classification.ipynb)\nor [TensorFlow notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/token_classification-tf.ipynb).\n\n</Tip>\n\n## Inference\n\nGreat, now that you've finetuned a model, you can use it for inference!\n\nGrab some text you'd like to run inference on:\n\n```py\n>>> text = \"The Golden State Warriors are an American professional basketball team based in San Francisco.\"\n```\n\nThe simplest way to try out your finetuned model for inference is to use it in a [`pipeline`]. Instantiate a `pipeline` for NER with your model, and pass your text to it:\n\n```py\n>>> from transformers import pipeline\n\n>>> classifier = pipeline(\"ner\", model=\"stevhliu/my_awesome_wnut_model\")\n>>> classifier(text)\n[{'entity': 'B-location',\n  'score': 0.42658573,\n  'index': 2,\n  'word': 'golden',\n  'start': 4,\n  'end': 10},\n {'entity': 'I-location',\n  'score': 0.35856336,\n  'index': 3,\n  'word': 'state',\n  'start': 11,\n  'end': 16},\n {'entity': 'B-group',\n  'score': 0.3064001,\n  'index': 4,\n  'word': 'warriors',\n  'start': 17,\n  'end': 25},\n {'entity': 'B-location',\n  'score': 0.65523505,\n  'index': 13,\n  'word': 'san',\n  'start': 80,"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: b1e6bf2e-fbbd-489c-8254-1b83eea3a9f7
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"b1e6bf2e-fbbd-489c-8254-1b83eea3a9f7\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"87783408-116d-44b3-8676-77022bd716fd\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"e4e37799b293f162c217dabdc0c9f6ff4e485a0aa73d11904590aaf30a6e12ac\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"405c6bc8-de41-4978-b96d-f03fc885f35c\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e2b9c89db616ded8c9a9d885c31b8597cb656a91a069386591f1e5554b823a0d\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": null, \"end_char_idx\": null, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "</Tip>\n\n## Inference\n\nGreat, now that you've finetuned a model, you can use it for inference!\n\nGrab some text you'd like to run inference on:\n\n```py\n>>> text = \"The Golden State Warriors are an American professional basketball team based in San Francisco.\"\n```\n\nThe simplest way to try out your finetuned model for inference is to use it in a [`pipeline`]. Instantiate a `pipeline` for NER with your model, and pass your text to it:\n\n```py\n>>> from transformers import pipeline\n\n>>> classifier = pipeline(\"ner\", model=\"stevhliu/my_awesome_wnut_model\")\n>>> classifier(text)\n[{'entity': 'B-location',\n  'score': 0.42658573,\n  'index': 2,\n  'word': 'golden',\n  'start': 4,\n  'end': 10},\n {'entity': 'I-location',\n  'score': 0.35856336,\n  'index': 3,\n  'word': 'state',\n  'start': 11,\n  'end': 16},\n {'entity': 'B-group',\n  'score': 0.3064001,\n  'index': 4,\n  'word': 'warriors',\n  'start': 17,\n  'end': 25},\n {'entity': 'B-location',\n  'score': 0.65523505,\n  'index': 13,\n  'word': 'san',\n  'start': 80,\n  'end': 83},\n {'entity': 'B-location',\n  'score': 0.4668663,\n  'index': 14,\n  'word': 'francisco',\n  'start': 84,\n  'end': 93}]\n```\n\nYou can also manually replicate the results of the `pipeline` if you'd like:\n\n<frameworkcontent>\n<pt>\nTokenize the text and return PyTorch tensors:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"stevhliu/my_awesome_wnut_model\")\n>>> inputs = tokenizer(text, return_tensors=\"pt\")\n```\n\nPass your inputs to the model and return the `logits`:\n\n```py\n>>> from transformers import AutoModelForTokenClassification\n\n>>> model = AutoModelForTokenClassification.from_pretrained(\"stevhliu/my_awesome_wnut_model\")\n>>> with torch.no_grad():\n.     logits = model(**inputs).logits\n```\n\nGet the class with the highest probability, and use the model's `id2label` mapping to convert it to a text label:\n\n```py\n>>> predictions = torch.argmax(logits, dim=2)\n>>> predicted_token_class = [model.config.id2label[t.item()] for t in predictions[0]]\n>>> predicted_token_class\n['O',\n 'O',\n 'B-location',\n 'I-location',\n 'B-group',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'B-location',\n 'B-location',\n 'O',\n 'O']\n```\n</pt>\n<tf>\nTokenize the text and return TensorFlow tensors:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"stevhliu/my_awesome_wnut_model\")\n>>> inputs = tokenizer(text,"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 405c6bc8-de41-4978-b96d-f03fc885f35c
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/token_classification", "title": "Token classification", "tokens": 4795, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"405c6bc8-de41-4978-b96d-f03fc885f35c\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"99e9cfbf-26cb-4967-aec7-5a0879f9fe44\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2e558a5bdc01661668c830be29b792690caf3fba9f44f2ddca71e69822f565f3\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b1e6bf2e-fbbd-489c-8254-1b83eea3a9f7\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/token_classification\", \"title\": \"Token classification\", \"tokens\": 4795, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"392af0077eb869393d0ecb290bc8bc2549b7d02c8bec451b12f7235344573c1f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": null, \"end_char_idx\": null, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "ref_doc_id": "99e9cfbf-26cb-4967-aec7-5a0879f9fe44", "chroma:document": "4668663,\n  'index': 14,\n  'word': 'francisco',\n  'start': 84,\n  'end': 93}]\n```\n\nYou can also manually replicate the results of the `pipeline` if you'd like:\n\n<frameworkcontent>\n<pt>\nTokenize the text and return PyTorch tensors:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"stevhliu/my_awesome_wnut_model\")\n>>> inputs = tokenizer(text, return_tensors=\"pt\")\n```\n\nPass your inputs to the model and return the `logits`:\n\n```py\n>>> from transformers import AutoModelForTokenClassification\n\n>>> model = AutoModelForTokenClassification.from_pretrained(\"stevhliu/my_awesome_wnut_model\")\n>>> with torch.no_grad():\n.     logits = model(**inputs).logits\n```\n\nGet the class with the highest probability, and use the model's `id2label` mapping to convert it to a text label:\n\n```py\n>>> predictions = torch.argmax(logits, dim=2)\n>>> predicted_token_class = [model.config.id2label[t.item()] for t in predictions[0]]\n>>> predicted_token_class\n['O',\n 'O',\n 'B-location',\n 'I-location',\n 'B-group',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'B-location',\n 'B-location',\n 'O',\n 'O']\n```\n</pt>\n<tf>\nTokenize the text and return TensorFlow tensors:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"stevhliu/my_awesome_wnut_model\")\n>>> inputs = tokenizer(text, return_tensors=\"tf\")\n```\n\nPass your inputs to the model and return the `logits`:\n\n```py\n>>> from transformers import TFAutoModelForTokenClassification\n\n>>> model = TFAutoModelForTokenClassification.from_pretrained(\"stevhliu/my_awesome_wnut_model\")\n>>> logits = model(**inputs).logits\n```\n\nGet the class with the highest probability, and use the model's `id2label` mapping to convert it to a text label:\n\n```py\n>>> predicted_token_class_ids = tf.math.argmax(logits, axis=-1)\n>>> predicted_token_class = [model.config.id2label[t] for t in predicted_token_class_ids[0].numpy().tolist()]\n>>> predicted_token_class\n['O',\n 'O',\n 'B-location',\n 'I-location',\n 'B-group',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'O',\n 'B-location',\n 'B-location',\n 'O',\n 'O']\n```\n</tf>\n</frameworkcontent>"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 823f65b7-4626-4069-8aa4-b52412f800f8
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/sequence_classification", "title": "Text classification", "tokens": 3451, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"823f65b7-4626-4069-8aa4-b52412f800f8\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0ba6ffc6-fc8f-4c02-ab78-e17886da84ed\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"0b2c612180b4f3f79bc906ce6f7c0ee445069a6b8280aa7a205b282b565b5367\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"97ac2680-efec-4716-942e-16e0b7994ba1\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"c8f70e656c6b7ff5b593c66ace565599914eb6283fcc8a714c33a92590bfdcab\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3081, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "ref_doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "chroma:document": "# Text classification\n\n[[open-in-colab]]\n\n<Youtube id=\"leNG9fN9FQU\"/>\n\nText classification is a common NLP task that assigns a label or class to text. Some of the largest companies run text classification in production for a wide range of practical applications. One of the most popular forms of text classification is sentiment analysis, which assigns a label like \ud83d\ude42 positive, \ud83d\ude41 negative, or \ud83d\ude10 neutral to a sequence of text.\n\nThis guide will show you how to:\n\n1. Finetune [DistilBERT](https://huggingface.co/distilbert/distilbert-base-uncased) on the [IMDb](https://huggingface.co/datasets/imdb) dataset to determine whether a movie review is positive or negative.\n2. Use your finetuned model for inference.\n\n<Tip>\n\nTo see all architectures and checkpoints compatible with this task, we recommend checking the [task-page](https://huggingface.co/tasks/text-classification).\n\n</Tip>\n\nBefore you begin, make sure you have all the necessary libraries installed:\n\n```bash\npip install transformers datasets evaluate accelerate\n```\n\nWe encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:\n\n```py\n>>> from huggingface_hub import notebook_login\n\n>>> notebook_login()\n```\n\n## Load IMDb dataset\n\nStart by loading the IMDb dataset from the \ud83e\udd17 Datasets library:\n\n```py\n>>> from datasets import load_dataset\n\n>>> imdb = load_dataset(\"imdb\")\n```\n\nThen take a look at an example:\n\n```py\n>>> imdb[\"test\"][0]\n{\n    \"label\": 0,\n    \"text\": \"I love sci-fi and am willing to put up with a lot. Sci-fi movies/TV are usually underfunded, under-appreciated and misunderstood. I tried to like this, I really did, but it is to good TV sci-fi as Babylon 5 is to Star Trek (the original). Silly prosthetics, cheap cardboard sets, stilted dialogues, CG that doesn't match the background, and painfully one-dimensional characters cannot be overcome with a 'sci-fi' setting. (I'm sure there are those of you out there who think Babylon 5 is good sci-fi TV. It's not. It's clich\u00e9d and uninspiring.) While US viewers might like emotion and character development, sci-fi is a genre that does not take itself seriously (cf. Star Trek). It may treat important issues, yet not as a serious philosophy. It's really difficult to care about the characters here as they are not simply foolish, just missing a spark of life. Their actions and reactions are wooden and predictable, often painful to watch. The makers of Earth KNOW it's rubbish as they have to always say \\\"Gene Roddenberry's Earth...\\\" otherwise people would not continue watching. Roddenberry's ashes must be turning in their orbit as this dull, cheap, poorly edited (watching it without advert breaks really brings this home) trudging Trabant of a show lumbers into space. Spoiler. So, kill off a main character. And then bring him back as another actor. Jeeez! Dallas all over again.\",\n}\n```\n\nThere are two fields in this dataset:\n\n- `text`: the movie review text.\n- `label`: a value that is either `0` for a negative review or `1` for a positive review."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 97ac2680-efec-4716-942e-16e0b7994ba1
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/sequence_classification", "title": "Text classification", "tokens": 3451, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"97ac2680-efec-4716-942e-16e0b7994ba1\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0ba6ffc6-fc8f-4c02-ab78-e17886da84ed\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"0b2c612180b4f3f79bc906ce6f7c0ee445069a6b8280aa7a205b282b565b5367\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"823f65b7-4626-4069-8aa4-b52412f800f8\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"16d3e10353f9a0eb2f06e33f1768f8dbe4123ba3dcbb484dfc1531a2a4b3b2d6\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"df3c86e4-85f3-4a05-b9c9-761b6401a8b9\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"7ee99d2dff91ce91cd085ce898a4341ab4217ee25a1d9fbcfa28f5fc107c9594\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 1573, \"end_char_idx\": 4641, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "ref_doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "chroma:document": "Sci-fi movies/TV are usually underfunded, under-appreciated and misunderstood. I tried to like this, I really did, but it is to good TV sci-fi as Babylon 5 is to Star Trek (the original). Silly prosthetics, cheap cardboard sets, stilted dialogues, CG that doesn't match the background, and painfully one-dimensional characters cannot be overcome with a 'sci-fi' setting. (I'm sure there are those of you out there who think Babylon 5 is good sci-fi TV. It's not. It's clich\u00e9d and uninspiring.) While US viewers might like emotion and character development, sci-fi is a genre that does not take itself seriously (cf. Star Trek). It may treat important issues, yet not as a serious philosophy. It's really difficult to care about the characters here as they are not simply foolish, just missing a spark of life. Their actions and reactions are wooden and predictable, often painful to watch. The makers of Earth KNOW it's rubbish as they have to always say \\\"Gene Roddenberry's Earth...\\\" otherwise people would not continue watching. Roddenberry's ashes must be turning in their orbit as this dull, cheap, poorly edited (watching it without advert breaks really brings this home) trudging Trabant of a show lumbers into space. Spoiler. So, kill off a main character. And then bring him back as another actor. Jeeez! Dallas all over again.\",\n}\n```\n\nThere are two fields in this dataset:\n\n- `text`: the movie review text.\n- `label`: a value that is either `0` for a negative review or `1` for a positive review.\n\n## Preprocess\n\nThe next step is to load a DistilBERT tokenizer to preprocess the `text` field:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"distilbert/distilbert-base-uncased\")\n```\n\nCreate a preprocessing function to tokenize `text` and truncate sequences to be no longer than DistilBERT's maximum input length:\n\n```py\n>>> def preprocess_function(examples):\n...     return tokenizer(examples[\"text\"], truncation=True)\n```\n\nTo apply the preprocessing function over the entire dataset, use \ud83e\udd17 Datasets [`~datasets.Dataset.map`] function. You can speed up `map` by setting `batched=True` to process multiple elements of the dataset at once:\n\n```py\ntokenized_imdb = imdb.map(preprocess_function, batched=True)\n```\n\nNow create a batch of examples using [`DataCollatorWithPadding`]. It's more efficient to *dynamically pad* the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length.\n\n<frameworkcontent>\n<pt>\n```py\n>>> from transformers import DataCollatorWithPadding\n\n>>> data_collator = DataCollatorWithPadding(tokenizer=tokenizer)\n```\n</pt>\n<tf>\n```py\n>>> from transformers import DataCollatorWithPadding\n\n>>> data_collator = DataCollatorWithPadding(tokenizer=tokenizer, return_tensors=\"tf\")\n```\n</tf>\n</frameworkcontent>\n\n## Evaluate\n\nIncluding a metric during training is often helpful for evaluating your model's performance. You can quickly load a evaluation method with the \ud83e\udd17 [Evaluate](https://huggingface.co/docs/evaluate/index) library."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: df3c86e4-85f3-4a05-b9c9-761b6401a8b9
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/sequence_classification", "title": "Text classification", "tokens": 3451, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"df3c86e4-85f3-4a05-b9c9-761b6401a8b9\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0ba6ffc6-fc8f-4c02-ab78-e17886da84ed\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"0b2c612180b4f3f79bc906ce6f7c0ee445069a6b8280aa7a205b282b565b5367\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"97ac2680-efec-4716-942e-16e0b7994ba1\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"111df497e755d206da1c0ba0f35896255d027ae0b83c6a87f514d37ed78bef5a\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"b8a1f960-8783-4747-b752-a65d8154c012\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"b77769ff2fd9e32b51471f005094ed1162e8a4b968124abc65fbd7b02a882965\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2992, \"end_char_idx\": 5904, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "ref_doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "chroma:document": "- `label`: a value that is either `0` for a negative review or `1` for a positive review.\n\n## Preprocess\n\nThe next step is to load a DistilBERT tokenizer to preprocess the `text` field:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"distilbert/distilbert-base-uncased\")\n```\n\nCreate a preprocessing function to tokenize `text` and truncate sequences to be no longer than DistilBERT's maximum input length:\n\n```py\n>>> def preprocess_function(examples):\n...     return tokenizer(examples[\"text\"], truncation=True)\n```\n\nTo apply the preprocessing function over the entire dataset, use \ud83e\udd17 Datasets [`~datasets.Dataset.map`] function. You can speed up `map` by setting `batched=True` to process multiple elements of the dataset at once:\n\n```py\ntokenized_imdb = imdb.map(preprocess_function, batched=True)\n```\n\nNow create a batch of examples using [`DataCollatorWithPadding`]. It's more efficient to *dynamically pad* the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length.\n\n<frameworkcontent>\n<pt>\n```py\n>>> from transformers import DataCollatorWithPadding\n\n>>> data_collator = DataCollatorWithPadding(tokenizer=tokenizer)\n```\n</pt>\n<tf>\n```py\n>>> from transformers import DataCollatorWithPadding\n\n>>> data_collator = DataCollatorWithPadding(tokenizer=tokenizer, return_tensors=\"tf\")\n```\n</tf>\n</frameworkcontent>\n\n## Evaluate\n\nIncluding a metric during training is often helpful for evaluating your model's performance. You can quickly load a evaluation method with the \ud83e\udd17 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [accuracy](https://huggingface.co/spaces/evaluate-metric/accuracy) metric (see the \ud83e\udd17 Evaluate [quick tour](https://huggingface.co/docs/evaluate/a_quick_tour) to learn more about how to load and compute a metric):\n\n```py\n>>> import evaluate\n\n>>> accuracy = evaluate.load(\"accuracy\")\n```\n\nThen create a function that passes your predictions and labels to [`~evaluate.EvaluationModule.compute`] to calculate the accuracy:\n\n```py\n>>> import numpy as np\n\n\n>>> def compute_metrics(eval_pred):\n...     predictions, labels = eval_pred\n...     predictions = np.argmax(predictions, axis=1)\n...     return accuracy.compute(predictions=predictions, references=labels)\n```\n\nYour `compute_metrics` function is ready to go now, and you'll return to it when you setup your training.\n\n## Train\n\nBefore you start training your model, create a map of the expected ids to their labels with `id2label` and `label2id`:\n\n```py\n>>> id2label = {0: \"NEGATIVE\", 1: \"POSITIVE\"}\n>>> label2id = {\"NEGATIVE\": 0, \"POSITIVE\": 1}\n```\n\n<frameworkcontent>\n<pt>\n<Tip>\n\nIf you aren't familiar with finetuning a model with the [`Trainer`], take a look at the basic tutorial [here](../training#train-with-pytorch-trainer)!\n\n</Tip>\n\nYou're ready to start training your model now!"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: b8a1f960-8783-4747-b752-a65d8154c012
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/sequence_classification", "title": "Text classification", "tokens": 3451, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"b8a1f960-8783-4747-b752-a65d8154c012\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0ba6ffc6-fc8f-4c02-ab78-e17886da84ed\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"0b2c612180b4f3f79bc906ce6f7c0ee445069a6b8280aa7a205b282b565b5367\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"df3c86e4-85f3-4a05-b9c9-761b6401a8b9\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"9eaa0ed9a1973c01fcbc4c658becb790837f754fcb4bb8e6393e061b256daace\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"8bfb1e30-925f-4bb1-9a08-02f738729675\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"49ca7d701c0816725ca87ef6d19f2889961420d973a7cf738b421786b87cdb82\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4526, \"end_char_idx\": 7682, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "ref_doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "chroma:document": "You can quickly load a evaluation method with the \ud83e\udd17 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [accuracy](https://huggingface.co/spaces/evaluate-metric/accuracy) metric (see the \ud83e\udd17 Evaluate [quick tour](https://huggingface.co/docs/evaluate/a_quick_tour) to learn more about how to load and compute a metric):\n\n```py\n>>> import evaluate\n\n>>> accuracy = evaluate.load(\"accuracy\")\n```\n\nThen create a function that passes your predictions and labels to [`~evaluate.EvaluationModule.compute`] to calculate the accuracy:\n\n```py\n>>> import numpy as np\n\n\n>>> def compute_metrics(eval_pred):\n...     predictions, labels = eval_pred\n...     predictions = np.argmax(predictions, axis=1)\n...     return accuracy.compute(predictions=predictions, references=labels)\n```\n\nYour `compute_metrics` function is ready to go now, and you'll return to it when you setup your training.\n\n## Train\n\nBefore you start training your model, create a map of the expected ids to their labels with `id2label` and `label2id`:\n\n```py\n>>> id2label = {0: \"NEGATIVE\", 1: \"POSITIVE\"}\n>>> label2id = {\"NEGATIVE\": 0, \"POSITIVE\": 1}\n```\n\n<frameworkcontent>\n<pt>\n<Tip>\n\nIf you aren't familiar with finetuning a model with the [`Trainer`], take a look at the basic tutorial [here](../training#train-with-pytorch-trainer)!\n\n</Tip>\n\nYou're ready to start training your model now! Load DistilBERT with [`AutoModelForSequenceClassification`] along with the number of expected labels, and the label mappings:\n\n```py\n>>> from transformers import AutoModelForSequenceClassification, TrainingArguments, Trainer\n\n>>> model = AutoModelForSequenceClassification.from_pretrained(\n...     \"distilbert/distilbert-base-uncased\", num_labels=2, id2label=id2label, label2id=label2id\n... )\n```\n\nAt this point, only three steps remain:\n\n1. Define your training hyperparameters in [`TrainingArguments`]. The only required parameter is `output_dir` which specifies where to save your model. You'll push this model to the Hub by setting `push_to_hub=True` (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the [`Trainer`] will evaluate the accuracy and save the training checkpoint.\n2. Pass the training arguments to [`Trainer`] along with the model, dataset, tokenizer, data collator, and `compute_metrics` function.\n3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> training_args = TrainingArguments(\n...     output_dir=\"my_awesome_model\",\n...     learning_rate=2e-5,\n...     per_device_train_batch_size=16,\n...     per_device_eval_batch_size=16,\n...     num_train_epochs=2,\n...     weight_decay=0.01,\n...     eval_strategy=\"epoch\",\n...     save_strategy=\"epoch\",\n...     load_best_model_at_end=True,\n...     push_to_hub=True,\n... )\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     train_dataset=tokenized_imdb[\"train\"],\n...     eval_dataset=tokenized_imdb[\"test\"],\n...     tokenizer=tokenizer,\n...     data_collator=data_collator,\n...     compute_metrics=compute_metrics,\n... )\n\n>>> trainer.train()\n```\n\n<Tip>\n\n[`Trainer`] applies dynamic padding by default when you pass `tokenizer` to it."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 8bfb1e30-925f-4bb1-9a08-02f738729675
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/sequence_classification", "title": "Text classification", "tokens": 3451, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"8bfb1e30-925f-4bb1-9a08-02f738729675\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0ba6ffc6-fc8f-4c02-ab78-e17886da84ed\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"0b2c612180b4f3f79bc906ce6f7c0ee445069a6b8280aa7a205b282b565b5367\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"b8a1f960-8783-4747-b752-a65d8154c012\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"3febbcfe3771c4e2b2d0b5cc741e2e985b13e00ca955795339a8125d37904448\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"4d80a1b8-edd4-4b42-b0a5-4097dc0ea872\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"54be051ea1b4f8569ed1e9459e02902f63ba0eba2f56698fd62f4a4bf34693e3\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6347, \"end_char_idx\": 8106, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "ref_doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "chroma:document": "Define your training hyperparameters in [`TrainingArguments`]. The only required parameter is `output_dir` which specifies where to save your model. You'll push this model to the Hub by setting `push_to_hub=True` (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the [`Trainer`] will evaluate the accuracy and save the training checkpoint.\n2. Pass the training arguments to [`Trainer`] along with the model, dataset, tokenizer, data collator, and `compute_metrics` function.\n3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> training_args = TrainingArguments(\n...     output_dir=\"my_awesome_model\",\n...     learning_rate=2e-5,\n...     per_device_train_batch_size=16,\n...     per_device_eval_batch_size=16,\n...     num_train_epochs=2,\n...     weight_decay=0.01,\n...     eval_strategy=\"epoch\",\n...     save_strategy=\"epoch\",\n...     load_best_model_at_end=True,\n...     push_to_hub=True,\n... )\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     train_dataset=tokenized_imdb[\"train\"],\n...     eval_dataset=tokenized_imdb[\"test\"],\n...     tokenizer=tokenizer,\n...     data_collator=data_collator,\n...     compute_metrics=compute_metrics,\n... )\n\n>>> trainer.train()\n```\n\n<Tip>\n\n[`Trainer`] applies dynamic padding by default when you pass `tokenizer` to it. In this case, you don't need to specify a data collator explicitly.\n\n</Tip>\n\nOnce training is completed, share your model to the Hub with the [`~transformers.Trainer.push_to_hub`] method so everyone can use your model:\n\n```py\n>>> trainer.push_to_hub()\n```\n</pt>\n<tf>\n<Tip>\n\nIf you aren't familiar with finetuning a model with Keras, take a look at the basic tutorial [here](../training#train-a-tensorflow-model-with-keras)!"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 4d80a1b8-edd4-4b42-b0a5-4097dc0ea872
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/sequence_classification", "title": "Text classification", "tokens": 3451, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"4d80a1b8-edd4-4b42-b0a5-4097dc0ea872\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0ba6ffc6-fc8f-4c02-ab78-e17886da84ed\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"0b2c612180b4f3f79bc906ce6f7c0ee445069a6b8280aa7a205b282b565b5367\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"8bfb1e30-925f-4bb1-9a08-02f738729675\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7cfb3bbbde2bd61ef9914b4c23003226075eb427f510d9e3cf745e0c215af9c0\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"4b29d11d-5996-4a8e-8c90-a2d7f2e0cbd2\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"7a50748331295bcd0994e80d4a29de9a67d331131de0ae96bcc3673319e535f3\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6625, \"end_char_idx\": 9807, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "ref_doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "chroma:document": "At the end of each epoch, the [`Trainer`] will evaluate the accuracy and save the training checkpoint.\n2. Pass the training arguments to [`Trainer`] along with the model, dataset, tokenizer, data collator, and `compute_metrics` function.\n3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> training_args = TrainingArguments(\n...     output_dir=\"my_awesome_model\",\n...     learning_rate=2e-5,\n...     per_device_train_batch_size=16,\n...     per_device_eval_batch_size=16,\n...     num_train_epochs=2,\n...     weight_decay=0.01,\n...     eval_strategy=\"epoch\",\n...     save_strategy=\"epoch\",\n...     load_best_model_at_end=True,\n...     push_to_hub=True,\n... )\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     train_dataset=tokenized_imdb[\"train\"],\n...     eval_dataset=tokenized_imdb[\"test\"],\n...     tokenizer=tokenizer,\n...     data_collator=data_collator,\n...     compute_metrics=compute_metrics,\n... )\n\n>>> trainer.train()\n```\n\n<Tip>\n\n[`Trainer`] applies dynamic padding by default when you pass `tokenizer` to it. In this case, you don't need to specify a data collator explicitly.\n\n</Tip>\n\nOnce training is completed, share your model to the Hub with the [`~transformers.Trainer.push_to_hub`] method so everyone can use your model:\n\n```py\n>>> trainer.push_to_hub()\n```\n</pt>\n<tf>\n<Tip>\n\nIf you aren't familiar with finetuning a model with Keras, take a look at the basic tutorial [here](../training#train-a-tensorflow-model-with-keras)!\n\n</Tip>\nTo finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:\n\n```py\n>>> from transformers import create_optimizer\n>>> import tensorflow as tf\n\n>>> batch_size = 16\n>>> num_epochs = 5\n>>> batches_per_epoch = len(tokenized_imdb[\"train\"]) // batch_size\n>>> total_train_steps = int(batches_per_epoch * num_epochs)\n>>> optimizer, schedule = create_optimizer(init_lr=2e-5, num_warmup_steps=0, num_train_steps=total_train_steps)\n```\n\nThen you can load DistilBERT with [`TFAutoModelForSequenceClassification`] along with the number of expected labels, and the label mappings:\n\n```py\n>>> from transformers import TFAutoModelForSequenceClassification\n\n>>> model = TFAutoModelForSequenceClassification.from_pretrained(\n...     \"distilbert/distilbert-base-uncased\", num_labels=2, id2label=id2label, label2id=label2id\n... )\n```\n\nConvert your datasets to the `tf.data.Dataset` format with [`~transformers.TFPreTrainedModel.prepare_tf_dataset`]:\n\n```py\n>>> tf_train_set = model.prepare_tf_dataset(\n...     tokenized_imdb[\"train\"],\n...     shuffle=True,\n...     batch_size=16,\n...     collate_fn=data_collator,\n... )\n\n>>> tf_validation_set = model.prepare_tf_dataset(\n...     tokenized_imdb[\"test\"],\n...     shuffle=False,\n...     batch_size=16,\n...     collate_fn=data_collator,\n... )\n```\n\nConfigure the model for training with [`compile`](https://keras.io/api/models/model_training_apis/#compile-method). Note that Transformers models all have a default task-relevant loss function, so you don't need to specify one unless you want to:\n\n```py\n>>> import tensorflow as tf\n\n>>> model.compile(optimizer=optimizer)  # No loss argument!"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 4b29d11d-5996-4a8e-8c90-a2d7f2e0cbd2
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/sequence_classification", "title": "Text classification", "tokens": 3451, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"4b29d11d-5996-4a8e-8c90-a2d7f2e0cbd2\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0ba6ffc6-fc8f-4c02-ab78-e17886da84ed\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"0b2c612180b4f3f79bc906ce6f7c0ee445069a6b8280aa7a205b282b565b5367\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"4d80a1b8-edd4-4b42-b0a5-4097dc0ea872\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"c8b452214b7304ee7d4d2ab296e72c7ded025dc2b0d82987fd670d2627d800cf\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"4e624e04-acdd-4b1d-8520-41525e89513c\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"0a2b117928ab9b5ba6db604303ff2a0a90432669fc21c51096ff8ba2f8f9ecf9\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9581, \"end_char_idx\": 11945, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "ref_doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "chroma:document": "Note that Transformers models all have a default task-relevant loss function, so you don't need to specify one unless you want to:\n\n```py\n>>> import tensorflow as tf\n\n>>> model.compile(optimizer=optimizer)  # No loss argument!\n```\n\nThe last two things to setup before you start training is to compute the accuracy from the predictions, and provide a way to push your model to the Hub. Both are done by using [Keras callbacks](../main_classes/keras_callbacks).\n\nPass your `compute_metrics` function to [`~transformers.KerasMetricCallback`]:\n\n```py\n>>> from transformers.keras_callbacks import KerasMetricCallback\n\n>>> metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_validation_set)\n```\n\nSpecify where to push your model and tokenizer in the [`~transformers.PushToHubCallback`]:\n\n```py\n>>> from transformers.keras_callbacks import PushToHubCallback\n\n>>> push_to_hub_callback = PushToHubCallback(\n...     output_dir=\"my_awesome_model\",\n...     tokenizer=tokenizer,\n... )\n```\n\nThen bundle your callbacks together:\n\n```py\n>>> callbacks = [metric_callback, push_to_hub_callback]\n```\n\nFinally, you're ready to start training your model! Call [`fit`](https://keras.io/api/models/model_training_apis/#fit-method) with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:\n\n```py\n>>> model.fit(x=tf_train_set, validation_data=tf_validation_set, epochs=3, callbacks=callbacks)\n```\n\nOnce training is completed, your model is automatically uploaded to the Hub so everyone can use it!\n</tf>\n</frameworkcontent>\n\n<Tip>\n\nFor a more in-depth example of how to finetune a model for text classification, take a look at the corresponding\n[PyTorch notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification.ipynb)\nor [TensorFlow notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification-tf.ipynb).\n\n</Tip>\n\n## Inference\n\nGreat, now that you've finetuned a model, you can use it for inference!\n\nGrab some text you'd like to run inference on:\n\n```py\n>>> text = \"This was a masterpiece. Not completely faithful to the books, but enthralling from beginning to end. Might be my favorite of the three.\"\n```\n\nThe simplest way to try out your finetuned model for inference is to use it in a [`pipeline`]."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 4e624e04-acdd-4b1d-8520-41525e89513c
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/sequence_classification", "title": "Text classification", "tokens": 3451, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"4e624e04-acdd-4b1d-8520-41525e89513c\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0ba6ffc6-fc8f-4c02-ab78-e17886da84ed\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"0b2c612180b4f3f79bc906ce6f7c0ee445069a6b8280aa7a205b282b565b5367\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"4b29d11d-5996-4a8e-8c90-a2d7f2e0cbd2\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/sequence_classification\", \"title\": \"Text classification\", \"tokens\": 3451, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"b2493ecf135965e1a9f4db1bbc5b04dc4c1a04b60256078834767fd449b4b681\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 10744, \"end_char_idx\": 13871, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "ref_doc_id": "0ba6ffc6-fc8f-4c02-ab78-e17886da84ed", "chroma:document": "Call [`fit`](https://keras.io/api/models/model_training_apis/#fit-method) with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:\n\n```py\n>>> model.fit(x=tf_train_set, validation_data=tf_validation_set, epochs=3, callbacks=callbacks)\n```\n\nOnce training is completed, your model is automatically uploaded to the Hub so everyone can use it!\n</tf>\n</frameworkcontent>\n\n<Tip>\n\nFor a more in-depth example of how to finetune a model for text classification, take a look at the corresponding\n[PyTorch notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification.ipynb)\nor [TensorFlow notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification-tf.ipynb).\n\n</Tip>\n\n## Inference\n\nGreat, now that you've finetuned a model, you can use it for inference!\n\nGrab some text you'd like to run inference on:\n\n```py\n>>> text = \"This was a masterpiece. Not completely faithful to the books, but enthralling from beginning to end. Might be my favorite of the three.\"\n```\n\nThe simplest way to try out your finetuned model for inference is to use it in a [`pipeline`]. Instantiate a `pipeline` for sentiment analysis with your model, and pass your text to it:\n\n```py\n>>> from transformers import pipeline\n\n>>> classifier = pipeline(\"sentiment-analysis\", model=\"stevhliu/my_awesome_model\")\n>>> classifier(text)\n[{'label': 'POSITIVE', 'score': 0.9994940757751465}]\n```\n\nYou can also manually replicate the results of the `pipeline` if you'd like:\n\n<frameworkcontent>\n<pt>\nTokenize the text and return PyTorch tensors:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"stevhliu/my_awesome_model\")\n>>> inputs = tokenizer(text, return_tensors=\"pt\")\n```\n\nPass your inputs to the model and return the `logits`:\n\n```py\n>>> from transformers import AutoModelForSequenceClassification\n\n>>> model = AutoModelForSequenceClassification.from_pretrained(\"stevhliu/my_awesome_model\")\n>>> with torch.no_grad():\n...     logits = model(**inputs).logits\n```\n\nGet the class with the highest probability, and use the model's `id2label` mapping to convert it to a text label:\n\n```py\n>>> predicted_class_id = logits.argmax().item()\n>>> model.config.id2label[predicted_class_id]\n'POSITIVE'\n```\n</pt>\n<tf>\nTokenize the text and return TensorFlow tensors:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"stevhliu/my_awesome_model\")\n>>> inputs = tokenizer(text, return_tensors=\"tf\")\n```\n\nPass your inputs to the model and return the `logits`:\n\n```py\n>>> from transformers import TFAutoModelForSequenceClassification\n\n>>> model = TFAutoModelForSequenceClassification.from_pretrained(\"stevhliu/my_awesome_model\")\n>>> logits = model(**inputs).logits\n```\n\nGet the class with the highest probability, and use the model's `id2label` mapping to convert it to a text label:\n\n```py\n>>> predicted_class_id = int(tf.math.argmax(logits, axis=-1)[0])\n>>> model.config.id2label[predicted_class_id]\n'POSITIVE'\n```\n</tf>\n</frameworkcontent>"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 4f4270bd-a3b4-4d57-b745-fe6871e92921
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification", "title": "Knowledge Distillation for Computer Vision", "tokens": 1908, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"4f4270bd-a3b4-4d57-b745-fe6871e92921\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification\", \"title\": \"Knowledge Distillation for Computer Vision\", \"tokens\": 1908, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"53e55709-8f4a-486b-bf7f-2cf852bdf653\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification\", \"title\": \"Knowledge Distillation for Computer Vision\", \"tokens\": 1908, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"00ef6ba89717fd17365ab61ba0f513f1ea2e522b0fca49368251caaefa8f1614\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"78b5ba2d-472f-4217-9d03-7861ea1173d9\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"f4101d13ac743e5a7ba8b06700dbae65724d23051cafcc31edef369b6d97a6e2\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3265, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "53e55709-8f4a-486b-bf7f-2cf852bdf653", "doc_id": "53e55709-8f4a-486b-bf7f-2cf852bdf653", "ref_doc_id": "53e55709-8f4a-486b-bf7f-2cf852bdf653", "chroma:document": "# Knowledge Distillation for Computer Vision\n\n[[open-in-colab]]\n\nKnowledge distillation is a technique used to transfer knowledge from a larger, more complex model (teacher) to a smaller, simpler model (student). To distill knowledge from one model to another, we take a pre-trained teacher model trained on a certain task (image classification for this case) and randomly initialize a student model to be trained on image classification. Next, we train the student model to minimize the difference between it's outputs and the teacher's outputs, thus making it mimic the behavior. It was first introduced in [Distilling the Knowledge in a Neural Network by Hinton et al](https://arxiv.org/abs/1503.02531). In this guide, we will do task-specific knowledge distillation. We will use the [beans dataset](https://huggingface.co/datasets/beans) for this.\n\nThis guide demonstrates how you can distill a [fine-tuned ViT model](https://huggingface.co/merve/vit-mobilenet-beans-224) (teacher model) to a [MobileNet](https://huggingface.co/google/mobilenet_v2_1.4_224) (student model) using the [Trainer\u00a0API](https://huggingface.co/docs/transformers/en/main_classes/trainer#trainer) of \ud83e\udd17 Transformers. \n\nLet's install the libraries needed for distillation and evaluating the process. \n\n```bash\npip install transformers datasets accelerate tensorboard evaluate --upgrade\n```\n\nIn this example, we are using the `merve/beans-vit-224` model as teacher model. It's an image classification model, based on `google/vit-base-patch16-224-in21k` fine-tuned on beans dataset. We will distill this model to a randomly initialized MobileNetV2.\n\nWe will now load the dataset. \n\n```python\nfrom datasets import load_dataset\n\ndataset = load_dataset(\"beans\")\n```\n\nWe can use an image processor from either of the models, as in this case they return the same output with same resolution. We will use the `map()` method of `dataset` to apply the preprocessing to every split of the dataset. \n\n```python\nfrom transformers import AutoImageProcessor\nteacher_processor = AutoImageProcessor.from_pretrained(\"merve/beans-vit-224\")\n\ndef process(examples):\n    processed_inputs = teacher_processor(examples[\"image\"])\n    return processed_inputs\n\nprocessed_datasets = dataset.map(process, batched=True)\n```\n\nEssentially, we want the student model (a randomly initialized MobileNet) to mimic the teacher model (fine-tuned vision transformer). To achieve this, we first get the logits output from the teacher and the student. Then, we divide each of them by the parameter `temperature` which controls the importance of each soft target. A parameter called `lambda` weighs the importance of the distillation loss. In this example, we will use `temperature=5` and `lambda=0.5`. We will use the Kullback-Leibler Divergence loss to compute the divergence between the student and teacher. Given two data P and Q, KL Divergence explains how much extra information we need to represent P using Q. If two are identical, their KL divergence is zero, as there's no other information needed to explain P from Q. Thus, in the context of knowledge distillation, KL divergence is useful.\n\n\n```python\nfrom transformers import TrainingArguments, Trainer\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 78b5ba2d-472f-4217-9d03-7861ea1173d9
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification", "title": "Knowledge Distillation for Computer Vision", "tokens": 1908, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"78b5ba2d-472f-4217-9d03-7861ea1173d9\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification\", \"title\": \"Knowledge Distillation for Computer Vision\", \"tokens\": 1908, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"53e55709-8f4a-486b-bf7f-2cf852bdf653\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification\", \"title\": \"Knowledge Distillation for Computer Vision\", \"tokens\": 1908, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"00ef6ba89717fd17365ab61ba0f513f1ea2e522b0fca49368251caaefa8f1614\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"4f4270bd-a3b4-4d57-b745-fe6871e92921\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification\", \"title\": \"Knowledge Distillation for Computer Vision\", \"tokens\": 1908, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"c95b0726a6bf8119ac2749e2a318018cfa190d4078363d8b849ee24301a87bc9\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"fdd9730f-6dc5-4395-b4e4-7669cec69a54\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"ca5d245df04c246f84d8905fd1b793d20047ad56d69ec53d7cfd79e0310a923f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 3137, \"end_char_idx\": 6506, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "53e55709-8f4a-486b-bf7f-2cf852bdf653", "doc_id": "53e55709-8f4a-486b-bf7f-2cf852bdf653", "ref_doc_id": "53e55709-8f4a-486b-bf7f-2cf852bdf653", "chroma:document": "```python\nfrom transformers import TrainingArguments, Trainer\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\n\nclass ImageDistilTrainer(Trainer):\n    def __init__(self, teacher_model=None, student_model=None, temperature=None, lambda_param=None,  *args, **kwargs):\n        super().__init__(model=student_model, *args, **kwargs)\n        self.teacher = teacher_model\n        self.student = student_model\n        self.loss_function = nn.KLDivLoss(reduction=\"batchmean\")\n        device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n        self.teacher.to(device)\n        self.teacher.eval()\n        self.temperature = temperature\n        self.lambda_param = lambda_param\n\n    def compute_loss(self, student, inputs, return_outputs=False):\n        student_output = self.student(**inputs)\n\n        with torch.no_grad():\n          teacher_output = self.teacher(**inputs)\n\n        # Compute soft targets for teacher and student\n        soft_teacher = F.softmax(teacher_output.logits / self.temperature, dim=-1)\n        soft_student = F.log_softmax(student_output.logits / self.temperature, dim=-1)\n\n        # Compute the loss\n        distillation_loss = self.loss_function(soft_student, soft_teacher) * (self.temperature ** 2)\n\n        # Compute the true label loss\n        student_target_loss = student_output.loss\n\n        # Calculate final loss\n        loss = (1. - self.lambda_param) * student_target_loss + self.lambda_param * distillation_loss\n        return (loss, student_output) if return_outputs else loss\n```\n\nWe will now login to Hugging Face Hub so we can push our model to the Hugging Face Hub through the `Trainer`. \n\n```python\nfrom huggingface_hub import notebook_login\n\nnotebook_login()\n```\n\nLet's set the `TrainingArguments`, the teacher model and the student model. \n\n```python\nfrom transformers import AutoModelForImageClassification, MobileNetV2Config, MobileNetV2ForImageClassification\n\ntraining_args = TrainingArguments(\n    output_dir=\"my-awesome-model\",\n    num_train_epochs=30,\n    fp16=True,\n    logging_dir=f\"{repo_name}/logs\",\n    logging_strategy=\"epoch\",\n    eval_strategy=\"epoch\",\n    save_strategy=\"epoch\",\n    load_best_model_at_end=True,\n    metric_for_best_model=\"accuracy\",\n    report_to=\"tensorboard\",\n    push_to_hub=True,\n    hub_strategy=\"every_save\",\n    hub_model_id=repo_name,\n    )\n\nnum_labels = len(processed_datasets[\"train\"].features[\"labels\"].names)\n\n# initialize models\nteacher_model = AutoModelForImageClassification.from_pretrained(\n    \"merve/beans-vit-224\",\n    num_labels=num_labels,\n    ignore_mismatched_sizes=True\n)\n\n# training MobileNetV2 from scratch\nstudent_config = MobileNetV2Config()\nstudent_config.num_labels = num_labels\nstudent_model = MobileNetV2ForImageClassification(student_config)\n```\n\nWe can use `compute_metrics` function to evaluate our model on the test set. This function will be used during the training process to compute the `accuracy` & `f1` of our model.\n\n```python\nimport evaluate\nimport numpy as np\n\naccuracy = evaluate.load(\"accuracy\")\n\ndef compute_metrics(eval_pred):\n    predictions, labels = eval_pred\n    acc = accuracy.compute(references=labels, predictions=np.argmax(predictions, axis=1))\n    return {\"accuracy\": acc[\"accuracy\"]}\n```\n\nLet's initialize the `Trainer` with the training arguments we defined. We will also initialize our data collator."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: fdd9730f-6dc5-4395-b4e4-7669cec69a54
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification", "title": "Knowledge Distillation for Computer Vision", "tokens": 1908, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"fdd9730f-6dc5-4395-b4e4-7669cec69a54\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification\", \"title\": \"Knowledge Distillation for Computer Vision\", \"tokens\": 1908, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"53e55709-8f4a-486b-bf7f-2cf852bdf653\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification\", \"title\": \"Knowledge Distillation for Computer Vision\", \"tokens\": 1908, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"00ef6ba89717fd17365ab61ba0f513f1ea2e522b0fca49368251caaefa8f1614\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"78b5ba2d-472f-4217-9d03-7861ea1173d9\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/knowledge_distillation_for_image_classification\", \"title\": \"Knowledge Distillation for Computer Vision\", \"tokens\": 1908, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"db04bb44c00f3d21fd1b0d5568e8bed7d15e3c9048c08289282417f14d801a9e\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4800, \"end_char_idx\": 7801, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "53e55709-8f4a-486b-bf7f-2cf852bdf653", "doc_id": "53e55709-8f4a-486b-bf7f-2cf852bdf653", "ref_doc_id": "53e55709-8f4a-486b-bf7f-2cf852bdf653", "chroma:document": "```python\nfrom huggingface_hub import notebook_login\n\nnotebook_login()\n```\n\nLet's set the `TrainingArguments`, the teacher model and the student model. \n\n```python\nfrom transformers import AutoModelForImageClassification, MobileNetV2Config, MobileNetV2ForImageClassification\n\ntraining_args = TrainingArguments(\n    output_dir=\"my-awesome-model\",\n    num_train_epochs=30,\n    fp16=True,\n    logging_dir=f\"{repo_name}/logs\",\n    logging_strategy=\"epoch\",\n    eval_strategy=\"epoch\",\n    save_strategy=\"epoch\",\n    load_best_model_at_end=True,\n    metric_for_best_model=\"accuracy\",\n    report_to=\"tensorboard\",\n    push_to_hub=True,\n    hub_strategy=\"every_save\",\n    hub_model_id=repo_name,\n    )\n\nnum_labels = len(processed_datasets[\"train\"].features[\"labels\"].names)\n\n# initialize models\nteacher_model = AutoModelForImageClassification.from_pretrained(\n    \"merve/beans-vit-224\",\n    num_labels=num_labels,\n    ignore_mismatched_sizes=True\n)\n\n# training MobileNetV2 from scratch\nstudent_config = MobileNetV2Config()\nstudent_config.num_labels = num_labels\nstudent_model = MobileNetV2ForImageClassification(student_config)\n```\n\nWe can use `compute_metrics` function to evaluate our model on the test set. This function will be used during the training process to compute the `accuracy` & `f1` of our model.\n\n```python\nimport evaluate\nimport numpy as np\n\naccuracy = evaluate.load(\"accuracy\")\n\ndef compute_metrics(eval_pred):\n    predictions, labels = eval_pred\n    acc = accuracy.compute(references=labels, predictions=np.argmax(predictions, axis=1))\n    return {\"accuracy\": acc[\"accuracy\"]}\n```\n\nLet's initialize the `Trainer` with the training arguments we defined. We will also initialize our data collator.\n\n```python\nfrom transformers import DefaultDataCollator\n\ndata_collator = DefaultDataCollator()\ntrainer = ImageDistilTrainer(\n    student_model=student_model,\n    teacher_model=teacher_model,\n    training_args=training_args,\n    train_dataset=processed_datasets[\"train\"],\n    eval_dataset=processed_datasets[\"validation\"],\n    data_collator=data_collator,\n    tokenizer=teacher_processor,\n    compute_metrics=compute_metrics,\n    temperature=5,\n    lambda_param=0.5\n)\n```\n\nWe can now train our model.\n\n```python\ntrainer.train()\n```\n\nWe can evaluate the model on the test set.\n\n```python\ntrainer.evaluate(processed_datasets[\"test\"])\n```\n\nOn test set, our model reaches 72 percent accuracy. To have a sanity check over efficiency of distillation, we also trained MobileNet on the beans dataset from scratch with the same hyperparameters and observed 63 percent accuracy on the test set. We invite the readers to try different pre-trained teacher models, student architectures, distillation parameters and report their findings. The training logs and checkpoints for distilled model can be found in [this repository](https://huggingface.co/merve/vit-mobilenet-beans-224), and MobileNetV2 trained from scratch can be found in this [repository](https://huggingface.co/merve/resnet-mobilenet-beans-5)."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 83e1c917-8506-42a8-bdfe-c922cfef912f
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification", "title": "Zero-shot image classification", "tokens": 1461, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"83e1c917-8506-42a8-bdfe-c922cfef912f\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification\", \"title\": \"Zero-shot image classification\", \"tokens\": 1461, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"4ac1f2d2-07a8-441b-b0b4-d884bb01cb77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification\", \"title\": \"Zero-shot image classification\", \"tokens\": 1461, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"ada39cb91a9e953c778492b4acff885c647402f9324c689d38146231867a72fa\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"34615b8d-952c-4959-b1ef-5627f6b20c22\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"1767be3d4528c63af3a20d0e2272351bb3b493bf92d4441a2cfd515980d2c582\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3248, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "4ac1f2d2-07a8-441b-b0b4-d884bb01cb77", "doc_id": "4ac1f2d2-07a8-441b-b0b4-d884bb01cb77", "ref_doc_id": "4ac1f2d2-07a8-441b-b0b4-d884bb01cb77", "chroma:document": "# Zero-shot image classification\n\n[[open-in-colab]]\n\nZero-shot image classification is a task that involves classifying images into different categories using a model that was\nnot explicitly trained on data containing labeled examples from those specific categories.\n\nTraditionally, image classification requires training a model on a specific set of labeled images, and this model learns to\n\"map\" certain image features to labels. When there's a need to use such model for a classification task that introduces a\nnew set of labels, fine-tuning is required to \"recalibrate\" the model.\n\nIn contrast, zero-shot or open vocabulary image classification models are typically multi-modal models that have been trained on a large\ndataset of images and associated descriptions. These models learn aligned vision-language representations that can be used for many downstream tasks including zero-shot image classification.\n\nThis is a more flexible approach to image classification that allows models to generalize to new and unseen categories\nwithout the need for additional training data and enables users to query images with free-form text descriptions of their target objects .\n\nIn this guide you'll learn how to:\n\n* create a zero-shot image classification pipeline\n* run zero-shot image classification inference by hand\n\nBefore you begin, make sure you have all the necessary libraries installed:\n\n```bash\npip install -q \"transformers[torch]\" pillow\n```\n\n## Zero-shot image classification pipeline\n\nThe simplest way to try out inference with a model supporting zero-shot image classification is to use the corresponding [`pipeline`].\nInstantiate a pipeline from a [checkpoint on the Hugging Face Hub](https://huggingface.co/models?pipeline_tag=zero-shot-image-classification&sort=downloads):\n\n```python\n>>> from transformers import pipeline\n\n>>> checkpoint = \"openai/clip-vit-large-patch14\"\n>>> detector = pipeline(model=checkpoint, task=\"zero-shot-image-classification\")\n```\n\nNext, choose an image you'd like to classify.\n\n```py\n>>> from PIL import Image\n>>> import requests\n\n>>> url = \"https://unsplash.com/photos/g8oS8-82DxI/download?ixid=MnwxMjA3fDB8MXx0b3BpY3x8SnBnNktpZGwtSGt8fHx8fDJ8fDE2NzgxMDYwODc&force=true&w=640\"\n>>> image = Image.open(requests.get(url, stream=True).raw)\n\n>>> image\n```\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/owl.jpg\" alt=\"Photo of an owl\"/>\n</div>\n\nPass the image and the candidate object labels to the pipeline. Here we pass the image directly; other suitable options\ninclude a local path to an image or an image url.\nThe candidate labels can be simple words like in this example, or more descriptive.\n\n```py\n>>> predictions = detector(image, candidate_labels=[\"fox\", \"bear\", \"seagull\", \"owl\"])\n>>> predictions\n[{'score': 0.9996670484542847, 'label': 'owl'},\n {'score': 0.000199399160919711, 'label': 'seagull'},\n {'score': 7.392891711788252e-05, 'label': 'fox'},\n {'score': 5.96074532950297e-05, 'label': 'bear'}]\n```\n\n## Zero-shot image classification by hand\n\nNow that you've seen how to use the zero-shot image classification pipeline, let's take a look how you can run zero-shot\nimage classification manually."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 34615b8d-952c-4959-b1ef-5627f6b20c22
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification", "title": "Zero-shot image classification", "tokens": 1461, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"34615b8d-952c-4959-b1ef-5627f6b20c22\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification\", \"title\": \"Zero-shot image classification\", \"tokens\": 1461, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"4ac1f2d2-07a8-441b-b0b4-d884bb01cb77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification\", \"title\": \"Zero-shot image classification\", \"tokens\": 1461, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"ada39cb91a9e953c778492b4acff885c647402f9324c689d38146231867a72fa\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"83e1c917-8506-42a8-bdfe-c922cfef912f\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification\", \"title\": \"Zero-shot image classification\", \"tokens\": 1461, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"bd975a3068313dae4e78e7b7c967d2fe49c9bb8e22b8074de1a81cf42944325e\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"f7e3ea57-d3bb-459e-b677-b629a111615e\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"50b3783ae1d12f9b73763d3c05c29bf00ed838cff6ec905a114117423236e6b3\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2020, \"end_char_idx\": 4604, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "4ac1f2d2-07a8-441b-b0b4-d884bb01cb77", "doc_id": "4ac1f2d2-07a8-441b-b0b4-d884bb01cb77", "ref_doc_id": "4ac1f2d2-07a8-441b-b0b4-d884bb01cb77", "chroma:document": "```py\n>>> from PIL import Image\n>>> import requests\n\n>>> url = \"https://unsplash.com/photos/g8oS8-82DxI/download?ixid=MnwxMjA3fDB8MXx0b3BpY3x8SnBnNktpZGwtSGt8fHx8fDJ8fDE2NzgxMDYwODc&force=true&w=640\"\n>>> image = Image.open(requests.get(url, stream=True).raw)\n\n>>> image\n```\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/owl.jpg\" alt=\"Photo of an owl\"/>\n</div>\n\nPass the image and the candidate object labels to the pipeline. Here we pass the image directly; other suitable options\ninclude a local path to an image or an image url.\nThe candidate labels can be simple words like in this example, or more descriptive.\n\n```py\n>>> predictions = detector(image, candidate_labels=[\"fox\", \"bear\", \"seagull\", \"owl\"])\n>>> predictions\n[{'score': 0.9996670484542847, 'label': 'owl'},\n {'score': 0.000199399160919711, 'label': 'seagull'},\n {'score': 7.392891711788252e-05, 'label': 'fox'},\n {'score': 5.96074532950297e-05, 'label': 'bear'}]\n```\n\n## Zero-shot image classification by hand\n\nNow that you've seen how to use the zero-shot image classification pipeline, let's take a look how you can run zero-shot\nimage classification manually.\n\nStart by loading the model and associated processor from a [checkpoint on the Hugging Face Hub](https://huggingface.co/models?pipeline_tag=zero-shot-image-classification&sort=downloads).\nHere we'll use the same checkpoint as before:\n\n```py\n>>> from transformers import AutoProcessor, AutoModelForZeroShotImageClassification\n\n>>> model = AutoModelForZeroShotImageClassification.from_pretrained(checkpoint)\n>>> processor = AutoProcessor.from_pretrained(checkpoint)\n```\n\nLet's take a different image to switch things up.\n\n```py\n>>> from PIL import Image\n>>> import requests\n\n>>> url = \"https://unsplash.com/photos/xBRQfR2bqNI/download?ixid=MnwxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNjc4Mzg4ODEx&force=true&w=640\"\n>>> image = Image.open(requests.get(url, stream=True).raw)\n\n>>> image\n```\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg\" alt=\"Photo of a car\"/>\n</div>\n\nUse the processor to prepare the inputs for the model. The processor combines an image processor that prepares the\nimage for the model by resizing and normalizing it, and a tokenizer that takes care of the text inputs.\n\n```py\n>>> candidate_labels = [\"tree\", \"car\", \"bike\", \"cat\"]\n# follows the pipeline prompt template to get same results\n>>> candidate_labels = [f'This is a photo of {label}.'"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: f7e3ea57-d3bb-459e-b677-b629a111615e
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification", "title": "Zero-shot image classification", "tokens": 1461, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"f7e3ea57-d3bb-459e-b677-b629a111615e\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification\", \"title\": \"Zero-shot image classification\", \"tokens\": 1461, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"4ac1f2d2-07a8-441b-b0b4-d884bb01cb77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification\", \"title\": \"Zero-shot image classification\", \"tokens\": 1461, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"ada39cb91a9e953c778492b4acff885c647402f9324c689d38146231867a72fa\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"34615b8d-952c-4959-b1ef-5627f6b20c22\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/zero_shot_image_classification\", \"title\": \"Zero-shot image classification\", \"tokens\": 1461, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"640e4ade939a089bbe67e52ad2f99662109ffb72b241e3772da26bcf42b88a32\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 3250, \"end_char_idx\": 5350, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "4ac1f2d2-07a8-441b-b0b4-d884bb01cb77", "doc_id": "4ac1f2d2-07a8-441b-b0b4-d884bb01cb77", "ref_doc_id": "4ac1f2d2-07a8-441b-b0b4-d884bb01cb77", "chroma:document": "Start by loading the model and associated processor from a [checkpoint on the Hugging Face Hub](https://huggingface.co/models?pipeline_tag=zero-shot-image-classification&sort=downloads).\nHere we'll use the same checkpoint as before:\n\n```py\n>>> from transformers import AutoProcessor, AutoModelForZeroShotImageClassification\n\n>>> model = AutoModelForZeroShotImageClassification.from_pretrained(checkpoint)\n>>> processor = AutoProcessor.from_pretrained(checkpoint)\n```\n\nLet's take a different image to switch things up.\n\n```py\n>>> from PIL import Image\n>>> import requests\n\n>>> url = \"https://unsplash.com/photos/xBRQfR2bqNI/download?ixid=MnwxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNjc4Mzg4ODEx&force=true&w=640\"\n>>> image = Image.open(requests.get(url, stream=True).raw)\n\n>>> image\n```\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg\" alt=\"Photo of a car\"/>\n</div>\n\nUse the processor to prepare the inputs for the model. The processor combines an image processor that prepares the\nimage for the model by resizing and normalizing it, and a tokenizer that takes care of the text inputs.\n\n```py\n>>> candidate_labels = [\"tree\", \"car\", \"bike\", \"cat\"]\n# follows the pipeline prompt template to get same results\n>>> candidate_labels = [f'This is a photo of {label}.' for label in candidate_labels]\n>>> inputs = processor(images=image, text=candidate_labels, return_tensors=\"pt\", padding=True)\n```\n\nPass the inputs through the model, and post-process the results:\n\n```py\n>>> import torch\n\n>>> with torch.no_grad():\n...     outputs = model(**inputs)\n\n>>> logits = outputs.logits_per_image[0]\n>>> probs = logits.softmax(dim=-1).numpy()\n>>> scores = probs.tolist()\n\n>>> result = [\n...     {\"score\": score, \"label\": candidate_label}\n...     for score, candidate_label in sorted(zip(probs, candidate_labels), key=lambda x: -x[0])\n... ]\n\n>>> result\n[{'score': 0.998572, 'label': 'car'},\n {'score': 0.0010570387, 'label': 'bike'},\n {'score': 0.0003393686, 'label': 'tree'},\n {'score': 3.1572064e-05, 'label': 'cat'}]\n```"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 1610bb4d-e366-4424-af9c-43c772a8ca45
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/visual_question_answering", "title": "Visual Question Answering", "tokens": 3788, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"1610bb4d-e366-4424-af9c-43c772a8ca45\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"2f4e4bf6-20dc-41cd-8c45-0e298efabe77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4beeead43ec2efaea2518803588709d06bb6b4bdfffceb248f2173f3e682aa8c\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"c72d755f-1c90-4e31-a34e-c3beaf6043ff\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"c57eb3e8f8f601c7c77ae445c2f7e1a83ae1b629cfa57d4d8079823b0f06dd8e\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 2985, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "ref_doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "chroma:document": "# Visual Question Answering\n\n[[open-in-colab]]\n\nVisual Question Answering (VQA) is the task of answering open-ended questions based on an image. \nThe input to models supporting this task is typically a combination of an image and a question, and the output is an \nanswer expressed in natural language.\n\nSome noteworthy use case examples for VQA include:\n* Accessibility applications for visually impaired individuals.\n* Education: posing questions about visual materials presented in lectures or textbooks. VQA can also be utilized in interactive museum exhibits or historical sites.\n* Customer service and e-commerce: VQA can enhance user experience by letting users ask questions about products. \n* Image retrieval: VQA models can be used to retrieve images with specific characteristics. For example, the user can ask \"Is there a dog?\" to find all images with dogs from a set of images.\n\nIn this guide you'll learn how to:\n\n- Fine-tune a classification VQA model, specifically [ViLT](../model_doc/vilt), on the [`Graphcore/vqa` dataset](https://huggingface.co/datasets/Graphcore/vqa).\n- Use your fine-tuned ViLT for inference.\n- Run zero-shot VQA inference with a generative model, like BLIP-2.\n\n## Fine-tuning ViLT\n\nViLT model incorporates text embeddings into a Vision Transformer (ViT), allowing it to have a minimal design for \nVision-and-Language Pre-training (VLP). This model can be used for several downstream tasks. For the VQA task, a classifier \nhead is placed on top (a linear layer on top of the final hidden state of the `[CLS]` token) and randomly initialized. \nVisual Question Answering is thus treated as a **classification problem**.\n\nMore recent models, such as BLIP, BLIP-2, and InstructBLIP, treat VQA as a generative task. Later in this guide we \nillustrate how to use them for zero-shot VQA inference. \n\nBefore you begin, make sure you have all the necessary libraries installed. \n\n```bash\npip install -q transformers datasets\n```\n\nWe encourage you to share your model with the community. Log in to your Hugging Face account to upload it to the \ud83e\udd17 Hub.\nWhen prompted, enter your token to log in:\n\n```py\n>>> from huggingface_hub import notebook_login\n\n>>> notebook_login()\n```\n\nLet's define the model checkpoint as a global variable.\n\n```py\n>>> model_checkpoint = \"dandelin/vilt-b32-mlm\"\n```\n\n## Load the data\n\nFor illustration purposes, in this guide we use a very small sample of the annotated visual question answering `Graphcore/vqa` dataset. \nYou can find the full dataset on [\ud83e\udd17 Hub](https://huggingface.co/datasets/Graphcore/vqa).\n\nAs an alternative to the [`Graphcore/vqa` dataset](https://huggingface.co/datasets/Graphcore/vqa), you can download the \nsame data manually from the official [VQA dataset page](https://visualqa.org/download.html). If you prefer to follow the \ntutorial with your custom data, check out how to [Create an image dataset](https://huggingface.co/docs/datasets/image_dataset#loading-script)\nguide in the \ud83e\udd17 Datasets documentation."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: c72d755f-1c90-4e31-a34e-c3beaf6043ff
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/visual_question_answering", "title": "Visual Question Answering", "tokens": 3788, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"c72d755f-1c90-4e31-a34e-c3beaf6043ff\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"2f4e4bf6-20dc-41cd-8c45-0e298efabe77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4beeead43ec2efaea2518803588709d06bb6b4bdfffceb248f2173f3e682aa8c\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"1610bb4d-e366-4424-af9c-43c772a8ca45\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"a80e884ceead7f0e3dcced861a919271149261d9fd9cf34b85ce2c801d511af7\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"8e1fbac6-e51e-4dd0-85a6-044c5470e6bd\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"0acb8adae8bd87e2910c4ca9df30d516a69aad0f0ce8d91dd6dad342761e8321\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 1375, \"end_char_idx\": 3477, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "ref_doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "chroma:document": "This model can be used for several downstream tasks. For the VQA task, a classifier \nhead is placed on top (a linear layer on top of the final hidden state of the `[CLS]` token) and randomly initialized. \nVisual Question Answering is thus treated as a **classification problem**.\n\nMore recent models, such as BLIP, BLIP-2, and InstructBLIP, treat VQA as a generative task. Later in this guide we \nillustrate how to use them for zero-shot VQA inference. \n\nBefore you begin, make sure you have all the necessary libraries installed. \n\n```bash\npip install -q transformers datasets\n```\n\nWe encourage you to share your model with the community. Log in to your Hugging Face account to upload it to the \ud83e\udd17 Hub.\nWhen prompted, enter your token to log in:\n\n```py\n>>> from huggingface_hub import notebook_login\n\n>>> notebook_login()\n```\n\nLet's define the model checkpoint as a global variable.\n\n```py\n>>> model_checkpoint = \"dandelin/vilt-b32-mlm\"\n```\n\n## Load the data\n\nFor illustration purposes, in this guide we use a very small sample of the annotated visual question answering `Graphcore/vqa` dataset. \nYou can find the full dataset on [\ud83e\udd17 Hub](https://huggingface.co/datasets/Graphcore/vqa).\n\nAs an alternative to the [`Graphcore/vqa` dataset](https://huggingface.co/datasets/Graphcore/vqa), you can download the \nsame data manually from the official [VQA dataset page](https://visualqa.org/download.html). If you prefer to follow the \ntutorial with your custom data, check out how to [Create an image dataset](https://huggingface.co/docs/datasets/image_dataset#loading-script)\nguide in the \ud83e\udd17 Datasets documentation.  \n\nLet's load the first 200 examples from the validation split and explore the dataset's features:  \n\n```python\n>>> from datasets import load_dataset\n\n>>> dataset = load_dataset(\"Graphcore/vqa\", split=\"validation[:200]\")\n>>> dataset\nDataset({\n    features: ['question', 'question_type', 'question_id', 'image_id', 'answer_type', 'label'],\n    num_rows: 200\n})\n```\n\nLet's take a look at an example to understand the dataset's features:\n\n```py\n>>> dataset[0]\n{'question': 'Where is he looking?"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 8e1fbac6-e51e-4dd0-85a6-044c5470e6bd
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/visual_question_answering", "title": "Visual Question Answering", "tokens": 3788, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"8e1fbac6-e51e-4dd0-85a6-044c5470e6bd\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"2f4e4bf6-20dc-41cd-8c45-0e298efabe77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4beeead43ec2efaea2518803588709d06bb6b4bdfffceb248f2173f3e682aa8c\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"c72d755f-1c90-4e31-a34e-c3beaf6043ff\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"61084e6f9dcff6c79e5b509c266c208e8c6e6a98fd766278db4ee44702c36042\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"eaac7005-3633-4fb5-8d50-700e2e87ca5b\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"a60eaf7042a93c1f1b08de60c13fafbe9cdcf01194db13ac0cc8e849cc5f4068\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 1830, \"end_char_idx\": 4618, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "ref_doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "chroma:document": "Before you begin, make sure you have all the necessary libraries installed. \n\n```bash\npip install -q transformers datasets\n```\n\nWe encourage you to share your model with the community. Log in to your Hugging Face account to upload it to the \ud83e\udd17 Hub.\nWhen prompted, enter your token to log in:\n\n```py\n>>> from huggingface_hub import notebook_login\n\n>>> notebook_login()\n```\n\nLet's define the model checkpoint as a global variable.\n\n```py\n>>> model_checkpoint = \"dandelin/vilt-b32-mlm\"\n```\n\n## Load the data\n\nFor illustration purposes, in this guide we use a very small sample of the annotated visual question answering `Graphcore/vqa` dataset. \nYou can find the full dataset on [\ud83e\udd17 Hub](https://huggingface.co/datasets/Graphcore/vqa).\n\nAs an alternative to the [`Graphcore/vqa` dataset](https://huggingface.co/datasets/Graphcore/vqa), you can download the \nsame data manually from the official [VQA dataset page](https://visualqa.org/download.html). If you prefer to follow the \ntutorial with your custom data, check out how to [Create an image dataset](https://huggingface.co/docs/datasets/image_dataset#loading-script)\nguide in the \ud83e\udd17 Datasets documentation.  \n\nLet's load the first 200 examples from the validation split and explore the dataset's features:  \n\n```python\n>>> from datasets import load_dataset\n\n>>> dataset = load_dataset(\"Graphcore/vqa\", split=\"validation[:200]\")\n>>> dataset\nDataset({\n    features: ['question', 'question_type', 'question_id', 'image_id', 'answer_type', 'label'],\n    num_rows: 200\n})\n```\n\nLet's take a look at an example to understand the dataset's features:\n\n```py\n>>> dataset[0]\n{'question': 'Where is he looking?',\n 'question_type': 'none of the above',\n 'question_id': 262148000,\n 'image_id': '/root/.cache/huggingface/datasets/downloads/extracted/ca733e0e000fb2d7a09fbcc94dbfe7b5a30750681d0e965f8e0a23b1c2f98c75/val2014/COCO_val2014_000000262148.jpg',\n 'answer_type': 'other',\n 'label': {'ids': ['at table', 'down', 'skateboard', 'table'],\n  'weights': [0.30000001192092896,\n   1.0,\n   0.30000001192092896,\n   0.30000001192092896]}}\n```\n\nThe features relevant to the task include: \n* `question`: the question to be answered from the image\n* `image_id`: the path to the image the question refers to\n* `label`: the annotations\n\nWe can remove the rest of the features as they won't be necessary: \n\n```py \n>>> dataset = dataset.remove_columns(['question_type', 'question_id', 'answer_type'])\n```\n\nAs you can see, the `label` feature contains several answers to the same question (called `ids` here) collected by different human annotators. \nThis is because the answer to a question can be subjective. In this case, the question is \"where is he looking?\". Some people \nannotated this with \"down\", others with \"at table\", another one with \"skateboard\", etc."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: eaac7005-3633-4fb5-8d50-700e2e87ca5b
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/visual_question_answering", "title": "Visual Question Answering", "tokens": 3788, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"eaac7005-3633-4fb5-8d50-700e2e87ca5b\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"2f4e4bf6-20dc-41cd-8c45-0e298efabe77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4beeead43ec2efaea2518803588709d06bb6b4bdfffceb248f2173f3e682aa8c\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"8e1fbac6-e51e-4dd0-85a6-044c5470e6bd\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"1ce75d49988fd46d5f6e0a98e1f67159320ddacd47ef77731ad63c9341773c39\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"45d8942b-6d8d-4a13-b9ec-662ed33d9002\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"847bf8da481c4cf10b0f7305232170266be8f2595332e18eab5160d0faaf62e9\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 3477, \"end_char_idx\": 6306, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "ref_doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "chroma:document": "',\n 'question_type': 'none of the above',\n 'question_id': 262148000,\n 'image_id': '/root/.cache/huggingface/datasets/downloads/extracted/ca733e0e000fb2d7a09fbcc94dbfe7b5a30750681d0e965f8e0a23b1c2f98c75/val2014/COCO_val2014_000000262148.jpg',\n 'answer_type': 'other',\n 'label': {'ids': ['at table', 'down', 'skateboard', 'table'],\n  'weights': [0.30000001192092896,\n   1.0,\n   0.30000001192092896,\n   0.30000001192092896]}}\n```\n\nThe features relevant to the task include: \n* `question`: the question to be answered from the image\n* `image_id`: the path to the image the question refers to\n* `label`: the annotations\n\nWe can remove the rest of the features as they won't be necessary: \n\n```py \n>>> dataset = dataset.remove_columns(['question_type', 'question_id', 'answer_type'])\n```\n\nAs you can see, the `label` feature contains several answers to the same question (called `ids` here) collected by different human annotators. \nThis is because the answer to a question can be subjective. In this case, the question is \"where is he looking?\". Some people \nannotated this with \"down\", others with \"at table\", another one with \"skateboard\", etc. \n\nTake a look at the image and consider which answer would you give:\n\n```python\n>>> from PIL import Image\n\n>>> image = Image.open(dataset[0]['image_id'])\n>>> image\n```\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/vqa-example.png\" alt=\"VQA Image Example\"/>\n</div>\n\nDue to the questions' and answers' ambiguity, datasets like this are treated as a multi-label classification problem (as \nmultiple answers are possibly valid). Moreover, rather than just creating a one-hot encoded vector, one creates a \nsoft encoding, based on the number of times a certain answer appeared in the annotations.\n\nFor instance, in the example above, because the answer \"down\" is selected way more often than other answers, it has a \nscore (called `weight` in the dataset) of 1.0, and the rest of the answers have scores < 1.0. \n\nTo later instantiate the model with an appropriate classification head, let's create two dictionaries: one that maps \nthe label name to an integer and vice versa:\n\n```py\n>>> import itertools\n\n>>> labels = [item['ids'] for item in dataset['label']]\n>>> flattened_labels = list(itertools.chain(*labels))\n>>> unique_labels = list(set(flattened_labels))\n\n>>> label2id = {label: idx for idx, label in enumerate(unique_labels)}\n>>> id2label = {idx: label for label, idx in label2id.items()} \n```\n\nNow that we have the mappings, we can replace the string answers with their ids, and flatten the dataset for a more convenient further preprocessing. \n\n```python\n>>> def replace_ids(inputs):\n...   inputs[\"label\"][\"ids\"] = [label2id[x] for x in inputs[\"label\"][\"ids\"]]\n...   return inputs"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 45d8942b-6d8d-4a13-b9ec-662ed33d9002
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/visual_question_answering", "title": "Visual Question Answering", "tokens": 3788, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"45d8942b-6d8d-4a13-b9ec-662ed33d9002\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"2f4e4bf6-20dc-41cd-8c45-0e298efabe77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4beeead43ec2efaea2518803588709d06bb6b4bdfffceb248f2173f3e682aa8c\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"eaac7005-3633-4fb5-8d50-700e2e87ca5b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"96dba756c088f18794f8065dd1ef540c842f11c37fd2f4adc18cbbb8d87fccba\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"580dadb0-cbb6-4a2d-8658-71c315c90784\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"dd80bb7eceaf85158ad0f552cdf468a66c929f97b1b4bc05533888e3bd28b088\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4621, \"end_char_idx\": 7755, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "ref_doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "chroma:document": "Take a look at the image and consider which answer would you give:\n\n```python\n>>> from PIL import Image\n\n>>> image = Image.open(dataset[0]['image_id'])\n>>> image\n```\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/vqa-example.png\" alt=\"VQA Image Example\"/>\n</div>\n\nDue to the questions' and answers' ambiguity, datasets like this are treated as a multi-label classification problem (as \nmultiple answers are possibly valid). Moreover, rather than just creating a one-hot encoded vector, one creates a \nsoft encoding, based on the number of times a certain answer appeared in the annotations.\n\nFor instance, in the example above, because the answer \"down\" is selected way more often than other answers, it has a \nscore (called `weight` in the dataset) of 1.0, and the rest of the answers have scores < 1.0. \n\nTo later instantiate the model with an appropriate classification head, let's create two dictionaries: one that maps \nthe label name to an integer and vice versa:\n\n```py\n>>> import itertools\n\n>>> labels = [item['ids'] for item in dataset['label']]\n>>> flattened_labels = list(itertools.chain(*labels))\n>>> unique_labels = list(set(flattened_labels))\n\n>>> label2id = {label: idx for idx, label in enumerate(unique_labels)}\n>>> id2label = {idx: label for label, idx in label2id.items()} \n```\n\nNow that we have the mappings, we can replace the string answers with their ids, and flatten the dataset for a more convenient further preprocessing. \n\n```python\n>>> def replace_ids(inputs):\n...   inputs[\"label\"][\"ids\"] = [label2id[x] for x in inputs[\"label\"][\"ids\"]]\n...   return inputs\n\n\n>>> dataset = dataset.map(replace_ids)\n>>> flat_dataset = dataset.flatten()\n>>> flat_dataset.features\n{'question': Value(dtype='string', id=None),\n 'image_id': Value(dtype='string', id=None),\n 'label.ids': Sequence(feature=Value(dtype='int64', id=None), length=-1, id=None),\n 'label.weights': Sequence(feature=Value(dtype='float64', id=None), length=-1, id=None)}\n```\n\n## Preprocessing data\n\nThe next step is to load a ViLT processor to prepare the image and text data for the model. \n[`ViltProcessor`] wraps a BERT tokenizer and ViLT image processor into a convenient single processor:\n\n```py \n>>> from transformers import ViltProcessor\n\n>>> processor = ViltProcessor.from_pretrained(model_checkpoint)\n```\n\nTo preprocess the data we need to encode the images and questions using the [`ViltProcessor`]. The processor will use \nthe [`BertTokenizerFast`] to tokenize the text and create `input_ids`, `attention_mask` and `token_type_ids` for the text data. \nAs for images, the processor will leverage [`ViltImageProcessor`] to resize and normalize the image, and create `pixel_values` and `pixel_mask`.\n\nAll these preprocessing steps are done under the hood, we only need to call the `processor`. However, we still need to \nprepare the target labels. In this representation, each element corresponds to a possible answer (label). For correct answers, the element holds \ntheir respective score (weight), while the remaining elements are set to zero."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 580dadb0-cbb6-4a2d-8658-71c315c90784
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/visual_question_answering", "title": "Visual Question Answering", "tokens": 3788, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"580dadb0-cbb6-4a2d-8658-71c315c90784\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"2f4e4bf6-20dc-41cd-8c45-0e298efabe77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4beeead43ec2efaea2518803588709d06bb6b4bdfffceb248f2173f3e682aa8c\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"45d8942b-6d8d-4a13-b9ec-662ed33d9002\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"6a4d9a8d6075c13f8dea0fbc27d5e86a4e135973ddbff061d72d04ac4d26725c\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"7c36ee6e-5ceb-4292-ac7a-17aab8a7f1c7\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"f8255841ffdfce85f3c0721f1214c436bf83f0228fa8a8c305268984bab2b930\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6171, \"end_char_idx\": 9561, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "ref_doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "chroma:document": "```python\n>>> def replace_ids(inputs):\n...   inputs[\"label\"][\"ids\"] = [label2id[x] for x in inputs[\"label\"][\"ids\"]]\n...   return inputs\n\n\n>>> dataset = dataset.map(replace_ids)\n>>> flat_dataset = dataset.flatten()\n>>> flat_dataset.features\n{'question': Value(dtype='string', id=None),\n 'image_id': Value(dtype='string', id=None),\n 'label.ids': Sequence(feature=Value(dtype='int64', id=None), length=-1, id=None),\n 'label.weights': Sequence(feature=Value(dtype='float64', id=None), length=-1, id=None)}\n```\n\n## Preprocessing data\n\nThe next step is to load a ViLT processor to prepare the image and text data for the model. \n[`ViltProcessor`] wraps a BERT tokenizer and ViLT image processor into a convenient single processor:\n\n```py \n>>> from transformers import ViltProcessor\n\n>>> processor = ViltProcessor.from_pretrained(model_checkpoint)\n```\n\nTo preprocess the data we need to encode the images and questions using the [`ViltProcessor`]. The processor will use \nthe [`BertTokenizerFast`] to tokenize the text and create `input_ids`, `attention_mask` and `token_type_ids` for the text data. \nAs for images, the processor will leverage [`ViltImageProcessor`] to resize and normalize the image, and create `pixel_values` and `pixel_mask`.\n\nAll these preprocessing steps are done under the hood, we only need to call the `processor`. However, we still need to \nprepare the target labels. In this representation, each element corresponds to a possible answer (label). For correct answers, the element holds \ntheir respective score (weight), while the remaining elements are set to zero.\n\nThe following function applies the `processor` to the images and questions and formats the labels as described above:\n\n```py\n>>> import torch\n\n>>> def preprocess_data(examples):\n...     image_paths = examples['image_id']\n...     images = [Image.open(image_path) for image_path in image_paths]\n...     texts = examples['question']    \n\n...     encoding = processor(images, texts, padding=\"max_length\", truncation=True, return_tensors=\"pt\")\n\n...     for k, v in encoding.items():\n...           encoding[k] = v.squeeze()\n    \n...     targets = []\n\n...     for labels, scores in zip(examples['label.ids'], examples['label.weights']):\n...         target = torch.zeros(len(id2label))\n\n...         for label, score in zip(labels, scores):\n...             target[label] = score\n      \n...         targets.append(target)\n\n...     encoding[\"labels\"] = targets\n    \n...     return encoding\n```\n\nTo apply the preprocessing function over the entire dataset, use \ud83e\udd17 Datasets [`~datasets.map`] function. You can speed up `map` by \nsetting `batched=True` to process multiple elements of the dataset at once. At this point, feel free to remove the columns you don't need.\n\n```py\n>>> processed_dataset = flat_dataset.map(preprocess_data, batched=True, remove_columns=['question','question_type',  'question_id', 'image_id', 'answer_type', 'label.ids', 'label.weights'])\n>>> processed_dataset\nDataset({\n    features: ['input_ids', 'token_type_ids', 'attention_mask', 'pixel_values', 'pixel_mask', 'labels'],\n    num_rows: 200\n})\n```\n\nAs a final step, create a batch of examples using [`DefaultDataCollator`]:\n\n```py\n>>> from transformers import DefaultDataCollator\n\n>>> data_collator = DefaultDataCollator()\n```\n\n## Train the model\n\nYou\u2019re ready to start training your model now! Load ViLT with [`ViltForQuestionAnswering`]."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 7c36ee6e-5ceb-4292-ac7a-17aab8a7f1c7
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/visual_question_answering", "title": "Visual Question Answering", "tokens": 3788, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"7c36ee6e-5ceb-4292-ac7a-17aab8a7f1c7\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"2f4e4bf6-20dc-41cd-8c45-0e298efabe77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4beeead43ec2efaea2518803588709d06bb6b4bdfffceb248f2173f3e682aa8c\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"580dadb0-cbb6-4a2d-8658-71c315c90784\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"3910178bf9ea01dc3e7ba7bd5f6efc34cc493f3a43ede3b1076bd1de19165df2\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"7ea42ff4-39be-4bb8-b18f-31fd0305f349\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"d834cd5660a1e4fb5399a7713ea8000b62145920c168ee083a0488363d97b325\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8745, \"end_char_idx\": 11830, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "ref_doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "chroma:document": "You can speed up `map` by \nsetting `batched=True` to process multiple elements of the dataset at once. At this point, feel free to remove the columns you don't need.\n\n```py\n>>> processed_dataset = flat_dataset.map(preprocess_data, batched=True, remove_columns=['question','question_type',  'question_id', 'image_id', 'answer_type', 'label.ids', 'label.weights'])\n>>> processed_dataset\nDataset({\n    features: ['input_ids', 'token_type_ids', 'attention_mask', 'pixel_values', 'pixel_mask', 'labels'],\n    num_rows: 200\n})\n```\n\nAs a final step, create a batch of examples using [`DefaultDataCollator`]:\n\n```py\n>>> from transformers import DefaultDataCollator\n\n>>> data_collator = DefaultDataCollator()\n```\n\n## Train the model\n\nYou\u2019re ready to start training your model now! Load ViLT with [`ViltForQuestionAnswering`]. Specify the number of labels \nalong with the label mappings:\n\n```py\n>>> from transformers import ViltForQuestionAnswering\n\n>>> model = ViltForQuestionAnswering.from_pretrained(model_checkpoint, num_labels=len(id2label), id2label=id2label, label2id=label2id)\n```\n\nAt this point, only three steps remain:\n\n1. Define your training hyperparameters in [`TrainingArguments`]:\n\n```py\n>>> from transformers import TrainingArguments\n\n>>> repo_id = \"MariaK/vilt_finetuned_200\"\n\n>>> training_args = TrainingArguments(\n...     output_dir=repo_id,\n...     per_device_train_batch_size=4,\n...     num_train_epochs=20,\n...     save_steps=200,\n...     logging_steps=50,\n...     learning_rate=5e-5,\n...     save_total_limit=2,\n...     remove_unused_columns=False,\n...     push_to_hub=True,\n... )\n```\n\n2. Pass the training arguments to [`Trainer`] along with the model, dataset, processor, and data collator.\n\n```py\n>>> from transformers import Trainer\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     data_collator=data_collator,\n...     train_dataset=processed_dataset,\n...     tokenizer=processor,\n... )\n```\n\n3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> trainer.train() \n```\n\nOnce training is completed, share your model to the Hub with the [`~Trainer.push_to_hub`] method to share your final model on the \ud83e\udd17 Hub:\n\n```py\n>>> trainer.push_to_hub()\n```\n\n## Inference\n\nNow that you have fine-tuned a ViLT model, and uploaded it to the \ud83e\udd17 Hub, you can use it for inference. The simplest\nway to try out your fine-tuned model for inference is to use it in a [`Pipeline`].\n\n```py\n>>> from transformers import pipeline\n\n>>> pipe = pipeline(\"visual-question-answering\", model=\"MariaK/vilt_finetuned_200\")\n```\n\nThe model in this guide has only been trained on 200 examples, so don't expect a lot from it. Let's see if it at least \nlearned something from the data and take the first example from the dataset to illustrate inference:\n\n```py\n>>> example = dataset[0]\n>>> image = Image.open(example['image_id'])\n>>> question = example['question']\n>>> print(question)\n>>> pipe(image, question, top_k=1)\n\"Where is he looking?\"\n[{'score': 0.5498199462890625, 'answer': 'down'}]\n```\n\nEven though not very confident, the model indeed has learned something."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 7ea42ff4-39be-4bb8-b18f-31fd0305f349
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/visual_question_answering", "title": "Visual Question Answering", "tokens": 3788, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"7ea42ff4-39be-4bb8-b18f-31fd0305f349\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"2f4e4bf6-20dc-41cd-8c45-0e298efabe77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4beeead43ec2efaea2518803588709d06bb6b4bdfffceb248f2173f3e682aa8c\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"7c36ee6e-5ceb-4292-ac7a-17aab8a7f1c7\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"3f6d457b0083514f057206c025ca5933864f27f9eebd2c298a3f9a87a23dd995\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"aba742c9-4691-42fb-b9ad-e947c21bbc10\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e674133eefc00b096425314c7c1f55afe77986fa70e3d17259aa0990bd9b8935\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 10348, \"end_char_idx\": 13430, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "ref_doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "chroma:document": "Pass the training arguments to [`Trainer`] along with the model, dataset, processor, and data collator.\n\n```py\n>>> from transformers import Trainer\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     data_collator=data_collator,\n...     train_dataset=processed_dataset,\n...     tokenizer=processor,\n... )\n```\n\n3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> trainer.train() \n```\n\nOnce training is completed, share your model to the Hub with the [`~Trainer.push_to_hub`] method to share your final model on the \ud83e\udd17 Hub:\n\n```py\n>>> trainer.push_to_hub()\n```\n\n## Inference\n\nNow that you have fine-tuned a ViLT model, and uploaded it to the \ud83e\udd17 Hub, you can use it for inference. The simplest\nway to try out your fine-tuned model for inference is to use it in a [`Pipeline`].\n\n```py\n>>> from transformers import pipeline\n\n>>> pipe = pipeline(\"visual-question-answering\", model=\"MariaK/vilt_finetuned_200\")\n```\n\nThe model in this guide has only been trained on 200 examples, so don't expect a lot from it. Let's see if it at least \nlearned something from the data and take the first example from the dataset to illustrate inference:\n\n```py\n>>> example = dataset[0]\n>>> image = Image.open(example['image_id'])\n>>> question = example['question']\n>>> print(question)\n>>> pipe(image, question, top_k=1)\n\"Where is he looking?\"\n[{'score': 0.5498199462890625, 'answer': 'down'}]\n```\n\nEven though not very confident, the model indeed has learned something. With more examples and longer training, you'll get far better results!\n\nYou can also manually replicate the results of the pipeline if you'd like:\n1. Take an image and a question, prepare them for the model using the processor from your model.\n2. Forward the result or preprocessing through the model.\n3. From the logits, get the most likely answer's id, and find the actual answer in the `id2label`.\n\n```py\n>>> processor = ViltProcessor.from_pretrained(\"MariaK/vilt_finetuned_200\")\n\n>>> image = Image.open(example['image_id'])\n>>> question = example['question']\n\n>>> # prepare inputs\n>>> inputs = processor(image, question, return_tensors=\"pt\")\n\n>>> model = ViltForQuestionAnswering.from_pretrained(\"MariaK/vilt_finetuned_200\")\n\n>>> # forward pass\n>>> with torch.no_grad():\n...     outputs = model(**inputs)\n\n>>> logits = outputs.logits\n>>> idx = logits.argmax(-1).item()\n>>> print(\"Predicted answer:\", model.config.id2label[idx])\nPredicted answer: down\n```\n\n## Zero-shot VQA\n\nThe previous model treated VQA as a classification task. Some recent models, such as BLIP, BLIP-2, and InstructBLIP approach \nVQA as a generative task. Let's take [BLIP-2](../model_doc/blip-2) as an example. It introduced a new visual-language pre-training \nparadigm in which any combination of pre-trained vision encoder and LLM can be used (learn more in the [BLIP-2 blog post](https://huggingface.co/blog/blip-2)). \nThis enables achieving state-of-the-art results on multiple visual-language tasks including visual question answering. \n\nLet's illustrate how you can use this model for VQA. First, let's load the model."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: aba742c9-4691-42fb-b9ad-e947c21bbc10
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/visual_question_answering", "title": "Visual Question Answering", "tokens": 3788, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"aba742c9-4691-42fb-b9ad-e947c21bbc10\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"2f4e4bf6-20dc-41cd-8c45-0e298efabe77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4beeead43ec2efaea2518803588709d06bb6b4bdfffceb248f2173f3e682aa8c\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"7ea42ff4-39be-4bb8-b18f-31fd0305f349\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"bb78642c4fe7af17fbb96bbf466994e17e83ff95d5a5b43381a100dffed3716f\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"2510247f-1d57-426d-9194-ec7246190276\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"be8b95418d0a422bce27dba3cbf966c13cc716a308af99ffa88e44b601d5f4d8\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 11831, \"end_char_idx\": 15013, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "ref_doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "chroma:document": "With more examples and longer training, you'll get far better results!\n\nYou can also manually replicate the results of the pipeline if you'd like:\n1. Take an image and a question, prepare them for the model using the processor from your model.\n2. Forward the result or preprocessing through the model.\n3. From the logits, get the most likely answer's id, and find the actual answer in the `id2label`.\n\n```py\n>>> processor = ViltProcessor.from_pretrained(\"MariaK/vilt_finetuned_200\")\n\n>>> image = Image.open(example['image_id'])\n>>> question = example['question']\n\n>>> # prepare inputs\n>>> inputs = processor(image, question, return_tensors=\"pt\")\n\n>>> model = ViltForQuestionAnswering.from_pretrained(\"MariaK/vilt_finetuned_200\")\n\n>>> # forward pass\n>>> with torch.no_grad():\n...     outputs = model(**inputs)\n\n>>> logits = outputs.logits\n>>> idx = logits.argmax(-1).item()\n>>> print(\"Predicted answer:\", model.config.id2label[idx])\nPredicted answer: down\n```\n\n## Zero-shot VQA\n\nThe previous model treated VQA as a classification task. Some recent models, such as BLIP, BLIP-2, and InstructBLIP approach \nVQA as a generative task. Let's take [BLIP-2](../model_doc/blip-2) as an example. It introduced a new visual-language pre-training \nparadigm in which any combination of pre-trained vision encoder and LLM can be used (learn more in the [BLIP-2 blog post](https://huggingface.co/blog/blip-2)). \nThis enables achieving state-of-the-art results on multiple visual-language tasks including visual question answering. \n\nLet's illustrate how you can use this model for VQA. First, let's load the model. Here we'll explicitly send the model to a \nGPU, if available, which we didn't need to do earlier when training, as [`Trainer`] handles this automatically: \n\n```py\n>>> from transformers import AutoProcessor, Blip2ForConditionalGeneration\n>>> import torch\n\n>>> processor = AutoProcessor.from_pretrained(\"Salesforce/blip2-opt-2.7b\")\n>>> model = Blip2ForConditionalGeneration.from_pretrained(\"Salesforce/blip2-opt-2.7b\", torch_dtype=torch.float16)\n>>> device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n>>> model.to(device)\n```\n\nThe model takes image and text as input, so let's use the exact same image/question pair from the first example in the VQA dataset: \n\n```py \n>>> example = dataset[0]\n>>> image = Image.open(example['image_id'])\n>>> question = example['question']\n```\n\nTo use BLIP-2 for visual question answering task, the textual prompt has to follow a specific format: `Question: {} Answer:`.\n\n```py\n>>> prompt = f\"Question: {question} Answer:\" \n```\n\nNow we need to preprocess the image/prompt with the model's processor, pass the processed input through the model, and decode the output:\n\n```py\n>>> inputs = processor(image, text=prompt, return_tensors=\"pt\").to(device, torch.float16)\n\n>>> generated_ids = model.generate(**inputs, max_new_tokens=10)\n>>> generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()\n>>> print(generated_text)\n\"He is looking at the crowd\" \n```\n\nAs you can see, the model recognized the crowd, and the direction of the face (looking down), however, it seems to miss \nthe fact the crowd is behind the skater."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 2510247f-1d57-426d-9194-ec7246190276
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/visual_question_answering", "title": "Visual Question Answering", "tokens": 3788, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"2510247f-1d57-426d-9194-ec7246190276\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"2f4e4bf6-20dc-41cd-8c45-0e298efabe77\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4beeead43ec2efaea2518803588709d06bb6b4bdfffceb248f2173f3e682aa8c\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"aba742c9-4691-42fb-b9ad-e947c21bbc10\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/visual_question_answering\", \"title\": \"Visual Question Answering\", \"tokens\": 3788, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"ffdd20022e74a54c57bca75163ab1dcebc1af81d01c226709daaf99cb280ab7f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 13402, \"end_char_idx\": 15138, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "ref_doc_id": "2f4e4bf6-20dc-41cd-8c45-0e298efabe77", "chroma:document": "First, let's load the model. Here we'll explicitly send the model to a \nGPU, if available, which we didn't need to do earlier when training, as [`Trainer`] handles this automatically: \n\n```py\n>>> from transformers import AutoProcessor, Blip2ForConditionalGeneration\n>>> import torch\n\n>>> processor = AutoProcessor.from_pretrained(\"Salesforce/blip2-opt-2.7b\")\n>>> model = Blip2ForConditionalGeneration.from_pretrained(\"Salesforce/blip2-opt-2.7b\", torch_dtype=torch.float16)\n>>> device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n>>> model.to(device)\n```\n\nThe model takes image and text as input, so let's use the exact same image/question pair from the first example in the VQA dataset: \n\n```py \n>>> example = dataset[0]\n>>> image = Image.open(example['image_id'])\n>>> question = example['question']\n```\n\nTo use BLIP-2 for visual question answering task, the textual prompt has to follow a specific format: `Question: {} Answer:`.\n\n```py\n>>> prompt = f\"Question: {question} Answer:\" \n```\n\nNow we need to preprocess the image/prompt with the model's processor, pass the processed input through the model, and decode the output:\n\n```py\n>>> inputs = processor(image, text=prompt, return_tensors=\"pt\").to(device, torch.float16)\n\n>>> generated_ids = model.generate(**inputs, max_new_tokens=10)\n>>> generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()\n>>> print(generated_text)\n\"He is looking at the crowd\" \n```\n\nAs you can see, the model recognized the crowd, and the direction of the face (looking down), however, it seems to miss \nthe fact the crowd is behind the skater. Still, in cases where acquiring human-annotated datasets is not feasible, this \napproach can quickly produce useful results."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 53078042-266d-47b5-8cd9-c4dbb723b32d
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/image_classification", "title": "Image classification", "tokens": 4527, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"53078042-266d-47b5-8cd9-c4dbb723b32d\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"79d912a7-d5d0-4c78-9856-3a9220ead88a\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7d9276d485ce3f5c84ce243d6affdad336f403f9a173068ecddf362aef8287c7\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"f39cbd72-6b3d-4e26-8904-f16ed89a6b68\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"f07cf64d6a3f473b4ed9581a79a687b78d7edcf3fe101b81cfc7d3baac827e1f\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3039, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "ref_doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "chroma:document": "# Image classification\n\n[[open-in-colab]]\n\n<Youtube id=\"tjAIM7BOYhw\"/>\n\nImage classification assigns a label or class to an image. Unlike text or audio classification, the inputs are the\npixel values that comprise an image. There are many applications for image classification, such as detecting damage\nafter a natural disaster, monitoring crop health, or helping screen medical images for signs of disease.\n\nThis guide illustrates how to:\n\n1. Fine-tune [ViT](model_doc/vit) on the [Food-101](https://huggingface.co/datasets/food101) dataset to classify a food item in an image.\n2. Use your fine-tuned model for inference.\n\n<Tip>\n\nTo see all architectures and checkpoints compatible with this task, we recommend checking the [task-page](https://huggingface.co/tasks/image-classification)\n\n</Tip>\n\nBefore you begin, make sure you have all the necessary libraries installed:\n\n```bash\npip install transformers datasets evaluate accelerate pillow torchvision scikit-learn\n```\n\nWe encourage you to log in to your Hugging Face account to upload and share your model with the community. When prompted, enter your token to log in:\n\n```py\n>>> from huggingface_hub import notebook_login\n\n>>> notebook_login()\n```\n\n## Load Food-101 dataset\n\nStart by loading a smaller subset of the Food-101 dataset from the \ud83e\udd17 Datasets library. This will give you a chance to\nexperiment and make sure everything works before spending more time training on the full dataset.\n\n```py\n>>> from datasets import load_dataset\n\n>>> food = load_dataset(\"food101\", split=\"train[:5000]\")\n```\n\nSplit the dataset's `train` split into a train and test set with the [`~datasets.Dataset.train_test_split`] method:\n\n```py\n>>> food = food.train_test_split(test_size=0.2)\n```\n\nThen take a look at an example:\n\n```py\n>>> food[\"train\"][0]\n{'image': <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=512x512 at 0x7F52AFC8AC50>,\n 'label': 79}\n```\n\nEach example in the dataset has two fields:\n\n- `image`: a PIL image of the food item\n- `label`: the label class of the food item\n\nTo make it easier for the model to get the label name from the label id, create a dictionary that maps the label name\nto an integer and vice versa:\n\n```py\n>>> labels = food[\"train\"].features[\"label\"].names\n>>> label2id, id2label = dict(), dict()\n>>> for i, label in enumerate(labels):\n...     label2id[label] = str(i)\n...     id2label[str(i)] = label\n```\n\nNow you can convert the label id to a label name:\n\n```py\n>>> id2label[str(79)]\n'prime_rib'\n```\n\n## Preprocess\n\nThe next step is to load a ViT image processor to process the image into a tensor:\n\n```py\n>>> from transformers import AutoImageProcessor\n\n>>> checkpoint = \"google/vit-base-patch16-224-in21k\"\n>>> image_processor = AutoImageProcessor.from_pretrained(checkpoint)\n```\n\n<frameworkcontent>\n<pt>\nApply some image transformations to the images to make the model more robust against overfitting. Here you'll use torchvision's [`transforms`](https://pytorch.org/vision/stable/transforms.html) module, but you can also use any image library you like."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: f39cbd72-6b3d-4e26-8904-f16ed89a6b68
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/image_classification", "title": "Image classification", "tokens": 4527, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"f39cbd72-6b3d-4e26-8904-f16ed89a6b68\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"79d912a7-d5d0-4c78-9856-3a9220ead88a\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7d9276d485ce3f5c84ce243d6affdad336f403f9a173068ecddf362aef8287c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"53078042-266d-47b5-8cd9-c4dbb723b32d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"886a0267b29d0b07c34d25e05b8c11e9e861874cd84d4d1995ba39948bbdda5f\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"00ba3b6b-850f-4121-8e93-97f9fc3bb900\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"f08f3d0f622ac08c0a2924aab247c9ae7ab6c449789efc2936b1da623800c471\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2887, \"end_char_idx\": 6194, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "ref_doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "chroma:document": "Here you'll use torchvision's [`transforms`](https://pytorch.org/vision/stable/transforms.html) module, but you can also use any image library you like.\n\nCrop a random part of the image, resize it, and normalize it with the image mean and standard deviation:\n\n```py\n>>> from torchvision.transforms import RandomResizedCrop, Compose, Normalize, ToTensor\n\n>>> normalize = Normalize(mean=image_processor.image_mean, std=image_processor.image_std)\n>>> size = (\n...     image_processor.size[\"shortest_edge\"]\n...     if \"shortest_edge\" in image_processor.size\n...     else (image_processor.size[\"height\"], image_processor.size[\"width\"])\n... )\n>>> _transforms = Compose([RandomResizedCrop(size), ToTensor(), normalize])\n```\n\nThen create a preprocessing function to apply the transforms and return the `pixel_values` - the inputs to the model - of the image:\n\n```py\n>>> def transforms(examples):\n...     examples[\"pixel_values\"] = [_transforms(img.convert(\"RGB\")) for img in examples[\"image\"]]\n...     del examples[\"image\"]\n...     return examples\n```\n\nTo apply the preprocessing function over the entire dataset, use \ud83e\udd17 Datasets [`~datasets.Dataset.with_transform`] method. The transforms are applied on the fly when you load an element of the dataset:\n\n```py\n>>> food = food.with_transform(transforms)\n```\n\nNow create a batch of examples using [`DefaultDataCollator`]. Unlike other data collators in \ud83e\udd17 Transformers, the `DefaultDataCollator` does not apply additional preprocessing such as padding.\n\n```py\n>>> from transformers import DefaultDataCollator\n\n>>> data_collator = DefaultDataCollator()\n```\n</pt>\n</frameworkcontent>\n\n\n<frameworkcontent>\n<tf>\n\nTo avoid overfitting and to make the model more robust, add some data augmentation to the training part of the dataset.\nHere we use Keras preprocessing layers to define the transformations for the training data (includes data augmentation),\nand transformations for the validation data (only center cropping, resizing and normalizing). You can use `tf.image`or\nany other library you prefer.\n\n```py\n>>> from tensorflow import keras\n>>> from tensorflow.keras import layers\n\n>>> size = (image_processor.size[\"height\"], image_processor.size[\"width\"])\n\n>>> train_data_augmentation = keras.Sequential(\n...     [\n...         layers.RandomCrop(size[0], size[1]),\n...         layers.Rescaling(scale=1.0 / 127.5, offset=-1),\n...         layers.RandomFlip(\"horizontal\"),\n...         layers.RandomRotation(factor=0.02),\n...         layers.RandomZoom(height_factor=0.2, width_factor=0.2),\n...     ],\n...     name=\"train_data_augmentation\",\n... )\n\n>>> val_data_augmentation = keras.Sequential(\n...     [\n...         layers.CenterCrop(size[0], size[1]),\n...         layers.Rescaling(scale=1.0 / 127.5, offset=-1),\n...     ],\n...     name=\"val_data_augmentation\",\n... )\n```\n\nNext, create functions to apply appropriate transformations to a batch of images, instead of one image at a time.\n\n```py\n>>> import numpy as np\n>>> import tensorflow as tf\n>>> from PIL import Image\n\n\n>>> def convert_to_tf_tensor(image: Image):\n...     np_image = np.array(image)\n...     tf_image = tf.convert_to_tensor(np_image)\n...     # `expand_dims()` is used to add a batch dimension since\n...     # the TF augmentation layers operates on batched inputs.\n...     return tf.expand_dims(tf_image, 0)"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 00ba3b6b-850f-4121-8e93-97f9fc3bb900
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/image_classification", "title": "Image classification", "tokens": 4527, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"00ba3b6b-850f-4121-8e93-97f9fc3bb900\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"79d912a7-d5d0-4c78-9856-3a9220ead88a\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7d9276d485ce3f5c84ce243d6affdad336f403f9a173068ecddf362aef8287c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"f39cbd72-6b3d-4e26-8904-f16ed89a6b68\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"3649120c3ec7ba7617dcfdf03893c95ee811b2fae54ac780dfc2dbc0c445a08c\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"6d2b0086-bd56-4f15-80dc-ca2a183bfc0b\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"856f897edd6dc468ad9d0b428d3806849118fbed4b8e33cd1a5467c5ab711f96\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4510, \"end_char_idx\": 6558, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "ref_doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "chroma:document": "<frameworkcontent>\n<tf>\n\nTo avoid overfitting and to make the model more robust, add some data augmentation to the training part of the dataset.\nHere we use Keras preprocessing layers to define the transformations for the training data (includes data augmentation),\nand transformations for the validation data (only center cropping, resizing and normalizing). You can use `tf.image`or\nany other library you prefer.\n\n```py\n>>> from tensorflow import keras\n>>> from tensorflow.keras import layers\n\n>>> size = (image_processor.size[\"height\"], image_processor.size[\"width\"])\n\n>>> train_data_augmentation = keras.Sequential(\n...     [\n...         layers.RandomCrop(size[0], size[1]),\n...         layers.Rescaling(scale=1.0 / 127.5, offset=-1),\n...         layers.RandomFlip(\"horizontal\"),\n...         layers.RandomRotation(factor=0.02),\n...         layers.RandomZoom(height_factor=0.2, width_factor=0.2),\n...     ],\n...     name=\"train_data_augmentation\",\n... )\n\n>>> val_data_augmentation = keras.Sequential(\n...     [\n...         layers.CenterCrop(size[0], size[1]),\n...         layers.Rescaling(scale=1.0 / 127.5, offset=-1),\n...     ],\n...     name=\"val_data_augmentation\",\n... )\n```\n\nNext, create functions to apply appropriate transformations to a batch of images, instead of one image at a time.\n\n```py\n>>> import numpy as np\n>>> import tensorflow as tf\n>>> from PIL import Image\n\n\n>>> def convert_to_tf_tensor(image: Image):\n...     np_image = np.array(image)\n...     tf_image = tf.convert_to_tensor(np_image)\n...     # `expand_dims()` is used to add a batch dimension since\n...     # the TF augmentation layers operates on batched inputs.\n...     return tf.expand_dims(tf_image, 0)\n\n\n>>> def preprocess_train(example_batch):\n...     \"\"\"Apply train_transforms across a batch.\"\"\"\n...     images = [\n...         train_data_augmentation(convert_to_tf_tensor(image.convert(\"RGB\"))) for image in example_batch[\"image\"]\n...     ]\n...     example_batch[\"pixel_values\"] = [tf.transpose(tf.squeeze(image)) for image in images]\n...     return example_batch"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 6d2b0086-bd56-4f15-80dc-ca2a183bfc0b
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/image_classification", "title": "Image classification", "tokens": 4527, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"6d2b0086-bd56-4f15-80dc-ca2a183bfc0b\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"79d912a7-d5d0-4c78-9856-3a9220ead88a\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7d9276d485ce3f5c84ce243d6affdad336f403f9a173068ecddf362aef8287c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"00ba3b6b-850f-4121-8e93-97f9fc3bb900\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"b6d38bd8fb5da8e0329116285c21c72c9bff5e9e560a664d358e106f2aa256a6\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"9ca0e485-0da0-4095-b7c1-75321e3cad0b\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"8ebf729f7c3e3d478a005928d544cdf05d8f33e29259247aa51839f57548fbca\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 5893, \"end_char_idx\": 9273, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "ref_doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "chroma:document": ">>> def convert_to_tf_tensor(image: Image):\n...     np_image = np.array(image)\n...     tf_image = tf.convert_to_tensor(np_image)\n...     # `expand_dims()` is used to add a batch dimension since\n...     # the TF augmentation layers operates on batched inputs.\n...     return tf.expand_dims(tf_image, 0)\n\n\n>>> def preprocess_train(example_batch):\n...     \"\"\"Apply train_transforms across a batch.\"\"\"\n...     images = [\n...         train_data_augmentation(convert_to_tf_tensor(image.convert(\"RGB\"))) for image in example_batch[\"image\"]\n...     ]\n...     example_batch[\"pixel_values\"] = [tf.transpose(tf.squeeze(image)) for image in images]\n...     return example_batch\n\n\n... def preprocess_val(example_batch):\n...     \"\"\"Apply val_transforms across a batch.\"\"\"\n...     images = [\n...         val_data_augmentation(convert_to_tf_tensor(image.convert(\"RGB\"))) for image in example_batch[\"image\"]\n...     ]\n...     example_batch[\"pixel_values\"] = [tf.transpose(tf.squeeze(image)) for image in images]\n...     return example_batch\n```\n\nUse \ud83e\udd17 Datasets [`~datasets.Dataset.set_transform`] to apply the transformations on the fly:\n\n```py\nfood[\"train\"].set_transform(preprocess_train)\nfood[\"test\"].set_transform(preprocess_val)\n```\n\nAs a final preprocessing step, create a batch of examples using `DefaultDataCollator`. Unlike other data collators in \ud83e\udd17 Transformers, the\n`DefaultDataCollator` does not apply additional preprocessing, such as padding.\n\n```py\n>>> from transformers import DefaultDataCollator\n\n>>> data_collator = DefaultDataCollator(return_tensors=\"tf\")\n```\n</tf>\n</frameworkcontent>\n\n## Evaluate\n\nIncluding a metric during training is often helpful for evaluating your model's performance. You can quickly load an\nevaluation method with the \ud83e\udd17 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load\nthe [accuracy](https://huggingface.co/spaces/evaluate-metric/accuracy) metric (see the \ud83e\udd17 Evaluate [quick tour](https://huggingface.co/docs/evaluate/a_quick_tour) to learn more about how to load and compute a metric):\n\n```py\n>>> import evaluate\n\n>>> accuracy = evaluate.load(\"accuracy\")\n```\n\nThen create a function that passes your predictions and labels to [`~evaluate.EvaluationModule.compute`] to calculate the accuracy:\n\n```py\n>>> import numpy as np\n\n\n>>> def compute_metrics(eval_pred):\n...     predictions, labels = eval_pred\n...     predictions = np.argmax(predictions, axis=1)\n...     return accuracy.compute(predictions=predictions, references=labels)\n```\n\nYour `compute_metrics` function is ready to go now, and you'll return to it when you set up your training.\n\n## Train\n\n<frameworkcontent>\n<pt>\n<Tip>\n\nIf you aren't familiar with finetuning a model with the [`Trainer`], take a look at the basic tutorial [here](../training#train-with-pytorch-trainer)!\n\n</Tip>\n\nYou're ready to start training your model now! Load ViT with [`AutoModelForImageClassification`]. Specify the number of labels along with the number of expected labels, and the label mappings:\n\n```py\n>>> from transformers import AutoModelForImageClassification, TrainingArguments, Trainer\n\n>>> model = AutoModelForImageClassification.from_pretrained(\n...     checkpoint,\n...     num_labels=len(labels),\n...     id2label=id2label,\n...     label2id=label2id,\n... )\n```\n\nAt this point, only three steps remain:\n\n1. Define your training hyperparameters in [`TrainingArguments`]."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 9ca0e485-0da0-4095-b7c1-75321e3cad0b
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/image_classification", "title": "Image classification", "tokens": 4527, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"9ca0e485-0da0-4095-b7c1-75321e3cad0b\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"79d912a7-d5d0-4c78-9856-3a9220ead88a\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7d9276d485ce3f5c84ce243d6affdad336f403f9a173068ecddf362aef8287c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"6d2b0086-bd56-4f15-80dc-ca2a183bfc0b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"c5768e828cc7050fb90d8c343bcff898768691e388c4078a72972134fd9a589f\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"e52b6025-b33c-4739-a28e-1ce83e5bd7cf\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"aad4b2649d3d96efc2568844bc5596a332a52834936a2874b294480a27ab0e45\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8180, \"end_char_idx\": 11434, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "ref_doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "chroma:document": ">>> def compute_metrics(eval_pred):\n...     predictions, labels = eval_pred\n...     predictions = np.argmax(predictions, axis=1)\n...     return accuracy.compute(predictions=predictions, references=labels)\n```\n\nYour `compute_metrics` function is ready to go now, and you'll return to it when you set up your training.\n\n## Train\n\n<frameworkcontent>\n<pt>\n<Tip>\n\nIf you aren't familiar with finetuning a model with the [`Trainer`], take a look at the basic tutorial [here](../training#train-with-pytorch-trainer)!\n\n</Tip>\n\nYou're ready to start training your model now! Load ViT with [`AutoModelForImageClassification`]. Specify the number of labels along with the number of expected labels, and the label mappings:\n\n```py\n>>> from transformers import AutoModelForImageClassification, TrainingArguments, Trainer\n\n>>> model = AutoModelForImageClassification.from_pretrained(\n...     checkpoint,\n...     num_labels=len(labels),\n...     id2label=id2label,\n...     label2id=label2id,\n... )\n```\n\nAt this point, only three steps remain:\n\n1. Define your training hyperparameters in [`TrainingArguments`]. It is important you don't remove unused columns because that'll drop the `image` column. Without the `image` column, you can't create `pixel_values`. Set `remove_unused_columns=False` to prevent this behavior! The only other required parameter is `output_dir` which specifies where to save your model. You'll push this model to the Hub by setting `push_to_hub=True` (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the [`Trainer`] will evaluate the accuracy and save the training checkpoint.\n2. Pass the training arguments to [`Trainer`] along with the model, dataset, tokenizer, data collator, and `compute_metrics` function.\n3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> training_args = TrainingArguments(\n...     output_dir=\"my_awesome_food_model\",\n...     remove_unused_columns=False,\n...     eval_strategy=\"epoch\",\n...     save_strategy=\"epoch\",\n...     learning_rate=5e-5,\n...     per_device_train_batch_size=16,\n...     gradient_accumulation_steps=4,\n...     per_device_eval_batch_size=16,\n...     num_train_epochs=3,\n...     warmup_ratio=0.1,\n...     logging_steps=10,\n...     load_best_model_at_end=True,\n...     metric_for_best_model=\"accuracy\",\n...     push_to_hub=True,\n... )\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     data_collator=data_collator,\n...     train_dataset=food[\"train\"],\n...     eval_dataset=food[\"test\"],\n...     tokenizer=image_processor,\n...     compute_metrics=compute_metrics,\n... )\n\n>>> trainer.train()\n```\n\nOnce training is completed, share your model to the Hub with the [`~transformers.Trainer.push_to_hub`] method so everyone can use your model:\n\n```py\n>>> trainer.push_to_hub()\n```\n</pt>\n</frameworkcontent>\n\n<frameworkcontent>\n<tf>\n\n<Tip>\n\nIf you are unfamiliar with fine-tuning a model with Keras, check out the [basic tutorial](./training#train-a-tensorflow-model-with-keras) first!\n\n</Tip>\n\nTo fine-tune a model in TensorFlow, follow these steps:\n1. Define the training hyperparameters, and set up an optimizer and a learning rate schedule.\n2. Instantiate a pre-trained model.\n3. Convert a \ud83e\udd17 Dataset to a `tf.data.Dataset`."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: e52b6025-b33c-4739-a28e-1ce83e5bd7cf
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/image_classification", "title": "Image classification", "tokens": 4527, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"e52b6025-b33c-4739-a28e-1ce83e5bd7cf\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"79d912a7-d5d0-4c78-9856-3a9220ead88a\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7d9276d485ce3f5c84ce243d6affdad336f403f9a173068ecddf362aef8287c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"9ca0e485-0da0-4095-b7c1-75321e3cad0b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"6c78d8e5e5f01fe72aaacb24efb4f27b6ca6ec67f83f902d495fcce52b421b17\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"d2e02770-bb8d-4ff4-9506-adc0fef8167a\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"04349a153348402a3382c78e9f4a8686e0ab9bf73f30b160645e7f4168f12582\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9943, \"end_char_idx\": 11581, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "ref_doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "chroma:document": "3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> training_args = TrainingArguments(\n...     output_dir=\"my_awesome_food_model\",\n...     remove_unused_columns=False,\n...     eval_strategy=\"epoch\",\n...     save_strategy=\"epoch\",\n...     learning_rate=5e-5,\n...     per_device_train_batch_size=16,\n...     gradient_accumulation_steps=4,\n...     per_device_eval_batch_size=16,\n...     num_train_epochs=3,\n...     warmup_ratio=0.1,\n...     logging_steps=10,\n...     load_best_model_at_end=True,\n...     metric_for_best_model=\"accuracy\",\n...     push_to_hub=True,\n... )\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     data_collator=data_collator,\n...     train_dataset=food[\"train\"],\n...     eval_dataset=food[\"test\"],\n...     tokenizer=image_processor,\n...     compute_metrics=compute_metrics,\n... )\n\n>>> trainer.train()\n```\n\nOnce training is completed, share your model to the Hub with the [`~transformers.Trainer.push_to_hub`] method so everyone can use your model:\n\n```py\n>>> trainer.push_to_hub()\n```\n</pt>\n</frameworkcontent>\n\n<frameworkcontent>\n<tf>\n\n<Tip>\n\nIf you are unfamiliar with fine-tuning a model with Keras, check out the [basic tutorial](./training#train-a-tensorflow-model-with-keras) first!\n\n</Tip>\n\nTo fine-tune a model in TensorFlow, follow these steps:\n1. Define the training hyperparameters, and set up an optimizer and a learning rate schedule.\n2. Instantiate a pre-trained model.\n3. Convert a \ud83e\udd17 Dataset to a `tf.data.Dataset`.\n4. Compile your model.\n5. Add callbacks and use the `fit()` method to run the training.\n6. Upload your model to \ud83e\udd17 Hub to share with the community."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: d2e02770-bb8d-4ff4-9506-adc0fef8167a
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/image_classification", "title": "Image classification", "tokens": 4527, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"d2e02770-bb8d-4ff4-9506-adc0fef8167a\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"79d912a7-d5d0-4c78-9856-3a9220ead88a\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7d9276d485ce3f5c84ce243d6affdad336f403f9a173068ecddf362aef8287c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"e52b6025-b33c-4739-a28e-1ce83e5bd7cf\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"266e90ba92f789967ce704cecc865da9cbe4b6384dce97945358cf3e5dd774ef\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"5e452998-66bc-4937-b2e2-811f650e2438\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"91f91fabf466cad9594a8578f516903c3aa88d8bb82fac7060a63121cbab67c0\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 9995, \"end_char_idx\": 13354, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "ref_doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "chroma:document": "```py\n>>> training_args = TrainingArguments(\n...     output_dir=\"my_awesome_food_model\",\n...     remove_unused_columns=False,\n...     eval_strategy=\"epoch\",\n...     save_strategy=\"epoch\",\n...     learning_rate=5e-5,\n...     per_device_train_batch_size=16,\n...     gradient_accumulation_steps=4,\n...     per_device_eval_batch_size=16,\n...     num_train_epochs=3,\n...     warmup_ratio=0.1,\n...     logging_steps=10,\n...     load_best_model_at_end=True,\n...     metric_for_best_model=\"accuracy\",\n...     push_to_hub=True,\n... )\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     data_collator=data_collator,\n...     train_dataset=food[\"train\"],\n...     eval_dataset=food[\"test\"],\n...     tokenizer=image_processor,\n...     compute_metrics=compute_metrics,\n... )\n\n>>> trainer.train()\n```\n\nOnce training is completed, share your model to the Hub with the [`~transformers.Trainer.push_to_hub`] method so everyone can use your model:\n\n```py\n>>> trainer.push_to_hub()\n```\n</pt>\n</frameworkcontent>\n\n<frameworkcontent>\n<tf>\n\n<Tip>\n\nIf you are unfamiliar with fine-tuning a model with Keras, check out the [basic tutorial](./training#train-a-tensorflow-model-with-keras) first!\n\n</Tip>\n\nTo fine-tune a model in TensorFlow, follow these steps:\n1. Define the training hyperparameters, and set up an optimizer and a learning rate schedule.\n2. Instantiate a pre-trained model.\n3. Convert a \ud83e\udd17 Dataset to a `tf.data.Dataset`.\n4. Compile your model.\n5. Add callbacks and use the `fit()` method to run the training.\n6. Upload your model to \ud83e\udd17 Hub to share with the community.\n\nStart by defining the hyperparameters, optimizer and learning rate schedule:\n\n```py\n>>> from transformers import create_optimizer\n\n>>> batch_size = 16\n>>> num_epochs = 5\n>>> num_train_steps = len(food[\"train\"]) * num_epochs\n>>> learning_rate = 3e-5\n>>> weight_decay_rate = 0.01\n\n>>> optimizer, lr_schedule = create_optimizer(\n...     init_lr=learning_rate,\n...     num_train_steps=num_train_steps,\n...     weight_decay_rate=weight_decay_rate,\n...     num_warmup_steps=0,\n... )\n```\n\nThen, load ViT with [`TFAutoModelForImageClassification`] along with the label mappings:\n\n```py\n>>> from transformers import TFAutoModelForImageClassification\n\n>>> model = TFAutoModelForImageClassification.from_pretrained(\n...     checkpoint,\n...     id2label=id2label,\n...     label2id=label2id,\n... )\n```\n\nConvert your datasets to the `tf.data.Dataset` format using the [`~datasets.Dataset.to_tf_dataset`] and your `data_collator`:\n\n```py\n>>> # converting our train dataset to tf.data.Dataset\n>>> tf_train_dataset = food[\"train\"].to_tf_dataset(\n...     columns=\"pixel_values\", label_cols=\"label\", shuffle=True, batch_size=batch_size, collate_fn=data_collator\n... )\n\n>>> # converting our test dataset to tf.data.Dataset\n>>> tf_eval_dataset = food[\"test\"].to_tf_dataset(\n...     columns=\"pixel_values\", label_cols=\"label\", shuffle=True, batch_size=batch_size, collate_fn=data_collator\n... )\n```\n\nConfigure the model for training with `compile()`:\n\n```py\n>>> from tensorflow.keras.losses import SparseCategoricalCrossentropy\n\n>>> loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)\n>>> model.compile(optimizer=optimizer, loss=loss)\n```\n\nTo compute the accuracy from the predictions and push your model to the \ud83e\udd17 Hub, use [Keras callbacks](../main_classes/keras_callbacks)."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 5e452998-66bc-4937-b2e2-811f650e2438
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/image_classification", "title": "Image classification", "tokens": 4527, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"5e452998-66bc-4937-b2e2-811f650e2438\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"79d912a7-d5d0-4c78-9856-3a9220ead88a\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7d9276d485ce3f5c84ce243d6affdad336f403f9a173068ecddf362aef8287c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"d2e02770-bb8d-4ff4-9506-adc0fef8167a\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"bb7d16ec35009b91499c801a449ace96344d033087e41cb08ed7d5d17a0c4676\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"8d8dd4c7-100e-47d2-a2ae-2ed5b4df1b99\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"79a30dbd43256465653a5ee56e274196f9a0b4a59e3c0a6aacc274ab0e8c9ae5\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 13355, \"end_char_idx\": 15022, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "ref_doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "chroma:document": "Pass your `compute_metrics` function to [KerasMetricCallback](../main_classes/keras_callbacks#transformers.KerasMetricCallback),\nand use the [PushToHubCallback](../main_classes/keras_callbacks#transformers.PushToHubCallback) to upload the model:\n\n```py\n>>> from transformers.keras_callbacks import KerasMetricCallback, PushToHubCallback\n\n>>> metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_eval_dataset)\n>>> push_to_hub_callback = PushToHubCallback(\n...     output_dir=\"food_classifier\",\n...     tokenizer=image_processor,\n...     save_strategy=\"no\",\n... )\n>>> callbacks = [metric_callback, push_to_hub_callback]\n```\n\nFinally, you are ready to train your model! Call `fit()` with your training and validation datasets, the number of epochs,\nand your callbacks to fine-tune the model:\n\n```py\n>>> model.fit(tf_train_dataset, validation_data=tf_eval_dataset, epochs=num_epochs, callbacks=callbacks)\nEpoch 1/5\n250/250 [==============================] - 313s 1s/step - loss: 2.5623 - val_loss: 1.4161 - accuracy: 0.9290\nEpoch 2/5\n250/250 [==============================] - 265s 1s/step - loss: 0.9181 - val_loss: 0.6808 - accuracy: 0.9690\nEpoch 3/5\n250/250 [==============================] - 252s 1s/step - loss: 0.3910 - val_loss: 0.4303 - accuracy: 0.9820\nEpoch 4/5\n250/250 [==============================] - 251s 1s/step - loss: 0.2028 - val_loss: 0.3191 - accuracy: 0.9900\nEpoch 5/5\n250/250 [==============================] - 238s 949ms/step - loss: 0.1232 - val_loss: 0.3259 - accuracy: 0.9890\n```\n\nCongratulations! You have fine-tuned your model and shared it on the \ud83e\udd17 Hub. You can now use it for inference!\n</tf>\n</frameworkcontent>"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 8d8dd4c7-100e-47d2-a2ae-2ed5b4df1b99
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/image_classification", "title": "Image classification", "tokens": 4527, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"8d8dd4c7-100e-47d2-a2ae-2ed5b4df1b99\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"79d912a7-d5d0-4c78-9856-3a9220ead88a\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7d9276d485ce3f5c84ce243d6affdad336f403f9a173068ecddf362aef8287c7\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"5e452998-66bc-4937-b2e2-811f650e2438\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/image_classification\", \"title\": \"Image classification\", \"tokens\": 4527, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"f841f082bca60a0b50f8914bee775cdc719f2554e0435ace2f8255f19ccb27ad\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 14050, \"end_char_idx\": 18122, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "ref_doc_id": "79d912a7-d5d0-4c78-9856-3a9220ead88a", "chroma:document": "Call `fit()` with your training and validation datasets, the number of epochs,\nand your callbacks to fine-tune the model:\n\n```py\n>>> model.fit(tf_train_dataset, validation_data=tf_eval_dataset, epochs=num_epochs, callbacks=callbacks)\nEpoch 1/5\n250/250 [==============================] - 313s 1s/step - loss: 2.5623 - val_loss: 1.4161 - accuracy: 0.9290\nEpoch 2/5\n250/250 [==============================] - 265s 1s/step - loss: 0.9181 - val_loss: 0.6808 - accuracy: 0.9690\nEpoch 3/5\n250/250 [==============================] - 252s 1s/step - loss: 0.3910 - val_loss: 0.4303 - accuracy: 0.9820\nEpoch 4/5\n250/250 [==============================] - 251s 1s/step - loss: 0.2028 - val_loss: 0.3191 - accuracy: 0.9900\nEpoch 5/5\n250/250 [==============================] - 238s 949ms/step - loss: 0.1232 - val_loss: 0.3259 - accuracy: 0.9890\n```\n\nCongratulations! You have fine-tuned your model and shared it on the \ud83e\udd17 Hub. You can now use it for inference!\n</tf>\n</frameworkcontent>\n\n\n<Tip>\n\nFor a more in-depth example of how to finetune a model for image classification, take a look at the corresponding [PyTorch notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb).\n\n</Tip>\n\n## Inference\n\nGreat, now that you've fine-tuned a model, you can use it for inference!\n\nLoad an image you'd like to run inference on:\n\n```py\n>>> ds = load_dataset(\"food101\", split=\"validation[:10]\")\n>>> image = ds[\"image\"][0]\n```\n\n<div class=\"flex justify-center\">\n    <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png\" alt=\"image of beignets\"/>\n</div>\n\nThe simplest way to try out your finetuned model for inference is to use it in a [`pipeline`]. Instantiate a `pipeline` for image classification with your model, and pass your image to it:\n\n```py\n>>> from transformers import pipeline\n\n>>> classifier = pipeline(\"image-classification\", model=\"my_awesome_food_model\")\n>>> classifier(image)\n[{'score': 0.31856709718704224, 'label': 'beignets'},\n {'score': 0.015232225880026817, 'label': 'bruschetta'},\n {'score': 0.01519392803311348, 'label': 'chicken_wings'},\n {'score': 0.013022331520915031, 'label': 'pork_chop'},\n {'score': 0.012728818692266941, 'label': 'prime_rib'}]\n```\n\nYou can also manually replicate the results of the `pipeline` if you'd like:\n\n<frameworkcontent>\n<pt>\nLoad an image processor to preprocess the image and return the `input` as PyTorch tensors:\n\n```py\n>>> from transformers import AutoImageProcessor\n>>> import torch\n\n>>> image_processor = AutoImageProcessor.from_pretrained(\"my_awesome_food_model\")\n>>> inputs = image_processor(image, return_tensors=\"pt\")\n```\n\nPass your inputs to the model and return the logits:\n\n```py\n>>> from transformers import AutoModelForImageClassification\n\n>>> model = AutoModelForImageClassification.from_pretrained(\"my_awesome_food_model\")\n>>> with torch.no_grad():\n...     logits = model(**inputs).logits\n```\n\nGet the predicted label with the highest probability, and use the model's `id2label` mapping to convert it to a label:\n\n```py\n>>> predicted_label = logits.argmax(-1).item()\n>>> model.config.id2label[predicted_label]\n'beignets'\n```\n</pt>\n</frameworkcontent>\n\n<frameworkcontent>\n<tf>\nLoad an image processor to preprocess the image and return the `input` as TensorFlow tensors:\n\n```py\n>>> from transformers import AutoImageProcessor\n\n>>> image_processor = AutoImageProcessor.from_pretrained(\"MariaK/food_classifier\")\n>>> inputs = image_processor(image, return_tensors=\"tf\")\n```\n\nPass your inputs to the model and return the logits:\n\n```py\n>>> from transformers import TFAutoModelForImageClassification\n\n>>> model = TFAutoModelForImageClassification.from_pretrained(\"MariaK/food_classifier\")\n>>> logits = model(**inputs).logits\n```\n\nGet the predicted label with the highest probability, and use the model's `id2label` mapping to convert it to a label:\n\n```py\n>>> predicted_class_id = int(tf.math.argmax(logits, axis=-1)[0])\n>>> model.config.id2label[predicted_class_id]\n'beignets'\n```\n\n</tf>\n</frameworkcontent>"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 4169dcdc-04f0-4578-970c-713a72eb2d90
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation", "title": "Monocular depth estimation", "tokens": 2170, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"4169dcdc-04f0-4578-970c-713a72eb2d90\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"1adf76d2-39b8-4c8c-8de3-84d00e5bb189\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"44b1eabc695f079866d1f46e61cd6aea2a966b045812ccdec9c9b361190b36af\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"58fcf0d4-8ec3-463a-872f-a69cc1713c35\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"f43c9d37b11f915c9ea0a8ff53076de7693fb192863f789e66f4c4b65ed225e8\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3286, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "doc_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "ref_doc_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "chroma:document": "# Monocular depth estimation\n\nMonocular depth estimation is a computer vision task that involves predicting the depth information of a scene from a\nsingle image. In other words, it is the process of estimating the distance of objects in a scene from\na single camera viewpoint.\n\nMonocular depth estimation has various applications, including 3D reconstruction, augmented reality, autonomous driving,\nand robotics. It is a challenging task as it requires the model to understand the complex relationships between objects\nin the scene and the corresponding depth information, which can be affected by factors such as lighting conditions,\nocclusion, and texture. \n\nThere are two main depth estimation categories:\n\n- **Absolute depth estimation**: This task variant aims to provide exact depth measurements from the camera. The term is used interchangeably with metric depth estimation, where depth is provided in precise measurements in meters or feet. Absolute depth estimation models output depth maps with numerical values that represent real-world distances.\n\n- **Relative depth estimation**: Relative depth estimation aims to predict the depth order of objects or points in a scene without providing the precise measurements. These models output a depth map that indicates which parts of the scene are closer or farther relative to each other without the actual distances to A and B.\n\nIn this guide, we will see how to infer with [Depth Anything V2](https://huggingface.co/depth-anything/Depth-Anything-V2-Large), a state-of-the-art zero-shot relative depth estimation model, and [ZoeDepth](https://huggingface.co/docs/transformers/main/en/model_doc/zoedepth), an absolute depth estimation model.\n\n<Tip>\n\nCheck the [Depth Estimation](https://huggingface.co/tasks/depth-estimation) task page to view all compatible architectures and checkpoints.\n\n</Tip>\n\nBefore we begin, we need to install the latest version of Transformers:\n\n```bash\npip install -q -U transformers\n```\n\n## Depth estimation pipeline\n\nThe simplest way to try out inference with a model supporting depth estimation is to use the corresponding [`pipeline`].\nInstantiate a pipeline from a [checkpoint on the Hugging Face Hub](https://huggingface.co/models?pipeline_tag=depth-estimation&sort=downloads):\n\n```py\n>>> from transformers import pipeline\n>>> import torch\n\n>>> device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n>>> checkpoint = \"depth-anything/Depth-Anything-V2-base-hf\"\n>>> pipe = pipeline(\"depth-estimation\", model=checkpoint, device=device)\n```\n\nNext, choose an image to analyze:\n\n```py\n>>> from PIL import Image\n>>> import requests\n\n>>> url = \"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg\"\n>>> image = Image.open(requests.get(url, stream=True).raw)\n>>> image\n```\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg\" alt=\"Photo of a bee\"/>\n</div>\n\nPass the image to the pipeline.\n\n```py\n>>> predictions = pipe(image)\n```\n\nThe pipeline returns a dictionary with two entries. The first one, called `predicted_depth`, is a tensor with the values\nbeing the depth expressed in meters for each pixel.\nThe second one, `depth`, is a PIL image that visualizes the depth estimation result."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 58fcf0d4-8ec3-463a-872f-a69cc1713c35
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation", "title": "Monocular depth estimation", "tokens": 2170, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"58fcf0d4-8ec3-463a-872f-a69cc1713c35\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"1adf76d2-39b8-4c8c-8de3-84d00e5bb189\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"44b1eabc695f079866d1f46e61cd6aea2a966b045812ccdec9c9b361190b36af\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"4169dcdc-04f0-4578-970c-713a72eb2d90\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"b73189b358261d46b70209cc028fbc6cf01314a3db602144f4dbf65e990e6555\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"82d7b026-7751-49da-9409-b63f8520bcb2\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"60b0ddf4ee66370f637617ab88d293ceaf59c5681e880f8810b1cf490e13453b\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 1699, \"end_char_idx\": 4875, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "doc_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "ref_doc_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "chroma:document": "<Tip>\n\nCheck the [Depth Estimation](https://huggingface.co/tasks/depth-estimation) task page to view all compatible architectures and checkpoints.\n\n</Tip>\n\nBefore we begin, we need to install the latest version of Transformers:\n\n```bash\npip install -q -U transformers\n```\n\n## Depth estimation pipeline\n\nThe simplest way to try out inference with a model supporting depth estimation is to use the corresponding [`pipeline`].\nInstantiate a pipeline from a [checkpoint on the Hugging Face Hub](https://huggingface.co/models?pipeline_tag=depth-estimation&sort=downloads):\n\n```py\n>>> from transformers import pipeline\n>>> import torch\n\n>>> device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n>>> checkpoint = \"depth-anything/Depth-Anything-V2-base-hf\"\n>>> pipe = pipeline(\"depth-estimation\", model=checkpoint, device=device)\n```\n\nNext, choose an image to analyze:\n\n```py\n>>> from PIL import Image\n>>> import requests\n\n>>> url = \"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg\"\n>>> image = Image.open(requests.get(url, stream=True).raw)\n>>> image\n```\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg\" alt=\"Photo of a bee\"/>\n</div>\n\nPass the image to the pipeline.\n\n```py\n>>> predictions = pipe(image)\n```\n\nThe pipeline returns a dictionary with two entries. The first one, called `predicted_depth`, is a tensor with the values\nbeing the depth expressed in meters for each pixel.\nThe second one, `depth`, is a PIL image that visualizes the depth estimation result.\n\nLet's take a look at the visualized result:\n\n```py\n>>> predictions[\"depth\"]\n```\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/depth-visualization.png\" alt=\"Depth estimation visualization\"/>\n</div>\n\n## Depth estimation inference by hand\n\nNow that you've seen how to use the depth estimation pipeline, let's see how we can replicate the same result by hand.\n\nStart by loading the model and associated processor from a [checkpoint on the Hugging Face Hub](https://huggingface.co/models?pipeline_tag=depth-estimation&sort=downloads).\nHere we'll use the same checkpoint as before:\n\n```py\n>>> from transformers import AutoImageProcessor, AutoModelForDepthEstimation\n\n>>> checkpoint = \"Intel/zoedepth-nyu-kitti\"\n\n>>> image_processor = AutoImageProcessor.from_pretrained(checkpoint)\n>>> model = AutoModelForDepthEstimation.from_pretrained(checkpoint).to(device)\n```\n\nPrepare the image input for the model using the `image_processor` that will take care of the necessary image transformations\nsuch as resizing and normalization:\n\n```py\n>>> pixel_values = image_processor(image, return_tensors=\"pt\").pixel_values.to(device)\n```\n\nPass the prepared inputs through the model:\n\n```py\n>>> import torch\n\n>>> with torch.no_grad():\n...     outputs = model(pixel_values)\n```\n\nLet's post-process and visualize the results. \n\nWe need to pad and then resize the outputs so that predicted depth map has the same dimension as the original image. After resizing we will remove the padded regions from the depth."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 82d7b026-7751-49da-9409-b63f8520bcb2
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation", "title": "Monocular depth estimation", "tokens": 2170, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"82d7b026-7751-49da-9409-b63f8520bcb2\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"1adf76d2-39b8-4c8c-8de3-84d00e5bb189\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"44b1eabc695f079866d1f46e61cd6aea2a966b045812ccdec9c9b361190b36af\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"58fcf0d4-8ec3-463a-872f-a69cc1713c35\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"2faf93440c6c365e155cc19b3b0234ad261651b062a08ef2e4cf3a3b7db3fd43\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"85227f88-b271-43cd-aa97-db8463ce1961\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"6611cb9536c1c338f1a29f73e6cb075f2cb8c09d8101cad937a6385494e23de0\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 3081, \"end_char_idx\": 6301, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "doc_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "ref_doc_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "chroma:document": "The first one, called `predicted_depth`, is a tensor with the values\nbeing the depth expressed in meters for each pixel.\nThe second one, `depth`, is a PIL image that visualizes the depth estimation result.\n\nLet's take a look at the visualized result:\n\n```py\n>>> predictions[\"depth\"]\n```\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/depth-visualization.png\" alt=\"Depth estimation visualization\"/>\n</div>\n\n## Depth estimation inference by hand\n\nNow that you've seen how to use the depth estimation pipeline, let's see how we can replicate the same result by hand.\n\nStart by loading the model and associated processor from a [checkpoint on the Hugging Face Hub](https://huggingface.co/models?pipeline_tag=depth-estimation&sort=downloads).\nHere we'll use the same checkpoint as before:\n\n```py\n>>> from transformers import AutoImageProcessor, AutoModelForDepthEstimation\n\n>>> checkpoint = \"Intel/zoedepth-nyu-kitti\"\n\n>>> image_processor = AutoImageProcessor.from_pretrained(checkpoint)\n>>> model = AutoModelForDepthEstimation.from_pretrained(checkpoint).to(device)\n```\n\nPrepare the image input for the model using the `image_processor` that will take care of the necessary image transformations\nsuch as resizing and normalization:\n\n```py\n>>> pixel_values = image_processor(image, return_tensors=\"pt\").pixel_values.to(device)\n```\n\nPass the prepared inputs through the model:\n\n```py\n>>> import torch\n\n>>> with torch.no_grad():\n...     outputs = model(pixel_values)\n```\n\nLet's post-process and visualize the results. \n\nWe need to pad and then resize the outputs so that predicted depth map has the same dimension as the original image. After resizing we will remove the padded regions from the depth. \n\n```py\n>>> import numpy as np\n>>> import torch.nn.functional as F\n\n>>> predicted_depth = outputs.predicted_depth.unsqueeze(dim=1)\n>>> height, width = pixel_values.shape[2:]\n\n>>> height_padding_factor = width_padding_factor = 3\n>>> pad_h = int(np.sqrt(height/2) * height_padding_factor)\n>>> pad_w = int(np.sqrt(width/2) * width_padding_factor)\n\n>>> if predicted_depth.shape[-2:] != pixel_values.shape[-2:]:\n>>>    predicted_depth = F.interpolate(predicted_depth, size= (height, width), mode='bicubic', align_corners=False)\n\n>>> if pad_h > 0:\n     predicted_depth = predicted_depth[:, :, pad_h:-pad_h,:]\n>>> if pad_w > 0:\n     predicted_depth = predicted_depth[:, :, :, pad_w:-pad_w]\n```\n\nWe can now visualize the results (the function below is taken from the [GaussianObject](https://github.com/GaussianObject/GaussianObject/blob/ad6629efadb57902d5f8bc0fa562258029a4bdf1/pred_monodepth.py#L11) framework).\n\n```py\nimport matplotlib\n\ndef colorize(value, vmin=None, vmax=None, cmap='gray_r', invalid_val=-99, invalid_mask=None, background_color=(128, 128, 128, 255), gamma_corrected=False, value_transform=None):\n    \"\"\"Converts a depth map to a color image.\n\n    Args:\n        value (torch.Tensor, numpy.ndarry): Input depth map. Shape: (H, W) or (1, H, W) or (1, 1, H, W). All singular dimensions are squeezed\n        vmin (float, optional): vmin-valued entries are mapped to start color of cmap. If None, value.min() is used."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 85227f88-b271-43cd-aa97-db8463ce1961
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation", "title": "Monocular depth estimation", "tokens": 2170, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"85227f88-b271-43cd-aa97-db8463ce1961\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"1adf76d2-39b8-4c8c-8de3-84d00e5bb189\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"44b1eabc695f079866d1f46e61cd6aea2a966b045812ccdec9c9b361190b36af\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"82d7b026-7751-49da-9409-b63f8520bcb2\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"22d64c64686a42fd54424782c6418e114973d4555b10a06954bb7833d3b25e93\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"fa0ca5f4-18ed-4461-ad4a-c2c4ece20fb5\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"20999b3db30623ebf30659893e85941c9a515b278ada537140a5baf9b5d985e4\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4811, \"end_char_idx\": 7739, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "doc_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "ref_doc_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "chroma:document": "After resizing we will remove the padded regions from the depth. \n\n```py\n>>> import numpy as np\n>>> import torch.nn.functional as F\n\n>>> predicted_depth = outputs.predicted_depth.unsqueeze(dim=1)\n>>> height, width = pixel_values.shape[2:]\n\n>>> height_padding_factor = width_padding_factor = 3\n>>> pad_h = int(np.sqrt(height/2) * height_padding_factor)\n>>> pad_w = int(np.sqrt(width/2) * width_padding_factor)\n\n>>> if predicted_depth.shape[-2:] != pixel_values.shape[-2:]:\n>>>    predicted_depth = F.interpolate(predicted_depth, size= (height, width), mode='bicubic', align_corners=False)\n\n>>> if pad_h > 0:\n     predicted_depth = predicted_depth[:, :, pad_h:-pad_h,:]\n>>> if pad_w > 0:\n     predicted_depth = predicted_depth[:, :, :, pad_w:-pad_w]\n```\n\nWe can now visualize the results (the function below is taken from the [GaussianObject](https://github.com/GaussianObject/GaussianObject/blob/ad6629efadb57902d5f8bc0fa562258029a4bdf1/pred_monodepth.py#L11) framework).\n\n```py\nimport matplotlib\n\ndef colorize(value, vmin=None, vmax=None, cmap='gray_r', invalid_val=-99, invalid_mask=None, background_color=(128, 128, 128, 255), gamma_corrected=False, value_transform=None):\n    \"\"\"Converts a depth map to a color image.\n\n    Args:\n        value (torch.Tensor, numpy.ndarry): Input depth map. Shape: (H, W) or (1, H, W) or (1, 1, H, W). All singular dimensions are squeezed\n        vmin (float, optional): vmin-valued entries are mapped to start color of cmap. If None, value.min() is used. Defaults to None.\n        vmax (float, optional):  vmax-valued entries are mapped to end color of cmap. If None, value.max() is used. Defaults to None.\n        cmap (str, optional): matplotlib colormap to use. Defaults to 'magma_r'.\n        invalid_val (int, optional): Specifies value of invalid pixels that should be colored as 'background_color'. Defaults to -99.\n        invalid_mask (numpy.ndarray, optional): Boolean mask for invalid regions. Defaults to None.\n        background_color (tuple[int], optional): 4-tuple RGB color to give to invalid pixels. Defaults to (128, 128, 128, 255).\n        gamma_corrected (bool, optional): Apply gamma correction to colored image. Defaults to False.\n        value_transform (Callable, optional): Apply transform function to valid pixels before coloring. Defaults to None.\n\n    Returns:\n        numpy.ndarray, dtype - uint8: Colored depth map. Shape: (H, W, 4)\n    \"\"\"\n    if isinstance(value, torch.Tensor):\n        value = value.detach().cpu().numpy()\n\n    value = value.squeeze()\n    if invalid_mask is None:\n        invalid_mask = value == invalid_val\n    mask = np.logical_not(invalid_mask)\n\n    # normalize\n    vmin = np.percentile(value[mask],2) if vmin is None else vmin\n    vmax = np.percentile(value[mask],85) if vmax is None else vmax\n    if vmin != vmax:\n        value = (value - vmin) / (vmax - vmin)  # vmin..vmax\n    else:\n        # Avoid 0-division\n        value = value * 0."}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: fa0ca5f4-18ed-4461-ad4a-c2c4ece20fb5
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation", "title": "Monocular depth estimation", "tokens": 2170, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"fa0ca5f4-18ed-4461-ad4a-c2c4ece20fb5\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"1adf76d2-39b8-4c8c-8de3-84d00e5bb189\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"44b1eabc695f079866d1f46e61cd6aea2a966b045812ccdec9c9b361190b36af\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"85227f88-b271-43cd-aa97-db8463ce1961\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/monocular_depth_estimation\", \"title\": \"Monocular depth estimation\", \"tokens\": 2170, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"7ee612ed24a323070aaa9b5fdf88f29dbeb593e4d7b02899cb7b4d961441fbb7\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 6148, \"end_char_idx\": 8680, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "doc_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "ref_doc_id": "1adf76d2-39b8-4c8c-8de3-84d00e5bb189", "chroma:document": "All singular dimensions are squeezed\n        vmin (float, optional): vmin-valued entries are mapped to start color of cmap. If None, value.min() is used. Defaults to None.\n        vmax (float, optional):  vmax-valued entries are mapped to end color of cmap. If None, value.max() is used. Defaults to None.\n        cmap (str, optional): matplotlib colormap to use. Defaults to 'magma_r'.\n        invalid_val (int, optional): Specifies value of invalid pixels that should be colored as 'background_color'. Defaults to -99.\n        invalid_mask (numpy.ndarray, optional): Boolean mask for invalid regions. Defaults to None.\n        background_color (tuple[int], optional): 4-tuple RGB color to give to invalid pixels. Defaults to (128, 128, 128, 255).\n        gamma_corrected (bool, optional): Apply gamma correction to colored image. Defaults to False.\n        value_transform (Callable, optional): Apply transform function to valid pixels before coloring. Defaults to None.\n\n    Returns:\n        numpy.ndarray, dtype - uint8: Colored depth map. Shape: (H, W, 4)\n    \"\"\"\n    if isinstance(value, torch.Tensor):\n        value = value.detach().cpu().numpy()\n\n    value = value.squeeze()\n    if invalid_mask is None:\n        invalid_mask = value == invalid_val\n    mask = np.logical_not(invalid_mask)\n\n    # normalize\n    vmin = np.percentile(value[mask],2) if vmin is None else vmin\n    vmax = np.percentile(value[mask],85) if vmax is None else vmax\n    if vmin != vmax:\n        value = (value - vmin) / (vmax - vmin)  # vmin..vmax\n    else:\n        # Avoid 0-division\n        value = value * 0.\n\n    # squeeze last dim if it exists\n    # grey out the invalid values\n\n    value[invalid_mask] = np.nan\n    cmapper = matplotlib.colormaps.get_cmap(cmap)\n    if value_transform:\n        value = value_transform(value)\n        # value = value / value.max()\n    value = cmapper(value, bytes=True)  # (nxmx4)\n\n    # img = value[:, :, :]\n    img = value[...]\n    img[invalid_mask] = background_color\n\n    #     return img.transpose((2, 0, 1))\n    if gamma_corrected:\n        # gamma correction\n        img = img / 255\n        img = np.power(img, 2.2)\n        img = img * 255\n        img = img.astype(np.uint8)\n    return img\n\n>>> result = colorize(predicted_depth.cpu().squeeze().numpy())\n>>> Image.fromarray(result)\n```\n\n\n\n<div class=\"flex justify-center\">\n     <img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/depth-visualization-zoe.png\" alt=\"Depth estimation visualization\"/>\n</div>"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 00011be6-9fe1-4d41-974b-d075c8b1a02b
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/multiple_choice", "title": "Multiple choice", "tokens": 3891, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"00011be6-9fe1-4d41-974b-d075c8b1a02b\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"08d762b4-3adb-4976-9101-4dffbbbe601c\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"017880e162f4b5b17fe17d1e4e107fee7f1f2a4bb77958970475d05c2faf69c6\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"76febda2-91cf-45d1-b055-39508cf53561\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"ec76c30556c9af596d7e0c3e842f8117db2d30443eac67efe33c949ddbab7bcd\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 2858, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "ref_doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "chroma:document": "# Multiple choice\n\n[[open-in-colab]]\n\nA multiple choice task is similar to question answering, except several candidate answers are provided along with a context and the model is trained to select the correct answer.\n\nThis guide will show you how to:\n\n1. Finetune [BERT](https://huggingface.co/google-bert/bert-base-uncased) on the `regular` configuration of the [SWAG](https://huggingface.co/datasets/swag) dataset to select the best answer given multiple options and some context.\n2. Use your finetuned model for inference.\n\nBefore you begin, make sure you have all the necessary libraries installed:\n\n```bash\npip install transformers datasets evaluate\n```\n\nWe encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:\n\n```py\n>>> from huggingface_hub import notebook_login\n\n>>> notebook_login()\n```\n\n## Load SWAG dataset\n\nStart by loading the `regular` configuration of the SWAG dataset from the \ud83e\udd17 Datasets library:\n\n```py\n>>> from datasets import load_dataset\n\n>>> swag = load_dataset(\"swag\", \"regular\")\n```\n\nThen take a look at an example:\n\n```py\n>>> swag[\"train\"][0]\n{'ending0': 'passes by walking down the street playing their instruments.',\n 'ending1': 'has heard approaching them.',\n 'ending2': \"arrives and they're outside dancing and asleep.\",\n 'ending3': 'turns the lead singer watches the performance.',\n 'fold-ind': '3416',\n 'gold-source': 'gold',\n 'label': 0,\n 'sent1': 'Members of the procession walk down the street holding small horn brass instruments.',\n 'sent2': 'A drum line',\n 'startphrase': 'Members of the procession walk down the street holding small horn brass instruments. A drum line',\n 'video-id': 'anetv_jkn6uvmqwh4'}\n```\n\nWhile it looks like there are a lot of fields here, it is actually pretty straightforward:\n\n- `sent1` and `sent2`: these fields show how a sentence starts, and if you put the two together, you get the `startphrase` field.\n- `ending`: suggests a possible ending for how a sentence can end, but only one of them is correct.\n- `label`: identifies the correct sentence ending.\n\n## Preprocess\n\nThe next step is to load a BERT tokenizer to process the sentence starts and the four possible endings:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"google-bert/bert-base-uncased\")\n```\n\nThe preprocessing function you want to create needs to:\n\n1. Make four copies of the `sent1` field and combine each of them with `sent2` to recreate how a sentence starts.\n2. Combine `sent2` with each of the four possible sentence endings.\n3. Flatten these two lists so you can tokenize them, and then unflatten them afterward so each example has a corresponding `input_ids`, `attention_mask`, and `labels` field.\n\n```py\n>>> ending_names = [\"ending0\", \"ending1\", \"ending2\", \"ending3\"]"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 76febda2-91cf-45d1-b055-39508cf53561
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/multiple_choice", "title": "Multiple choice", "tokens": 3891, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"76febda2-91cf-45d1-b055-39508cf53561\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"08d762b4-3adb-4976-9101-4dffbbbe601c\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"017880e162f4b5b17fe17d1e4e107fee7f1f2a4bb77958970475d05c2faf69c6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"00011be6-9fe1-4d41-974b-d075c8b1a02b\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"608961c7eed4d3d5cf0066c2b86117738271075f0ef2a3d5aa5d01d5ca632000\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"29910927-07d3-45cc-aca1-b12f3a55a314\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"a11acb0ccf274d2237be12b7aa9bf4519a33b6b4e53e4ee8993507253230d449\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 2861, \"end_char_idx\": 5965, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "ref_doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "chroma:document": ">>> def preprocess_function(examples):\n...     first_sentences = [[context] * 4 for context in examples[\"sent1\"]]\n...     question_headers = examples[\"sent2\"]\n...     second_sentences = [\n...         [f\"{header} {examples[end][i]}\" for end in ending_names] for i, header in enumerate(question_headers)\n...     ]\n\n...     first_sentences = sum(first_sentences, [])\n...     second_sentences = sum(second_sentences, [])\n\n...     tokenized_examples = tokenizer(first_sentences, second_sentences, truncation=True)\n...     return {k: [v[i : i + 4] for i in range(0, len(v), 4)] for k, v in tokenized_examples.items()}\n```\n\nTo apply the preprocessing function over the entire dataset, use \ud83e\udd17 Datasets [`~datasets.Dataset.map`] method. You can speed up the `map` function by setting `batched=True` to process multiple elements of the dataset at once:\n\n```py\ntokenized_swag = swag.map(preprocess_function, batched=True)\n```\n\n\ud83e\udd17 Transformers doesn't have a data collator for multiple choice, so you'll need to adapt the [`DataCollatorWithPadding`] to create a batch of examples. It's more efficient to *dynamically pad* the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length.\n\n`DataCollatorForMultipleChoice` flattens all the model inputs, applies padding, and then unflattens the results:\n\n<frameworkcontent>\n<pt>\n```py\n>>> from dataclasses import dataclass\n>>> from transformers.tokenization_utils_base import PreTrainedTokenizerBase, PaddingStrategy\n>>> from typing import Optional, Union\n>>> import torch\n\n\n>>> @dataclass\n... class DataCollatorForMultipleChoice:\n...     \"\"\"\n...     Data collator that will dynamically pad the inputs for multiple choice received.\n...     \"\"\"\n\n...     tokenizer: PreTrainedTokenizerBase\n...     padding: Union[bool, str, PaddingStrategy] = True\n...     max_length: Optional[int] = None\n...     pad_to_multiple_of: Optional[int] = None\n\n...     def __call__(self, features):\n...         label_name = \"label\" if \"label\" in features[0].keys() else \"labels\"\n...         labels = [feature.pop(label_name) for feature in features]\n...         batch_size = len(features)\n...         num_choices = len(features[0][\"input_ids\"])\n...         flattened_features = [\n...             [{k: v[i] for k, v in feature.items()} for i in range(num_choices)] for feature in features\n...         ]\n...         flattened_features = sum(flattened_features, [])\n\n...         batch = self.tokenizer.pad(\n...             flattened_features,\n...             padding=self.padding,\n...             max_length=self.max_length,\n...             pad_to_multiple_of=self.pad_to_multiple_of,\n...             return_tensors=\"pt\",\n...         )\n\n...         batch = {k: v.view(batch_size, num_choices, -1) for k, v in batch.items()}\n...         batch[\"labels\"] = torch.tensor(labels, dtype=torch.int64)\n...         return batch\n```\n</pt>\n<tf>\n```py\n>>> from dataclasses import dataclass\n>>> from transformers.tokenization_utils_base import PreTrainedTokenizerBase, PaddingStrategy\n>>> from typing import Optional, Union\n>>> import tensorflow as tf"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 29910927-07d3-45cc-aca1-b12f3a55a314
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/multiple_choice", "title": "Multiple choice", "tokens": 3891, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"29910927-07d3-45cc-aca1-b12f3a55a314\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"08d762b4-3adb-4976-9101-4dffbbbe601c\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"017880e162f4b5b17fe17d1e4e107fee7f1f2a4bb77958970475d05c2faf69c6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"76febda2-91cf-45d1-b055-39508cf53561\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"bf25ec0f767ec49f26d7f01e2b21536db447fc9b016296c3299ea4e389c7bc0d\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"d0961b44-9bf5-49fe-ac2d-d9b11d3c1b3d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e9d978765075db1b22f1d74c74b718ef61d94a6a8bc634d06b440c420a259fdf\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 4429, \"end_char_idx\": 8024, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "ref_doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "chroma:document": ">>> @dataclass\n... class DataCollatorForMultipleChoice:\n...     \"\"\"\n...     Data collator that will dynamically pad the inputs for multiple choice received.\n...     \"\"\"\n\n...     tokenizer: PreTrainedTokenizerBase\n...     padding: Union[bool, str, PaddingStrategy] = True\n...     max_length: Optional[int] = None\n...     pad_to_multiple_of: Optional[int] = None\n\n...     def __call__(self, features):\n...         label_name = \"label\" if \"label\" in features[0].keys() else \"labels\"\n...         labels = [feature.pop(label_name) for feature in features]\n...         batch_size = len(features)\n...         num_choices = len(features[0][\"input_ids\"])\n...         flattened_features = [\n...             [{k: v[i] for k, v in feature.items()} for i in range(num_choices)] for feature in features\n...         ]\n...         flattened_features = sum(flattened_features, [])\n\n...         batch = self.tokenizer.pad(\n...             flattened_features,\n...             padding=self.padding,\n...             max_length=self.max_length,\n...             pad_to_multiple_of=self.pad_to_multiple_of,\n...             return_tensors=\"pt\",\n...         )\n\n...         batch = {k: v.view(batch_size, num_choices, -1) for k, v in batch.items()}\n...         batch[\"labels\"] = torch.tensor(labels, dtype=torch.int64)\n...         return batch\n```\n</pt>\n<tf>\n```py\n>>> from dataclasses import dataclass\n>>> from transformers.tokenization_utils_base import PreTrainedTokenizerBase, PaddingStrategy\n>>> from typing import Optional, Union\n>>> import tensorflow as tf\n\n\n>>> @dataclass\n... class DataCollatorForMultipleChoice:\n...     \"\"\"\n...     Data collator that will dynamically pad the inputs for multiple choice received.\n...     \"\"\"\n\n...     tokenizer: PreTrainedTokenizerBase\n...     padding: Union[bool, str, PaddingStrategy] = True\n...     max_length: Optional[int] = None\n...     pad_to_multiple_of: Optional[int] = None\n\n...     def __call__(self, features):\n...         label_name = \"label\" if \"label\" in features[0].keys() else \"labels\"\n...         labels = [feature.pop(label_name) for feature in features]\n...         batch_size = len(features)\n...         num_choices = len(features[0][\"input_ids\"])\n...         flattened_features = [\n...             [{k: v[i] for k, v in feature.items()} for i in range(num_choices)] for feature in features\n...         ]\n...         flattened_features = sum(flattened_features, [])\n\n...         batch = self.tokenizer.pad(\n...             flattened_features,\n...             padding=self.padding,\n...             max_length=self.max_length,\n...             pad_to_multiple_of=self.pad_to_multiple_of,\n...             return_tensors=\"tf\",\n...         )\n\n...         batch = {k: tf.reshape(v, (batch_size, num_choices, -1)) for k, v in batch.items()}\n...         batch[\"labels\"] = tf.convert_to_tensor(labels, dtype=tf.int64)\n...         return batch\n```\n</tf>\n</frameworkcontent>\n\n## Evaluate\n\nIncluding a metric during training is often helpful for evaluating your model's performance. You can quickly load a evaluation method with the \ud83e\udd17 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [accuracy](https://huggingface.co/spaces/evaluate-metric/accuracy) metric (see the \ud83e\udd17 Evaluate [quick tour](https://huggingface.co/docs/evaluate/a_quick_tour) to learn more about how to load and compute a metric):\n\n```py\n>>> import evaluate\n\n>>> accuracy = evaluate.load(\"accuracy\")\n```\n\nThen create a function that passes your predictions and labels to [`~evaluate.EvaluationModule.compute`] to calculate the accuracy:\n\n```py\n>>> import numpy as np"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: d0961b44-9bf5-49fe-ac2d-d9b11d3c1b3d
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/multiple_choice", "title": "Multiple choice", "tokens": 3891, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"d0961b44-9bf5-49fe-ac2d-d9b11d3c1b3d\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"08d762b4-3adb-4976-9101-4dffbbbe601c\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"017880e162f4b5b17fe17d1e4e107fee7f1f2a4bb77958970475d05c2faf69c6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"29910927-07d3-45cc-aca1-b12f3a55a314\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4216bf7a99464d29834fd7d80b6d86f828b5dc8b23cb2cb7d67529de9d1efdf2\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"5f1e4001-5631-4697-9c36-0f88db4e94e3\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"66596a8766692767c9b6d27923e0c7ded80324e4ccd5e9b64dfd8b0773a749e1\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8027, \"end_char_idx\": 10511, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "ref_doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "chroma:document": ">>> def compute_metrics(eval_pred):\n...     predictions, labels = eval_pred\n...     predictions = np.argmax(predictions, axis=1)\n...     return accuracy.compute(predictions=predictions, references=labels)\n```\n\nYour `compute_metrics` function is ready to go now, and you'll return to it when you setup your training.\n\n## Train\n\n<frameworkcontent>\n<pt>\n<Tip>\n\nIf you aren't familiar with finetuning a model with the [`Trainer`], take a look at the basic tutorial [here](../training#train-with-pytorch-trainer)!\n\n</Tip>\n\nYou're ready to start training your model now! Load BERT with [`AutoModelForMultipleChoice`]:\n\n```py\n>>> from transformers import AutoModelForMultipleChoice, TrainingArguments, Trainer\n\n>>> model = AutoModelForMultipleChoice.from_pretrained(\"google-bert/bert-base-uncased\")\n```\n\nAt this point, only three steps remain:\n\n1. Define your training hyperparameters in [`TrainingArguments`]. The only required parameter is `output_dir` which specifies where to save your model. You'll push this model to the Hub by setting `push_to_hub=True` (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the [`Trainer`] will evaluate the accuracy and save the training checkpoint.\n2. Pass the training arguments to [`Trainer`] along with the model, dataset, tokenizer, data collator, and `compute_metrics` function.\n3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> training_args = TrainingArguments(\n...     output_dir=\"my_awesome_swag_model\",\n...     eval_strategy=\"epoch\",\n...     save_strategy=\"epoch\",\n...     load_best_model_at_end=True,\n...     learning_rate=5e-5,\n...     per_device_train_batch_size=16,\n...     per_device_eval_batch_size=16,\n...     num_train_epochs=3,\n...     weight_decay=0.01,\n...     push_to_hub=True,\n... )\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     train_dataset=tokenized_swag[\"train\"],\n...     eval_dataset=tokenized_swag[\"validation\"],\n...     tokenizer=tokenizer,\n...     data_collator=DataCollatorForMultipleChoice(tokenizer=tokenizer),\n...     compute_metrics=compute_metrics,\n... )\n\n>>> trainer.train()\n```\n\nOnce training is completed, share your model to the Hub with the [`~transformers.Trainer.push_to_hub`] method so everyone can use your model:\n\n```py\n>>> trainer.push_to_hub()\n```\n</pt>\n<tf>\n<Tip>\n\nIf you aren't familiar with finetuning a model with Keras, take a look at the basic tutorial [here](../training#train-a-tensorflow-model-with-keras)!"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 5f1e4001-5631-4697-9c36-0f88db4e94e3
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/multiple_choice", "title": "Multiple choice", "tokens": 3891, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"5f1e4001-5631-4697-9c36-0f88db4e94e3\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"08d762b4-3adb-4976-9101-4dffbbbe601c\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"017880e162f4b5b17fe17d1e4e107fee7f1f2a4bb77958970475d05c2faf69c6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"d0961b44-9bf5-49fe-ac2d-d9b11d3c1b3d\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"15fbfe3819d5ef6d3b4bc5e1ca13cdc3b56c80dbdc140310b5b3aaddc0eb0924\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"ac27eac9-0cfc-40e8-80dd-5c7ebe35d926\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"236a52b799fa6cd29198d206d0ef024845498ba2a8f422b42b1eb05ba9c54b04\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 8931, \"end_char_idx\": 12049, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "ref_doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "chroma:document": "The only required parameter is `output_dir` which specifies where to save your model. You'll push this model to the Hub by setting `push_to_hub=True` (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the [`Trainer`] will evaluate the accuracy and save the training checkpoint.\n2. Pass the training arguments to [`Trainer`] along with the model, dataset, tokenizer, data collator, and `compute_metrics` function.\n3. Call [`~Trainer.train`] to finetune your model.\n\n```py\n>>> training_args = TrainingArguments(\n...     output_dir=\"my_awesome_swag_model\",\n...     eval_strategy=\"epoch\",\n...     save_strategy=\"epoch\",\n...     load_best_model_at_end=True,\n...     learning_rate=5e-5,\n...     per_device_train_batch_size=16,\n...     per_device_eval_batch_size=16,\n...     num_train_epochs=3,\n...     weight_decay=0.01,\n...     push_to_hub=True,\n... )\n\n>>> trainer = Trainer(\n...     model=model,\n...     args=training_args,\n...     train_dataset=tokenized_swag[\"train\"],\n...     eval_dataset=tokenized_swag[\"validation\"],\n...     tokenizer=tokenizer,\n...     data_collator=DataCollatorForMultipleChoice(tokenizer=tokenizer),\n...     compute_metrics=compute_metrics,\n... )\n\n>>> trainer.train()\n```\n\nOnce training is completed, share your model to the Hub with the [`~transformers.Trainer.push_to_hub`] method so everyone can use your model:\n\n```py\n>>> trainer.push_to_hub()\n```\n</pt>\n<tf>\n<Tip>\n\nIf you aren't familiar with finetuning a model with Keras, take a look at the basic tutorial [here](../training#train-a-tensorflow-model-with-keras)!\n\n</Tip>\nTo finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:\n\n```py\n>>> from transformers import create_optimizer\n\n>>> batch_size = 16\n>>> num_train_epochs = 2\n>>> total_train_steps = (len(tokenized_swag[\"train\"]) // batch_size) * num_train_epochs\n>>> optimizer, schedule = create_optimizer(init_lr=5e-5, num_warmup_steps=0, num_train_steps=total_train_steps)\n```\n\nThen you can load BERT with [`TFAutoModelForMultipleChoice`]:\n\n```py\n>>> from transformers import TFAutoModelForMultipleChoice\n\n>>> model = TFAutoModelForMultipleChoice.from_pretrained(\"google-bert/bert-base-uncased\")\n```\n\nConvert your datasets to the `tf.data.Dataset` format with [`~transformers.TFPreTrainedModel.prepare_tf_dataset`]:\n\n```py\n>>> data_collator = DataCollatorForMultipleChoice(tokenizer=tokenizer)\n>>> tf_train_set = model.prepare_tf_dataset(\n...     tokenized_swag[\"train\"],\n...     shuffle=True,\n...     batch_size=batch_size,\n...     collate_fn=data_collator,\n... )\n\n>>> tf_validation_set = model.prepare_tf_dataset(\n...     tokenized_swag[\"validation\"],\n...     shuffle=False,\n...     batch_size=batch_size,\n...     collate_fn=data_collator,\n... )\n```\n\nConfigure the model for training with [`compile`](https://keras.io/api/models/model_training_apis/#compile-method). Note that Transformers models all have a default task-relevant loss function, so you don't need to specify one unless you want to:\n\n```py\n>>> model.compile(optimizer=optimizer)  # No loss argument!"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: ac27eac9-0cfc-40e8-80dd-5c7ebe35d926
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/multiple_choice", "title": "Multiple choice", "tokens": 3891, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"ac27eac9-0cfc-40e8-80dd-5c7ebe35d926\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"08d762b4-3adb-4976-9101-4dffbbbe601c\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"017880e162f4b5b17fe17d1e4e107fee7f1f2a4bb77958970475d05c2faf69c6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"5f1e4001-5631-4697-9c36-0f88db4e94e3\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"5d15353e830553f06a19d30ab3c8d490ce12a46e75e704ac54fac0d70ed0b220\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"4886b3d0-29a6-4e2d-a9e0-f3a617fd3a0d\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"124d71ddebd8ec2fb2cb468b4020e45de97ffb9f4d0e01e488b0ea2775438c48\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 10513, \"end_char_idx\": 13401, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "ref_doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "chroma:document": "</Tip>\nTo finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:\n\n```py\n>>> from transformers import create_optimizer\n\n>>> batch_size = 16\n>>> num_train_epochs = 2\n>>> total_train_steps = (len(tokenized_swag[\"train\"]) // batch_size) * num_train_epochs\n>>> optimizer, schedule = create_optimizer(init_lr=5e-5, num_warmup_steps=0, num_train_steps=total_train_steps)\n```\n\nThen you can load BERT with [`TFAutoModelForMultipleChoice`]:\n\n```py\n>>> from transformers import TFAutoModelForMultipleChoice\n\n>>> model = TFAutoModelForMultipleChoice.from_pretrained(\"google-bert/bert-base-uncased\")\n```\n\nConvert your datasets to the `tf.data.Dataset` format with [`~transformers.TFPreTrainedModel.prepare_tf_dataset`]:\n\n```py\n>>> data_collator = DataCollatorForMultipleChoice(tokenizer=tokenizer)\n>>> tf_train_set = model.prepare_tf_dataset(\n...     tokenized_swag[\"train\"],\n...     shuffle=True,\n...     batch_size=batch_size,\n...     collate_fn=data_collator,\n... )\n\n>>> tf_validation_set = model.prepare_tf_dataset(\n...     tokenized_swag[\"validation\"],\n...     shuffle=False,\n...     batch_size=batch_size,\n...     collate_fn=data_collator,\n... )\n```\n\nConfigure the model for training with [`compile`](https://keras.io/api/models/model_training_apis/#compile-method). Note that Transformers models all have a default task-relevant loss function, so you don't need to specify one unless you want to:\n\n```py\n>>> model.compile(optimizer=optimizer)  # No loss argument!\n```\n\nThe last two things to setup before you start training is to compute the accuracy from the predictions, and provide a way to push your model to the Hub. Both are done by using [Keras callbacks](../main_classes/keras_callbacks).\n\nPass your `compute_metrics` function to [`~transformers.KerasMetricCallback`]:\n\n```py\n>>> from transformers.keras_callbacks import KerasMetricCallback\n\n>>> metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_validation_set)\n```\n\nSpecify where to push your model and tokenizer in the [`~transformers.PushToHubCallback`]:\n\n```py\n>>> from transformers.keras_callbacks import PushToHubCallback\n\n>>> push_to_hub_callback = PushToHubCallback(\n...     output_dir=\"my_awesome_model\",\n...     tokenizer=tokenizer,\n... )\n```\n\nThen bundle your callbacks together:\n\n```py\n>>> callbacks = [metric_callback, push_to_hub_callback]\n```\n\nFinally, you're ready to start training your model! Call [`fit`](https://keras.io/api/models/model_training_apis/#fit-method) with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:\n\n```py\n>>> model.fit(x=tf_train_set, validation_data=tf_validation_set, epochs=2, callbacks=callbacks)\n```\n\nOnce training is completed, your model is automatically uploaded to the Hub so everyone can use it!\n</tf>\n</frameworkcontent>"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 4886b3d0-29a6-4e2d-a9e0-f3a617fd3a0d
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/multiple_choice", "title": "Multiple choice", "tokens": 3891, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"4886b3d0-29a6-4e2d-a9e0-f3a617fd3a0d\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"08d762b4-3adb-4976-9101-4dffbbbe601c\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"017880e162f4b5b17fe17d1e4e107fee7f1f2a4bb77958970475d05c2faf69c6\", \"class_name\": \"RelatedNodeInfo\"}, \"2\": {\"node_id\": \"ac27eac9-0cfc-40e8-80dd-5c7ebe35d926\", \"node_type\": \"1\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/multiple_choice\", \"title\": \"Multiple choice\", \"tokens\": 3891, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"4f7cb78e44f3e160d2d1959cd7e6b7399cc2da18d4c83d5c714a8c9daace8a8c\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 11852, \"end_char_idx\": 15851, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "ref_doc_id": "08d762b4-3adb-4976-9101-4dffbbbe601c", "chroma:document": "Note that Transformers models all have a default task-relevant loss function, so you don't need to specify one unless you want to:\n\n```py\n>>> model.compile(optimizer=optimizer)  # No loss argument!\n```\n\nThe last two things to setup before you start training is to compute the accuracy from the predictions, and provide a way to push your model to the Hub. Both are done by using [Keras callbacks](../main_classes/keras_callbacks).\n\nPass your `compute_metrics` function to [`~transformers.KerasMetricCallback`]:\n\n```py\n>>> from transformers.keras_callbacks import KerasMetricCallback\n\n>>> metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_validation_set)\n```\n\nSpecify where to push your model and tokenizer in the [`~transformers.PushToHubCallback`]:\n\n```py\n>>> from transformers.keras_callbacks import PushToHubCallback\n\n>>> push_to_hub_callback = PushToHubCallback(\n...     output_dir=\"my_awesome_model\",\n...     tokenizer=tokenizer,\n... )\n```\n\nThen bundle your callbacks together:\n\n```py\n>>> callbacks = [metric_callback, push_to_hub_callback]\n```\n\nFinally, you're ready to start training your model! Call [`fit`](https://keras.io/api/models/model_training_apis/#fit-method) with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:\n\n```py\n>>> model.fit(x=tf_train_set, validation_data=tf_validation_set, epochs=2, callbacks=callbacks)\n```\n\nOnce training is completed, your model is automatically uploaded to the Hub so everyone can use it!\n</tf>\n</frameworkcontent>\n\n\n<Tip>\n\nFor a more in-depth example of how to finetune a model for multiple choice, take a look at the corresponding\n[PyTorch notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/multiple_choice.ipynb)\nor [TensorFlow notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/multiple_choice-tf.ipynb).\n\n</Tip>\n\n## Inference\n\nGreat, now that you've finetuned a model, you can use it for inference!\n\nCome up with some text and two candidate answers:\n\n```py\n>>> prompt = \"France has a bread law, Le D\u00e9cret Pain, with strict rules on what is allowed in a traditional baguette.\"\n>>> candidate1 = \"The law does not apply to croissants and brioche.\"\n>>> candidate2 = \"The law applies to baguettes.\"\n```\n\n<frameworkcontent>\n<pt>\nTokenize each prompt and candidate answer pair and return PyTorch tensors. You should also create some `labels`:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"my_awesome_swag_model\")\n>>> inputs = tokenizer([[prompt, candidate1], [prompt, candidate2]], return_tensors=\"pt\", padding=True)\n>>> labels = torch.tensor(0).unsqueeze(0)\n```\n\nPass your inputs and labels to the model and return the `logits`:\n\n```py\n>>> from transformers import AutoModelForMultipleChoice\n\n>>> model = AutoModelForMultipleChoice.from_pretrained(\"my_awesome_swag_model\")\n>>> outputs = model(**{k: v.unsqueeze(0) for k, v in inputs.items()}, labels=labels)\n>>> logits = outputs.logits\n```\n\nGet the class with the highest probability:\n\n```py\n>>> predicted_class = logits.argmax().item()\n>>> predicted_class\n'0'\n```\n</pt>\n<tf>\nTokenize each prompt and candidate answer pair and return TensorFlow tensors:\n\n```py\n>>> from transformers import AutoTokenizer\n\n>>> tokenizer = AutoTokenizer.from_pretrained(\"my_awesome_swag_model\")\n>>> inputs = tokenizer([[prompt, candidate1], [prompt, candidate2]], return_tensors=\"tf\", padding=True)\n```\n\nPass your inputs to the model and return the `logits`:\n\n```py\n>>> from transformers import TFAutoModelForMultipleChoice\n\n>>> model = TFAutoModelForMultipleChoice.from_pretrained(\"my_awesome_swag_model\")\n>>> inputs = {k: tf.expand_dims(v, 0) for k, v in inputs.items()}\n>>> outputs = model(inputs)\n>>> logits = outputs.logits\n```\n\nGet the class with the highest probability:\n\n```py\n>>> predicted_class = int(tf.math.argmax(logits, axis=-1)[0])\n>>> predicted_class\n'0'\n```\n</tf>\n</frameworkcontent>"}


created_at: 2024-08-26 20:30:03
topic: persistent://default/default/621deaf2-9359-4ac4-ada0-047176703e13
id: 6d8decf9-34b1-4d00-88ad-7c2317023217
encoding: FLOAT32
metadata:
{"url": "https://huggingface.co/docs/transformers/tasks/question_answering", "title": "Question answering", "tokens": 3690, "retrieve_doc": true, "source": "transformers", "_node_content": "{\"id_\": \"6d8decf9-34b1-4d00-88ad-7c2317023217\", \"embedding\": null, \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/question_answering\", \"title\": \"Question answering\", \"tokens\": 3690, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"excluded_embed_metadata_keys\": [\"url\", \"tokens\", \"retrieve_doc\", \"source\"], \"excluded_llm_metadata_keys\": [\"title\", \"tokens\", \"retrieve_doc\", \"source\"], \"relationships\": {\"1\": {\"node_id\": \"0644af4b-e7db-4d46-a9bc-a8d41dc816fb\", \"node_type\": \"4\", \"metadata\": {\"url\": \"https://huggingface.co/docs/transformers/tasks/question_answering\", \"title\": \"Question answering\", \"tokens\": 3690, \"retrieve_doc\": true, \"source\": \"transformers\"}, \"hash\": \"d40ef902670412e44c6eab15348ba95f1cc6da7be2d725be4f054d04caa135cd\", \"class_name\": \"RelatedNodeInfo\"}, \"3\": {\"node_id\": \"a0dff318-8d41-4545-9a93-1843e0a6306c\", \"node_type\": \"1\", \"metadata\": {}, \"hash\": \"e04c506eb29a179de6d43eac4643a755c26e7f0cc743519bb09c2845305b7e39\", \"class_name\": \"RelatedNodeInfo\"}}, \"text\": \"\", \"mimetype\": \"text/plain\", \"start_char_idx\": 0, \"end_char_idx\": 3063, \"text_template\": \"{metadata_str}\\n\\n{content}\", \"metadata_template\": \"{key}: {value}\", \"metadata_seperator\": \"\\n\", \"class_name\": \"TextNode\"}", "_node_type": "TextNode", "document_id": "0644af4b-e7db-4d46-a9bc-a8d41dc816fb", "doc_id": "0644af4b-e7db-4d46-a9bc-a8d41dc816fb", "ref_doc_id": "0644af4b-e7db-4d46-a9bc-a8d41dc816fb", "chroma:document": "# Question answering\n\n[[open-in-colab]]\n\n<Youtube id=\"ajPx5LwJD-I\"/>\n\nQuestion answering tasks return an answer given a question. If you've ever asked a virtual assistant like Alexa, Siri or Google what the weather is, then you've used a question answering model before. There are two common types of question answering tasks:\n\n- Extractive: extract the answer from the given context.\n- Abstractive: generate an answer from the context that correctly answers the question.\n\nThis guide will show you how to:\n\n1. Finetune [DistilBERT](https://huggingface.co/distilbert/distilbert-base-uncased) on the [SQuAD](https://huggingface.co/datasets/squad) dataset for extractive question answering.\n2. Use your finetuned model for inference.\n\n<Tip>\n\nTo see all architectures and checkpoints compatible with this task, we recommend checking the [task-page](https://huggingface.co/tasks/question-answering)\n\n</Tip>\n\nBefore you begin, make sure you have all the necessary libraries installed:\n\n```bash\npip install transformers datasets evaluate\n```\n\nWe encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:\n\n```py\n>>> from huggingface_hub import notebook_login\n\n>>> notebook_login()\n```\n\n## Load SQuAD dataset\n\nStart by loading a smaller subset of the SQuAD dataset from the \ud83e\udd17 Datasets library. This'll give you a chance to experiment and make sure everything works before spending more time training on the full dataset.\n\n```py\n>>> from datasets import load_dataset\n\n>>> squad = load_dataset(\"squad\", split=\"train[:5000]\")\n```\n\nSplit the dataset's `train` split into a train and test set with the [`~datasets.Dataset.train_test_split`] method:\n\n```py\n>>> squad = squad.train_test_split(test_size=0.2)\n```\n\nThen take a look at an example:\n\n```py\n>>> squad[\"train\"][0]\n{'answers': {'answer_start': [515], 'text': ['Saint Bernadette Soubirous']},\n 'context': 'Architecturally, the school has a Catholic character. Atop the Main Building\\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend \"Venite Ad Me Omnes\". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.',\n 'id': '5733be284776f41900661182',\n 'question': 'To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?',\n 'title': 'University_of_Notre_Dame'\n}\n```\n\nThere are several important fields here:\n\n- `answers`: the starting location of the answer token and the answer text.\n- `context`: background information from which the model needs to extract the answer.\n- `question`: the question a model should answer."}


