Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
Citations GitHub Copilot Grounding Hallucinations IMCSEIAN intermediate Tutorial

Hallucination Reduction with Grounding and Citations

Reviewed & accurate
AI Summary
IMCSEIAN · GitHub Copilot Master Course

Hallucination Reduction with Grounding and Citations

Cut hallucinations with sources — 'cite file:line', 'if uncertain say so', grounding via attachments.

Phase 2 — Intermediate Lesson IN-31 Difficulty: Intermediate 10 min read
Course: GitHub Copilot Phase 2 — Intermediate 10 min read Last verified: 2026-08-30

What You Will Learn

  • Reduce hallucinations with grounding.
  • Use citation-style prompts.
  • Add 'if uncertain say so'.
  • Ground via attachments.
  • Measure hallucination rate.

Why This Matters

Hallucinations (BE-31) are reduced dramatically by grounding Copilot in specific sources and asking for citations. This lesson builds the grounding habit that cuts hallucination rate.

Concept Explained

Grounding anchors Copilot's answers in specific sources: attached files, cited code, explicit 'if uncertain say so'. Grounded answers are verifiable; ungrounded answers are trust-me.

How It Works

Attach relevant files. Add 'cite file:line for each claim'. Add 'if uncertain, say so explicitly'. Verify citations against actual code. Treat unverified claims as hallucinations.

Step-by-Step Tutorial

1. Attach sources

Files, docs, code. Primary context.

2. Add citation requirement

'Cite file:line for each claim.'

3. Add uncertainty requirement

'If you're not certain, say so explicitly. Don't guess.'

4. Verify citations

Open each cited file:line. Confirm claim matches.

5. Reject unverified

Claims without citations = hallucinations. Don't trust.

Real-World Example

A team adopted grounding for all codebase questions. Hallucination rate dropped from ~30% (unverified) to <5% (with grounding + citations). The 5% were caught by verification. Grounding transformed Copilot from 'unreliable assistant' to 'verifiable colleague'.

Example Prompts / Commands / Code

Grounding prompt templateimcseian
@workspace [Your question]

For each claim:
1. Cite the file:line where it's implemented.
2. Mark [GROUNDED] if you found it in code.
3. Mark [INFERRED] if from general knowledge.
4. If uncertain, say 'I'm not certain about this' explicitly.

Don't guess. If you can't find it in the codebase, say so.
Attachment groundingimcseian
Attach: src/auth/service.ts
Attach: docs/auth-architecture.md

Based on these sources, answer: How does token refresh work?

Cite file:line from the attached sources for each step.
If the attached sources don't cover something, say so.

Common Mistakes

  • Not attaching sources — Copilot guesses.
  • Not asking for citations — can't verify.
  • Not verifying citations — Copilot can cite wrong lines.
  • Trusting INFERRED claims — they're not grounded.

Best Practices

  • Attach relevant files as primary context.
  • Ask for file:line citations.
  • Use [GROUNDED] vs [INFERRED] markers.
  • Add 'if uncertain, say so' instruction.
  • Verify citations by reading code.

Troubleshooting

ProblemHow to Fix
Copilot can't citeIt's hallucinating. Don't trust. Attach more context.
Citations are wrongVerify yourself. Re-ask with correct file attached.

Practical Exercise

Your Turn

Take a codebase question. Ask without grounding. Then ask with grounding + citations. Compare answer quality and verifiability.

Professional Challenge

Stretch Goal

Measure hallucination rate before and after grounding. Run 20 questions each way. Document the improvement.

Key Takeaways

  • Grounding anchors answers in specific sources.
  • Attach relevant files.
  • Ask for file:line citations.
  • Use [GROUNDED] vs [INFERRED] markers.
  • Add 'if uncertain, say so' instruction.

Frequently Asked Questions

Does grounding eliminate hallucinations?
No — reduces dramatically. Verification catches the rest.
Is 'INFERRED' always wrong?
No — but lower confidence. Verify before trusting.

Further Reading

Official References

Related lessons: BE-31, IN-14

SEO Metadata

SEO title: Hallucination Reduction with Grounding and Citations

Meta description: Cut hallucinations with sources — 'cite file:line', 'if uncertain say so', grounding via attachments.

Primary keyword: hallucination reduction with grounding and citations

Secondary keywords: hallucination reduction with grounding and citations

Search intent: Informational

URL slug: /hallucination-reduction-grounding-citations-copilot

Categories: AI Tools, GitHub Copilot

Tags: GitHub Copilot, Intermediate, Hallucinations, Grounding, Citations, IMCSEIAN, Tutorial, IMCSEIAN

Featured image concept: IMCSEIAN lesson card for Hallucination Reduction with Grounding and Citations

Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments