Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Information extraction from Cheshire fire incident reports using Mistral #2201

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

SurajBaloni
Copy link
Collaborator

@SurajBaloni SurajBaloni commented Jan 17, 2025

This PR adds sample notebook on - Information extraction from Cheshire fire incident reports using Mistral language model.

#2115

Table Of Contents location:
Deep Learning > NLP > Information extraction from Cheshire fire incident reports using Mistral

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@SurajBaloni
Copy link
Collaborator Author

@BP-Ent Please review this sample notebook

Copy link
Collaborator

@jyaistMap jyaistMap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • looks good visually from my review, but cannot speak to technical accuracy
  • local build of doc appears like this for half of doc, rest of it looks good
  • the right-hand navigation all works

image
image

@jyaistMap
Copy link
Collaborator

@priyankatuteja

  • when you approve this, I can merge python-api-doc #288 to update the Table of Contents to reflect new sample

@@ -0,0 +1,1208 @@
{
Copy link
Collaborator

@BP-Ent BP-Ent Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Reply via ReviewNB

@@ -0,0 +1,1208 @@
{
Copy link
Collaborator

@BP-Ent BP-Ent Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data preparation involves splitting the data into training and validation sets, creating the necessary data structures for loading data into the model. The prepare_data() function can directly read the training samples in one of the above specified formats and automate the entire process.


Reply via ReviewNB

@@ -0,0 +1,1208 @@
{
Copy link
Collaborator

@BP-Ent BP-Ent Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EntityRecognizer model in arcgis.learn can be used with Hugging Face Transformers or with large language model backbones. For this sample use case, we will use the Mistral model backbone to extract entities from the text.

Run the command below to see what backbones are supported for the entity recognition task.


Reply via ReviewNB

@@ -0,0 +1,1208 @@
{
Copy link
Collaborator

@BP-Ent BP-Ent Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First we will create the model using the EntityRecognizer() constructor and passing the following parameters:

data: The databunch created using the prepare_textdata method.

backbone: To use mistral as the model backbone, use backbone="mistral".

prompt: Text string describing the task and its guardrails. This is an optional parameter.


Reply via ReviewNB

@@ -0,0 +1,1208 @@
{
Copy link
Collaborator

@BP-Ent BP-Ent Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important metrics to look at while measuring the performance of the EntityRecognizer model are PrecisionRecall, and F1-measures.


Reply via ReviewNB

@@ -0,0 +1,1208 @@
{
Copy link
Collaborator

@BP-Ent BP-Ent Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To find precisionrecall, and f1 scores per label/class, we will call the model's metrics_per_label() method.


Reply via ReviewNB

@@ -0,0 +1,1208 @@
{
Copy link
Collaborator

@BP-Ent BP-Ent Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have the trained model, let's look at how the model performs.


Reply via ReviewNB

@@ -0,0 +1,1208 @@
{
Copy link
Collaborator

@BP-Ent BP-Ent Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The load() method takes the path to the .emd file as a required argument.


Reply via ReviewNB

@@ -0,0 +1,1208 @@
{
Copy link
Collaborator

@BP-Ent BP-Ent Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we can use the trained model to extract entities from new text documents using the extract_entities() method. This method expects either the folder path of where the new text documents are located or a list of text documents.


Reply via ReviewNB

BP-Ent
BP-Ent previously requested changes Jan 28, 2025
Copy link
Collaborator

@BP-Ent BP-Ent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions made on reviewnb

@priyankatuteja priyankatuteja merged commit c4959d0 into next Jan 31, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants