# Response Inconsistency

## The Problem

Same query returns different answers on repeated asks, causing user confusion and reducing trust in the AI system.

### Symptoms

* ❌ Different facts for identical queries
* ❌ Contradictory answers in same session
* ❌ Unpredictable response quality
* ❌ Cannot reproduce errors
* ❌ Users report "AI is unreliable"

### Real-World Example

```
Query: "What's the API rate limit?"

Response 1: "The rate limit is 1000 requests per hour"
Response 2: "You can make up to 100 requests per minute"
Response 3: "Rate limits vary by plan tier"

All from same knowledge base!
Causes: Different retrieved chunks, different model sampling, different timestamp
```

***

## Deep Technical Analysis

### Sources of Inconsistency

**Retrieval Variance:**

```
Vector search returns slightly different results:
→ Query embedding has minor variations
→ Reranker scores fluctuate
→ Top-K boundary shifts

Query 1 retrieves: Chunks A, B, C
Query 2 (identical) retrieves: Chunks A, C, D
→ Different context → different answer
```

**Temperature/Sampling:**

```
With temperature > 0:
→ Stochastic token sampling
→ Different paths through text generation
→ Same context → different phrasing

Can cause factual inconsistency if rephrasing drifts
```

**Timestamp Dependencies:**

```
Knowledge base updates:
→ Morning: Old doc present
→ Afternoon: Doc updated
→ Same query, different answers

Time-based inconsistency
```

***

## How to Solve

**Set temperature=0 for deterministic output + implement query deduplication with caching + use consistent retrieval (fixed random seed) + log query-response pairs for debugging + add "last updated" timestamps to responses.** See [Response Consistency](/rag-scenarios-and-solutions/llm/response-inconsistency.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.twig.so/rag-scenarios-and-solutions/llm/response-inconsistency.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
