Chapter 08
1. 理解 Langchain Basic
NotebookPython 3 (ipykernel)54 cells
-
Agent 最重要的两个道路:
-
Prompt Engineering Based Agent System
- 今天我们讲的就是这个 系统怎么构建;
-
RL 强化学习优化单个模型的能力上限
- 推荐赵老师的 《强化学习数学原理》
1. 理解 Langchain Basic
In [11]python · cell 3
python
# %%capture
# !pip install langchain
"""
langchain 0.3.25
langchain-core 0.3.65
langchain-openai 0.3.23
langchain-text-splitters 0.3.8
langgraph 0.4.8
langgraph-checkpoint 2.0.26
langgraph-prebuilt 0.2.2
langgraph-sdk 0.1.70
langsmith 0.3.45
"""Output
'\nlangchain 0.3.25\nlangchain-core 0.3.65\nlangchain-openai 0.3.23\nlangchain-text-splitters 0.3.8\nlanggraph 0.4.8\nlanggraph-checkpoint 2.0.26\nlanggraph-prebuilt 0.2.2\nlanggraph-sdk 0.1.70\nlangsmith 0.3.45\n'
In [185]python · cell 4
python
from dotenv import load_dotenv
import os
load_dotenv(".env")Output
True
In [188]python · cell 5
python
BASE_URL = "https://api.deepseek.com"
API_KEY = os.environ.get("API_KEY")
deepseek_chat_model = "deepseek-chat"
# deepseek_reason_model = "deepseek-reasoner"- langchain, init model; 使用 invoke, 以及 prompt template
- langgraph memory
- langgraph 的 create_react_agent
1.1 方式1 openai sdk
通过 OpenAI sdk
In [191]python · cell 8
python
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage
from langchain_core.prompts import ChatPromptTemplate
llm1 = ChatOpenAI(model=deepseek_chat_model, api_key=API_KEY, base_url=BASE_URL)
llm1.invoke([HumanMessage("帮我写一个关于 电脑的笑话")])Output
AIMessage(content='好的!这里有一个关于电脑的笑话:\n\n---\n\n**笑话:电脑的抱怨**\n\n有一天,一个人对他的电脑说:“你真是太慢了,简直像蜗牛一样!” \n电脑冷冷地回复:“嘿,至少我从不‘死机’……哦,等等。” \n(屏幕突然蓝屏) \n\n---\n\n希望这个笑话能让你笑一笑!如果需要其他类型的笑话,随时告诉我哦! 😄', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 82, 'prompt_tokens': 11, 'total_tokens': 93, 'completion_tokens_details': None, 'prompt_tokens_details': {'audio_tokens': None, 'cached_tokens': 0}, 'prompt_cache_hit_tokens': 0, 'prompt_cache_miss_tokens': 11}, 'model_name': 'deepseek-chat', 'system_fingerprint': 'fp_8802369eaa_prod0425fp8', 'id': 'bf2db262-2625-4eaf-b579-88ec3921ef91', 'service_tier': None, 'finish_reason': 'stop', 'logprobs': None}, id='run--90e2e2b7-4c29-45d3-95af-61ab652d106c-0', usage_metadata={'input_tokens': 11, 'output_tokens': 82, 'total_tokens': 93, 'input_token_details': {'cache_read': 0}, 'output_token_details': {}})1.2 方式2 deepseek
使用 deepseek sdk
In [18]python · cell 10
python
# !pip install -U langchain-deepseekIn [193]python · cell 11
python
# 其他
from langchain_deepseek import ChatDeepSeek
llm2 = ChatDeepSeek(model=deepseek_chat_model, api_key=API_KEY)
messages = [HumanMessage("你是谁?")]
print(llm2.invoke(messages).content)Output
我是DeepSeek Chat,由深度求索公司(DeepSeek)创造的智能AI助手!🤖✨ 我的使命是帮助你解答问题、提供信息、陪你聊天,甚至帮你处理各种文本和文件内容。无论是学习、工作,还是日常生活中的疑问,我都会尽力帮你解决!😊 有什么我可以帮你的吗?
1.3 使用 统一的 方式
In [194]python · cell 13
python
# pip install -U langchain-deepseek
from langchain.chat_models import init_chat_model
llm3 = init_chat_model(
deepseek_chat_model, # deepseek-chat
api_key=API_KEY,
)
print(llm3.invoke(messages).content)Output
我是DeepSeek Chat,由深度求索公司(DeepSeek)创造的智能AI助手!✨ 我的使命是帮助你解答问题、提供建议、陪你聊天,还能处理各种文本、文档等内容。无论是学习、工作,还是日常生活中的疑问,我都会尽力帮你解决!😊 有什么我可以帮你的吗?
2. 了解 LangChain Chain
2.1 ChatAgent Using LangChain
In [195]python · cell 16
python
from langchain_core.prompts import ChatPromptTemplateIn [196]python · cell 17
python
prompt_template = ChatPromptTemplate(
[
("system", "you are a helpful assistant"),
("human", "帮我写一个和 {topic} 相关的笑话"),
]
)In [197]python · cell 18
python
prompt_template.input_variablesOutput
['topic']
In [ ]python · cell 19
python
# llm.invoke(messages)
# llm.invoke({"topic": "xxxxx"})In [198]python · cell 20
python
prompt_template.invoke({"topic": "cat"}).to_messages()Output
[SystemMessage(content='you are a helpful assistant', additional_kwargs={}, response_metadata={}),
HumanMessage(content='帮我写一个和 cat 相关的笑话', additional_kwargs={}, response_metadata={})]In [199]python · cell 21
python
# langchain 的 Chain 是什么意思?
# A | B | C | D
basic_chain = prompt_template | llm2In [200]python · cell 22
python
# Use the chain
ans = basic_chain.invoke(
{
"topic": "cat",
}
)
print(ans.content)Output
当然!这里有一个和猫有关的笑话: --- **笑话:** 有一天,一只猫走进了一家酒吧。 酒保看着它问:“你想喝点什么?” 猫想了想说:“给我来一杯‘喵喵白葡萄酒’。” 酒保好奇地问:“这名字挺特别,为什么叫这个?” 猫淡定地回答:“因为每次我喝完,都会‘喵~’地唱起来!” --- 希望这个笑话能让你开心!😺
2.2 结构化输出
In [ ]python · cell 24
python
from pydantic import BaseModel, Field
class Joke(BaseModel):
"""Joke to tell user."""
setup: str = Field(description="The setup of the joke")
punchline: str = Field(description="The punchline to the joke")
# 创建 chain
joke_chain = prompt_template | llm2.with_structured_output(Joke)
# 调用 chain,结构化输出
joke_chain.invoke({"topic": "cat"})
# 缺点: FunctionCall 能力的模型才能使用;Output
Joke(setup='Why did the cat sit on the computer?', punchline='Because it wanted to keep an eye on the mouse!')
In [202]python · cell 25
python
from pydantic import BaseModel, Field
from langchain_core.output_parsers import JsonOutputParser
class Joke(BaseModel):
"""Joke to tell user."""
setup: str = Field(description="The setup of the joke")
punchline: str = Field(description="The punchline to the joke")
# 创建包含输出格式要求的提示模板
prompt_template = ChatPromptTemplate(
[
(
"system",
"""你是一个幽默助手。请按照以下JSON格式返回笑话:
{{
"setup": "笑话的铺垫",
"punchline": "笑话的包袱"
}}
只返回JSON格式,不要其他内容。""",
),
("human", "帮我写一个和 {topic} 相关的笑话"),
]
)
# 创建解析器
parser = JsonOutputParser(pydantic_object=Joke)
# 创建 chain
joke_chain = prompt_template | llm2 | parser
# 调用 chain
response = joke_chain.invoke({"topic": "cat"})
print(response)Output
{'setup': '为什么猫咪不喜欢玩扑克?', 'punchline': '因为遇到黑猫它们总是输!'}
总结一下
- 统一的用 init_chat_model / ChatXxxModel 初始化一个 chat model
- 统一的用 invoke(messages) or invoke({"topic": "xxxx"})
- 我们可以用 PromptTemplate 构建结构化的 模板
- (不重点),结构化输出
3. LangGraph Memory
In [204]python · cell 28
python
output = llm2.invoke(messages)
# memory
# message 以及 output , 两者要我们自己加起来;In [ ]python · cell 29
python
# class MessagesState(TypedDict):
# messages: Annotated[list[AnyMessage], add_messages]
# {
# "messages": []
# }In [206]python · cell 30
python
from langgraph.checkpoint.memory import MemorySaver
from langgraph.graph import START, MessagesState, StateGraph
# Define a new graph
workflow = StateGraph(state_schema=MessagesState)
# Define the function that calls the model
def call_model(state: MessagesState):
response = llm2.invoke(state["messages"])
return {"messages": response}
workflow.add_node("node1", call_model)
# Define the (single) node in the graph
workflow.add_edge(START, "node1")
# Add memory
memory = MemorySaver()
graph = workflow.compile(checkpointer=memory)In [207]python · cell 31
python
config = {"configurable": {"thread_id": "abc123"}}
query = "Hi! I'm chaofa."
input_messages = [HumanMessage(query)]
output = graph.invoke({"messages": input_messages}, config)
output["messages"][-1].pretty_print() # output contains all messages in stateOutput
==================================[1m Ai Message [0m================================== Hi Chaofa! 👋 It's great to meet you. How can I assist you today? Whether you have questions, need recommendations, or just want to chat, I'm here to help! 😊 Let me know what's on your mind—maybe a fun fact, a tricky problem, or even your favorite hobby?
In [208]python · cell 32
python
outputOutput
{'messages': [HumanMessage(content="Hi! I'm chaofa.", additional_kwargs={}, response_metadata={}, id='5c5441e2-b85f-4522-8a5b-e105ed75c06f'),
AIMessage(content="Hi Chaofa! 👋 It's great to meet you. How can I assist you today? Whether you have questions, need recommendations, or just want to chat, I'm here to help! 😊 \n\nLet me know what's on your mind—maybe a fun fact, a tricky problem, or even your favorite hobby?", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 67, 'prompt_tokens': 10, 'total_tokens': 77, 'completion_tokens_details': None, 'prompt_tokens_details': {'audio_tokens': None, 'cached_tokens': 0}, 'prompt_cache_hit_tokens': 0, 'prompt_cache_miss_tokens': 10}, 'model_name': 'deepseek-chat', 'system_fingerprint': 'fp_8802369eaa_prod0425fp8', 'id': 'f5d1c125-6ec3-4a17-9b45-4d2a2f693f7b', 'service_tier': None, 'finish_reason': 'stop', 'logprobs': None}, id='run--c5f75e2e-c1a2-47ff-b437-c9bb5d36bcae-0', usage_metadata={'input_tokens': 10, 'output_tokens': 67, 'total_tokens': 77, 'input_token_details': {'cache_read': 0}, 'output_token_details': {}})]}In [ ]python · cell 33
python
query = "What's my name?"
input_messages = [HumanMessage(query)]
output = graph.invoke({"messages": input_messages}, config)
output["messages"][-1].pretty_print()Output
==================================[1m Ai Message [0m================================== Your name is **Chaofa**! 🌟 (I remember because you've mentioned it twice—let me know if you'd prefer a nickname!) What’s on your mind, Chaofa? 😊
In [209]python · cell 34
python
config = {"configurable": {"thread_id": "abc345"}}
query = "What's my name?"
input_messages = [HumanMessage(query)]
output = graph.invoke({"messages": input_messages}, config)
output["messages"][-1].pretty_print()Output
==================================[1m Ai Message [0m================================== I don’t have access to personal information about you unless you share it with me. If you’d like, you can tell me your name, and I’ll be happy to use it in our conversation! 😊
4. Agents
4.1 Single Agent(With Tool)
In [211]python · cell 37
python
# function call 使用和 訓練
# https://www.bilibili.com/video/BV1cqdPY8EzT/In [212]python · cell 38
python
from langgraph.prebuilt import create_react_agentIn [213]python · cell 39
python
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
def multiply(a: int, b: int) -> int:
"""Multiply two numbers."""
return a * bIn [214]python · cell 40
python
agent = create_react_agent(
model=ChatDeepSeek(model=deepseek_chat_model, api_key=API_KEY),
tools=[multiply, add],
)In [215]python · cell 41
python
output = agent.invoke({"messages": [HumanMessage("帮我计算 1 + 2")]})In [216]python · cell 42
python
for item in output["messages"]:
item.pretty_print()Output
================================[1m Human Message [0m=================================
帮我计算 1 + 2
==================================[1m Ai Message [0m==================================
Tool Calls:
add (call_0_c1d0d208-ae81-4ded-a7ff-4bdb69b74666)
Call ID: call_0_c1d0d208-ae81-4ded-a7ff-4bdb69b74666
Args:
a: 1
b: 2
=================================[1m Tool Message [0m=================================
Name: add
3
==================================[1m Ai Message [0m==================================
1 + 2 = 3
In [125]python · cell 43
python
multi_output = agent.invoke({"messages": [HumanMessage("帮我计算 1 * 2")]})
for item in multi_output["messages"]:
item.pretty_print()Output
================================[1m Human Message [0m=================================
帮我计算 1 * 2
==================================[1m Ai Message [0m==================================
Tool Calls:
multiply (call_0_893cc7fc-8ac8-4012-a6c4-fff050050543)
Call ID: call_0_893cc7fc-8ac8-4012-a6c4-fff050050543
Args:
a: 1
b: 2
=================================[1m Tool Message [0m=================================
Name: multiply
2
==================================[1m Ai Message [0m==================================
1 乘以 2 的结果是 2。
4.2 DeepResearch
In [144]python · cell 45
python
# !pip install langchain_community
# !!pip install -U duckduckgo-search
# !!pip install -U langchain-tavilydr 概念理解
单一目标执行原则;
- planning agent 做规划,要搜索什么东西;
- search agent,根据 plan 调用 Search tool 检索结果;(可以循环的搜索)
- report agent,只需要写报告;
In [147]python · cell 47
python
from langchain_tavily import TavilySearch
search_tool = TavilySearch(
max_results=5, topic="general", tavily_api_key=os.environ.get("TAVILY_KEY")
)
search_tool.invoke("chaofa用代码打点酱油")Output
{'query': 'chaofa用代码打点酱油',
'follow_up_questions': None,
'answer': None,
'images': [],
'results': [{'title': 'bbruceyuan (Chaofa Yuan) - GitHub',
'url': 'https://github.com/bbruceyuan',
'content': '博客:https://bruceyuan.com 公众号👏:chaofa用代码打点酱油. bbruceyuan has 25 repositories available. Follow their code on GitHub.',
'score': 0.76554126,
'raw_content': None},
{'title': 'chaofa用代码打点酱油 | Notion',
'url': 'https://chaofa.notion.site/11a569b3ecce49b2826d679f5e2fdb54?v=1550d5d337e68005a0d5000c1d731b37',
'content': 'hi,我是 chaofa,目前是个大模型算法工程师,对于搜索、广告也有我一定的了解~ 这是我的 notion blog. 记录平常的一些学习记录,主要是 paper阅读方面的内容~ 此外会记录一些公开的创作计划; 个人中文博客: chaofa用代码打点酱油 (推荐)',
'score': 0.6506676,
'raw_content': None},
{'title': 'chaofa用代码打点酱油的动态 - 哔哩哔哩',
'url': 'https://www.bilibili.com/opus/987060205629997076',
'content': 'PyTorch手写多头注意力(Multi-Head Self-Attention)-- Self Attention 四重境界 part2(面试常考)',
'score': 0.52962893,
'raw_content': None},
{'title': 'chaofa用代码打点酱油 - YouTube',
'url': 'https://www.youtube.com/@bbruceyuan',
'content': '该频道主要会讲一些大模型相关的分享,让我们一起成长为大佬~欢迎阅读我的博客 bruceyuan.com 获得更好的文字阅读体验,或者',
'score': 0.5195463,
'raw_content': None},
{'title': 'chaofa用代码打点酱油',
'url': 'https://bruceyuan.com/',
'content': '杂谈 chaofa month-summary 深度解读 Kimi-K1.5,真正了解 RL 数据是怎么筛选的 深度解读 Kimi K1.5 论文,介绍其多模态推理模型的技术原理与发展路线,涵盖预训练、监督微调、强化学习及其核心启发,提供详细的算法处理细节和数据构建方法。',
'score': 0.4237686,
'raw_content': None}],
'response_time': 1.72}In [162]python · cell 48
python
# from langchain_core.messages import HumanMessage, SystemMessage
# from langgraph.prebuilt import create_react_agent
# from typing import List
# from pprint import pprint
# from langgraph.types import Send
# # Create plan agent
# plan_prompt = """You are a research planner. Break down the research task into specific steps.
# Format: List 1-3 key questions to answer."""
# class QueryAndReason(BaseModel):
# query: str = Field(..., description="检索的 Query,需要符合搜索习惯")
# reason: str = Field(..., description="为什么要检索这个 query")
# # Define the structured output format for plan agent
# class ResearchPlan(BaseModel):
# """Research plan with key questions"""
# questions: List[QueryAndReason] = Field(
# description="List of 1-3 key research questions to investigate.", max_items=3
# )
# plan_agent = ChatDeepSeek(
# model=deepseek_chat_model, api_key=API_KEY
# ).with_structured_output(ResearchPlan)
# pprint(plan_agent.invoke([HumanMessage("write an description about andrej karthy")]))In [217]python · cell 49
python
from pydantic import BaseModel, Field
from typing import List
from langgraph.graph import START, END
# Define the structured output format for plan agent
class ResearchPlan(BaseModel):
"""Research plan with key questions"""
questions: List[str] = Field(
description="List of 1-3 key research questions to investigate",
max_items=3
)
# planner agent 输出 json / markdown ( - [] 第一条要做的事情 -[ ] 第二条要做的事情)
# Create plan agent with structured output
plan_prompt = """You are a research planner. Break down the research task into specific steps.
Your response must be a JSON object with a 'questions' field containing 1-3 key research questions.
Example format:
{
"questions": [
"What is X?",
"How does Y work?",
"What are the implications of Z?"
]
}
Only return the JSON object, no other text."""
plan_agent = create_react_agent(
model=ChatDeepSeek(model=deepseek_chat_model, api_key=API_KEY),
tools=[],
prompt=plan_prompt
)
search_agent = create_react_agent(
model=ChatDeepSeek(model=deepseek_chat_model, api_key=API_KEY),
tools=[search_tool],
prompt="you are a helpful assistant. you can search result in search_tool. 当你获得检索结果之后,输出“检索完毕”,必要额外输出任何东西。",
)
report_agent = create_react_agent(
model=ChatDeepSeek(model=deepseek_chat_model, api_key=API_KEY),
tools=[],
prompt="你是一个擅长写作的人。 你可以根据用户的问题,以及检索的结果,生成一个最终的报告。"
)
# plan -> search -> report
# Create state graph with custom state
class ResearchState(MessagesState):
"""Custom state that includes research plan"""
plan: ResearchPlan | None = None
# Update workflow with new state
workflow = StateGraph(ResearchState)
# Add nodes and edges with state transformations
workflow.add_node("plan_agent", plan_agent)
workflow.add_node("search_agent", search_agent)
workflow.add_node("report_agent", report_agent)
workflow.add_edge(START, "plan_agent")
workflow.add_edge("plan_agent", "search_agent")
workflow.add_edge("search_agent", "report_agent")
workflow.add_edge("report_agent", END)
# Compile workflow
app = workflow.compile()In [173]python · cell 50
python
output = app.invoke(
{"messages": [
HumanMessage("write an description about andrej karthy")
]}
)In [174]python · cell 51
python
outputOutput
{'messages': [HumanMessage(content='write an description about andrej karthy', additional_kwargs={}, response_metadata={}, id='6ec66ea6-15f4-4ee5-a70a-8354000a4acc'),
AIMessage(content='```json\n{\n "questions": [\n "Who is Andrej Karpathy and what are his notable contributions in the field of AI and machine learning?",\n "What roles has Andrej Karpathy held at companies like OpenAI and Tesla?",\n "What are some of Andrej Karpathy\'s most influential projects or publications?"\n ]\n}\n```', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 75, 'prompt_tokens': 94, 'total_tokens': 169, 'completion_tokens_details': None, 'prompt_tokens_details': {'audio_tokens': None, 'cached_tokens': 64}, 'prompt_cache_hit_tokens': 64, 'prompt_cache_miss_tokens': 30}, 'model_name': 'deepseek-chat', 'system_fingerprint': 'fp_8802369eaa_prod0425fp8', 'id': '00df10ab-adc5-4a2d-bad6-67a1391d03ce', 'service_tier': None, 'finish_reason': 'stop', 'logprobs': None}, id='run--1a15fa77-1708-44d4-ae76-54a1ff509d01-0', usage_metadata={'input_tokens': 94, 'output_tokens': 75, 'total_tokens': 169, 'input_token_details': {'cache_read': 64}, 'output_token_details': {}}),
AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_0_9f568643-fc2c-4b87-83f8-24e746141279', 'function': {'arguments': '{"query": "Who is Andrej Karpathy and what are his notable contributions in the field of AI and machine learning?"}', 'name': 'tavily_search'}, 'type': 'function', 'index': 0}, {'id': 'call_1_c86e7717-4d5b-4ba0-a4d7-aea74be2848f', 'function': {'arguments': '{"query": "What roles has Andrej Karpathy held at companies like OpenAI and Tesla?"}', 'name': 'tavily_search'}, 'type': 'function', 'index': 1}, {'id': 'call_2_c81df54b-e458-4137-800a-b600551eb765', 'function': {'arguments': '{"query": "What are some of Andrej Karpathy\'s most influential projects or publications?"}', 'name': 'tavily_search'}, 'type': 'function', 'index': 2}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 112, 'prompt_tokens': 1350, 'total_tokens': 1462, 'completion_tokens_details': None, 'prompt_tokens_details': {'audio_tokens': None, 'cached_tokens': 0}, 'prompt_cache_hit_tokens': 0, 'prompt_cache_miss_tokens': 1350}, 'model_name': 'deepseek-chat', 'system_fingerprint': 'fp_8802369eaa_prod0425fp8', 'id': 'aeba1e3d-5f99-46e9-b7a5-fdd155c3fdcd', 'service_tier': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run--159fd3cd-a188-4edc-b5de-4d6141213571-0', tool_calls=[{'name': 'tavily_search', 'args': {'query': 'Who is Andrej Karpathy and what are his notable contributions in the field of AI and machine learning?'}, 'id': 'call_0_9f568643-fc2c-4b87-83f8-24e746141279', 'type': 'tool_call'}, {'name': 'tavily_search', 'args': {'query': 'What roles has Andrej Karpathy held at companies like OpenAI and Tesla?'}, 'id': 'call_1_c86e7717-4d5b-4ba0-a4d7-aea74be2848f', 'type': 'tool_call'}, {'name': 'tavily_search', 'args': {'query': "What are some of Andrej Karpathy's most influential projects or publications?"}, 'id': 'call_2_c81df54b-e458-4137-800a-b600551eb765', 'type': 'tool_call'}], usage_metadata={'input_tokens': 1350, 'output_tokens': 112, 'total_tokens': 1462, 'input_token_details': {'cache_read': 0}, 'output_token_details': {}}),
ToolMessage(content='{"query": "Who is Andrej Karpathy and what are his notable contributions in the field of AI and machine learning?", "follow_up_questions": null, "answer": null, "images": [], "results": [{"title": "Andrej Karpathy. Bridging the Gap Between Academia and… | by ...", "url": "https://medium.com/thedeephub/andrej-karpathy-bridging-the-gap-between-academia-and-ai-in-the-real-world-bc55e8649fb8", "content": "During his Ph.D., Karpathy worked under the guidance of Fei-Fei Li, a prominent figure in AI, and became deeply involved in the development of Convolutional Neural Networks (CNNs), a cornerstone technology in the field of computer vision. After completing his Ph.D. at Stanford, Karpathy emerged as a leading figure in the AI research community, particularly in the domains of deep learning and computer vision. One of Karpathy’s most notable academic contributions was his work on image captioning — teaching AI systems to generate descriptive text for images. Karpathy’s work at Tesla involved deep neural networks, particularly focusing on computer vision. Andrej Karpathy’s educational contributions are notable for their impact on the field of artificial intelligence and machine learning, especially in making complex concepts accessible to a broader audience.", "score": 0.8851659, "raw_content": null}, {"title": "Andrej Karpathy - The Education Journey of a Leading AI Expert and ...", "url": "https://aiforsocialgood.ca/blog/andrej-karpathy-the-education-journey-of-a-leading-ai-expert-and-teslas-director-of-ai", "content": "Deep Learning and Machine Learning. During his studies, Karpathy devoted significant time and effort to deep learning and machine learning. These disciplines allowed him to develop a deep understanding of how computers can learn and adapt from large amounts of data, paving the way for his notable contributions to the field. Focus on Neural Networks", "score": 0.8116913, "raw_content": null}, {"title": "Andrej Karpathy - Wikipedia", "url": "https://en.wikipedia.org/wiki/Andrej_Karpathy", "content": "He co-founded and formerly worked at OpenAI,[3][4][5] where he specialized in deep learning and computer vision. [6][7][1][8] Education and early life [edit] Karpathy was born in Bratislava, Czechoslovakia (now Slovakia)[9][10][11][12] and moved with his family to Toronto when he was 15. [13] He completed his Computer Science and Physics bachelor\'s degrees at University of Toronto in 2009[14] and his master\'s degree at University of British Columbia in 2011,[14] where he worked on physically-simulated figures (for example, a simulated runner or a simulated person in a crowd) with his adviser Michiel van de Panne. Karpathy received a PhD from Stanford University in 2015 under the supervision of Fei-Fei Li, focusing on the intersection of natural language processing and computer vision, and deep learning models suited for this task.", "score": 0.7471924, "raw_content": null}, {"title": "Who is Andrej Karpathy — OpenAI to Tesla & Back - Gold Penguin", "url": "https://goldpenguin.org/blog/who-is-andrej-karpathy/", "content": "Published Time: 2024-03-29T04:54:00+00:00 Who is Andrej Karpathy — OpenAI to Tesla & Back | Gold Penguin Gold Penguin ToolsCategoriesBlogGet FeaturedSubmit a Product ToolsCategoriesBlogGet FeaturedSubmit a Product Artificial Intelligence Who is Andrej Karpathy — OpenAI to Tesla & Back Andrej Karpathy is another noteworthy figure in the AI industry who’s played a pivotal role in OpenAI and Tesla. Moreover, the advent of autonomous vehicles wouldn’t be a thing nowadays if not for this one person who’s also worked behind the scenes: Andrej Karpathy. He has worked with OpenAI and Tesla to join them in their AI missions. In this article, we’ll dive into the story of how he started traversing the world of AI from theoretical research to practical application.", "score": 0.7306941, "raw_content": null}, {"title": "Andrej Karpathy: The 100 Most Influential People in AI 2024 - TIME", "url": "https://time.com/7012851/andrej-karpathy/", "content": "Andrej Karpathy’s name is strewn across the history of modern AI. In 2015, Karpathy, alongside his colleague Professor Fei-Fei Li, designed Stanford University’s first course dedicated to deep-learning, for which he was the primary instructor. “I’m a little bit obsessed with coming to the core of things, ” Karpathy says. His latest venture, Eureka Labs, founded July 2024, aims to build a school that is “AI native.” Its first product will be an undergraduate-level course on AI, designed by a human and guided by an AI teaching assistant. When he first built his AI course at Stanford nine years ago, he was working part-time, and it was done over a few months. Buy your copy of the TIME100 AI issue here", "score": 0.6383174, "raw_content": null}], "response_time": 2.52}', name='tavily_search', id='1ddfe173-9403-4a00-946e-8e44c99d490b', tool_call_id='call_0_9f568643-fc2c-4b87-83f8-24e746141279'),
ToolMessage(content='{"query": "What roles has Andrej Karpathy held at companies like OpenAI and Tesla?", "follow_up_questions": null, "answer": null, "images": [], "results": [{"title": "Andrej Karpathy Departs From OpenAI to Pursue Personal Projects", "url": "https://www.cryptopolitan.com/andrej-karpathy-parts-ways-with-openai/", "content": "Andrej Karpathy has left OpenAI to focus on personal projects. He previously played a key role in AI development at Tesla and has been a significant figure in the AI community. ... Before his latest tenure at OpenAI, Karpathy held a pivotal role at Tesla, where he was instrumental in advancing the electric vehicle giant\'s AI capabilities", "score": 0.9039154, "raw_content": null}, {"title": "6 A.I. Startups Backed by OpenAI Co-Founder Andrej Karpathy - Observer", "url": "https://observer.com/2025/02/openai-cofounder-andrej-karpathy-ai-startups/", "content": "As one of OpenAI\'s 11 co-founders, he played a key role in developing the GPT model before leaving in 2017 to lead Tesla\'s Autopilot effort. He returned to OpenAI in February 2023 as a", "score": 0.85216236, "raw_content": null}, {"title": "Who is Andrej Karpathy — OpenAI to Tesla & Back - Gold Penguin", "url": "https://goldpenguin.org/blog/who-is-andrej-karpathy/", "content": "Before Karpathy\'s Affair with OpenAI and Tesla. Andrej first found his place in academia, then into the divisions of Google. Here are the things that he\'s done prior to his OpenAI-Tesla ventures while in his Stanford and Google era, and everything in between. His Role in Google Brain, Research, and DeepMind", "score": 0.85097736, "raw_content": null}, {"title": "Andrej Karpathy - The AI Champion. - LinkedIn", "url": "https://www.linkedin.com/pulse/andrej-karpathy-ai-champion-serviots-tianf", "content": "After leaving Tesla in 2022, Karpathy returned to OpenAI in 2023 to lead a small team focused on improving GPT-4 and ChatGPT. However, his current passion lies in AI-driven education and fostering", "score": 0.8443195, "raw_content": null}, {"title": "The Professional Journey of Andrej Karpathy - Perplexity", "url": "https://www.perplexity.ai/page/the-professional-journey-of-an-OvR1nmNIQNS5gJPAtPMk5w", "content": "Andrej Karpathy\'s association with OpenAI has been marked by two distinct periods of involvement, each contributing significantly to the organization\'s development in artificial intelligence. Initially joining as one of the founding members, Karpathy played a pivotal role in the early stages of OpenAI, helping to establish its reputation as a", "score": 0.7407191, "raw_content": null}], "response_time": 1.74}', name='tavily_search', id='d33ab955-6983-4985-a30e-67ad9f3cceee', tool_call_id='call_1_c86e7717-4d5b-4ba0-a4d7-aea74be2848f'),
ToolMessage(content='{"query": "What are some of Andrej Karpathy\'s most influential projects or publications?", "follow_up_questions": null, "answer": null, "images": [], "results": [{"title": "Andrej Karpathy: The 100 Most Influential People in AI 2024 - TIME", "url": "https://time.com/7012851/andrej-karpathy/", "content": "Andrej Karpathy’s name is strewn across the history of modern AI. In 2015, Karpathy, alongside his colleague Professor Fei-Fei Li, designed Stanford University’s first course dedicated to deep-learning, for which he was the primary instructor. “I’m a little bit obsessed with coming to the core of things, ” Karpathy says. His latest venture, Eureka Labs, founded July 2024, aims to build a school that is “AI native.” Its first product will be an undergraduate-level course on AI, designed by a human and guided by an AI teaching assistant. When he first built his AI course at Stanford nine years ago, he was working part-time, and it was done over a few months. Buy your copy of the TIME100 AI issue here", "score": 0.70483154, "raw_content": null}, {"title": "Andrej Karpathy\'s research works | Stanford University, CA (SU) and ...", "url": "https://www.researchgate.net/scientific-contributions/Andrej-Karpathy-70761057", "content": "Andrej Karpathy\'s 14 research works with 53,299 citations and 32,220 reads, including: PixelCNN++: Improving the PixelCNN with Discretized Logistic Mixture Likelihood and Other Modifications", "score": 0.62633044, "raw_content": null}, {"title": "\u202aAndrej Karpathy\u202c - \u202aGoogle Scholar\u202c", "url": "https://scholar.google.com/citations?user=l8WuQJgAAAAJ&hl=en", "content": "Andrej Karpathy. Computer Science PhD student, Stanford University. Verified email at cs.stanford.edu - Homepage. Machine Learning Computer Vision Artificial Intelligence. ... A Karpathy, S Miller, L Fei-Fei. 2013 IEEE International Conference on Robotics and Automation, 2088-2095, 2013. 230:", "score": 0.5654673, "raw_content": null}, {"title": "Unlock Genius: Dive Into Andrej Karpathy\'s Top 8 Mind ... - Medium", "url": "https://medium.com/@Reviewbooks/unlock-genius-dive-into-andrej-karpathys-top-8-mind-blowing-book-picks-7458dcbef3b1", "content": "Why is Andrej Karpathy so famous? Andrej Karpathy has gained widespread recognition for his significant contributions to the field of artificial intelligence (AI), particularly in the development", "score": 0.49538648, "raw_content": null}, {"title": "Andrej Karpathy", "url": "https://karpathy.ai/", "content": "2024 - I started Eureka Labs, a new AI+Education company. Meanwhile, I also make educational videos on AI on my YouTube channel. General audience track: Deep Dive into LLMs like ChatGPT is on under-the hood fundamentals of LLMs. 2017 - 2022 I was the Sr. Director of AI at Tesla, where I led the computer vision team of Tesla Autopilot. This includes in-house data labeling, neural network training, the science of making it work, and deployment in production running on our custom inference chip.", "score": 0.40967003, "raw_content": null}], "response_time": 2.13}', name='tavily_search', id='6c5a6a9c-cd28-4f49-8fd9-a8a2be6f9cef', tool_call_id='call_2_c81df54b-e458-4137-800a-b600551eb765'),
AIMessage(content='检索完毕', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 2, 'prompt_tokens': 4054, 'total_tokens': 4056, 'completion_tokens_details': None, 'prompt_tokens_details': {'audio_tokens': None, 'cached_tokens': 1344}, 'prompt_cache_hit_tokens': 1344, 'prompt_cache_miss_tokens': 2710}, 'model_name': 'deepseek-chat', 'system_fingerprint': 'fp_8802369eaa_prod0425fp8', 'id': '9459ef60-f220-4b23-956e-00923f12ad6b', 'service_tier': None, 'finish_reason': 'stop', 'logprobs': None}, id='run--d50f2bb9-5e92-499b-aa86-67bbcf79bf02-0', usage_metadata={'input_tokens': 4054, 'output_tokens': 2, 'total_tokens': 4056, 'input_token_details': {'cache_read': 1344}, 'output_token_details': {}}),
AIMessage(content="# Andrej Karpathy: AI Visionary and Innovator\n\n## Who is Andrej Karpathy?\n\nAndrej Karpathy is a leading figure in artificial intelligence and machine learning, known for his significant contributions to deep learning, computer vision, and autonomous systems. Born in Bratislava (now Slovakia), he moved to Toronto at age 15 and completed his education in computer science and physics at the University of Toronto, followed by a master's at the University of British Columbia and a PhD at Stanford University under AI pioneer Fei-Fei Li.\n\n## Notable Contributions\n\nKarpathy has made several groundbreaking contributions to AI:\n\n- **Convolutional Neural Networks (CNNs)**: Worked on advancing this cornerstone technology in computer vision during his PhD\n- **Image Captioning**: Developed AI systems capable of generating descriptive text for images\n- **Deep Learning Education**: Co-designed Stanford University's first deep learning course in 2015 with Fei-Fei Li\n- **Autonomous Vehicles**: Advanced Tesla's Autopilot capabilities through deep neural networks\n\n## Professional Roles\n\nKarpathy has held key positions at major technology companies:\n\n- **OpenAI**: \n - Co-founded OpenAI and specialized in deep learning and computer vision\n - Returned in 2023 to lead a team improving GPT-4 and ChatGPT\n- **Tesla**: \n - Served as Senior Director of AI (2017-2022)\n - Led Tesla's computer vision team for Autopilot\n - Oversaw in-house data labeling, neural network training, and production deployment\n\n## Influential Projects and Publications\n\nKarpathy's most impactful work includes:\n\n- **Stanford's Deep Learning Course**: Pioneering curriculum that educated thousands in AI\n- **PixelCNN++**: Improved image generation model with discretized logistic mixture likelihood\n- **Autonomous Driving Systems**: Developed Tesla's vision-based self-driving technology\n- **Eureka Labs**: His newest venture (founded 2024) creating AI-native education solutions\n\nWith over 53,000 citations for his research works, Karpathy continues to shape the AI field through both technical innovation and education. His current focus includes AI-driven learning platforms that combine human expertise with AI teaching assistants.", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 457, 'prompt_tokens': 2817, 'total_tokens': 3274, 'completion_tokens_details': None, 'prompt_tokens_details': {'audio_tokens': None, 'cached_tokens': 0}, 'prompt_cache_hit_tokens': 0, 'prompt_cache_miss_tokens': 2817}, 'model_name': 'deepseek-chat', 'system_fingerprint': 'fp_8802369eaa_prod0425fp8', 'id': 'badc381f-6e4a-40a3-b5df-c04884b9314b', 'service_tier': None, 'finish_reason': 'stop', 'logprobs': None}, id='run--7cbdff1a-2da8-413d-b2e2-05a15759b9bc-0', usage_metadata={'input_tokens': 2817, 'output_tokens': 457, 'total_tokens': 3274, 'input_token_details': {'cache_read': 0}, 'output_token_details': {}})]}In [175]python · cell 52
python
for item in output["messages"]:
item.pretty_print()Output
================================[1m Human Message [0m=================================
write an description about andrej karthy
==================================[1m Ai Message [0m==================================
```json
{
"questions": [
"Who is Andrej Karpathy and what are his notable contributions in the field of AI and machine learning?",
"What roles has Andrej Karpathy held at companies like OpenAI and Tesla?",
"What are some of Andrej Karpathy's most influential projects or publications?"
]
}
```
==================================[1m Ai Message [0m==================================
Tool Calls:
tavily_search (call_0_9f568643-fc2c-4b87-83f8-24e746141279)
Call ID: call_0_9f568643-fc2c-4b87-83f8-24e746141279
Args:
query: Who is Andrej Karpathy and what are his notable contributions in the field of AI and machine learning?
tavily_search (call_1_c86e7717-4d5b-4ba0-a4d7-aea74be2848f)
Call ID: call_1_c86e7717-4d5b-4ba0-a4d7-aea74be2848f
Args:
query: What roles has Andrej Karpathy held at companies like OpenAI and Tesla?
tavily_search (call_2_c81df54b-e458-4137-800a-b600551eb765)
Call ID: call_2_c81df54b-e458-4137-800a-b600551eb765
Args:
query: What are some of Andrej Karpathy's most influential projects or publications?
=================================[1m Tool Message [0m=================================
Name: tavily_search
{"query": "Who is Andrej Karpathy and what are his notable contributions in the field of AI and machine learning?", "follow_up_questions": null, "answer": null, "images": [], "results": [{"title": "Andrej Karpathy. Bridging the Gap Between Academia and… | by ...", "url": "https://medium.com/thedeephub/andrej-karpathy-bridging-the-gap-between-academia-and-ai-in-the-real-world-bc55e8649fb8", "content": "During his Ph.D., Karpathy worked under the guidance of Fei-Fei Li, a prominent figure in AI, and became deeply involved in the development of Convolutional Neural Networks (CNNs), a cornerstone technology in the field of computer vision. After completing his Ph.D. at Stanford, Karpathy emerged as a leading figure in the AI research community, particularly in the domains of deep learning and computer vision. One of Karpathy’s most notable academic contributions was his work on image captioning — teaching AI systems to generate descriptive text for images. Karpathy’s work at Tesla involved deep neural networks, particularly focusing on computer vision. Andrej Karpathy’s educational contributions are notable for their impact on the field of artificial intelligence and machine learning, especially in making complex concepts accessible to a broader audience.", "score": 0.8851659, "raw_content": null}, {"title": "Andrej Karpathy - The Education Journey of a Leading AI Expert and ...", "url": "https://aiforsocialgood.ca/blog/andrej-karpathy-the-education-journey-of-a-leading-ai-expert-and-teslas-director-of-ai", "content": "Deep Learning and Machine Learning. During his studies, Karpathy devoted significant time and effort to deep learning and machine learning. These disciplines allowed him to develop a deep understanding of how computers can learn and adapt from large amounts of data, paving the way for his notable contributions to the field. Focus on Neural Networks", "score": 0.8116913, "raw_content": null}, {"title": "Andrej Karpathy - Wikipedia", "url": "https://en.wikipedia.org/wiki/Andrej_Karpathy", "content": "He co-founded and formerly worked at OpenAI,[3][4][5] where he specialized in deep learning and computer vision. [6][7][1][8] Education and early life [edit] Karpathy was born in Bratislava, Czechoslovakia (now Slovakia)[9][10][11][12] and moved with his family to Toronto when he was 15. [13] He completed his Computer Science and Physics bachelor's degrees at University of Toronto in 2009[14] and his master's degree at University of British Columbia in 2011,[14] where he worked on physically-simulated figures (for example, a simulated runner or a simulated person in a crowd) with his adviser Michiel van de Panne. Karpathy received a PhD from Stanford University in 2015 under the supervision of Fei-Fei Li, focusing on the intersection of natural language processing and computer vision, and deep learning models suited for this task.", "score": 0.7471924, "raw_content": null}, {"title": "Who is Andrej Karpathy — OpenAI to Tesla & Back - Gold Penguin", "url": "https://goldpenguin.org/blog/who-is-andrej-karpathy/", "content": "Published Time: 2024-03-29T04:54:00+00:00 Who is Andrej Karpathy — OpenAI to Tesla & Back | Gold Penguin Gold Penguin ToolsCategoriesBlogGet FeaturedSubmit a Product ToolsCategoriesBlogGet FeaturedSubmit a Product Artificial Intelligence Who is Andrej Karpathy — OpenAI to Tesla & Back Andrej Karpathy is another noteworthy figure in the AI industry who’s played a pivotal role in OpenAI and Tesla. Moreover, the advent of autonomous vehicles wouldn’t be a thing nowadays if not for this one person who’s also worked behind the scenes: Andrej Karpathy. He has worked with OpenAI and Tesla to join them in their AI missions. In this article, we’ll dive into the story of how he started traversing the world of AI from theoretical research to practical application.", "score": 0.7306941, "raw_content": null}, {"title": "Andrej Karpathy: The 100 Most Influential People in AI 2024 - TIME", "url": "https://time.com/7012851/andrej-karpathy/", "content": "Andrej Karpathy’s name is strewn across the history of modern AI. In 2015, Karpathy, alongside his colleague Professor Fei-Fei Li, designed Stanford University’s first course dedicated to deep-learning, for which he was the primary instructor. “I’m a little bit obsessed with coming to the core of things, ” Karpathy says. His latest venture, Eureka Labs, founded July 2024, aims to build a school that is “AI native.” Its first product will be an undergraduate-level course on AI, designed by a human and guided by an AI teaching assistant. When he first built his AI course at Stanford nine years ago, he was working part-time, and it was done over a few months. Buy your copy of the TIME100 AI issue here", "score": 0.6383174, "raw_content": null}], "response_time": 2.52}
=================================[1m Tool Message [0m=================================
Name: tavily_search
{"query": "What roles has Andrej Karpathy held at companies like OpenAI and Tesla?", "follow_up_questions": null, "answer": null, "images": [], "results": [{"title": "Andrej Karpathy Departs From OpenAI to Pursue Personal Projects", "url": "https://www.cryptopolitan.com/andrej-karpathy-parts-ways-with-openai/", "content": "Andrej Karpathy has left OpenAI to focus on personal projects. He previously played a key role in AI development at Tesla and has been a significant figure in the AI community. ... Before his latest tenure at OpenAI, Karpathy held a pivotal role at Tesla, where he was instrumental in advancing the electric vehicle giant's AI capabilities", "score": 0.9039154, "raw_content": null}, {"title": "6 A.I. Startups Backed by OpenAI Co-Founder Andrej Karpathy - Observer", "url": "https://observer.com/2025/02/openai-cofounder-andrej-karpathy-ai-startups/", "content": "As one of OpenAI's 11 co-founders, he played a key role in developing the GPT model before leaving in 2017 to lead Tesla's Autopilot effort. He returned to OpenAI in February 2023 as a", "score": 0.85216236, "raw_content": null}, {"title": "Who is Andrej Karpathy — OpenAI to Tesla & Back - Gold Penguin", "url": "https://goldpenguin.org/blog/who-is-andrej-karpathy/", "content": "Before Karpathy's Affair with OpenAI and Tesla. Andrej first found his place in academia, then into the divisions of Google. Here are the things that he's done prior to his OpenAI-Tesla ventures while in his Stanford and Google era, and everything in between. His Role in Google Brain, Research, and DeepMind", "score": 0.85097736, "raw_content": null}, {"title": "Andrej Karpathy - The AI Champion. - LinkedIn", "url": "https://www.linkedin.com/pulse/andrej-karpathy-ai-champion-serviots-tianf", "content": "After leaving Tesla in 2022, Karpathy returned to OpenAI in 2023 to lead a small team focused on improving GPT-4 and ChatGPT. However, his current passion lies in AI-driven education and fostering", "score": 0.8443195, "raw_content": null}, {"title": "The Professional Journey of Andrej Karpathy - Perplexity", "url": "https://www.perplexity.ai/page/the-professional-journey-of-an-OvR1nmNIQNS5gJPAtPMk5w", "content": "Andrej Karpathy's association with OpenAI has been marked by two distinct periods of involvement, each contributing significantly to the organization's development in artificial intelligence. Initially joining as one of the founding members, Karpathy played a pivotal role in the early stages of OpenAI, helping to establish its reputation as a", "score": 0.7407191, "raw_content": null}], "response_time": 1.74}
=================================[1m Tool Message [0m=================================
Name: tavily_search
{"query": "What are some of Andrej Karpathy's most influential projects or publications?", "follow_up_questions": null, "answer": null, "images": [], "results": [{"title": "Andrej Karpathy: The 100 Most Influential People in AI 2024 - TIME", "url": "https://time.com/7012851/andrej-karpathy/", "content": "Andrej Karpathy’s name is strewn across the history of modern AI. In 2015, Karpathy, alongside his colleague Professor Fei-Fei Li, designed Stanford University’s first course dedicated to deep-learning, for which he was the primary instructor. “I’m a little bit obsessed with coming to the core of things, ” Karpathy says. His latest venture, Eureka Labs, founded July 2024, aims to build a school that is “AI native.” Its first product will be an undergraduate-level course on AI, designed by a human and guided by an AI teaching assistant. When he first built his AI course at Stanford nine years ago, he was working part-time, and it was done over a few months. Buy your copy of the TIME100 AI issue here", "score": 0.70483154, "raw_content": null}, {"title": "Andrej Karpathy's research works | Stanford University, CA (SU) and ...", "url": "https://www.researchgate.net/scientific-contributions/Andrej-Karpathy-70761057", "content": "Andrej Karpathy's 14 research works with 53,299 citations and 32,220 reads, including: PixelCNN++: Improving the PixelCNN with Discretized Logistic Mixture Likelihood and Other Modifications", "score": 0.62633044, "raw_content": null}, {"title": "Andrej Karpathy - Google Scholar", "url": "https://scholar.google.com/citations?user=l8WuQJgAAAAJ&hl=en", "content": "Andrej Karpathy. Computer Science PhD student, Stanford University. Verified email at cs.stanford.edu - Homepage. Machine Learning Computer Vision Artificial Intelligence. ... A Karpathy, S Miller, L Fei-Fei. 2013 IEEE International Conference on Robotics and Automation, 2088-2095, 2013. 230:", "score": 0.5654673, "raw_content": null}, {"title": "Unlock Genius: Dive Into Andrej Karpathy's Top 8 Mind ... - Medium", "url": "https://medium.com/@Reviewbooks/unlock-genius-dive-into-andrej-karpathys-top-8-mind-blowing-book-picks-7458dcbef3b1", "content": "Why is Andrej Karpathy so famous? Andrej Karpathy has gained widespread recognition for his significant contributions to the field of artificial intelligence (AI), particularly in the development", "score": 0.49538648, "raw_content": null}, {"title": "Andrej Karpathy", "url": "https://karpathy.ai/", "content": "2024 - I started Eureka Labs, a new AI+Education company. Meanwhile, I also make educational videos on AI on my YouTube channel. General audience track: Deep Dive into LLMs like ChatGPT is on under-the hood fundamentals of LLMs. 2017 - 2022 I was the Sr. Director of AI at Tesla, where I led the computer vision team of Tesla Autopilot. This includes in-house data labeling, neural network training, the science of making it work, and deployment in production running on our custom inference chip.", "score": 0.40967003, "raw_content": null}], "response_time": 2.13}
==================================[1m Ai Message [0m==================================
检索完毕
==================================[1m Ai Message [0m==================================
# Andrej Karpathy: AI Visionary and Innovator
## Who is Andrej Karpathy?
Andrej Karpathy is a leading figure in artificial intelligence and machine learning, known for his significant contributions to deep learning, computer vision, and autonomous systems. Born in Bratislava (now Slovakia), he moved to Toronto at age 15 and completed his education in computer science and physics at the University of Toronto, followed by a master's at the University of British Columbia and a PhD at Stanford University under AI pioneer Fei-Fei Li.
## Notable Contributions
Karpathy has made several groundbreaking contributions to AI:
- **Convolutional Neural Networks (CNNs)**: Worked on advancing this cornerstone technology in computer vision during his PhD
- **Image Captioning**: Developed AI systems capable of generating descriptive text for images
- **Deep Learning Education**: Co-designed Stanford University's first deep learning course in 2015 with Fei-Fei Li
- **Autonomous Vehicles**: Advanced Tesla's Autopilot capabilities through deep neural networks
## Professional Roles
Karpathy has held key positions at major technology companies:
- **OpenAI**:
- Co-founded OpenAI and specialized in deep learning and computer vision
- Returned in 2023 to lead a team improving GPT-4 and ChatGPT
- **Tesla**:
- Served as Senior Director of AI (2017-2022)
- Led Tesla's computer vision team for Autopilot
- Oversaw in-house data labeling, neural network training, and production deployment
## Influential Projects and Publications
Karpathy's most impactful work includes:
- **Stanford's Deep Learning Course**: Pioneering curriculum that educated thousands in AI
- **PixelCNN++**: Improved image generation model with discretized logistic mixture likelihood
- **Autonomous Driving Systems**: Developed Tesla's vision-based self-driving technology
- **Eureka Labs**: His newest venture (founded 2024) creating AI-native education solutions
With over 53,000 citations for his research works, Karpathy continues to shape the AI field through both technical innovation and education. His current focus includes AI-driven learning platforms that combine human expertise with AI teaching assistants.
In [170]python · cell 53
python
events = app.stream(
{"messages": [{"role": "user", "content": "帮我写一个 chaofa 的个人生平"}]},
config,
stream_mode="values",
)
for event in events:
event["messages"][-1].pretty_print()Output
================================[1m Human Message [0m=================================
帮我写一个 chaofa 的个人生平
==================================[1m Ai Message [0m==================================
```json
{
"questions": [
"Who is Chaofa and what are their notable achievements?",
"What are the key events in Chaofa's life?",
"How has Chaofa contributed to their field or society?"
]
}
```
==================================[1m Ai Message [0m==================================
以下是根据搜索结果整理的关于“Chaofa”的个人生平信息:
---
### **Chaofa 的生平与成就**
1. **Zhang Chaofa(张朝发)**
- **背景**:张朝发是中国清朝时期的一位将领,活跃于鸦片战争期间。
- **关键事件**:
- 在鸦片战争中,张朝发率领军队与英军作战,并在战斗中表现出色。
- 在一次战斗中,他利用敌军船只漏水的机会追击并取得胜利,因此被连续三次晋升,最终成为总兵(高级将领)。
- 然而,在定海失守后,朝廷调查责任时,张朝发被错误指控为战败的罪魁祸首,最终被处决。
- **贡献**:他的英勇作战和牺牲精神在鸦片战争中留下了深刻的印记。
2. **Hmong ChaoFa(苗族王国)**
- **背景**:Hmong ChaoFa 是一个致力于为老挝苗族人民争取自决权的组织。
- **关键事件**:
- 1998年,Hmong ChaoFa 通过了宪法,并开始为苗族人民的权利和自由奋斗。
- 该组织的领导人因其在冲突解决和受压迫人民权利方面的贡献,获得了荷兰政府的骑士称号。
- **贡献**:Hmong ChaoFa 在国际社会中为苗族人民的权益发声,并致力于和平与自决。
3. **Wei Chaofa(魏朝发)**
- **背景**:魏朝发是一位艺术家,其作品和生平在 MutualArt 等艺术平台上有记录。
- **贡献**:他的艺术创作可能对当代艺术领域有所影响,但具体成就需进一步查阅。
4. **Biography Chaofa(传记潮发)**
- **背景**:这是一个专注于食品安全的牛肉火锅品牌,拥有自己的牛养殖基地和分销链。
- **贡献**:通过严格控制食品安全,为消费者提供高质量的食品。
---
### 总结
“Chaofa”这一名称可能指代不同的人物或组织,包括历史人物张朝发、苗族权利组织 Hmong ChaoFa、艺术家魏朝发或商业品牌传记潮发。如果您需要更具体的信息,请提供更多背景或明确所指的对象。
==================================[1m Ai Message [0m==================================
以下是关于不同领域"Chaofa"的详细生平报告整理:
一、历史人物:张朝发(清代抗英将领)
1. 军事生涯
- 鸦片战争时期清军将领
- 在定海保卫战中指挥作战
- 曾利用敌军战船漏水时机成功追击获胜
- 因战功获三次晋升至总兵衔
2. 历史事件
- 1841年定海失守后被朝廷追责
- 遭钦差大臣诬陷承担战败责任
- 最终被冤判斩首
- 成为鸦片战争首位殉国的高级将领
3. 历史评价
- 体现晚清军人气节
- 其冤案反映清朝军政体系弊端
- 现被视为民族气节象征人物
二、社会组织:Hmong ChaoFa(老挝苗族权益组织)
1. 成立发展
- 1998年正式成立并颁布宪法
- 致力于老挝苗族民族自决运动
- 2018年加入UNPO(无代表国家与民族组织)
2. 主要活动
- 争取苗族政治权利
- 反对老挝政府土地侵占政策
- 建立海外联络网络
- 领导人获荷兰政府骑士勋章
3. 现状挑战
- 成员常遭老挝军方打击
- 2018年遭遇军事袭击造成伤亡
- 持续受到老挝政府压制
三、商业品牌:传记潮发(餐饮企业)
1. 经营特色
- 宁夏自有肉牛养殖基地
- 广州至宁夏全程冷链配送
- 主打高端牛肉火锅市场
- 实现从牧场到餐桌全链条管控
2. 企业理念
- 严格食品安全标准
- 主打优质秦川牛肉
- 建立自有物流团队
- 强调食材可追溯体系
四、其他相关人物
1. 魏朝发
- 当代艺术家
- 作品见于MutualArt等平台
- 具体艺术成就需进一步考证
注:由于"Chaofa"对应多个实体,本报告已分类整理。如需特定对象的深入资料,建议提供更明确的指向信息。历史人物张朝发部分基于清代战史记载,社会组织部分依据国际NGO档案,企业信息来自商业报道。
In [183]python · cell 54
python
from pydantic import BaseModel, Field
class A(BaseModel):
x: str = Field(default="123", description="this is for x")
ins = A()
ins.model_dump()Output
{'x': '123'}