Chaturmind
LearnDSASystem DesignInterview PrepDevOpsEngineering GrowthBlog
Start learning
Chaturmind

Structured learning paths for engineers who want to go deep. Written by practitioners.

Learn

  • Java
  • DSA
  • System Design
  • Spring Boot
  • AI / ML
  • DevOps
  • Engineering Growth
  • Java Interview Prep

Company

  • About
  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Chaturmind. All rights reserved.

Built for engineers who want to go deep.


← Java Interview Prep: 8+ Years (Senior & Lead)

Revise the 5–8 Years Tier

  • Revise: Advanced Core Java & Design Patterns (5–8 Years Tier)
  • Revise: Spring Boot Internals & Spring Security (5–8 Years Tier)
  • Revise: Microservices & Microservice Patterns (5–8 Years Tier)

Expert Core Java

  • Tricky Java Output, Operators & OOP Edge Cases — Interview Questions
  • Tricky Exceptions, Memory & Keyword Questions — Interview Questions
  • Classic Java Language Questions, Senior-Grade Answers — Interview Questions
  • Classic Collections, Threads & JDK APIs, Senior-Grade Answers — Interview Questions
  • Reflection, Dynamic Proxies, final & Modern OOP Design — Interview Questions

JVM Internals & Performance

  • Class Loading, Bytecode & Object Layout — Interview Questions
  • JIT Compilation & Runtime Optimisations — Interview Questions
  • Garbage Collectors Deep Dive — Interview Questions
  • JVM Tuning, GC Logs & Memory Footprint — Interview Questions
  • Memory Leaks, OutOfMemoryErrors & Profiling Tools — Interview Questions
  • Modules, Agents & Advanced JVM APIs — Interview Questions

Collections & Concurrency at Scale

  • Collections Internals & Complexity — Interview Questions
  • Iterators, Comparators & Ordering Contracts — Interview Questions
  • Concurrent Collections, Queues & Lock-Free Structures — Interview Questions
  • Threads, Executors & ForkJoin Internals — Interview Questions
  • Locks, Atomics, CAS & Synchronizers — Interview Questions
  • Java Memory Model, volatile, Fences & ThreadLocal — Interview Questions
  • Deadlock, Livelock, Starvation & Concurrent Design — Interview Questions
  • CompletableFuture, Parallel Streams & Non-Blocking I/O — Interview Questions

Modern Java (8 to 21+)

  • Lambdas & Functional Interfaces Internals — Interview Questions
  • Streams & Collectors Deep Dive — Interview Questions
  • Optional & Interface Default/Static Methods — Interview Questions
  • Java 9–25 Features & Virtual Threads — Interview Questions

Design Patterns, SOLID & Clean Code

  • Design Pattern Trade-offs & Combinations — Interview Questions
  • SOLID, Clean Code & Anti-Patterns — Interview Questions

Spring & Spring Boot Internals

  • IoC, Dependency Injection & Bean Lifecycle Internals — Interview Questions
  • Spring AOP, Proxies & @Async Internals — Interview Questions
  • Spring Configuration, Auto-Configuration & Custom Starters — Interview Questions
  • Spring MVC & REST Internals, Exception Frameworks — Interview Questions
  • Spring Security Advanced Internals — Interview Questions
  • Spring WebFlux, Reactor & R2DBC — Interview Questions
  • Spring Cloud, Observability & Distributed Tracing — Interview Questions
  • Spring Boot 3, Native Images & Production Scenarios — Interview Questions

JPA, Hibernate & Databases at Scale

  • Spring Data JPA — Queries, Projections, Custom Repositories & Locking — Interview Questions
  • JPA Entity Mapping, Associations & Cascades — Interview Questions
  • JPQL vs Native Queries in Depth — Interview Questions
  • Hibernate Caching — First-Level, Second-Level & Query Cache — Interview Questions
  • Lazy vs Eager Loading, LazyInitializationException & N+1 — Interview Questions
  • JPA Transactions, Propagation, Isolation & Dirty Checking — Interview Questions
  • SQL vs NoSQL, Indexing & Query Tuning — Interview Questions
  • Database Scaling, Replication, Pooling & Consistency Models — Interview Questions
  • Redis, Search, Time-Series, CDC & Transactional Data Modelling — Interview Questions

Testing Strategy & API Design

  • Spring Boot Test Slices, Context & Test Strategy — Interview Questions
  • Testing Web, Persistence, Security, Async & Messaging in Spring Boot — Interview Questions
  • JUnit 5 & Mockito, Advanced — Interview Questions
  • MockMvc, WebTestClient & Testcontainers in Depth — Interview Questions
  • REST Principles, Status Codes & Resource Design — Interview Questions
  • OpenAPI, Validation Errors, API Versioning & GraphQL — Interview Questions

Build, DevOps & Cloud

  • Maven & Gradle at Scale — Interview Questions
  • Git, CI/CD Pipelines & Release Safety — Interview Questions
  • Docker & Kubernetes for Java Engineers — Interview Questions
  • Quality Gates, Artifact Repositories & Secrets Management — Interview Questions
  • AWS Deployment & Scaling for Spring Boot — Interview Questions
  • Multi-Cloud Deployment, High Availability, Cost & Cloud Troubleshooting — Interview Questions
  • Protocols, Supply-Chain Security, SRE Metrics & Platform Engineering — Interview Questions

Kafka & Messaging

  • Kafka Internals & Delivery Semantics — Interview Questions
  • Spring Kafka — Error Handling, DLQs, Schemas & Operations — Interview Questions
  • RabbitMQ, JMS & Messaging Models — Interview Questions

Microservices & Architecture

  • Distributed Systems Fundamentals — CAP, Consistency, Availability & SLOs — Interview Questions
  • DDD, Hexagonal Architecture & Service Boundaries — Interview Questions
  • Event-Driven Architecture, CQRS, Event Sourcing, Sharding & Idempotency — Interview Questions
  • Rate Limiting, Resilience, Caching at Scale & Chaos Engineering — Interview Questions
  • Files, Documents & Internationalisation in Java Backends — Interview Questions
  • WebSockets, Schedulers, Notifications & Real-Time Pipelines — Interview Questions

System Design Scenarios

  • Booking Systems, CRS, Inventory & Concurrency Control — Interview Questions
  • Dynamic Pricing & Rule Engines — Interview Questions
  • Partner Integrations — OTA Sync, Retries, Webhooks, Reconciliation & Bulk Data — Interview Questions
  • Designing Caches & Rate Limiters — Interview Questions
  • Event-Driven Architecture, Kafka at Scale, IoT & Real-Time Pipelines — Interview Questions
  • Observability, Logging, Alerting & Audit Systems — Interview Questions
  • Multi-Tenant SaaS, Identity & Platform Services — Interview Questions
  • Search, Notifications, Chat, Fraud Detection & Workflows — Interview Questions
  • Extreme Scale, 99.99% Availability, DR & Project Deep-Dive Stories — Interview Questions

Security for Senior Engineers

  • Tokens, OAuth2 PKCE, Web Attacks & API Security — Interview Questions
  • TLS, mTLS, Zero Trust, Secrets, DDoS & Privacy Compliance — Interview Questions

AI & LLM Integration

  • LLM Integration in Java — Spring AI, Bedrock, Prompts, Streaming & Orchestration — Interview Questions
  • RAG, Embeddings, Vector Databases & Conversational Memory — Interview Questions
  • AI Security, Guardrails, Cost & Operations — Interview Questions

DSA Coding Round

  • Array Problems — Rotation, Subarrays, Intervals, In-Place Tricks — Interview Questions
  • String Problems & Sliding Window — Interview Questions
  • Backtracking & Recursion — Interview Questions
  • Linked Lists, LRU & LFU Caches — Interview Questions
  • Stacks, Queues & Monotonic Stacks — Interview Questions
  • Binary Trees & BSTs — Interview Questions
  • Graph Algorithms — Interview Questions
  • Dynamic Programming — Interview Questions
  • Heaps & Greedy Algorithms — Interview Questions
  • Bit Manipulation & Math — Interview Questions
  • Concurrency Coding Round — Thread Pool, Blocking Queue, Latch, Future, File Processor — Interview Questions
  • Low-Level Design (Machine Coding) Problems — Interview Questions

Leadership & Behavioural

  • Leadership Style, Motivation & Team Health — Interview Questions
  • Delivery, Planning & Decisions Under Uncertainty — Interview Questions
  • Problem Solving, Growth & Career Stories — Interview Questions
  • Stakeholder Communication, Ethics & Compliance — Interview Questions
  • Mentoring, Knowledge Sharing & Code Reviews — Interview Questions
  • Agile & Scrum Practices for Senior Engineers — Interview Questions
  • Architecture Decision-Making — Interview Questions
  • Conflict Resolution & Difficult Conversations — Interview Questions
Chaturmind
← Java Interview Prep: 8+ Years (Senior & Lead)

Revise the 5–8 Years Tier

  • Revise: Advanced Core Java & Design Patterns (5–8 Years Tier)
  • Revise: Spring Boot Internals & Spring Security (5–8 Years Tier)
  • Revise: Microservices & Microservice Patterns (5–8 Years Tier)

Expert Core Java

  • Tricky Java Output, Operators & OOP Edge Cases — Interview Questions
  • Tricky Exceptions, Memory & Keyword Questions — Interview Questions
  • Classic Java Language Questions, Senior-Grade Answers — Interview Questions
  • Classic Collections, Threads & JDK APIs, Senior-Grade Answers — Interview Questions
  • Reflection, Dynamic Proxies, final & Modern OOP Design — Interview Questions

JVM Internals & Performance

  • Class Loading, Bytecode & Object Layout — Interview Questions
  • JIT Compilation & Runtime Optimisations — Interview Questions
  • Garbage Collectors Deep Dive — Interview Questions
  • JVM Tuning, GC Logs & Memory Footprint — Interview Questions
  • Memory Leaks, OutOfMemoryErrors & Profiling Tools — Interview Questions
  • Modules, Agents & Advanced JVM APIs — Interview Questions

Collections & Concurrency at Scale

  • Collections Internals & Complexity — Interview Questions
  • Iterators, Comparators & Ordering Contracts — Interview Questions
  • Concurrent Collections, Queues & Lock-Free Structures — Interview Questions
  • Threads, Executors & ForkJoin Internals — Interview Questions
  • Locks, Atomics, CAS & Synchronizers — Interview Questions
  • Java Memory Model, volatile, Fences & ThreadLocal — Interview Questions
  • Deadlock, Livelock, Starvation & Concurrent Design — Interview Questions
  • CompletableFuture, Parallel Streams & Non-Blocking I/O — Interview Questions

Modern Java (8 to 21+)

  • Lambdas & Functional Interfaces Internals — Interview Questions
  • Streams & Collectors Deep Dive — Interview Questions
  • Optional & Interface Default/Static Methods — Interview Questions
  • Java 9–25 Features & Virtual Threads — Interview Questions

Design Patterns, SOLID & Clean Code

  • Design Pattern Trade-offs & Combinations — Interview Questions
  • SOLID, Clean Code & Anti-Patterns — Interview Questions

Spring & Spring Boot Internals

  • IoC, Dependency Injection & Bean Lifecycle Internals — Interview Questions
  • Spring AOP, Proxies & @Async Internals — Interview Questions
  • Spring Configuration, Auto-Configuration & Custom Starters — Interview Questions
  • Spring MVC & REST Internals, Exception Frameworks — Interview Questions
  • Spring Security Advanced Internals — Interview Questions
  • Spring WebFlux, Reactor & R2DBC — Interview Questions
  • Spring Cloud, Observability & Distributed Tracing — Interview Questions
  • Spring Boot 3, Native Images & Production Scenarios — Interview Questions

JPA, Hibernate & Databases at Scale

  • Spring Data JPA — Queries, Projections, Custom Repositories & Locking — Interview Questions
  • JPA Entity Mapping, Associations & Cascades — Interview Questions
  • JPQL vs Native Queries in Depth — Interview Questions
  • Hibernate Caching — First-Level, Second-Level & Query Cache — Interview Questions
  • Lazy vs Eager Loading, LazyInitializationException & N+1 — Interview Questions
  • JPA Transactions, Propagation, Isolation & Dirty Checking — Interview Questions
  • SQL vs NoSQL, Indexing & Query Tuning — Interview Questions
  • Database Scaling, Replication, Pooling & Consistency Models — Interview Questions
  • Redis, Search, Time-Series, CDC & Transactional Data Modelling — Interview Questions

Testing Strategy & API Design

  • Spring Boot Test Slices, Context & Test Strategy — Interview Questions
  • Testing Web, Persistence, Security, Async & Messaging in Spring Boot — Interview Questions
  • JUnit 5 & Mockito, Advanced — Interview Questions
  • MockMvc, WebTestClient & Testcontainers in Depth — Interview Questions
  • REST Principles, Status Codes & Resource Design — Interview Questions
  • OpenAPI, Validation Errors, API Versioning & GraphQL — Interview Questions

Build, DevOps & Cloud

  • Maven & Gradle at Scale — Interview Questions
  • Git, CI/CD Pipelines & Release Safety — Interview Questions
  • Docker & Kubernetes for Java Engineers — Interview Questions
  • Quality Gates, Artifact Repositories & Secrets Management — Interview Questions
  • AWS Deployment & Scaling for Spring Boot — Interview Questions
  • Multi-Cloud Deployment, High Availability, Cost & Cloud Troubleshooting — Interview Questions
  • Protocols, Supply-Chain Security, SRE Metrics & Platform Engineering — Interview Questions

Kafka & Messaging

  • Kafka Internals & Delivery Semantics — Interview Questions
  • Spring Kafka — Error Handling, DLQs, Schemas & Operations — Interview Questions
  • RabbitMQ, JMS & Messaging Models — Interview Questions

Microservices & Architecture

  • Distributed Systems Fundamentals — CAP, Consistency, Availability & SLOs — Interview Questions
  • DDD, Hexagonal Architecture & Service Boundaries — Interview Questions
  • Event-Driven Architecture, CQRS, Event Sourcing, Sharding & Idempotency — Interview Questions
  • Rate Limiting, Resilience, Caching at Scale & Chaos Engineering — Interview Questions
  • Files, Documents & Internationalisation in Java Backends — Interview Questions
  • WebSockets, Schedulers, Notifications & Real-Time Pipelines — Interview Questions

System Design Scenarios

  • Booking Systems, CRS, Inventory & Concurrency Control — Interview Questions
  • Dynamic Pricing & Rule Engines — Interview Questions
  • Partner Integrations — OTA Sync, Retries, Webhooks, Reconciliation & Bulk Data — Interview Questions
  • Designing Caches & Rate Limiters — Interview Questions
  • Event-Driven Architecture, Kafka at Scale, IoT & Real-Time Pipelines — Interview Questions
  • Observability, Logging, Alerting & Audit Systems — Interview Questions
  • Multi-Tenant SaaS, Identity & Platform Services — Interview Questions
  • Search, Notifications, Chat, Fraud Detection & Workflows — Interview Questions
  • Extreme Scale, 99.99% Availability, DR & Project Deep-Dive Stories — Interview Questions

Security for Senior Engineers

  • Tokens, OAuth2 PKCE, Web Attacks & API Security — Interview Questions
  • TLS, mTLS, Zero Trust, Secrets, DDoS & Privacy Compliance — Interview Questions

AI & LLM Integration

  • LLM Integration in Java — Spring AI, Bedrock, Prompts, Streaming & Orchestration — Interview Questions
  • RAG, Embeddings, Vector Databases & Conversational Memory — Interview Questions
  • AI Security, Guardrails, Cost & Operations — Interview Questions

DSA Coding Round

  • Array Problems — Rotation, Subarrays, Intervals, In-Place Tricks — Interview Questions
  • String Problems & Sliding Window — Interview Questions
  • Backtracking & Recursion — Interview Questions
  • Linked Lists, LRU & LFU Caches — Interview Questions
  • Stacks, Queues & Monotonic Stacks — Interview Questions
  • Binary Trees & BSTs — Interview Questions
  • Graph Algorithms — Interview Questions
  • Dynamic Programming — Interview Questions
  • Heaps & Greedy Algorithms — Interview Questions
  • Bit Manipulation & Math — Interview Questions
  • Concurrency Coding Round — Thread Pool, Blocking Queue, Latch, Future, File Processor — Interview Questions
  • Low-Level Design (Machine Coding) Problems — Interview Questions

Leadership & Behavioural

  • Leadership Style, Motivation & Team Health — Interview Questions
  • Delivery, Planning & Decisions Under Uncertainty — Interview Questions
  • Problem Solving, Growth & Career Stories — Interview Questions
  • Stakeholder Communication, Ethics & Compliance — Interview Questions
  • Mentoring, Knowledge Sharing & Code Reviews — Interview Questions
  • Agile & Scrum Practices for Senior Engineers — Interview Questions
  • Architecture Decision-Making — Interview Questions
  • Conflict Resolution & Difficult Conversations — Interview Questions
HomeLearnJava Interview PrepJava Interview Prep: 8+ Years (Senior & Lead)AI & LLM Integration
✓ FreeAdvanced· 8 min read

RAG, Embeddings, Vector Databases & Conversational Memory — Interview Questions

What Retrieval-Augmented Generation is and how to build it, what embeddings are and how to store them, what a vector database is and how to integrate one, Pinecone vs Elasticsearch/OpenSearch vectors (and pgvector), storing chat context and building conversational memory, preventing hallucination, and building an AI-based recommendation engine.

Published September 25, 2026


How to use this lesson

RAG is the most common production pattern for LLMs in business applications. A strong answer covers:

  • the ingestion pipeline (chunking, embedding, metadata);
  • retrieval quality (hybrid search, filters, reranking);
  • access control on the retrieved data;
  • evaluation.

It also admits the limits: RAG reduces hallucination; it doesn't eliminate it.

Q1. What is Retrieval-Augmented Generation (RAG)?

Short answer: RAG retrieves relevant information from your own data at query time, and puts it into the prompt, so the model answers grounded in that context, rather than only from its training data. It gives current, private, domain-specific answers, with citations, and without fine-tuning.

The pipeline:

  1. Ingestion (offline):
    • load the documents (policies, FAQs, manuals, knowledge base) → clean them → chunk them (for example, 300–800 tokens, with overlap, split by headings or semantics);
    • embed each chunk;
    • store the vector, the text and the metadata (source, hotel or tenant, language, access level, date) in a vector store.
  2. Query (online):
    • (optionally) rewrite the question (using the chat history);
    • embed it;
    • retrieve the top-k similar chunks, with metadata filters (tenant, permissions), ideally hybrid (vector plus keyword BM25);
    • rerank them (a cross-encoder);
    • build a prompt with the context, and instructions to answer only from it and cite the sources;
    • generate the answer.
  3. Evaluate: retrieval quality (recall@k), and answer faithfulness or groundedness and relevance (frameworks such as Ragas, or LLM-as-judge on a golden set).

Keeping it fresh: re-ingest on document changes (events or CDC), and delete the vectors of removed documents.

ChatClient chat = ChatClient.builder(chatModel)
    .defaultAdvisors(QuestionAnswerAdvisor.builder(vectorStore)
        .searchRequest(SearchRequest.builder().topK(5).similarityThreshold(0.7)
            .filterExpression("tenant == '" + tenantId + "'").build())
        .build())
    .build();
String answer = chat.prompt().user(question).call().content();

Common trap: building filter expressions by string concatenation from untrusted values is an injection risk (as in SQL). Use the builder APIs (FilterExpressionBuilder) with values taken from the authenticated context, never from user input.

Q2. What are embeddings? How do you store embeddings?

Short answer:

  • An embedding is a dense vector of numbers (for example 384–3,072 dimensions) produced by an embedding model, where semantically similar texts are close together (measured by cosine similarity or dot product). "Late check-out policy" and "can I leave the room at 2 pm?" are near each other, even with no shared words.
  • Uses: semantic search, RAG retrieval, clustering, deduplication, recommendations, classification.
  • Storing them:
    • in a vector store that supports approximate nearest-neighbour (ANN) indexes, usually HNSW (a graph-based index: fast and accurate, but memory-hungry) or IVF (clusters), optionally with quantisation (to reduce memory);
    • store the vector, the source text and the metadata together;
    • record which embedding model and version produced them. Vectors from different models aren't comparable, so changing the model means re-embedding everything (plan it as a migration, with a new index and an alias switch);
    • use normalised vectors if you use dot-product similarity.
  • Cost and size: dimensions × 4 bytes (float32) × the number of chunks. For example, 1 million chunks × 1,536 dimensions ≈ 6 GB raw, before index overhead. Consider smaller dimensions (Matryoshka embeddings), or quantisation (int8 or binary).

Q3. What is a vector database? How do you integrate one? Pinecone versus Elasticsearch vectors?

Short answer:

  • A vector database stores embeddings, and performs fast similarity search (k-nearest neighbours), with metadata filtering, CRUD, scaling and persistence.
  • The options:
    • Dedicated: Pinecone (fully managed, serverless), Weaviate, Qdrant, Milvus.
    • Added to existing databases:
      • PostgreSQL + pgvector (HNSW and IVFFlat indexes; transactions, joins and SQL filters in one database; great up to millions of vectors, with the least new infrastructure);
      • Elasticsearch/OpenSearch (dense_vector / k-NN fields);
      • Redis (vector search);
      • MongoDB Atlas vector search.
  • Pinecone vs Elasticsearch:
PineconeElasticsearch / OpenSearch
ModelManaged vector DB, serverlessSearch engine with vector fields
StrengthSimple ops, scale, fast ANNHybrid search (BM25 + vectors) in one query, rich filters/aggregations, existing search infra
OpsNothing to run; vendor lock-in; data leaves your VPC (unless private options)You operate it (or managed); memory tuning for HNSW
Best whenVector-first workload, small teamAlready using ES for search; need keyword + semantic hybrid
  • Integration in Spring: the Spring AI VectorStore abstraction (add(documents), similaritySearch(request)) with starters for PGVector, Elasticsearch, Pinecone, Redis, Qdrant and others; ETL readers (PDF, Markdown, JSON), with token-based text splitters.
  • Selection criteria:
    • scale (the number of vectors, QPS);
    • the filtering needs (tenant isolation);
    • hybrid search;
    • operational fit (does the team already run PostgreSQL or Elasticsearch?);
    • data residency;
    • cost.

Q4. How do you store chat context? How do you build conversational memory?

Short answer:

  • LLMs are stateless: every call must include the relevant history. Memory is your application's job.
  • Short-term memory (the current conversation):
    • store the messages per conversation ID (Redis with a TTL for active sessions; a database for durability and audit);
    • send a window of recent messages (the last N turns, or the last N tokens), within the context limit;
    • when it gets long, summarise older turns into a running summary (a summary plus a recent window).
  • Long-term memory (across sessions): extract facts and preferences ("prefers high floors", "vegetarian") into a user profile store, or embed past interactions in a vector store, retrieved on relevance. Get consent, allow users to see and delete it, and apply retention limits (it's personal data).
  • In Spring AI: a ChatMemory (for example MessageWindowChatMemory), with a repository (in-memory, JDBC, Cassandra, Neo4j…), plugged into the ChatClient through a MessageChatMemoryAdvisor, keyed by conversation ID.
  • Security: memory is scoped to the user and tenant; never mix conversations; redact sensitive data before storing it; encrypt it at rest.
ChatMemory memory = MessageWindowChatMemory.builder()
        .chatMemoryRepository(jdbcChatMemoryRepository).maxMessages(20).build();
String reply = chatClient.prompt()
        .advisors(MessageChatMemoryAdvisor.builder(memory).conversationId(conversationId).build())
        .user(message).call().content();

Q5. How do you prevent (reduce) hallucination?

Short answer: Hallucination (fluent but false output) can't be fully eliminated; you reduce it and contain it:

  • Grounding: RAG with good retrieval; instructions to answer only from the provided context, and to say "I don't know" otherwise; citations to the sources.
  • Use tools for facts: prices, availability and booking status come from API calls, never from the model's memory.
  • Constrain the output: structured outputs (schemas), enumerations, low temperature for factual tasks.
  • Verify:
    • validate the outputs against the source data (IDs exist; numbers match);
    • groundedness checks (a second model or a guardrail that checks that the claims are supported by the context);
    • rules that block unsupported commitments (refunds, discounts).
  • Choose appropriate models, and evaluate them on your domain with golden datasets; monitor production samples.
  • UX: show sources, make the AI's role clear, and have human review for high-stakes outputs.

Q6. How do you build an AI-based recommendation engine?

Short answer: Example: recommending hotels, room upgrades or add-ons.

  • Classic, proven layers:
    • candidate generation: collaborative filtering (users who booked X also booked Y), content-based similarity (item embeddings from descriptions and attributes), popularity or trending, and rules (location, dates, availability);
    • ranking: a learning-to-rank model (gradient-boosted trees or a neural model) using user, item and context features (price sensitivity, past stays, device, season), optimised for bookings or revenue;
    • business rules and filters: availability, diversity, margin, fairness, and the exclusion of what's already booked.
  • Where LLMs and embeddings help:
    • embeddings for semantic item similarity and cold start (a new hotel with no booking history);
    • understanding natural-language preferences ("quiet place near the beach for a family"), turning them into structured filters and embeddings;
    • generating explanations ("recommended because you liked…").
  • The architecture:
    • features come from a feature store, and events (views, clicks, bookings) through Kafka;
    • batch training, and online serving with a low-latency candidate index (a vector store) plus the ranking service;
    • caching of recommendations per segment.
  • Evaluation: offline (precision@k, NDCG), then online A/B tests (conversion, revenue per visitor); watch feedback loops and filter bubbles; respect privacy and consent.

Advertisement

Follow-up questions this topic invites — and their answers

Q: How do you choose a chunk size? A: Big enough to hold a complete idea, small enough to be specific (a few hundred tokens is common), split on document structure (headings, paragraphs), with some overlap. Validate the choice with retrieval metrics on real questions.

Q: What is hybrid search? A: Combining keyword (BM25) and vector similarity scores, often with reciprocal rank fusion. Keywords catch exact terms (codes, names); vectors catch meaning and paraphrases. Together they beat either alone.

Q: What is reranking? A: A second, more accurate (and slower) model, such as a cross-encoder, re-scores the top candidates from retrieval against the query, improving the precision of the few chunks put into the prompt.

Q: RAG or fine-tuning? A: RAG for knowledge that changes or must be cited (policies, catalogues). Fine-tuning for style, format or narrow task behaviour. They can be combined. RAG is usually the first choice because it's cheaper, fresher and more controllable.

Advertisement

Previous

LLM Integration in Java — Spring AI, Bedrock, Prompts, Streaming & Orchestration — Interview Questions

Next

AI Security, Guardrails, Cost & Operations — Interview Questions

AI Tutor

Lesson: RAG, Embeddings, Vector Databases & Conversational Memory — Interview Questions

Quick actions

AI responses can be inaccurate. Verify critical information.