" \"I absolutely love the new QuantumX Pro camera! The picture quality is stellar and the battery life is amazing. Shipped super fast too. A++!\",\n",
"\n",
" # Review 2: Negative with specific issue\n",
" \"The SonicWave earbuds have a serious design flaw. The left earbud stopped charging after just one week. I expected better for the price. Very disappointed.\",\n",
"\n",
" # Review 3: Mixed with a question\n",
" \"The Titan smartwatch is decent. The screen is bright and the features are good, but the step counter seems inaccurate. It's off by at least 20%. Is there a way to calibrate it?\",\n",
"\n",
" # Review 4: Negative with multiple issues\n",
" \"My order for the AeroDrone was a disaster. It arrived with a broken propeller and the battery was completely dead on arrival. Customer service has been unresponsive for 3 days.\",\n",
"\n",
" # Review 5: Positive but mentions a minor issue\n",
" \"Overall, I'm happy with the PureGlow Air Purifier. It's quiet and effective. My only complaint is that the replacement filters are a bit expensive.\"\n",
"C:\\Users\\281879\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Review: The Titan smartwatch is decent. The screen is bright and the features are good, but the step counter seems inaccurate. It's off by at least 20%. Is there a way to calibrate it?\n",
"##### In this the token list are not identical got GPT-2 Tokens there are 41 tokens and BERT Tokens there are 44 tokens and the splitting pattern is also different\n",
"##### In GPT-2 it uses the symbol Ġ for tockenising and it refers that before this symbol space is there and in BERT it uses ## symbol and defines like one word splitted into 2\n",
"##### These models have distinct splitting patterns because of variation in Algorithm,training data,tried to balance how many words it can understand and how fast it can work"
],
"id": "b547dc499b4309f9"
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-10-08T13:35:36.200411Z",
"start_time": "2025-10-08T13:35:36.163158Z"
}
},
"cell_type": "code",
"source": [
"from dotenv import load_dotenv\n",
"import os\n",
"\n",
"# Load environment variables from the .env file\n",
"response = model.generate_content(f\"\"\"from this input {reviews} i need the output in the format positive,negative and mixed review like example 1: the moview is amazing example 2: positive\n",
"example 2:\n",
"Input: servie was terrible and slow\n",
"output: Negative\n",
"example 3:\n",
"Input:product is okay nothing special\n",
"output: Mixed\"\"\")\n",
"\n",
"\n",
"# Step 5: Print the result\n",
"print(response.text)\n"
],
"id": "59e929211ee96fa6",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Here's the classification of each review from your input, based on your provided examples:\n",
"\n",
"1. **Input:** 'I absolutely love the new QuantumX Pro camera! The picture quality is stellar and the battery life is amazing. Shipped super fast too. A++!'\n",
" **Output:** Positive\n",
"\n",
"2. **Input:** 'The SonicWave earbuds have a serious design flaw. The left earbud stopped charging after just one week. I expected better for the price. Very disappointed.'\n",
" **Output:** Negative\n",
"\n",
"3. **Input:** \"The Titan smartwatch is decent. The screen is bright and the features are good, but the step counter seems inaccurate. It's off by at least 20%. Is there a way to calibrate it?\"\n",
" **Output:** Mixed\n",
"\n",
"4. **Input:** 'My order for the AeroDrone was a disaster. It arrived with a broken propeller and the battery was completely dead on arrival. Customer service has been unresponsive for 3 days.'\n",
" **Output:** Negative\n",
"\n",
"5. **Input:** \"Overall, I'm happy with the PureGlow Air Purifier. It's quiet and effective. My only complaint is that the replacement filters are a bit expensive.\"\n",
" **Output:** Mixed\n",
"\n"
]
}
],
"execution_count": 10
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-10-08T13:36:25.269513Z",
"start_time": "2025-10-08T13:36:22.731210Z"
}
},
"cell_type": "code",
"source": [
"\n",
"response = model.generate_content(f\"\"\"From this review, I want the product_name, issue_summary and sentiment (positive, negative or mixed) in a JSON format.\n",
"\n",
"Examples:\n",
"Input: \"The Sony Speaker is so good, but battery drains so quickly\"\n",
"Output:\n",
"{{\n",
"\"product_name\": \"Sony Speaker\",\n",
"\"issue_summary\": \"battery drains so quickly\",\n",
"\"sentiment\": \"Mixed\"\n",
"}}\n",
"\n",
"Input: \"Movie is so good\"\n",
"Output:\n",
"{{\n",
"\"product_name\": \"N/A\",\n",
"\"issue_summary\": \"N/A\",\n",
"\"sentiment\": \"Positive\"\n",
"}}\n",
"\n",
"Now analyze this review:\n",
"Input: \"{reviews}\"\n",
"Output:\"\"\")\n",
"\n",
"\n",
"# Step 5: Print the result\n",
"print(response.text)\n"
],
"id": "eeccac983f0b013f",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"```json\n",
"[\n",
" {\n",
" \"product_name\": \"QuantumX Pro camera\",\n",
" \"issue_summary\": \"N/A\",\n",
" \"sentiment\": \"Positive\"\n",
" },\n",
" {\n",
" \"product_name\": \"SonicWave earbuds\",\n",
" \"issue_summary\": \"left earbud stopped charging after just one week\",\n",
" \"issue_summary\": \"arrived with a broken propeller and the battery was completely dead on arrival. Customer service has been unresponsive\",\n",
" \"sentiment\": \"Negative\"\n",
" },\n",
" {\n",
" \"product_name\": \"PureGlow Air Purifier\",\n",
" \"issue_summary\": \"replacement filters are a bit expensive\",\n",
" \"sentiment\": \"Mixed\"\n",
" }\n",
"]\n",
"```\n"
]
}
],
"execution_count": 11
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-10-08T13:48:51.613267Z",
"start_time": "2025-10-08T13:48:49.018569Z"
}
},
"cell_type": "code",
"source": [
"\n",
"response = model.generate_content(f\"\"\"Analyze the following customer review to identify the root cause of their issue. First, state the main problem. Second, explain your reasoning in a single sentence. Let's think step by step.\n",
"from \"{reviews}\" i need to get like first the product name then state the main problem and then the reasoning\n",
"\n",
"\n",
"Analysis:\n",
"step 1 - : find main problem of that product\n",
"step 2 - : fin the reasoning part\"\"\")\n",
"\n",
"\n",
"# Step 5: Print the result\n",
"print(response.text)\n"
],
"id": "bab82e5965d4830a",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Here's the breakdown of each review, identifying the product, main problem, and reasoning:\n",
"\n",
"* **Product:** SonicWave earbuds\n",
" * **Main Problem:** Left earbud stopped charging after one week.\n",
" * **Reasoning:** The customer states the earbud failed after only a week, expressing disappointment given the price, indicating a quality control or design flaw.\n",
" * **Reasoning:** The drone arrived with a broken propeller and a dead battery, implying damage during shipping or a faulty product, compounded by the lack of customer service, indicating a problem with both product quality and support.\n",
"\n",
"* **Product:** PureGlow Air Purifier\n",
" * **Main Problem:** Replacement filters are expensive.\n",
" * **Reasoning:** The customer expresses a complaint about the high cost of replacement filters, implying that the ongoing cost of maintaining the product is a concern.\n",