Automating AI Summarization for Technical Hardware Descriptions with Ollama

Automating AI Summarization for Technical Hardware Descriptions with Ollama

Introduction

In an era where content automation is key, leveraging AI for technical product descriptions is a game-changer. Instead of manually writing CPU, memory, and storage specifications, we can use LLama2 running on an RTX 3060 Ti to generate up to 20,000 product summaries per day.

This blog explores how we adapted our AI summarization tool from a niche industry (fishing tackle) to focus on hardware components, how we structured our SQLite3 database, and why proper rule sets make AI-generated content usable across any domain.


1. Why Automate Technical Product Summaries?

For businesses managing large-scale eCommerce platforms, manually writing thousands of CPU, RAM, and SSD descriptions is time-consuming and inconsistent. AI can:
✅ Ensure a consistent and engaging brand tone
✅ Maintain technical accuracy based on hardware specifications
✅ Process thousands of entries at scale
✅ Save countless hours of manual work

With LLama2 running on a single RTX 3060 Ti, we can generate 20,000+ summaries per day (depending on length and model tuning).


2. How We Built It: AI-Powered Hardware Descriptions

We used SQLite3 as the database and updated a table containing hardware specifications to include AI-generated descriptions. Here’s how:

✅ Extract raw hardware data from product listings
✅ Sanitize and clean descriptions before AI processing
✅ Send the cleaned text to Ollama for AI summarization
✅ Store the AI-generated summary in our database

We modified our Python script to adapt it to hardware specifications, removing unnecessary logic and ensuring AI-generated summaries align with technical accuracy.


3. Python Code: AI-Generated Hardware Summaries

#!/usr/bin/env python

import sqlite3
import requests
from bs4 import BeautifulSoup

# Database file
DB_PATH = "products.db"
TABLE_NAME = "products"
MODEL = "llama2"
#MODEL = "deepseak-r1"
OLLAMA_API = "http://ai.akadata.ltd:11434/api/generate"
TESTING = False

def clean_html(raw_html):
    """Remove HTML tags from text."""
    soup = BeautifulSoup(raw_html, "html.parser")
    return soup.get_text()

def validate_and_clean_response(response, product_name):
    """Ensure the response is formatted correctly."""
    soup = BeautifulSoup(response, "html.parser")
    h1 = soup.find("h1") or f"<h1>{product_name}</h1>"
    p = soup.find("p") or f"<p>{soup.get_text().strip()}</p>"
    return f"{h1}{p}"

def summarize_with_ollama(data, brand, category, product_name):
    """Send data to Ollama for summarization."""
    url = OLLAMA_API
    payload = {
        "model": MODEL,
        "temperature": 0.3,
        "system": (
            "You are a product description AI for technical hardware components, including CPUs, RAM, storage devices, and GPUs. "
            "Your response must be formatted strictly in valid HTML as follows: "
            "<h1>Product Name</h1><p>Description</p>. Ensure the description is concise, accurate, and technical."
        ),
        "prompt": (
            f"<h1>{product_name}</h1>\n<p>"
            f"This is a {category} product from {brand}. Generate a concise and accurate technical summary "
            f"focusing on performance, specifications, and use cases. The response must follow the exact format: \n\n"
            f"<h1>{product_name}</h1>\n<p>[Product description]</p>\n\n"
            f"Product details:\n{data}"
        ),
        "stream": False
    }

    headers = {"Content-Type": "application/json"}
    
    try:
        response = requests.post(url, json=payload, headers=headers)
        response.raise_for_status()
        raw_description = response.json().get("response", "Unable to generate description.").strip()
        return validate_and_clean_response(raw_description, product_name)
    except requests.exceptions.RequestException as e:
        print(f"Error communicating with Ollama: {e}")
        return f"<h1>{product_name}</h1><p>Unable to generate description.</p>"

def process_and_update_db():
    """Process hardware descriptions and update the database."""
    try:
        conn = sqlite3.connect(DB_PATH)
        cursor = conn.cursor()
        cursor.execute(f"SELECT ID, _sku, ProductName, ProductDescription, Brand, Category, RawData FROM {TABLE_NAME} WHERE AIDescription =''")
        rows = cursor.fetchall()
        
        for row in rows:
            product_id, sku, product_name, product_desc, brand, category, raw_data = row
            raw_data_cleaned = clean_html(raw_data)
            input_text = f"Product Name: {product_name}\nDescription: {product_desc}\nBrand: {brand}\nCategory: {category}"
            product_description = summarize_with_ollama(input_text, brand, category, product_name)
            print(f"Generated AI summary for SKU {sku}:")
            print(product_description)
            update_query = f"UPDATE {TABLE_NAME} SET AIDescription = ? WHERE _sku = ?"
            try:
                cursor.execute(update_query, (product_description, sku.strip()))
                conn.commit()
                print(f"Updated description for SKU {sku}")
            except sqlite3.Error as e:
                print(f"SQLite update error for SKU {sku}: {e}")
    except sqlite3.Error as e:
        print(f"SQLite error: {e}")
    finally:
        if conn:
            conn.close()

if __name__ == "__main__":
    process_and_update_db()

4. Why This Approach Works

Using strict formatting rules ensures AI-generated content remains clean, structured, and professional.

✅ Prevents hallucinated AI data by keeping prompts specific.
✅ Ensures consistency across thousands of product descriptions.
✅ Leverages SQLite3 for easy data management.
✅ Can be adapted for any domain by adjusting the input prompts and rules.

With proper constraints, AI-generated content is reliable, scalable, and removes tedious manual labor.


Conclusion

Using Ollama + LLaMA2 on consumer-grade hardware (RTX 3060 Ti 12Gb VRAM), we’ve automated technical product descriptions at scale. With this system in place, we:

✅ Generate 20,000+ summaries per day
✅ Maintain accurate and engaging product descriptions
✅ Ensure structured formatting using AI-generated HTML

🚀 Need help automating content for your business? AKADATA provides AI-powered automation solutions tailored to your needs!