惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
L
LINUX DO - 热门话题
S
Schneier on Security
NISL@THU
NISL@THU
T
Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
量子位
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
月光博客
月光博客
Cyberwarzone
Cyberwarzone
B
Blog
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Microsoft Security Blog
Microsoft Security Blog
Vercel News
Vercel News
小众软件
小众软件
M
MIT News - Artificial intelligence
I
InfoQ
aimingoo的专栏
aimingoo的专栏
C
CXSECURITY Database RSS Feed - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
美团技术团队
Google DeepMind News
Google DeepMind News
T
The Blog of Author Tim Ferriss
Help Net Security
Help Net Security
WordPress大学
WordPress大学
V
Vulnerabilities – Threatpost
T
Tenable Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
Blog — PlanetScale
Blog — PlanetScale
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
D
Docker
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
H
Hacker News: Front Page
A
About on SuperTechFans
L
LINUX DO - 最新话题
B
Blog RSS Feed
D
DataBreaches.Net
博客园 - 司徒正美
Recorded Future
Recorded Future
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog

博客园 - ExplorerMan

大模型sft微调参数优化2 大模型RAG实战,从被骂不靠谱到成为部门MVP,这是我的踩坑全记录【转】 渐进式SFT内化 [推荐]双塔模型(介绍) Agno - 轻量级Python多智能体系统框架 Open WebUI:打造友好且强大的自托管 AI 平台 【gradio】使用Gradio快速开发前端界面:基础知识 文本切割方案进化概览:从“机械切割”到“智能解构” 大模型RAG的上下文压缩与过滤 SemanticChunker 语义相似拆分 基于LangChain 实现 Advanced RAG-后检索优化(上)-Reranker 基于LangChain 实现 Advanced RAG-后检索优化(下)-上下文压缩与过滤 多Agent协作入门:基于A2A协议的Agent通信(中) ollama部署与open-webui 0基础也能看懂!从0到1手把手教你本地部署大模型Ollama 什么是 AutoModel 大模型基础应用框架(ReACT\SFT\RAG)技术创新及零售业务落地应用 - ExplorerMan - 博客园 多模态Embedding模型:从文本到多模态的全面选型指南! rag 查询检索轮换
推荐 Prompt 模板(大幅提升 JSON 质量)
ExplorerMan · 2026-01-28 · via 博客园 - ExplorerMan

请严格按照以下要求输出:

1. 输出必须是**严格合法的 JSON**,可直接被 Python json.loads() 解析
2. 所有键和字符串值必须用**英文双引号**包围
3. 不要包含任何 JSON 之外的文本(如"```json"或解释)
4. 遵循以下 Schema:
{
"type": "object",
"properties": {
"name": {"type": "string"},
"score": {"type": "number", "minimum": 0, "maximum": 100}
},
"required": ["name", "score"]
}

现在请输出:

方案1:JSON + JSON Schema(90% 场景)

# 使用 OpenAI JSON Mode(自动保证合法性)

response = client.chat.completions.create(

    model="gpt-4o",

    messages=[{"role": "user", "content": "提取用户姓名和年龄"}],

    response_format={ "type": "json_object" },  # ← 关键!

    temperature=0.0

)

data = json.loads(response.choices[0].message.content)

方案2:JSON + 后处理校验(开源模型必备)

def safe_parse_json(text):

    # 尝试1:直接解析

    try:

        return json.loads(text)

    except:

        pass

    # 尝试2:提取首尾花括号间内容

    match = re.search(r'\{.*\}', text, re.DOTALL)

    if match:

        try:

            return json.loads(match.group())

        except:

            pass

    # 尝试3:用大模型修复

    fix_prompt = f"修复以下JSON错误,只输出合法JSON:\n{text}"

    # ... 调用模型修复

    raise ValueError("JSON 无法修复")