This project demonstrates how to label sentiment in a text prompt using a pre-trained BERT model with JFrog ML.
It showcases how to:
- Define the QwakModel class
- Initialize the pre-trained BERT model
- Predict phrase sentiment using JFrog ML's API
The code is designed to work seamlessly with JFrog ML and serves as a practical example.
-
Clone the Repository: Clone this GitHub repository to your local machine.
-
Install Dependencies: Make sure you have the required dependencies installed, as specified in the
conda.yml
file.conda env create -f ./main/conda.yml conda activate bert_sentiment_analysis
-
Install and Configure the JFrog ML SDK: Use your account JFrog ML API Key to set up your SDK locally.
pip install qwak-sdk qwak configure
-
Run the Model Locally: Execute the following command to test the model locally:
python test_model_locally.py
-
Build on JFrog ML:
Create a new model on Qwak using the command:
qwak models create "BERT Sentiment Analysis" --project "Sample Project"
Initiate a model build with:
qwak models build --model-id <your-model-id> ./bert_conda
-
Deploy the Model on JFrog ML with a Real-Time Endpoint:
To deploy your model via the CLI, use the following command:
qwak models deploy realtime --model-id <your-model-id> --build-id <your-build-id>
-
Test the Live Model with a Sample Request:
Install the Qwak Inference SDK:
pip install qwak-inference
Call the Real-Time endpoint using your Model ID from JFrog ML:
python test_live_mode.py <your-qwak-model-id>
.
├── main # Main directory containing core code
│ ├── __init__.py # An empty file that indicates this directory is a Python package
│ ├── model.py # Defines the Credit Risk Model
│ └── conda.yaml # Conda environment configurationdata
|
├── test_model_locally.py # Script to test the model locally
├── test_live_model.py # Script to test the live model with a sample REST request
└── README.md # Documentation