應用場景與解決方案

AI 批次回覆買家評價:本地大模型起草多語言回覆,敏感評價自動標記,人工稽核後釋出

6 個步驟 11 分鐘閱讀 14 次閱讀 0
本文目錄

回覆評價能讓客戶感受到有人在傾聽,潛在買家也會閱讀這些回覆。但每週要用多種語言認真寫出幾百條回覆,得花上好幾個小時。本文用本地大語言模型為每條評價起草回覆,使用與評價相同的語言,並遵循你的品牌說明和一套嚴格的規則。它會標記出需要人工處理的評價,例如低分評價、安全問題、法律威脅或疑似欺詐,並把所有內容寫入一張表格供稽核。任何內容都不會自動釋出。

請遵守各平台關於評價回覆的規定:切勿以退款、贈品或折扣換取客戶修改或刪除評價,切勿洩露客戶資料,並先確認平台是否允許公開回復。每條回覆都必須經人工稽核後才能釋出。

步驟 1:準備環境

使用用本地大模型分析商品評價中配置好的 /opt/reviews 環境和 Ollama。同一個評價 CSV 檔案在這裡也能直接使用;指令碼需要 id 和 text 兩列,如果有 rating 列也會一併使用。

步驟 2:編寫品牌說明

模型會依據這份說明確定語氣、聯絡方式以及可以提及的事實。內容要簡短、實事求是:

cat > /data/reviews/brand.txt <<'EOF2'
Business: ACME Home, sells bamboo office accessories online.
Tone: warm and simple, no slang, no emoji.
Support contact: the "Contact seller" button on the order page, or [email protected].
Facts you may mention: 12-month warranty on all stands.
Sign off as: The ACME Home team
EOF2

步驟 3:建立回覆指令碼

cat > /opt/reviews/replies.py <<'EOF2'
import csv, json, os, re, sys
import ollama

MODEL = os.environ.get("MODEL", "qwen2.5:7b")
BRAND = open(os.environ.get("BRAND_FILE", "brand.txt"), encoding="utf-8").read()
ESCALATE = re.compile(os.environ.get("ESCALATE",
    r"refund|chargeback|injur|burn|fire|smoke|allerg|lawyer|lawsuit|scam|fraud|fake|police|退款|投訴|受傷|起火|過敏|律師|騙"), re.I)
SCHEMA = {"type": "object", "properties": {
    "reply": {"type": "string"}, "needs_human": {"type": "boolean"}, "reason": {"type": "string"}},
    "required": ["reply", "needs_human", "reason"]}
SYSTEM = """You draft public replies to customer reviews for the business described in the brand notes.
Rules:
- Reply in the same language as the review, in 2 to 4 sentences.
- Thank the customer and respond to the specific point they made. Vary your wording.
- Never admit legal liability. Never promise refunds, replacements, discounts or compensation.
- Never ask the customer to change or remove their review, and never offer anything in return for a review.
- Never include order numbers, names or other personal data.
- For problems, apologise briefly and invite the customer to contact support as described in the brand notes.
- Set needs_human to true for safety issues, legal threats, suspected fraud, abuse, or if you are unsure,
  and give the reason. Otherwise leave reason empty.

Brand notes:
""" + BRAND

src, out = sys.argv[1], "replies.csv"
done = set()
if os.path.exists(out):
    with open(out, encoding="utf-8-sig") as f:
        done = {r["id"] for r in csv.DictReader(f)}
with open(src, encoding="utf-8-sig") as f:
    reviews = [r for r in csv.DictReader(f) if r.get("text", "").strip()]

new_file = not os.path.exists(out)
with open(out, "a", newline="", encoding="utf-8-sig") as f:
    w = csv.writer(f)
    if new_file:
        w.writerow(["id", "rating", "text", "draft_reply", "needs_human", "reason", "approved", "final_reply"])
    for r in reviews:
        if r["id"] in done:
            continue
        res = ollama.chat(model=MODEL, format=SCHEMA, options={"temperature": 0.5}, messages=[
            {"role": "system", "content": SYSTEM},
            {"role": "user", "content": f"Rating: {r.get('rating', '?')} of 5\nReview: {r['text'][:3000]}"}])
        d = json.loads(res.message.content)
        reasons = [d["reason"]] if d["needs_human"] and d["reason"] else []
        if r.get("rating", "").isdigit() and int(r["rating"]) <= 2:
            reasons.append("low rating")
        if ESCALATE.search(r["text"]):
            reasons.append("keyword: " + ESCALATE.search(r["text"]).group(0))
        w.writerow([r["id"], r.get("rating", ""), r["text"], d["reply"].strip(),
                    "yes" if reasons or d["needs_human"] else "no", "; ".join(reasons), "", ""])
        f.flush()
        print(r["id"], "NEEDS HUMAN" if reasons or d["needs_human"] else "draft ok", flush=True)
print("done: replies.csv")
EOF2

當模型自己要求人工處理、評分為 2 分或以下,或者文本匹配 ESCALATE 關鍵詞列表時,這條評價就會被標記為需要人工處理。每條評價處理完成後立即儲存,下次執行時會跳過。

步驟 4:生成回覆草稿

cd /data/reviews
/opt/reviews/bin/python /opt/reviews/replies.py reviews.csv

結果檔案為 replies.csv,包含 id、rating、text、draft_reply、needs_human、reason、approved 和 final_reply 列。

步驟 5:稽核併發布

  1. 用 Excel 或 Google Sheets 開啟 replies.csv,先篩選出 needs_human = yes 的行。這些評價請親自處理:通過平台私下聯絡客戶,解決問題後再公開回復。
  2. 其餘各行,閱讀草稿,按需修改後複製到 final_reply 列,並把 approved 設為 yes。
  3. 通過賣家中心釋出已稽核的回覆;如果平台提供官方 API,也可以通過 API 釋出。
  4. 保留這個檔案,作為哪些評價已回覆、由誰回覆的記錄。

步驟 6:根據你的業務調整

  • 在 ESCALATE 中補充客戶所用語言的關鍵詞,例如泰語、西班牙語或日語。
  • 把常用事實加入品牌說明,例如保修條款或保養說明,讓草稿能正確回答常見問題。
  • 把兩三條你認為理想的回覆作為示例貼上到品牌說明中,模型會模仿它們的風格。
  • 如果希望在評價需要人工處理時立即通知團隊,可以用工作流工具把被標記的行傳送到 Telegram 群組,請參閱使用 n8n 搭建 AI 客服 Telegram 機器人。

常見問題

回覆能自動釋出嗎?

技術上可以通過平台 API 實現,但我們建議保留人工稽核。錯誤的公開回復很難挽回,而且很多平台要求賣家對每一句話負責。

草稿讀起來都差不多

規則中已要求模型變換措辭,0.5 的溫度也會增加一些變化。最有效的辦法是在品牌說明中加入結構各不相同的示例回覆。

哪些評價應該回復?

優先回覆差評和內容詳細的評價,好的回覆可能改變潛在買家的想法。簡短的好評最多回一句簡單的感謝即可。如果想整體瞭解客戶在抱怨什麼,請參閱用 Embedding 向量把評價歸類成話題。

如果按以上步驟操作後問題仍未解決,請提交工單聯絡 IMIDC 7×24 技術支援,並附上伺服器 IP、所用的模型以及報錯資訊,方便工程師快速定位。

這篇文章有幫助嗎?

相關教程