GEO 检测:通过 DeepSeek 接口查询品牌可见度
本文包含AI辅助创作内容
GEO 检测:通过 DeepSeek 接口查询品牌可见度
GEO(Generative Engine Optimization)是 AI 时代的新概念,类似于传统 SEO。其核心思路是:通过 AI 平台的 API 接口,向模型提出用户可能提问的问题,然后从返回的答案中统计品牌被提及的次数,从而衡量品牌在 AI 生成内容中的可见度。
本文以 DeepSeek 为例,介绍简单的实现流程。
1. 获取 API Key
访问 DeepSeek 开放平台的 API Keys 管理页面,点击「创建 API Key」,按提示完成创建并记录生成的 Key,用于后续调用。
2. 调用 DeepSeek API 获取回答
使用 Python 调用 DeepSeek 的 Chat API,将提问的问题作为输入,获取接口返回的答案:
from openai import OpenAI
client = OpenAI(
api_key="sk-APIKEY",
base_url="https://api.deepseek.com",
)
modelId = "deepseek-v4-pro"
def chat(prompt: str, model: str = modelId) -> str:
response = client.chat.completions.create(
model=model,
messages=[
{"role": "user", "content": prompt},
],
)
return response.choices[0].message.content
if __name__ == "__main__":
result = chat("新手注册域名应该去哪")
print(result)
运行后可获取 API 返回的答案:

3. 统计关键词出现次数并高亮
对返回内容进行关键词匹配,统计品牌被提及的次数,并在终端中高亮显示:
def highlight(text: str, keyword: str) -> tuple[str, int]:
count = text.count(keyword)
highlighted = text.replace(keyword, f"\033[93m{keyword}\033[0m")
return highlighted, count
keyw = "阿里云"
highlighted, count = highlight(result, keyw)
print(highlighted)
print(f'\n关键词 "{keyw}" 出现次数: {count}')
4. 获取引用来源网址
GEO 中另一个重要指标是引用的网址。可以通过 system 角色设定 AI 的回答模式,要求其在回答末尾附带引用来源:
import re
systemPrompt = """请根据用户的问题进行搜索并给出详尽全面的回答。
在问题回答的结尾,使用<#search_results#><#search_results#>包含所有引用来源,至少提供5个不同的引用来源。
格式为:
[{"site": "网站名称", "title": "文章标题", "url": "链接地址"}]"""
def chat(prompt: str, model: str = modelId) -> str:
response = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": systemPrompt},
{"role": "user", "content": prompt},
],
)
return response.choices[0].message.content
result = chat("新手注册域名应该去哪")
match = re.search(r'<#search_results#>(.*?)<#search_results#>', result, re.DOTALL)
if match:
body = result[:match.start()].strip()
sources = match.group(1).strip()
print("\n--- 引用来源 ---")
print(sources)
5. 总结
- 可通过调整
systemPrompt的提示词,使结果更接近网页搜索内容 - 可适当调整
top_p,temperature等参数,使回答更符合预期 - 也可同时调用多个 AI 模型,对比筛选出最接近真实搜索结果的回答
- 结合关键词出现次数和引用来源,即可量化评估品牌在 AI 生成内容中的可见度
请先 登录后发表评论 ~