Real-time Question-Answering System with Two-Stage LLM Architecture for Sales Content Recommendations

microsoft · Tech · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Sales copilot content recommendation and question answering

Microsoft sellers needed relevant sales documentation from Seismic inside MSX Sales Copilot quickly enough to use during calls or preparation, despite lacking programmatic access to full document content.

Constraints:

Architecture

The system uses a two-stage retrieval architecture deployed as an Azure Machine Learning endpoint and invoked from MSX Sales Copilot through Semantic Kernel. A DistilBERT bi-encoder embeds seller queries and metadata-engineered document prompts for fast top-100 retrieval; a MiniLM cross-encoder then re-ranks query-document pairs and returns the top five sales documents.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  A["MSX Sales Copilot"] --> B["Semantic Kernel planner"]
  B --> C["AML recommendation endpoint"]
  D["Seismic metadata catalog"] --> E["Metadata prompt builder"]
  E --> F["Offline document embeddings"]
  J["Weekly metadata refresh"] --> D
  J --> F
  C --> G["Bi-encoder retriever"]
  F --> G
  G --> H["Cross-encoder reranker"]
  H --> I["Top-5 recommendation results"]
  I --> A
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
MSX Sales Copilot Dynamics CRM copilot interface used by Microsoft sellers. Semantic Kernel planner
Semantic Kernel planner Routes seller questions to the content recommendation skill. MSX Sales Copilot, AML recommendation endpoint
AML recommendation endpoint Real-time inference endpoint hosting the two-stage recommender. Semantic Kernel planner, Bi-encoder retriever, Cross-encoder reranker
Seismic metadata catalog Sales-content metadata source used because full document content was unavailable. Metadata prompt builder
Metadata prompt builder Converts categorical and numerical metadata into natural-language document prompts. Seismic metadata catalog, Offline document embeddings
Offline document embeddings Precomputed document-prompt embeddings for fast retrieval. Metadata prompt builder, Bi-encoder retriever
Bi-encoder retriever DistilBERT/MS MARCO retrieval stage that embeds queries and retrieves top candidates by cosine similarity. AML recommendation endpoint, Offline document embeddings, Cross-encoder reranker
Cross-encoder reranker MiniLM/MS MARCO re-ranking stage over query-document pairs. AML recommendation endpoint, Bi-encoder retriever, Top-5 recommendation results
Top-5 recommendation results Ranked sales documents returned to the seller. Cross-encoder reranker, MSX Sales Copilot
Weekly metadata refresh Refresh process that keeps document metadata current with Seismic changes. Seismic metadata catalog, Offline document embeddings

Data flow

Seismic metadata is transformed into natural-language document prompts and embedded offline by the bi-encoder. At query time, Semantic Kernel routes a seller request to the AML endpoint, the query is embedded, cosine similarity retrieves top candidates, the cross-encoder re-ranks the top 100 query-document pairs, and the Copilot interface returns the top five documents.

3 supporting quotes
“LLM embeddings of sellers' queries can be matched with the relevant content.”article, stated
“Using a bi-encoder with cross-encoder re-ranker architecture”article, stated
“Our recommender system is deployed as an AML endpoint for real-time inferencing”article, stated

Why this architecture

The two-stage design balances latency and relevance: precomputed bi-encoder embeddings make retrieval fast, while the cross-encoder adds query-document interaction only on a narrowed candidate set. Metadata prompt engineering compensates for the lack of direct document-content access.

3 supporting quotes
“The key advantage is that document embeddings can be pre-computed offline and cached, making real-time inference fast.”summary, stated
“The limitation of this approach is that it neglects cross-interaction between query and document”summary, stated
“did not have programmatic access to the actual content of documents, only their metadata.”summary, stated

Models used: DistilBERT MS MARCO bi-encoder · MS MARCO MiniLM cross-encoder

Scale

Alternatives considered (roads not taken)

Use a single-stage bi-encoder retriever only

Rejected because: The full two-stage architecture produced more relevant recommendations for most evaluated queries.

“The team validated the two-stage architecture against a single-stage retriever-only baseline.”summary, stated
“Human experts confirmed that 90% of queries received more relevant recommendations using the full architecture.”summary, stated

Pass too few candidates to the cross-encoder

Rejected because: Small K values lacked enough diversity for the reranker.

“Too few candidates (K≲20) provided insufficient diversity”summary, stated

Pass too many candidates to the cross-encoder

Rejected because: Large K values created unacceptable latency.

“too many (K≳200) created unacceptable latency.”summary, stated

Search full document content directly

Rejected because: Programmatic access to actual document content was not available at the time.

“Dependence on metadata alone limits recommendation quality compared to content-aware systems”summary, stated

Patterns

rag-retrieval (retrieval)

The recommender matches seller questions to relevant sales documents using bi-encoder retrieval and cross-encoder re-ranking.

“LLM embeddings of sellers' queries can be matched with the relevant content.”article, stated

cost-aware-routing (operations)

Offline document embeddings, top-K retrieval, and tuned cross-encoder batch size reduce real-time compute and latency.

“The offline pre-computation of document embeddings is a critical optimization pattern for production systems, reducing inference-time compute to only query embedding and similarity computation for the first stage.”summary, stated
“The cross-encoder batch size parameter proved critical for latency optimization. Testing showed that batch sizes of 2 or 4 provided the best latency characteristics.”summary, stated

eval-driven-development (quality)

The team used human annotation, ablation studies, latency tests, and seller survey feedback to validate retrieval quality and production usefulness.

“Four human domain experts rated the top-5 results for 31 evaluation queries on a 0-5 scale (where 5 means all results are relevant). Results showed:”summary, stated
“The team validated the two-stage architecture against a single-stage retriever-only baseline. Human experts confirmed that 90% of queries received more relevant recommendations using the full architecture.”summary, stated

prompt-versioning (context)

Document metadata was engineered into natural-language prompts so the embedding model could operate on structured features.

“engineering prompts in an elaborate fashion that makes use of the rich set of meta-features available for documents and sellers.”article, stated

Tradeoffs

Use a bi-encoder followed by a cross-encoder.

Chose Two-stage retrieval and re-ranking over Single-stage retrieval.

Rationale: The bi-encoder gives speed through cached embeddings; the cross-encoder adds pairwise relevance for the narrowed set.

“The first stage uses a DistilBERT model pre-trained on the MS MARCO dataset to generate embeddings. This architecture processes the query and document prompts independently through the same encoder, then computes cosine similarity between them.”summary, stated
“The second stage uses a MS MARCO MiniLM cross-encoder model that processes query-document pairs together, enabling attention mechanisms between them.”summary, stated

Represent numerical metadata as categorical labels in prompts.

Chose Percentile-mapped high/medium/low/zero labels over Raw numerical metadata in document prompts.

Rationale: Natural-language prompts fit the embedding model better than raw metrics while preserving engagement signals.

“For numerical features, the team introduced a mapping function that converts raw numbers into categorical labels (high, medium, low, zero) based on percentile thresholds (85th and 65th percentiles).”summary, stated

Refresh metadata weekly rather than continuously.

Chose Weekly refresh cycle over Real-time document metadata updates.

Rationale: A weekly cadence kept the catalog current enough while avoiding a real-time update pipeline.

“The system operates on a weekly refresh cycle to accommodate changes in document metadata from the Seismic catalog.”summary, stated

Gotchas (what bit them)

No direct document-content access forced a metadata-only recommender.

Root cause: The Seismic document content was not programmatically accessible.

Resolution: The team converted about 20 metadata features into English-formed document prompts for embedding.

“did not have programmatic access to the actual content of documents, only their metadata.”summary, stated
“Since document content was unavailable, the team developed an elaborate prompt engineering approach to transform document metadata into natural language descriptions suitable for embedding. Each document is characterized by approximately 20 metadata features (both categorical and numerical).”summary, stated

The cross-encoder improves relevance but can dominate latency if the candidate set is too large.

Root cause: Cross-encoder inference must process query-document pairs at request time.

Resolution: The team tuned K and found K=100 balanced recall and latency.

“The cross-encoder cannot operate offline since the query is not known in advance.”summary, stated
“The team experimented with different values for K (the number of candidates passed to the re-ranker) and found K=100 to be optimal, balancing latency against recall. Too few candidates (K≲20) provided insufficient diversity, while too many (K≳200) created unacceptable latency.”summary, stated

Verbose or generic seller queries hurt recommendation relevance.

Root cause: The semantic matching setup struggled when queries lacked focused retrieval intent.

Resolution: Human evaluation identified this failure mode for future refinement.

“Annotators noted that "not relevant" queries tended to be too verbose or generic. Individual annotator averages ranged from 2.74 to 3.26, indicating consistent evaluation without significant bias.”summary, stated

Evaluation

Microsoft used human expert ratings, ablation against a retriever-only baseline, latency tests across Azure VM configurations, and post-launch seller feedback.

Metrics: Top-5 relevance score from four human experts · 15/31 relevant queries · 9/31 somewhat relevant queries · 7/31 not relevant queries · 90% of queries improved by full two-stage architecture · Median latency by VM/batch size · Task relevance rating 4/5 · Document relevancy rating 3.7/5

3 supporting quotes
“• 15/31 queries rated as "relevant" (scores 3.5-5)”summary, stated
“Human experts confirmed that 90% of queries received more relevant recommendations using the full architecture.”summary, stated
“• Task relevance rating: 4 out of 5”summary, stated

Outcomes

Production deployment in MSX Sales Copilot; top-100 retrieval, top-5 results, 31-query expert evaluation, K=100 reranking, weekly metadata refresh, GPU median latency of 0.54s at batch size 2.

3 supporting quotes
“integrated into a Copilot interface that is now deployed in the production version of the Dynamics CRM, known as MSX”article, stated
“Sellers reported the new system as a "tremendous improvement" over the previous filter-based external search, particularly valuing the integration directly into the MSX interface rather than requiring navigation to the Seismic website.”summary, stated
“• Document relevancy rating: 3.7 out of 5”summary, stated