Working with Documents and PDFs
Learn what files Claude can read, how to ask questions that point into a document, how to ask for quotes and locations, and how to check every quote against the source with a real program.
In this lesson you will
- Know what documents and images Claude can read
- Ask questions that point into a document
- Ask for quotes and locations
- Verify quotes against the source
About 22 minutes
Anil wants the key points of a thirty-page report
Anil has a thirty-page committee report and ten minutes before a meeting. He uploads the file to Claude and asks, ‘What did the committee decide, and what are the limits on the budget?’ The reply is clear and confident. It includes a neat quotation about the budget. In the meeting, someone asks where that sentence appears in the report. Anil cannot find it. The wording was close, but one figure was different. This lesson is about working with documents: how to give them to Claude, how to ask good questions of them, and how to make sure what comes back is really in the document.
What you can give Claude
Anthropic’s help pages list the kinds of document Claude can work with, which include PDF, Word documents, spreadsheets, plain text, web pages saved as HTML, e-books and JSON, plus image files such as JPEG, PNG, GIF and WebP. You attach them through the add-files button in the chat box, by dragging them in, or by pasting images from the clipboard, and in a project you can add files that stay available to every chat. Limits on file size, number of files and page counts exist, and they differ by plan and change, so this course does not quote them: look at the current upload help page before you rely on a big file.
Two details from that help page are worth remembering. First, for a PDF, Claude can read both the text and the visual parts, such as charts, when the document is short enough, while for much longer PDFs it may read only the text. Second, for most other file types it extracts the text only, so images embedded inside a Word document may not be seen. If a chart matters, ask yourself whether Claude can actually see it, and if you are not sure, describe it, paste the numbers or upload the chart as an image.
Ask questions that point into the document
- Say what the document is. ‘This is a committee report about the village festival.’
- Say what you need and why. ‘I need the decisions and deadlines, for a meeting in ten minutes.’
- Ask for locations. ‘Give the page or section for each point.’ When you mention pages yourself, use the page numbers shown in your PDF viewer, which can differ from the numbers printed on the page.
- Ask for quotes first. Anthropic’s guidance for long documents suggests asking Claude to extract word-for-word quotes before it answers, and to withdraw any claim it cannot support with a quote.
- Allow gaps. ‘If the document does not say, reply not in the document.’
This is a committee report about the village festival. First, list the exact quotes that mention decisions, dates, or money. Then, using only those quotes, summarise the decisions in five bullet points. Next to each bullet, give the page. If the report does not say, write "not in the report".
Check every quote
Quotes are the easiest thing to check, because a real quotation must appear word for word in the source. The program below takes a short source text and four quotations that a summary claims to take from it. It tidies the spacing and quote marks, and then asks of each one: does it appear exactly? If not, how close is the nearest sentence? It uses a standard way to measure how similar two pieces of text are, with a score from 0 to 1.
import difflib, re
source = ("The committee met on Tuesday and agreed to move the festival to Saturday 17 June "
"because of the weather forecast.\n\nVolunteers will be needed for tables, tea and "
"clean-up. The budget for the day is capped at 400 pounds.\n\nPosters must be "
"printed by Friday, with a 3 mm bleed.")
def norm(t):
return re.sub(r"\s+", " ", t.replace("’", "'").replace("“", '"').replace("”", '"')).strip().lower()
claimed = [
"agreed to move the festival to Saturday 17 June",
"the budget for the day is capped at 500 pounds",
"volunteers will be needed for tables, tea and clean-up",
"the mayor will open the event",
]
src = norm(source)
sentences = [norm(s) for s in re.split(r"(?<=[.!?])\s+", source)]
for q in claimed:
n = norm(q)
if n in src:
print("exact: " + q[:34])
continue
best = max(sentences, key=lambda s: difflib.SequenceMatcher(None, n, s).ratio())
r = difflib.SequenceMatcher(None, n, best).ratio()
print(f"{'altered' if r > 0.7 else 'not found'} ({r:.2f}): " + q[:28])
exact: agreed to move the festival to Sat
altered (0.97): the budget for the day is ca
exact: volunteers will be needed for tabl
not found (0.40): the mayor will open the even
The first and third quotations are exact. The second is altered, with a similarity of 0.97 to the nearest sentence, which is very close, and yet it says 500 pounds where the source says 400. That is the dangerous case: a quotation that looks right and has one changed fact. The fourth, about the mayor, is not found, with a similarity of only 0.40, so it was probably invented. The program cannot tell you why a quote is wrong, only that it is not in the source. That is precisely what you need before you repeat it in a meeting.
Working with long documents
- Start with the structure: ‘List the headings of this document and one line on each.’
- Pick the sections that matter, and ask your real questions of those.
- For very long files, split them into parts, as you learned in lesson 4, summarise each, and then combine.
- Ask for quotes and locations, and spot-check at least three against the original.
- Keep a note of what Claude could not find, because gaps are information too.
Asking a question that mixes the document with what Claude already knows. If you ask ‘Is the budget reasonable?’, it may blend the report’s figures with general knowledge. If you want the document’s own answer, say ‘using only this document’.
Do not upload documents that you are not allowed to share, and remember lesson 9: remove private details first when you can. Check your workplace’s rules about confidential files.
Practice for this lesson
Check what you learned
Five quick questions. Pick an answer and you will see straight away whether it is right and why.
Why ask for quotes before a summary?
- It makes the summary longer
- Quotes tie each claim to the source
- It changes the language
- It skips pages
Pulling out exact quotes first grounds the answer in the actual text.
What kind of quote error is the most dangerous?
- One that is obviously invented
- An exact one
- A short one
- A close one with one changed fact
An almost-right quote looks trustworthy while carrying a wrong figure.
Which page numbers should you use when pointing Claude to a PDF page?
- The numbers shown in your PDF viewer
- The numbers printed on the page only
- Any numbers
- None
Anthropic’s help advises using the PDF viewer’s page numbers.
What does a similarity of 0.40 to the nearest sentence suggest?
- The quote is exact
- The quote is altered slightly
- The quote is probably not in the source
- The source is empty
A low similarity means nothing in the source is close, so the quote was likely invented.
What should you add to keep Claude to the document?
- Be creative
- Use the internet
- Guess if unsure
- Using only this document
Restricting Claude to the document stops it blending in general knowledge.
Summary
- Claude can read many file types, and some content such as charts may not be seen.
- Say what the document is, what you need and ask for locations and quotes.
- Check every quote: exact, altered or not found.
- Restrict answers to the document when you want its own answer.
Questions
What file types can I upload?
Anthropic lists documents such as PDF, DOCX, CSV, TXT, HTML, ODT, RTF, EPUB, JSON and XLSX under some conditions, and images in JPEG, PNG, GIF and WebP. Limits and options change, so check the current upload help page.
Can Claude see charts in a PDF?
For shorter PDFs it can read visual parts as well as text, according to Anthropic's help. For very long PDFs, or other file types, it may read only the text, so do not assume.
Why did it quote something that is not in my document?
Quotes can look authoritative and still be wrong. Ask for exact quotes and page numbers, and verify them against the original.
