Skip to content

Commit

Permalink
Review suggestions added
Browse files Browse the repository at this point in the history
  • Loading branch information
SurajBaloni committed Apr 16, 2024
1 parent 545864d commit 37810ef
Showing 1 changed file with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
" </ul>\n",
" <ul class=\"toc-item\">\n",
" <li>\n",
" <span><a href=\"#mistral_with_textclassifier_model\" data-toc-modified-id=\"mistral_with_textclassifier_model\"><span class=\"toc-item-num\"></span>Mistral with <code>TextClassifier</code> model</a></span>\n",
" <span><a href=\"#mistral_with_textclassifier_model\" data-toc-modified-id=\"mistral_with_textclassifier_model\"><span class=\"toc-item-num\"></span>Mistral with the <code>TextClassifier</code> model</a></span>\n",
" </li>\n",
" <ul class=\"toc-item\">\n",
" <li><span><a href=\"#import_mistral_text_classifier\" data-toc-modified-id=\"import_mistral_text_classifier\"><span class=\"toc-item-num\"></span> Import the <code>TextClassifier</code> class from <code>arcgis.learn.text</code> module</a></span></li>\n",
" <li><span><a href=\"#import_mistral_text_classifier\" data-toc-modified-id=\"import_mistral_text_classifier\"><span class=\"toc-item-num\"></span> Import the <code>TextClassifier</code> class from the <code>arcgis.learn.text</code> module</a></span></li>\n",
" </ul>\n",
" <ul class=\"toc-item\">\n",
" <li><span><a href=\"#initialize_textclassifier_model_databunch\" data-toc-modified-id=\"initialize_textclassifier_model_databunch\"><span class=\"toc-item-num\"></span>Initialize <code>TextClassifier</code> model with databunch</a></span></li>\n",
" <li><span><a href=\"#initialize_textclassifier_model_databunch\" data-toc-modified-id=\"initialize_textclassifier_model_databunch\"><span class=\"toc-item-num\"></span>Initialize the <code>TextClassifier</code> model with a databunch</a></span></li>\n",
" </ul>\n",
" <ul class=\"toc-item\">\n",
" <li><span><a href=\"#initialize_textclassifier_model_nodatabunch\" data-toc-modified-id=\"initialize_textclassifier_model_nodatabunch\"><span class=\"toc-item-num\"></span> Initialize <code>TextClassifier</code> model without databunch</a></span></li>\n",
" <li><span><a href=\"#initialize_textclassifier_model_nodatabunch\" data-toc-modified-id=\"initialize_textclassifier_model_nodatabunch\"><span class=\"toc-item-num\"></span> Initialize the<code>TextClassifier</code> model without a databunch</a></span></li>\n",
" </ul>\n",
" <ul class=\"toc-item\">\n",
" <li><span><a href=\"#classify_text_using_mistral_model\" data-toc-modified-id=\"classify_text_using_mistral_model\"><span class=\"toc-item-num\"></span>Classify text using mistral model</a></span></li>\n",
" <li><span><a href=\"#classify_text_using_mistral_model\" data-toc-modified-id=\"classify_text_using_mistral_model\"><span class=\"toc-item-num\"></span>Classify the text using mistral model</a></span></li>\n",
" </ul>\n",
" <ul class=\"toc-item\">\n",
" <li><span><a href=\"#load_model\" data-toc-modified-id=\"load_model\"><span class=\"toc-item-num\"></span>Load the model</a></span></li>\n",
Expand All @@ -53,19 +53,19 @@
" </ul>\n",
" <ul class=\"toc-item\">\n",
" <li>\n",
" <span><a href=\"#mistral_with_entityrecognizer_model\" data-toc-modified-id=\"mistral_with_entityrecognizer_model\"><span class=\"toc-item-num\"></span>Mistral with <code>EntityRecognizer</code> model</a></span>\n",
" <span><a href=\"#mistral_with_entityrecognizer_model\" data-toc-modified-id=\"mistral_with_entityrecognizer_model\"><span class=\"toc-item-num\"></span>Mistral with an<code>EntityRecognizer</code> model</a></span>\n",
" </li>\n",
" <ul class=\"toc-item\">\n",
" <li><span><a href=\"#import_mistral_entity_recognizer\" data-toc-modified-id=\"import_mistral_entity_recognizer\"><span class=\"toc-item-num\"></span> Import the <code>EntityRecognizer</code> class from <code>arcgis.learn.text</code> module</a></span></li>\n",
" <li><span><a href=\"#import_mistral_entity_recognizer\" data-toc-modified-id=\"import_mistral_entity_recognizer\"><span class=\"toc-item-num\"></span> Import the <code>EntityRecognizer</code> class from the <code>arcgis.learn.text</code> module</a></span></li>\n",
" </ul>\n",
" <ul class=\"toc-item\">\n",
" <li><span><a href=\"#initialize_entity_recognizer_model_databunch\" data-toc-modified-id=\"initialize_entity_recognizer_model_databunch\"><span class=\"toc-item-num\"></span>Initialize <code>EntityRecognizer</code> model with databunch</a></span></li>\n",
" <li><span><a href=\"#initialize_entity_recognizer_model_databunch\" data-toc-modified-id=\"initialize_entity_recognizer_model_databunch\"><span class=\"toc-item-num\"></span>Initialize the <code>EntityRecognizer</code> model with a databunch</a></span></li>\n",
" </ul>\n",
" <ul class=\"toc-item\">\n",
" <li><span><a href=\"#initialize_entity_recognizer_model_nodatabunch\" data-toc-modified-id=\"initialize_entity_recognizer_model_nodatabunch\"><span class=\"toc-item-num\"></span> Initialize <code>EntityRecognizer</code> model without databunch</a></span></li>\n",
" <li><span><a href=\"#initialize_entity_recognizer_model_nodatabunch\" data-toc-modified-id=\"initialize_entity_recognizer_model_nodatabunch\"><span class=\"toc-item-num\"></span> Initialize the <code>EntityRecognizer</code> model without a databunch</a></span></li>\n",
" </ul>\n",
" <ul class=\"toc-item\">\n",
" <li><span><a href=\"#extract_entities_using_mistral_model\" data-toc-modified-id=\"extract_entities_using_mistral_model\"><span class=\"toc-item-num\"></span>Extract entities using mistral model</a></span></li>\n",
" <li><span><a href=\"#extract_entities_using_mistral_model\" data-toc-modified-id=\"extract_entities_using_mistral_model\"><span class=\"toc-item-num\"></span>Extract entities using the mistral model</a></span></li>\n",
" </ul>\n",
" <ul class=\"toc-item\">\n",
" <li><span><a href=\"#load_model_er\" data-toc-modified-id=\"load_model_er\"><span class=\"toc-item-num\"></span>Load the model</a></span></li>\n",
Expand Down Expand Up @@ -99,7 +99,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The Mistral 7B is a decoder-based language model trained using almost 7 billion parameters designed to deliver both efficiency and high performance for real-world applications.\n",
"Mistral 7B is a decoder-based language model trained using almost 7 billion parameters designed to deliver both efficiency and high performance for real-world applications.\n",
"\n",
"Employing attention mechanisms like Sliding Window Attention, Mistral 7B can train with an 8k context length and a fixed cache size, resulting in a theoretical attention span of 128K tokens. This capability allows the model to focus on crucial parts of the text efficiently. Moreover, the model incorporates Grouped Query Attention (GQA) to accelerate inference and reduce cache size, thereby expediting its inference process. Additionally, its Byte-fallback tokenizer ensures consistent representation of characters, eliminating the need for out-of-vocabulary tokens.\n",
"\n",
Expand Down Expand Up @@ -141,14 +141,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Mistral with TextClassifier model <a id=\"mistral_with_textclassifier_model\"></a>"
"## Mistral with the TextClassifier model <a id=\"mistral_with_textclassifier_model\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Import the TextClassifier class from arcgis.learn.text module <a id=\"import_mistral_text_classifier\"></a>"
"### Import the TextClassifier class from the arcgis.learn.text module <a id=\"import_mistral_text_classifier\"></a>"
]
},
{
Expand All @@ -164,14 +164,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Initialize TextClassifier model with databunch <a id=\"initialize_textclassifier_model_databunch\"></a>"
"### Initialize the TextClassifier model with a databunch <a id=\"initialize_textclassifier_model_databunch\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Prepare databunch for <code>TextClassifier</code> model using <code>prepare_textdata</code> method in <code>arcgis.learn</code>."
"Prepare databunch for the <code>TextClassifier</code> model using the<code>prepare_textdata</code> method in <code>arcgis.learn</code>."
]
},
{
Expand All @@ -189,17 +189,17 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Once the data is prepared, <code>TextClassifier</code> model object can be instantiated as below with the following parameters:"
"Once the data is prepared, the <code>TextClassifier</code> model object can be instantiated as below with the following parameters:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<code>data</code>: Databunch created using the <code>prepare_textdata</code> method.\n",
"<code>data</code>: The databunch created using the <i>prepare_textdata</i> method.\n",
"\n",
"<code>backbone</code>: To use mistral as the model backbone, use <i>backbone=\"mistral\"</i>.\n",
"\n",
"<code>backbone</code>: For using mistral as model backbone use <i>backbone=\"mistral\"</i>.\n",
" \n",
"<code>prompt</code>: Text string describing the task and its guardrails. This is an optional parameter."
]
},
Expand All @@ -220,14 +220,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Initialize TextClassifier model without databunch <a id=\"initialize_textclassifier_model_nodatabunch\"></a>"
"### Initialize the TextClassifier model without a databunch <a id=\"initialize_textclassifier_model_nodatabunch\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A <code>TextClassifier</code> model with mistral backbone can also be created without a large dataset and by using only a few examples."
"A <code>TextClassifier</code> model with a mistral backbone can also be created without a large dataset using only a few examples."
]
},
{
Expand All @@ -236,9 +236,9 @@
"source": [
"Below are the parameters to be passed into <code>TextClassifier</code>:\n",
"\n",
"<code>backbone</code>: For using mistral as model backbone use <i>backbone=\"mistral\"</i>.\n",
" \n",
"<code>examples</code>:User defined examples to the mistral model, in python dictionary format:<br/>\n",
"<code>backbone</code>: To use mistral as the model backbone, use <i>backbone=\"mistral\"</i>.\n",
"\n",
"<code>examples</code>: User defined examples to provide the mistral model, in python dictionary format:\n",
"```\n",
"{\n",
" \"label_1\" :[\"input_text_example_1\", \"input_text_example_2\", ...],\n",
Expand Down Expand Up @@ -271,14 +271,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Classify text using mistral model <a id=\"classify_text_using_mistral_model\"></a>"
"### Classify the text using mistral model <a id=\"classify_text_using_mistral_model\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To classify text using the mistral model use the <code>predict</code> method from <code>TextClassifier</code> class. The input to the method will be a text string or a list of text string."
"To classify text using the mistral model, use the <code>predict</code> method from the <code>TextClassifier</code> class. The input to the method will be a text string or a list of text string."
]
},
{
Expand All @@ -301,7 +301,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To load a mistral model saved earlier use <code>from_model</code> method from <code>TextClassifier</code> class."
"To load a saved mistral model, use the <code>from_model</code> method from the <code>TextClassifier</code> class."
]
},
{
Expand All @@ -324,7 +324,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This method saves the model weights and creates a Deep Learning Package (.dlpk)."
"The following method saves the model weights and creates a Deep Learning Package (.dlpk)."
]
},
{
Expand All @@ -340,14 +340,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Mistral with EntityRecognizer model <a id=\"mistral_with_entityrecognizer_model\"></a>"
"## Mistral with an EntityRecognizer model <a id=\"mistral_with_entityrecognizer_model\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Import the EntityRecognizer class from arcgis.learn.text module <a id=\"import_mistral_entity_recognizer\"></a>"
"### Import the EntityRecognizer class from the arcgis.learn.text module <a id=\"import_mistral_entity_recognizer\"></a>"
]
},
{
Expand All @@ -363,14 +363,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Initialize EntityRecognizer model with databunch <a id=\"initialize_entity_recognizer_model_databunch\"></a>"
"### Initialize the EntityRecognizer model with a databunch <a id=\"initialize_entity_recognizer_model_databunch\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Prepare databunch for <code>EntityRecognizer</code> model using <code>prepare_textdata</code> method in <code>arcgis.learn</code>."
"Prepare the databunch for the <code>EntityRecognizer</code> model using the <code>prepare_textdata</code> method in arcgis.learn."
]
},
{
Expand All @@ -387,17 +387,17 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Once the data is prepared, <code>EntityRecognizer</code> model object can be instantiated as below with the following parameters:"
"Once the data is prepared, the <code>EntityRecognizer</code> model object can be instantiated with the following parameters:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<code>data</code>: Databunch created using the prepare_textdata method.\n",
"<code>data</code>: The databunch created using the <code>prepare_textdata</code> method.\n",
"\n",
"<code>backbone</code>: To use mistral as the model backbone, use <i>backbone=\"mistral\"</i>.\n",
"\n",
"<code>backbone</code>: For using mistral as model backbone use <i>backbone=\"mistral\"</i>.\n",
" \n",
"<code>prompt</code>: Text string describing the task and its guardrails. This is an optional parameter."
]
},
Expand All @@ -418,14 +418,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Initialize EntityRecognizer model without databunch <a id=\"initialize_entity_recognizer_model_nodatabunch\"></a>"
"### Initialize the EntityRecognizer model without a databunch <a id=\"initialize_entity_recognizer_model_nodatabunch\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"An <code>EntityRecognizer</code> model with mistral backbone can also be created without a large dataset and by using only a few examples."
"An <code>EntityRecognizer</code> model with a mistral backbone can also be created without a large dataset by using only a few examples."
]
},
{
Expand All @@ -434,9 +434,9 @@
"source": [
"Below are the parameters to be passed into <code>EntityRecognizer</code> :\n",
"\n",
"<code>backbone</code>: For using mistral as model backbone use <i>backbone=\"mistral\"</i>.\n",
"<code>backbone</code>: To use mistral as the model backbone, use backbone=\"mistral\".\n",
"\n",
"<code>examples</code>: User defined examples to the mistral model, in python list format:\n",
"<code>examples</code>: User defined examples for the mistral model, in python list format:\n",
"\n",
"```\n",
"[\n",
Expand Down Expand Up @@ -483,14 +483,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Extract entities using mistral model <a id=\"extract_entities_using_mistral_model\"></a>"
"### Extract entities using the mistral model <a id=\"extract_entities_using_mistral_model\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To extract named entities using the mistral model use the <code>extract_entities</code> method from <code>EntityRecognizer</code> class. The input to the method will be a text string or a list of text string."
"To extract named entities using the mistral model, use the <code>extract_entities</code> method from the <code>EntityRecognizer</code> class. The input to the method will be a text string or a list of text strings."
]
},
{
Expand All @@ -513,7 +513,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To load a mistral model saved earlier use <code>from_model</code> method from <code>EntityRecognizer</code> class."
"To load a saved mistral model, use the <code>from_model</code> method from the <code>EntityRecognizer</code> class."
]
},
{
Expand Down Expand Up @@ -559,7 +559,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In this guide we saw the steps to initialize and perform inference using the Mistral LLM as a backbone with the <code>TextClassifier</code> and <code>EntityRecognizer</code> models in <code>arcgis.learn</code>."
"In this guide we demonstrated the steps to initialize and perform inference using the Mistral LLM as a backbone with the TextClassifier and EntityRecognizer models in arcgis.learn."
]
},
{
Expand Down

0 comments on commit 37810ef

Please sign in to comment.