Skip to content

Commit

Permalink
adding user guide notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
Mturgal committed Mar 28, 2023
1 parent 5048d06 commit 89b0a68
Show file tree
Hide file tree
Showing 2 changed files with 321 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# marketplace-vnlp
# marketplace-vnlp
VNLP, the cutting-edge sentiment analysis product that helps you understand the sentiment and emotions behind Turkish text. Our state-of-the-art natural language processing technology analyzes text data quickly and accurately, enabling you to gain insights into your customers’ opinions, attitudes, and emotions. With our intuitive user interface, you can easily upload your Turkish text data and get comprehensive analysis results in seconds. VNGRS is designed with simplicity and ease of use in mind, so you can quickly and easily make data-driven decisions to improve your overall customer experience. Trust VNGRS to take your business to the next level!

VNLP Sentiment Analyzer was trained on a diverse and extensive collection of Turkish language text data gathered from a variety of sources, including social media, customer feedback, and product reviews. The data was sourced from reputable online platforms such as Kaggle and GitHub, and has been carefully compiled, cleaned, and standardized to ensure consistency and accuracy.
317 changes: 317 additions & 0 deletions VNLP_Turkish_Sentiment_Analyzer.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "117be672-cd66-4c86-91a9-e461e4d475f7",
"metadata": {},
"source": [
"### VNLP Turkish Sentiment Analyzer"
]
},
{
"cell_type": "markdown",
"id": "9bf1f98c-7b43-449a-8210-2c047afc29c2",
"metadata": {},
"source": [
"Introducing VNLP, the cutting-edge sentiment analysis product that helps you understand the sentiment and emotions behind Turkish text. Our state-of-the-art natural language processing technology analyzes text data quickly and accurately, enabling you to gain insights into your customers’ opinions, attitudes, and emotions. With our intuitive user interface, you can easily upload your Turkish text data and get comprehensive analysis results in seconds. VNGRS is designed with simplicity and ease of use in mind, so you can quickly and easily make data-driven decisions to improve your overall customer experience. Trust VNGRS to take your business to the next level!"
]
},
{
"cell_type": "markdown",
"id": "1b579d10-3761-4346-a75d-7cab633d97f8",
"metadata": {},
"source": [
"### Prerequisite"
]
},
{
"cell_type": "markdown",
"id": "8e4ee541-ebd0-4498-83a6-2d9e0f091df3",
"metadata": {},
"source": [
"\n",
"To run this algorithm you need to have access to the following AWS Services:"
]
},
{
"cell_type": "markdown",
"id": "b033a654-4580-41fc-b397-e0fb422cd9c7",
"metadata": {},
"source": [
"- Access to AWS SageMaker and the model package.\n",
"- An S3 bucket to specify input/output.\n",
"- Role for AWS SageMaker to access input/output from S3."
]
},
{
"cell_type": "markdown",
"id": "764acb7f-979c-4e0d-bdae-f727f2aadd76",
"metadata": {},
"source": [
"### Set up the environment"
]
},
{
"cell_type": "markdown",
"id": "7f6539d4-aebd-428c-b852-4102f61b84f2",
"metadata": {},
"source": [
"Here we specify a bucket to use and the role that will be used for working with SageMaker.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "97df83e9-0a19-4b68-9b90-eaabb3111ee9",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# S3 prefix\n",
"prefix = \"vnlp-model-serving-marketplace\"\n",
"\n",
"# Define IAM role\n",
"import boto3\n",
"import re\n",
"\n",
"import os\n",
"import numpy as np\n",
"import pandas as pd\n",
"from sagemaker import get_execution_role\n",
"\n",
"role = get_execution_role()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "891b79a8-8d6c-4f82-ba03-115b6d47ea74",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from sagemaker.model import Model\n",
"from sagemaker.serializers import JSONSerializer\n",
"from sagemaker.deserializers import JSONDeserializer\n",
"from sagemaker.predictor import Predictor\n",
"import json\n",
"from sagemaker import ModelPackage\n"
]
},
{
"cell_type": "markdown",
"id": "334de313-7105-407f-ba66-f355d4dae4ae",
"metadata": {},
"source": [
"### Create the session"
]
},
{
"cell_type": "markdown",
"id": "10466e2b-a6f0-47a5-9afb-d437b71b6c9d",
"metadata": {},
"source": [
"The session remembers our connection parameters to SageMaker. We'll use it to perform all of our SageMaker operations.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "1099b7b7-0b93-453e-8587-0f1f96bf116d",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import sagemaker as sage\n",
"from time import gmtime, strftime"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "93bdd20c-2723-41c8-b82a-a9bd9693654c",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"sagemaker_session = sage.Session()\n",
"#bucket = sagemaker_session.default_bucket()\n",
"runtime = boto3.client(\"runtime.sagemaker\")"
]
},
{
"cell_type": "markdown",
"id": "dfb43ee7-edbd-45dc-8c3a-cfd7908fa132",
"metadata": {
"tags": []
},
"source": [
"### Create a deployable model from model package"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "d0e70ef8-f555-47d0-8e42-c0d24c95dc7f",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"modelpackage_arn = 'arn:aws:sagemaker:eu-west-1:707858255059:model-package/vnlp-sentiment-validated-1679584123'"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "714daaef-5c94-480a-9807-dc890486499c",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"sentiment_analyses_model = ModelPackage(\n",
" role=role,\n",
" model_package_arn=modelpackage_arn,\n",
" sagemaker_session=sagemaker_session,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "a089c9da-2ff2-4012-bd45-3cbb6dd3d2b9",
"metadata": {},
"source": [
"### Deploy an endpoint with the SageMaker model that is created"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "6794f555-9299-42f1-aeaf-14458e12a76c",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"endpoint_name = \"vnlp-sentiment-analyses-endpoint\""
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "3fd35adb-ae10-4d42-970d-8c6653c1e032",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"----!"
]
}
],
"source": [
"predictor_sentiment_analyser = sentiment_analyses_model.deploy(\n",
" 1, \"ml.c4.2xlarge\", endpoint_name=endpoint_name,\n",
" serializer=JSONSerializer(),\n",
" deserializer=JSONDeserializer(),\n",
")"
]
},
{
"cell_type": "markdown",
"id": "796a74b5-11da-4680-8217-32854cc52d35",
"metadata": {},
"source": [
"### Perform real-time inference on the model."
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "26b5176c-49b1-4775-aea1-6bad78df3c19",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"payload = '{\"sentiment\": \"Gerçek tarafsız kaliteli soft power gazetecilik iyiki varsın\"}'\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "a328faf4-3b0b-43a1-83b2-46a165632206",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"response = runtime.invoke_endpoint(EndpointName=endpoint_name, ContentType=\"application/json\",\n",
" Body=payload)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "859879ab-f5b8-4364-83d1-ac95cf414894",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"sent_analyse_result = response[\"Body\"].read().decode()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "7680a2b0-d524-4d4c-863b-7f1560bdfa88",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"prediction\": 0.9991540908813477}\n"
]
}
],
"source": [
"print(sent_analyse_result)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "conda_pytorch_p39",
"language": "python",
"name": "conda_pytorch_p39"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 89b0a68

Please sign in to comment.