Perplexity AI Engineer Interview Questions
Short answers to 15 AI engineering questions asked at Perplexity.
Questions and answers (15)
Answers are written in plain English and reviewed for technical accuracy. Each answer states the point first, then the reason.
1. Implement a client pool over multiple LLM providers with failover: providers fail, time out, or rate-limit, and callers should just get a completion.
Wrap each provider in a client that has a timeout and a retry budget. A router tries providers in order and moves to the next one on error, timeout, or rate limit. Callers call one function and get a completion or a final error. Keep per-provider health state so a failing provider gets less traffic.
def complete(prompt):
for p in healthy_providers():
try:
return p.call(prompt, timeout=2.0)
except (Timeout, RateLimit, ProviderError):
mark_unhealthy(p)
raise AllProvidersFailed()
2. You're ingesting millions of web pages a day. Detect near-duplicates (same article, different boilerplate) efficiently.
Use MinHash with shingles and banded LSH to find candidate pairs, then verify with Jaccard similarity. MinHash estimates set similarity in constant space per page. LSH bands cut the comparison count from N squared to near linear. Boilerplate removal before shingling raises precision. A threshold near 0.8 Jaccard works well for news articles.
mh = MinHash(num_perm=128)
for s in shingles(text, k=5): mh.update(s.encode())
lsh.insert(doc_id, mh)
cands = lsh.query(mh)
3. You need to embed millions of text chunks. The embedding service takes batches with a max batch size and a max total-token limit. Write the batcher and make it fast.
Group chunks into batches that respect both the max batch size and the max total-token limit. Count tokens with the same tokenizer that the embedding model uses. Sort by length or pack greedily to keep batches full and fast. Send batches with a bounded thread pool to hide network latency.
def batches(chunks, max_n, max_tok):
buf, tok = [], 0
for c in chunks:
n = len(tokenizer.encode(c))
if buf and (len(buf) >= max_n or tok + n > max_tok):
yield buf; buf, tok = [], 0
buf.append(c); tok += n
if buf: yield buf
4. Implement beam search for an autoregressive model. When would an answer engine actually use it?
Beam search keeps the top k partial sequences at each step and expands all of them. It scores each path by the sum of log probabilities, often with a length penalty. Greedy decoding is cheaper and often enough for short answers. An answer engine uses beam search when exact wording matters, such as structured output or translation. A beam width of 4 to 8 gives most of the gain.
beams = [([], 0.0)]
for _ in range(max_len):
cand = [(s + [t], lp + logp) for s, lp in beams
for t, logp in top_k(model(s), k)]
beams = sorted(cand, key=lambda x: x[1], reverse=True)[:k]
5. p95 time-to-first-token regressed from 1.2 s to 3 s after a release. Walk me through finding and fixing it.
Compare latency traces before and after the release and split time-to-first-token into queue wait, prefill, and network. Check the KV cache hit rate and the prompt length distribution first. A common cause is a longer system prompt or a disabled prefix cache. Fix the regression at the source and add a p95 alert on time-to-first-token.
# split the metric by stage
span('queue_wait'); span('prefill'); span('first_token')
# alert on p95 per stage, not only end to end
6. Discuss reranker architecture choices: cross-encoder, ColBERT, LLM-based.
A cross-encoder scores each query-passage pair jointly and gives the best accuracy at high cost. ColBERT keeps per-token embeddings and scores with late interaction, which is cheaper and cacheable. An LLM-based reranker gives strong relevance and reasoning but adds latency and cost. Use a cross-encoder for top 50, and reserve LLM reranking for small candidate sets.
7. You retrieved 50 candidate passages but the model's useful context budget is ~10. How do you choose, and how do you know your choices are good?
Score the 50 passages with a reranker and keep the top 10 under the token budget. Diversify the set so near-duplicate passages do not fill the budget. Measure quality with labeled query-passage pairs and track recall at 10 and answer accuracy. A small held-out set of 200 queries is enough to catch regressions.
8. Design an answer engine: a user types a question and gets a cited, streamed answer. Your end-to-end budget is 3 seconds to a complete short answer.
Stream tokens as soon as retrieval finishes and keep the first answer short. Run retrieval and query rewriting in parallel, then start generation with a small top-k context. Cache frequent questions and prefetch common sources. Budget about 300 ms for retrieval, 200 ms for reranking, and the rest for prefill and streaming.
9. Design the retrieval pipeline pulling from 100B web pages with sub-second latency and freshness guarantees.
Use a two-tier index. A shard-and-replica layer serves fresh pages from memory, and a cold layer holds the long tail on disk. Keep the hot tier small, for example the top 1B pages, so a query touches few shards. Push new pages to the hot tier within minutes and rebuild cold shards daily.
10. Design the ranking system combining BM25, dense retrieval and LLM reranking across multiple indexes.
Run BM25 and dense retrieval in parallel on separate indexes. Merge the two candidate lists with reciprocal rank fusion, then send the top 100 to an LLM reranker. Keep the reranker pool small because each LLM call adds latency and cost.
fused = sum(1 / (k + rank_i) for each list)
candidates = top_n(fused, 100)
final = llm_rerank(query, candidates)
11. Design Comet's hybrid browser architecture combining on-device privacy with cloud AI assistance.
Keep private data on the device and send only redacted context to the cloud. The browser runs a small local model for sensitive tasks and calls cloud models for heavy reasoning. This split protects privacy but adds sync complexity and some latency.
12. How does an answer engine handle breaking news: a query about something that happened 20 minutes ago?
Detect the freshness intent and route the query to a live news index. Fetch pages published in the last hour and add the publish time to the prompt. Label the answer as developing when sources disagree or are fewer than three.
13. How would you evaluate answer quality for an answer engine, continuously and at scale, with both automated and human signals?
Score every answer with automated checks and sample a small share for human review. Automated checks cover citation support, fact overlap with sources, and refusal rate. Humans rate a random sample each day, and you track agreement between the two signals.
14. Design the citation-verification system to reduce hallucinations in generated answers. How do you ensure every claim is actually supported by its cited source?
Split the answer into atomic claims and check each claim against its cited passage. A verifier model returns supported, partial, or unsupported for each pair. Drop or flag unsupported claims before you show the answer.
for claim in split_claims(answer):
src = sources[claim.citation]
label = verify(claim.text, src.text)
if label != "supported":
flag(claim)
15. What makes a Perplexity answer great vs mediocre? Where does Perplexity lose to traditional search, and where does it win? You clearly use it: what's broken, and what would you ship to fix it?
A great answer is correct, cited, current, and short. A mediocre answer is vague, uncited, or padded with filler. Traditional search wins on navigational queries and on fresh local data. An answer engine wins on multi-step questions that need synthesis. The main gap is trust in citations, so ship a visible per-claim source check.