Prompt
How do I compare citation frequency across ChatGPT, Claude, and Perplexity without doing it by hand?
Latest observation
You can automate this, but first define what “citation frequency” means, because ChatGPT, Claude, and Perplexity expose references differently.
A practical way to compare them
1) Pick a fixed test set
Use the same prompts across all three tools, for example:
- 50–200 questions
- mix of factual, current-event, and domain-specific queries
- same wording, same order, same temperature/settings if available
2) Standardize the output you’re counting
Decide whether you mean:
- any citation present
- number of cited sources
- citation density = citations per 1,000 words
- claim-level support rate = how often a factual claim is backed by a citation
For comparison, citation density is usually easiest: [ \text{citation density} = \frac{\text{number of citations}}{\text{response length in words}} \times 1000 ]
3) Collect responses automatically
Use APIs or exportable interfaces:
- ChatGPT: OpenAI API
- Claude: Anthropic API
- Perplexity: if you have API access, use that; otherwise you may need browser automation or manual export
Store each response in a structured format like JSON:
{
"model": "chatgpt",
"prompt_id": 12,
"prompt": "...",
"response": "...",
"timestamp": "..."
}
4) Parse citations programmatically
Each platform formats citations differently:
- bracketed numbers:
[1] - inline URLs
- footnotes
- source cards / metadata separate from the text
So use a parser that looks for:
- markdown links
- URLs
- citation markers like
[1],(source), footnote patterns - separate “sources” fields in API output if available
A simple Python approach:
import re
def count_citations(text):
patterns = [
r'\[\d+\]', # [1], [2]
r'https?://\S+', # URLs
r'\(\s*source\s*\)', # (source)
]
count = 0
for p in patterns:
count += len(re.findall(p, text, flags=re.I))
return count
5) Normalize and compare
Compute per response:
- total words
- citation count
- citation density
- citation presence rate
Then aggregate by model:
- mean
- median
- confidence intervals
- by prompt category
6) Use a spreadsheet or notebook
You can do this in:
- Python + pandas
- Google Sheets if the data volume is small
- a database if you’re running many prompts
Example analysis in pandas:
import pandas as pd
df = pd.read_json("responses.jsonl", lines=True)
df["word_count"] = df["response"].str.split().str.len()
df["citation_count"] = df["response"].apply(count_citations)
df["citation_density"] = df["citation_count"] / df["word_count"] * 1000
summary = df.groupby("model")[["citation_count", "citation_density"]].mean()
print(summary)
Important caveat
These models may cite differently because of product design, not just behavior:
- Perplexity is citation-first
- ChatGPT may cite less unless browsing or source-backed mode is enabled
- Claude may not produce formal citations unless prompted or using a tool/workflow that supplies sources
So compare them under the same instructions if you want a fair test, for example:
“Answer with citations for every factual claim if possible, and include sources inline.”
Best practice
If you want a robust study, measure more than just count:
- citation frequency
- source diversity
- citation accuracy
- whether citations actually support the claim
- hallucinated or irrelevant citations
If you want, I can help you with one of these:
- a Python script to do the whole comparison
- a spreadsheet template
- a research design for a fair benchmark
- a browser-automation approach if you don’t have APIs