A query engine turns questions about indexed documents into generated responses. With LlamaIndex, configure it from an index and an LLM, then call query(). section 7.3.7
Querying local documents
A Hugging Face Llama model can run locally through HuggingFaceLLM. Select Apple Metal, CUDA, or CPU processing, then ask questions with query_engine.query(question).response. section 7.3.7
Choose the interaction pattern that matches the application:
- Use query() for independent questions; it does not remember earlier turns. section 7.3.11
- Use as_chat_engine() and chat() for follow-up questions that require conversation context. section 7.3.11
- Bind the query function to Gradio to provide a browser-based text interface. section 7.3.10
A cloud OpenAI model such as gpt-4o-mini can improve speed and response quality, but requires an API key, incurs usage charges, and sends query context to OpenAI. section 7.3.9


