Anthropic 面试题型总结整理:Coding、System Design、RL Fundamentals 和 Culture 怎么准备
Anthropic 面试题型总结整理:Coding、System Design、RL Fundamentals 和 Culture 怎么准备
Anthropic 的面试准备不能只按普通大厂 SWE 来做。近期面经信号里,Anthropic 常出现 coding screen、system design、RL fundamentals、neural network fundamentals、culture、management/leadership、AI safety fellowship 或 research 相关评估。不同岗位差异很大,但它们共同看重两件事:技术判断和价值观/协作方式。
本文基于近期公开面经标题和本地整理信号,不代表官方流程。
近期面经信号
- Coding 里出现过
Q2/Q3/Q6、LRU/cache、configuration、JS + concurrency、numpy debugging 等关键词。 - System design 方向出现过
batch service、inference、开放型设计题。 - Research/Safety 方向常见
RL Fundamentals、neural network fundamentals、experiment design。 - Culture/HM 轮在不少 full loop 里占重要位置,且可能不是工程师面试官。
面试真题题目合集
下面是 Anthropic 相关面经里出现过的题目和题型摘要:
- Web crawler:单线程爬取同 host 页面。
- Web crawler follow-up:多线程 crawler。
- Web crawler follow-up:URL fragment sanitize 后去重。
- Stack trace 解析。
- Stack trace follow-up:只保留最后 m 个 trace frame 时怎么恢复。
- Stack trace follow-up:循环 call 的 corner case。
- Mode / median:分布式节点上找 mode 或 median。
- Mode / median follow-up:map-reduce 和网络传输效率。
- File dedup:查找重复文件。
- File dedup follow-up:CPU bound vs IO bound。
- File dedup follow-up:分布式系统里怎么 scale。
- LRU cache 变体。
- Tokenizer / tokenization 题。
- In-memory DB OA:多 level 数据库操作。
- In-memory DB follow-up:TTL。
- In-memory DB follow-up:
get_when。 - In-memory DB follow-up:backup / restore。
- Bank system OA:transfer、accept、cashback。
- Bank system follow-up:merge account 和历史记录。
- Prompt engineering playground / design ChatGPT。
- Share conversation 功能设计。
- Inference system design。
- Batch service system design。
- Model downloader:chunk + pipeline 下载模型。
- Model downloader follow-up:不用 coordinator 怎么恢复。
- Parameter sweeps 系统设计。
- ML Configuration System。
- Prompting and Engineering with LLMs。
- Numpy bug fixing / numpy 捉虫。
- Image processing:blur、flip 等 operation。
- Performance engineer:TTFT、SITL、end-to-end latency。
- GPU vs TPU vs NeuronCore 的选择。
- KV cache、prefill、decode 阶段瓶颈。
- AI safety / culture round 问题。
- Controlled experiment for LLM training。
真题整理与分析
Anthropic 的反馈里有一个明显特点:题目不一定是传统 LeetCode 高频题,但会非常在意代码清晰度、边界条件、性能解释和安全/价值观一致性。
真题 1:Performance engineer 电话面
题目大意:讨论 TTFT、SITL、end-to-end latency 等延迟指标;比较 GPU、TPU、NeuronCore 等硬件选择;追问在不同推理 workload 下如何取舍。
考点分析: 这类题不能只背硬件名词。你需要讲清楚 token prefill 和 decode 阶段的瓶颈差异,batching 对吞吐和延迟的影响,模型大小、上下文长度、KV cache、网络传输分别怎么影响指标。好的答案会把“用户感知延迟”和“系统吞吐成本”分开。
真题 2:Crawler / stack trace / mode median 类 coding
题目大意:候选人反馈中出现过 crawler、stack trace 解析、mode/median 等题型;面试形式是纯 programming interview,不依赖 ML 库。
考点分析: Anthropic 更像是在看基础工程能力:能不能快速建模输入、写出可读代码、解释复杂度、覆盖 corner case。比如 stack trace 题要关注嵌套调用、异常路径、输出格式;mode/median 要关注 stream vs batch、排序 vs heap/hash map。
真题 3:File dedup / LRU cache 变体
题目大意:有候选人准备 file dedup,但实际可能遇到 LRU cache 或类似状态维护题。要求通常是 core Python,不让依赖大型库。
考点分析: 这类题考“数据结构是否真的懂”。LRU 要准备 hashmap + doubly linked list,能写 move-to-front、evict、update existing key;file dedup 则要讲 size prefilter、hash、collision、chunking、内存限制。不要只说用 OrderedDict,除非面试官允许。
真题 4:Scalable, secure, reliable systems
题目大意:系统设计邮件提示强调 scalable、secure、reliable,不要求 ML/research special knowledge。
考点分析: Anthropic 的系统设计不一定要求你知道模型训练细节,但会看你能否在需求不完整时澄清安全边界。比如权限、审计、数据保留、滥用防护、rate limit、incident recovery,都应该自然出现。
真题 5:价值观 / AI safety
题目大意:Performance engineer 面试里也会问 AI safety、为什么 Anthropic、如何看待安全和产品速度的平衡。
考点分析: 这里不能回答成空泛口号。要准备一个具体例子:你如何在上线速度、用户影响、风险评估之间做取舍;遇到不确定风险时怎么升级、记录和回滚。
高频题最优解速查
Web crawler
最优解思路: 单线程版本用 queue + visited set 做 BFS/DFS;每抓到一个 URL,先 normalize,再过滤 host,再去重。多线程版本用 thread pool + concurrent queue,visited set 要加锁或用线程安全结构。
复杂度: 单线程 O(V + E),V 是页面数,E 是链接数。多线程主要瓶颈是网络 IO,吞吐取决于并发数和目标站点限制。
面试要讲的边界: fragment 要去掉再去重;相对 URL 要 resolve;只爬同 host;失败重试;robots/rate limit;多线程下同一个 URL 不能被重复抓。
Stack trace 解析
最优解思路: 把 trace 当成调用栈事件流。遇到 function enter push,遇到 return/exit pop;如果输入是 stack snapshots,则用相邻 snapshot 的最长公共前缀判断哪些 frame 退出、哪些 frame 进入。只保留最后 m 个 frame 的 follow-up,要说明只能恢复 suffix 信息,完整路径需要额外上下文或 checkpoint。
复杂度: O(total frames)。
面试要讲的边界: 递归调用、同名函数、异常提前退出、缺失 frame、循环 call、最后一行是否需要输出 end。
Mode / Median in distributed nodes
最优解思路: Mode 可以每个节点本地 count,再把 local top candidates 或完整 counter 聚合到 coordinator。Median 更难,精确解通常需要多轮分布式选择;实用解可以用 histogram / quantile sketch 先缩小范围,再二次查询。
复杂度: Mode 本地 O(n),聚合 O(k * nodes)。Median 精确解取决于迭代轮数;近似解通信量更低。
面试要讲的边界: 网络传输比 CPU 更贵;不能默认把所有数据拉到一台机器;要问 exact 还是 approximate;数据倾斜时 coordinator 会不会爆内存。
In-memory DB with TTL / Backup
最优解思路: 每个 cell 存 value, set_time, expire_at。读和 scan 时 lazy 删除过期数据。backup 保存某个 timestamp 下仍有效的数据,并记录剩余 TTL;restore 到某个 backup 时重新计算新的 expire_at。
复杂度: get O(1),scan O(k log k) 如果需要排序输出;backup O(n),restore O(n)。
面试要讲的边界: backup 不应保存过期 key;restore 后 TTL 不能沿用旧绝对时间;scan 要过滤过期字段;timestamp 相同的操作顺序要定义清楚。
可直接练习的答案骨架
Coding sample:单线程 Web crawler
from collections import deque
from urllib.parse import urldefrag, urljoin, urlparse
def crawl(start_url, fetch_links):
host = urlparse(start_url).netloc
q = deque([normalize(start_url, start_url)])
visited = set()
result = []
while q:
url = q.popleft()
if url in visited:
continue
visited.add(url)
result.append(url)
for raw_link in fetch_links(url):
nxt = normalize(raw_link, url)
if urlparse(nxt).netloc == host and nxt not in visited:
q.append(nxt)
return result
def normalize(link, base_url):
absolute = urljoin(base_url, link)
without_fragment, _ = urldefrag(absolute)
parsed = urlparse(without_fragment)
return parsed._replace(path=parsed.path or "/").geturl()
OOD class definition:LRU cache
class Node:
def __init__(self, key=None, value=None):
self.key = key
self.value = value
self.prev = None
self.next = None
class LRUCache:
def __init__(self, capacity: int):
self.capacity = capacity
self.nodes = {}
self.head = Node()
self.tail = Node()
self.head.next = self.tail
self.tail.prev = self.head
def get(self, key):
if key not in self.nodes:
return None
node = self.nodes[key]
self._remove(node)
self._add_after_head(node)
return node.value
def put(self, key, value):
if key in self.nodes:
node = self.nodes[key]
node.value = value
self._remove(node)
self._add_after_head(node)
return
node = Node(key, value)
self.nodes[key] = node
self._add_after_head(node)
if len(self.nodes) > self.capacity:
evicted = self.tail.prev
self._remove(evicted)
del self.nodes[evicted.key]
def _remove(self, node):
node.prev.next = node.next
node.next.prev = node.prev
def _add_after_head(self, node):
node.prev = self.head
node.next = self.head.next
self.head.next.prev = node
self.head.next = node
System design:Inference serving
flowchart LR
Client --> Gateway["API Gateway"]
Gateway --> Router["Model Router"]
Router --> Queue["Request Queue"]
Queue --> Batch["Batcher"]
Batch --> Runtime["Model Runtime"]
Runtime --> KV["KV Cache"]
Runtime --> Stream["Token Stream"]
Stream --> Client
Runtime --> Metrics[("Metrics")]
API design
POST /v1/messages
POST /v1/messages:stream
GET /v1/requests/{request_id}
POST /v1/requests/{request_id}/cancel
Data model
requests(id, user_id, model, status, prompt_tokens, output_tokens, created_at)
request_events(id, request_id, event_type, payload, created_at)
rate_limits(user_id, model, window_start, used_tokens, token_limit)
面试里要讲清 prefill 和 decode 的瓶颈不同;TTFT、tokens/sec、queue time 要分开观测;batching 会提升吞吐但可能伤害尾延迟。
题目逐题答案速查
Coding:stack trace parser
Sample code
def diff_stacks(prev_stack, cur_stack):
i = 0
while i < min(len(prev_stack), len(cur_stack)) and prev_stack[i] == cur_stack[i]:
i += 1
exited = prev_stack[i:][::-1]
entered = cur_stack[i:]
return exited, entered
讲解重点: 如果输入是连续 stack snapshot,核心是 longest common prefix。follow-up 只给最后 m 个 frame 时,要说明信息不完整,只能恢复 suffix 范围内的 enter/exit。
Coding:mode in distributed nodes
Sample code
from collections import Counter
def local_count(values):
return Counter(values)
def merge_counts(counters):
total = Counter()
for counter in counters:
total.update(counter)
return total.most_common(1)[0]
讲解重点: 这是最基础可工作解。优化方向是每个节点只传 top candidates、heavy hitter sketch,或者按 key hash 分区聚合。
Coding:file dedup
Sample code
from collections import defaultdict
import hashlib
def group_duplicate_files(files, read_bytes):
by_size = defaultdict(list)
for path, size in files:
by_size[size].append(path)
duplicates = []
for same_size_files in by_size.values():
if len(same_size_files) <= 1:
continue
by_hash = defaultdict(list)
for path in same_size_files:
digest = hashlib.sha256(read_bytes(path)).hexdigest()
by_hash[digest].append(path)
duplicates.extend(group for group in by_hash.values() if len(group) > 1)
return duplicates
讲解重点: size prefilter -> hash -> byte compare。分布式 follow-up:按 size/hash 分区,避免单机读全部文件。
Coding:LRU cache
本页上面已经给了完整 LRU class。面试里要继续补:
- Python 标准库可用
OrderedDict,但要能手写双向链表。 - 多线程版本先全局锁,再讲 sharded LRU。
- 写磁盘 follow-up 可以做 write-through 或 write-back cache。
Coding:tokenizer
Sample code
def tokenize(s, vocab):
dp = [False] * (len(s) + 1)
parent = [-1] * (len(s) + 1)
dp[0] = True
for i in range(len(s)):
if not dp[i]:
continue
for token in vocab:
if s.startswith(token, i):
j = i + len(token)
dp[j] = True
parent[j] = i
return dp[-1]
讲解重点: boolean segmentation 用 DP;概率版本用 Viterbi + log probability。
System design:prompt playground / shared conversation
flowchart LR
User --> API["Conversation API"]
API --> Conv[("Conversation DB")]
API --> Model["LLM Runtime"]
Model --> Msg[("Messages")]
User --> Share["Share API"]
Share --> ShareDB[("Share Links")]
API design
POST /conversations
POST /conversations/{id}/messages
GET /conversations/{id}
POST /conversations/{id}/share
GET /shared/{share_id}
Data model
conversations(id, owner_id, title, visibility, created_at)
messages(id, conversation_id, role, content, created_at)
share_links(id, conversation_id, permission, expires_at)
System design:model downloader
答案骨架: manifest 记录 chunk checksum;worker 并发下载 chunk;本地 registry 只在所有 chunk 校验通过后切换 active version。无 coordinator follow-up:每个 worker 根据 manifest 和 chunk status 自恢复。
准备重点
Coding:准备多 part 编程题、cache、并发、状态管理、numpy debug。不要只追求写完,要能解释边界条件和测试。
System Design:重点准备 inference service、batch processing、model serving、task scheduler、evaluation pipeline、可靠性和资源限制。Anthropic 相关面经常会追问设计目标和 failure mode。
Research/ML Fundamentals:如果岗位偏 research 或 safety,准备 RL 基础、loss function、training/evaluation、实验设计、模型行为分析。不要背概念,要能用例子解释。
Culture:准备“你不喜欢做什么”“模糊项目怎么推进”“和 manager 怎么合作”“道德判断/价值冲突”等问题。回答要体现成熟判断,而不是模板 STAR。
7 天冲刺计划
- Day 1:确认岗位是 SWE/Infra、Research、Safety 还是 Fellowship。
- Day 2:练 cache/concurrency/numpy debugging。
- Day 3:练一个 inference 或 batch service system design。
- Day 4:准备一个技术项目 deep dive。
- Day 5:复习 RL/NN/experiment design 基础。
- Day 6:整理 5 个 culture 故事。
- Day 7:做一轮混合 mock:coding + culture。
常见失分点
- Culture 轮只背 STAR,讲不出判断原则。
- System design 只画服务,不讲安全、可靠性和评估。
- ML fundamentals 只背定义,不会用具体例子解释。
- Coding 题写出 happy path,但测试和边界不足。
CTA
如果你已经拿到 Anthropic 面试,建议先确认轮次类型,再做定制 mock。你可以在服务和价格页面查看 behavioral、coding、system design 和 project deep dive 辅导;也可以通过联系我们页面发送岗位和面试安排。