A summary without sources is just claims without evidence. Lack of citations is one of the primary reasons users don't trust AI-generated content.
Let's add citations to our summary so users can verify and explore further. Citations matter for:
The simplest approach is to have the LLM keep track of all the sources during summarization, in other words, just asking the model to include sources in its output:
Write a summary that answers the query.
Cite the sources I've given you using the format [1], [2], etc. when referencing them.
Expected LLM output is now:
"The most intense bear attacks occur in The Revenant [1] where Hugh Glass is
mauled by a grizzly, and Backcountry [3] which depicts a true story of a camping
trip gone wrong."
Which we can display alongside the actual search results:
Add a citation-aware answer command that references its sources.
prompt = f"""Answer the query below and give information based on the provided documents.
The answer should be tailored to users of Hoopla, a movie streaming service.
If not enough information is available to provide a good answer, say so, but give the best answer possible while citing the sources available.
Query: {query}
Documents:
{documents}
Instructions:
- Provide a comprehensive answer that addresses the query
- Cite sources in the format [1], [2], etc. when referencing information
- If sources disagree, mention the different viewpoints
- If the answer isn't in the provided documents, say "I don't have enough information"
- Be direct and informative
Answer:"""
Search Results:
- Dark Star
- Terra
- Eliminators
- Destricted
- The Octagon
LLM Answer:
<ANSWER WITH CITATIONS>
Once the new command is working, submit the CLI tests.