应用场景与解决方案

AI 批量回复买家评价:本地大模型起草多语言回复,敏感评价自动标记,人工审核后发布

6 个步骤 11 分钟阅读 59 次阅读 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、所用的模型以及报错信息,方便工程师快速定位。

这篇文章有帮助吗?

相关教程