Skip to content

Commit

Permalink
Merge pull request #994 from madeline-underwood/third_AI
Browse files Browse the repository at this point in the history
ThirdAI_KB to review
  • Loading branch information
jasonrandrews committed Jun 11, 2024
2 parents 9b31dbd + ac106c7 commit 946ea8a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ title: Run Text Classification with ThirdAI on Arm servers

minutes_to_complete: 10

who_is_this_for: This is an introduction for software developers who want to learn how to run text classification tasks with ThirdAI on Arm servers.
who_is_this_for: This is for software developers who want to learn how to run text classification tasks with ThirdAI on Arm servers.

learning_objectives:
- Train, evaluate, and deploy a ThirdAI model.
- Set up your Arm server for text classification tasks with ThirdAI.

prerequisites:
- An [Arm based instance](/learning-paths/servers-and-cloud-computing/csp/) from a cloud service provider or an on-premise Arm server.
- An [Arm-based instance](/learning-paths/servers-and-cloud-computing/csp/) from a cloud service provider or an on-premise Arm server.

author_primary: ThirdAI

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
next_step_guidance: Thank you for completing this learning path on how to run text classification tasks on Arm CPUs with ThirdAI. You might be interested how to use the HuggingFace library and transformers to accomplish a similar task.
next_step_guidance: Thank you for completing this Learning Path on how to run text classification tasks on Arm CPUs with ThirdAI. You might be interested in how to use the HuggingFace library and transformers to accomplish a similar task.

recommended_path: /learning-paths/servers-and-cloud-computing/nlp-hugging-face/

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Background and Overview of Learning Path
weight: 2

### FIXED, DO NOT MODIFY
layout: learningpathall
---
## What is ThirdAI?

ThirdAI is a multi-purpose library that provides a high-level API to build machine learning models.

It provides APIs to support common machine learning problems, such as:
- Text classification and NLP (Natural Language Processing).
- Search and recommendation.
- Time-series forecasting and predictions.
- Tabular classification.
- Graph classification.

## Learning Path Overview

This Learning Path shows you how to use ThirdAI's library for *text classification* tasks on your Arm servers.

Specifically, the Learning Path shows you how to perform the following tasks:

- Download a sentiment classification dataset using the Hugging Face `datasets` library.
- Format the data for the model to understand.
- Create a UniversalDeepTransformer, and configure it for text classification.
- Train the model and print the training metrics.
- Save the model to `sentiment_analysis.model` for further deployment.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Evaluate the model
weight: 3
weight: 4

### FIXED, DO NOT MODIFY
layout: learningpathall
Expand Down Expand Up @@ -54,9 +54,9 @@ validate | epoch 0 | train_steps 8790 | val_categorical_accuracy=0.843548 | val
```

This example performs the following tasks:
- Load the trained model from the saved file
- Run the evaluation on the test dataset and report accuracy metrics
- Give an example of how to handle a prediction in a real time inference setting
- Load the trained model from the saved file.
- Run the evaluation on the test dataset and report accuracy metrics.
- Give an example of how to handle a prediction in a real time inference setting.

The first output line provides the accuracy results and run time for the 40,000 text strings of test data.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
---
title: Train a model for text classification
weight: 2
weight: 3

### FIXED, DO NOT MODIFY
layout: learningpathall
---

![alt-text #center](thirdai_logo.png)

## What is ThirdAI?

ThirdAI is a multi-purpose library that provides a high-level API to build machine learning models.

It provides APIs to support common machine learning problems, such as:
- Text Classification and NLP (Natural Language Processing)
- Search and Recommendation
- Time-series Forecasting and Predictions
- Tabular Classification
- Graph Classification

The following steps show you how to use ThirdAI's library for Text Classification tasks on your Arm servers.

## Install dependencies

You need to install Python and pip to use ThirdAI. The instructions below are for Ubuntu, but other Linux distributions can be used.
You will need to install Python and pip to use ThirdAI. The instructions below are for Ubuntu, but you can use other Linux distributions.

```bash { target="ubuntu:latest" }
sudo apt install python3-pip python3-venv -y
```

Create a virtual environment to avoid dependency conflicts.
Create a virtual environment to avoid dependency conflicts:

```bash
python3 -m venv thirdai
Expand All @@ -38,7 +23,7 @@ source thirdai/bin/activate

The prompt of your terminal now has (thirdai) as a prefix to indicate the virtual environment is active.

To start, you will need to install the ThirdAI package:
To start, you need to install the ThirdAI package:

```bash
pip3 install thirdai
Expand All @@ -60,7 +45,7 @@ The dataset is called "polarity" because it focuses on binary sentiment classifi

This dataset is often used in natural language processing tasks related to sentiment analysis, where the goal is to determine the sentiment expressed in a piece of text.

## Train the model
## Download dataset and train the model

You are now ready to download the text classification dataset and train a classification model with ThirdAI.

Expand Down Expand Up @@ -111,14 +96,6 @@ model = bolt.UniversalDeepTransformer.load(save_location)
model.evaluate(test_filename, metrics=["categorical_accuracy"])

```

This example performs the following tasks:
- Download a sentiment classification dataset using the Hugging Face `datasets` library
- Format the data for the model to understand
- Create a UniversalDeepTransformer and configure it for text classification
- Train the model and print the training metrics
- Save the model to `sentiment_analysis.model` for further deployment

To train the model run the script:

```bash
Expand Down Expand Up @@ -152,7 +129,7 @@ validate | epoch 0 | train_steps 8790 | val_categorical_accuracy=0.843548 | val
```

With each epoch, the model refines its understanding of the training data, leading to an increase in accuracy. This means it's getting better at making correct predictions.
With each epoch, the model refines its understanding of the training data, leading to increased accuracy. This means it is getting better at making correct predictions.

To examine the training data, open the `amazon_polarity_train.csv` file. Each line contains a phrase and is followed by either a 1, signifying a positive review, or a 0, representing a negative review.

Expand Down

0 comments on commit 946ea8a

Please sign in to comment.