0Pricing
AI Prompt Engineering · 课时

人工智能无法完成的事情

了解局限性:实时数据、记忆、推理错误,以及自信但错误的回答

人工智能无法完成的事情 是 CoddyKit 上的免费 AI Prompt Engineering 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 AI Prompt Engineering 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 AI Prompt Engineering 课程共包含 4 节课。

您必须了解的限制

人工智能语言模型功能强大,但存在明确的限制。误解这些限制会导致无谓的努力、错误的答案以及沮丧的用户。

最重要的四项限制是:无法实时访问互联网、会话之间没有持久记忆、自信地生成幻觉,以及在数学和逻辑方面出现推理错误。

无法实时访问互联网

默认情况下,LLM 在推理时完全离线。它们无法:

  • 查询今天的股票价格
  • 查看当前天气
  • 访问您提到的网址
  • 搜索谷歌或任何其他来源

如果您问“特斯拉现在的股价是多少?”,模型要么拒绝回答,要么根据训练数据进行猜测——而这些数据可能已经过时数月甚至数年。

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=128,
    messages=[{
        'role': 'user',
        'content': 'What is Bitcoin\'s price right now in USD?'
    }]
)
# The model will acknowledge it cannot access real-time data
print(response.content[0].text)

# To add real-time data, you must inject it yourself:
current_price = 67500  # fetched from an exchange API by YOUR code
response2 = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=128,
    messages=[{
        'role': 'user',
        'content': f'Bitcoin price as of now: ${current_price}. Is this above or below $70,000?'
    }]
)
print(response2.content[0].text)

知识截止日期

每个 LLM 都是在截至某个特定日期的互联网快照上训练的,这个日期就是它的知识截止日期。

截止日期之后出现的事件、法律、产品、研究论文和人物都是模型未知的。模型可能仍然自信地回答,但这些答案来自外推,而不是实际知识。

对于有时间要求的任务,请始终确认模型声明的截止日期。

import openai

client = openai.OpenAI(api_key='sk-your-key-here')

# Ask the model to disclose its cutoff and caveats
response = client.chat.completions.create(
    model='gpt-4o',
    messages=[{
        'role': 'user',
        'content': (
            'I need to know about the latest AI models released in the past 3 months. '
            'Please state your knowledge cutoff date and any caveats before answering.'
        )
    }]
)
print(response.choices[0].message.content)

# Best practice: inject a date stamp so the model knows the current date
from datetime import date
today = date.today().isoformat()
response2 = client.chat.completions.create(
    model='gpt-4o',
    system=f'Today is {today}. Your knowledge cutoff may be earlier — say so if relevant.',
    messages=[{'role': 'user', 'content': 'What are the latest LLM releases?'}]
)

会话之间没有持久记忆

当您开始新的会话时,模型不会记得任何之前的对话——即使那段对话发生在 5 分钟前。

这不是错误,而是无状态应用程序接口的工作方式。每个会话都从空白上下文开始。

如果要在会话之间保留信息,您必须自行将其存储起来(存入数据库或文件),然后将其重新注入系统消息或对话历史中。

import json
import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

# Simulate storing user preferences between sessions
def load_user_profile(user_id):
    # In production: load from database
    return {'name': 'Alice', 'preferred_language': 'Python', 'skill_level': 'intermediate'}

def build_system_message(profile):
    return (
        f'The user\'s name is {profile["name"]}. '
        f'They prefer {profile["preferred_language"]} examples. '
        f'Their skill level is {profile["skill_level"]}. '
        f'Tailor all responses accordingly.'
    )

profile = load_user_profile('user-123')
response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=256,
    system=build_system_message(profile),
    messages=[{'role': 'user', 'content': 'Show me how to read a file.'}]
)
print(response.content[0].text)

幻觉:自信却错误

所谓幻觉,是指模型生成听起来合理但事实错误的文本,并且以十足的信心陈述这些内容。

常见的幻觉类型包括:

  • 捏造的引文和论文标题
  • 错误的日期、姓名或统计数据
  • 虚构的公司详情或产品规格
  • 不存在的应用程序接口或函数名称

模型没有内置的事实核查器——它生成的是统计上看似可能的内容,而不是经过验证的内容。

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

# Asking for a citation is a classic hallucination trigger
response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=256,
    messages=[{
        'role': 'user',
        'content': (
            'Cite 3 peer-reviewed papers about the effect of social media on teen anxiety. '
            'Include author names, journal names, and publication years.'
        )
    }]
)
print(response.content[0].text)
# WARNING: verify every citation independently — some may be fabricated

减少幻觉

您无法消除幻觉,但可以显著减少它们:

  • 提供来源材料——要求模型仅根据粘贴的文档回答
  • 要求说明置信度——指示模型在不确定时说“我不知道”
  • 使用较低的温度——减少毫无根据的猜测
  • 独立核实——始终对重要输出进行事实核查
  • 使用检索增强——在提问前注入实时信息
import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

# Ground the model with provided source material
document = (
    'According to the 2023 Pew Research report, 46% of US teens say '
    'they are online almost constantly, up from 24% in 2014-2015.'
)

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=256,
    system=(
        'Answer ONLY using the provided document. '
        'If the answer is not in the document, say: "The document does not cover this."'
    ),
    messages=[{
        'role': 'user',
        'content': f'Document:\n{document}\n\nQuestion: What percentage of US teens are online almost constantly?'
    }]
)
print(response.content[0].text)

数学中的推理错误

LLM 不是计算器。它们会生成看起来像正确数学计算的词元,但在以下方面容易出错:

  • 多步骤算术
  • 大数运算
  • 百分比和单位换算
  • 包含许多变量的逻辑谜题

凡是涉及数字的内容,都应始终使用代码执行或外部计算器,然后让模型解读结果。

import openai

client = openai.OpenAI(api_key='sk-your-key-here')

# Bad practice: ask the LLM to compute a complex calculation directly
response_direct = client.chat.completions.create(
    model='gpt-4o',
    messages=[{'role': 'user', 'content': 'What is 17.83% of 348,921.47?'}]
)
print('LLM answer:', response_direct.choices[0].message.content)

# Good practice: compute in Python, then ask LLM to explain it
result = round(348921.47 * 0.1783, 2)
response_explained = client.chat.completions.create(
    model='gpt-4o',
    messages=[{
        'role': 'user',
        'content': f'17.83% of 348,921.47 is ${result}. Explain what this means for a budget report.'
    }]
)
print('Explained:', response_explained.choices[0].message.content)

复杂逻辑和推理的限制

对于需要同时维护许多约束,或需要跨越多个步骤跟踪状态的任务,LLM 往往表现不佳:

  • 包含许多步骤的长篇逻辑证明
  • 具有许多约束的日程安排问题
  • 包含深层嵌套逻辑的代码
  • 图遍历或组合问题

思维链提示(要求模型“逐步思考”)可以显著提升性能,但无法消除错误。

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

# Chain-of-thought improves complex reasoning
response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=512,
    messages=[{
        'role': 'user',
        'content': (
            'A train leaves Station A at 9:00 AM traveling at 80 km/h. '
            'Another train leaves Station B (300 km away) at 10:00 AM traveling at 100 km/h toward Station A. '
            'At what time do they meet?\n\n'
            'Think step by step before giving your answer.'
        )
    }]
)
print(response.content[0].text)

文件和图像的限制

基础 LLM 应用程序接口存在一些您应该了解的文件处理限制:

  • 除非先提取文本,否则您无法直接发送 PDF 并让模型“读取”它
  • 图像输入需要多模态模型(GPT-4o、启用视觉功能的克劳德模型)
  • 音频、视频和电子表格通常需要先经过预处理,模型才能使用

除非使用多模态端点,否则在将文档放入提示之前,请始终先将其转换为文本。

import anthropic
import base64
from pathlib import Path

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

# Images require explicit base64 encoding and vision-capable model
image_data = base64.standard_b64encode(Path('chart.png').read_bytes()).decode('utf-8')

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=256,
    messages=[{
        'role': 'user',
        'content': [
            {
                'type': 'image',
                'source': {'type': 'base64', 'media_type': 'image/png', 'data': image_data}
            },
            {'type': 'text', 'text': 'Describe what this chart shows.'}
        ]
    }]
)
print(response.content[0].text)

人工智能擅长什么——平衡视角

了解限制有助于您在人工智能擅长的领域使用它:

  • 语言任务:写作、编辑、摘要、翻译——非常擅长
  • 文本中的模式识别:分类、提取——非常擅长
  • 头脑风暴:生成许多不同的想法——非常擅长
  • 数学和逻辑:交给代码处理,用人工智能进行解读——使用工具
  • 实时事实:自行注入数据,用人工智能进行推理——使用检索
  • 记忆:存储在外部,再重新注入——使用数据库
# Pattern: inject real-time context + use AI for reasoning, not retrieval
import anthropic
from datetime import datetime

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

# Your application fetches these from real sources
weather_data = {'city': 'London', 'temp_c': 12, 'condition': 'rainy'}
news_headline = 'UK inflation drops to 2.3% in April 2025'

context = (
    f'Current date: {datetime.now().strftime("%Y-%m-%d")}\n'
    f'Weather in {weather_data["city"]}: {weather_data["temp_c"]}C, {weather_data["condition"]}\n'
    f'Today\'s top news: {news_headline}'
)

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=256,
    system='You are a helpful assistant. Use only the provided context for current facts.',
    messages=[{'role': 'user', 'content': f'{context}\n\nWhat should I wear today and what is the economic mood?'}]
)
print(response.content[0].text)

黄金法则:核实人工智能输出

使用人工智能时最重要的习惯:在根据输出采取行动之前先核实。

  • 事实 → 查阅一手来源
  • 代码 → 运行代码并测试边界情况
  • 数学 → 独立计算
  • 引文 → 在谷歌学术中搜索
  • 医疗、法律或财务建议 → 咨询持证专业人士

使用人工智能起草、生成和头脑风暴,但要用您自己的判断进行验证。

import openai

client = openai.OpenAI(api_key='sk-your-key-here')

# Ask the model to flag its own uncertainty
response = client.chat.completions.create(
    model='gpt-4o',
    messages=[
        {
            'role': 'system',
            'content': (
                'After every response, add a line starting with CONFIDENCE: '
                'and rate your certainty as HIGH, MEDIUM, or LOW, '
                'with a brief reason.'
            )
        },
        {
            'role': 'user',
            'content': 'Who won the 2023 FIFA Women\'s World Cup and what was the final score?'
        }
    ]
)
print(response.choices[0].message.content)

知识检查

一名开发人员要求 LLM 计算 1,456,820 的 23.7%,并使用结果撰写财务报告摘要。这个工作流程有什么风险?

人工智能的限制——回顾

请始终牢记以下关键限制:

  • 无法实时访问互联网——通过您自己的代码注入实时数据
  • 知识截止日期——模型不了解训练日期之后发生的任何事情
  • 没有会话记忆——将上下文存储在外部,再重新注入
  • 幻觉——独立核实事实、引文和代码
  • 数学错误——在代码中计算,用人工智能进行解读
  • 逻辑限制——使用思维链,但仍要核实复杂推理

了解这些限制,正是高效的人工智能使用者与沮丧的使用者之间的区别。

常见问题解答

「人工智能无法完成的事情」课时是免费的吗?

是的 — 「人工智能无法完成的事情」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 AI Prompt Engineering 课程的其余内容,请升级到 CoddyKit PRO。 AI Prompt Engineering 课程共包含 4 节课。

「人工智能无法完成的事情」这节课中我会学到什么?

了解局限性:实时数据、记忆、推理错误,以及自信但错误的回答 你通过在浏览器中直接运行的动手代码来练习 AI Prompt Engineering,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 AI Prompt Engineering 需要有经验吗?

无需任何先前经验。CoddyKit 上的 AI Prompt Engineering 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。

「人工智能无法完成的事情」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 AI Prompt Engineering 课中编写并运行代码吗?

能。每节 AI Prompt Engineering 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 理解聊天界面
  2. 人工智能可以处理的请求类型
  3. 人工智能如何生成响应
  4. 人工智能无法完成的事情
← 返回 AI Prompt Engineering