AI / LlamaIndex Interview Questions
Explain the difference between the low-level composition API and the high-level API in LlamaIndex?
The high-level API is the one-liner style most tutorials use: VectorStoreIndex.from_documents(documents) followed by index.as_query_engine(). It picks sensible defaults for the node parser, retriever, and synthesizer automatically, which is great for getting started quickly.
The low-level composition API exposes each of those pieces as objects you construct and wire together yourself: building an IngestionPipeline with explicit transformations, constructing a retriever directly with custom parameters, choosing a specific response synthesizer, and combining them into a query engine by hand rather than through as_query_engine().
from llama_index.core.retrievers import VectorIndexRetriever from llama_index.core.query_engine import RetrieverQueryEngine from llama_index.core.response_synthesizers import get_response_synthesizer retriever = VectorIndexRetriever(index=index, similarity_top_k=8) synthesizer = get_response_synthesizer(response_mode="tree_summarize") query_engine = RetrieverQueryEngine(retriever=retriever, response_synthesizer=synthesizer)
You reach for the low-level API when the defaults genuinely don't fit: custom retrieval logic that combines multiple retrievers, a bespoke ordering of postprocessors, or swapping in components the high-level constructors don't expose parameters for. Most production systems end up using a mix, starting from high-level defaults and dropping to the low-level API only where customization is actually needed.
More Related questions...