LangChain на собеседовании Data Scientist

Готовься к собесу аналитика как в Duolingo
10 минут в день — SQL, Python, A/B, метрики. 1700+ вопросов в Telegram
Открыть Карьерник в Telegram

Карьерник — Duolingo для аналитиков: 10 минут в день тренируй SQL, Python, A/B, статистику, метрики и ещё 3 темы собеса. 1500+ вопросов в Telegram-боте. Бесплатно.

Что такое LangChain

Framework для LLM apps. Provider-agnostic abstractions.

from langchain.llms import OpenAI

llm = OpenAI()
response = llm("Hello")

Chains

Pipeline LLM calls с structured input / output.

from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate

prompt = PromptTemplate.from_template("Translate to {lang}: {text}")
chain = LLMChain(llm=llm, prompt=prompt)
result = chain.invoke({"lang": "Russian", "text": "Hello"})

Compose chains в complex flows.

Agents

LLM decides which tool call.

from langchain.agents import initialize_agent, Tool

tools = [
    Tool(name="search", func=search_web, description="..."),
    Tool(name="calc", func=calculate, description="..."),
]
agent = initialize_agent(tools, llm, agent="react")
agent.run("What's the weather в Moscow * 2?")

Memory

Persistent state между LLM calls (conversation, summary, vector store).

from langchain.memory import ConversationBufferMemory

memory = ConversationBufferMemory()
chain = ConversationChain(llm=llm, memory=memory)

История conversation passed в каждый prompt.

Готовься к собесу аналитика как в Duolingo
10 минут в день — SQL, Python, A/B, метрики. 1700+ вопросов в Telegram
Открыть Карьерник в Telegram

LangGraph

LangChain successor для complex agentic workflows. Graph-based, stateful.

from langgraph.graph import StateGraph

builder = StateGraph(AgentState)
builder.add_node("classify", classifier)
builder.add_node("route_a", handler_a)
builder.add_node("route_b", handler_b)
builder.add_conditional_edges("classify", route)
graph = builder.compile()

Better для production — explicit state, error handling, durability.

Alternatives

LlamaIndex. Focus на RAG.

Haystack. German alternative.

Pydantic AI. Type-safe.

Vercel AI SDK. TypeScript-first.

OpenAI Assistants API. Native, но vendor-locked.

LangChain ecosystem — largest, but criticized для over-abstraction.

Связанные темы

FAQ

Это официальная информация?

Нет. Статья основана на документации LangChain / LangGraph.


Тренируйте Data Science — откройте тренажёр с 1500+ вопросами для собесов.