# Citations and confidence (/docs/knowledge/answers/citations-and-confidence)
A model can sound sure about something it never read. Docklee checks every answer against the chunks the engine actually used before it returns it. Citations show where an answer came from, and confidence shows how well your sources support it.

## How an answer is checked [#how-an-answer-is-checked]

1. **Keep only real citations.** A citation that doesn't point to one of the chunks used for the answer is removed.
2. **Compare the answer with the sources.** Docklee measures how much of the answer's wording appears in those chunks.
3. **Adjust confidence.** The confidence the model reported is then adjusted:

| The check finds | Confidence becomes |
| --- | --- |
| No valid citation | `0` |
| Little overlap between the answer and its sources | Half of the reported value |
| Strong overlap between the answer and its sources | The reported value plus `0.1`, up to `1` |
| Anything in between | The reported value |

## Citations [#citations]

| Python | TypeScript | HTTP | Description |
| --- | --- | --- | --- |
| `chunk_id` | `chunkId` | `chunk_id` | The chunk the answer drew on. Matches `chunk_id` from `retrieve`. |
| `page_number` | `pageNumber` | `page_number` | The page in the source, when the source has pages. |
| | | `section_title` | The section heading in the source, when there is one. |

Use `page_number` and `section_title` to label a citation, such as "Refund policy, page 4".

## Use confidence in your app [#use-confidence-in-your-app]

<CodeTabs items={['Python', 'TypeScript']}>
  <Tab value="Python">
    ```python
    result = lynk.query_sync(question)

    if result.confidence == 0:
        reply = "I couldn't find that in our documentation."
    elif result.confidence < 0.5:
        reply = f"{result.answer}\n\nPlease double-check this with the source."
    else:
        reply = result.answer
    ```
  </Tab>
  <Tab value="TypeScript">
    ```ts
    const result = (await lynk.query(question)) as KnowledgeResult;

    let reply: string;
    if (result.confidence === 0) {
      reply = "I couldn't find that in our documentation.";
    } else if (result.confidence < 0.5) {
      reply = `${result.answer}\n\nPlease double-check this with the source.`;
    } else {
      reply = result.answer;
    }
    ```
  </Tab>
</CodeTabs>

<Callout type="idea">
Pick thresholds by testing real questions against your own engine. A cutoff that suits one set of sources can be too strict for another.
</Callout>

## Answers without citations [#answers-without-citations]

A [Precision Mode](/docs/knowledge/retrieval/precision-mode) answer is prepared ahead of time, so it comes back with its confidence and no citations.

## Next steps [#next-steps]

You can tell how much to trust an answer. See how an engine searches both kinds of source next.

<Cards>
  <Card title="Vector and OKF together" href="/docs/knowledge/retrieval/vector-and-okf" description="How results from both are merged." />
  <Card title="Answer modes" href="/docs/knowledge/answers/answer-modes" description="How strictly answers stay within your sources." />
  <Card title="Troubleshooting" href="/docs/knowledge/troubleshooting" description="When answers aren't what you expect." />
</Cards>
