-
Notifications
You must be signed in to change notification settings - Fork 770
Gave instructions to correct citation on answer #929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
key should be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR clarifies the required citation format by preventing the use of non-citation-key formats in answers.
- Updates the test suite to reject answers containing a citation with a name and year
- Enhances the prompt instructions to specify allowed citation formats and provide examples
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/test_agents.py | Adds a test assertion to ensure answers contain valid citation keys |
paperqa/prompts.py | Updates prompt instructions to enforce strict citation key formats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the PR description, can you provide the output that made you discover this issue, for posterity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
tests/test_agents.py
Outdated
@@ -973,6 +973,30 @@ async def test_clinical_tool_usage(agent_test_settings) -> None: | |||
), "No clinical trials were put into contexts" | |||
|
|||
|
|||
@pytest.mark.asyncio | |||
async def test_citation_formatting(agent_test_settings): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of collapsing this test into a subtest of test_agent_types
, and it would actually:
- Decrease CI runtime (since we're already running the agent in those tests)
- Increase the coverage of the assertions, since more agents types are used there
tests/test_agents.py
Outdated
assert not re.search( | ||
name_year_regex, response.session.answer | ||
), "Answer contains citation with name and year instead of citation key" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion fails on current main
branch, nice work here!! 🚀
The LLM sometimes broke the pattern by using citation styles other than the citation key, which caused problems on the platform downstream. This PR gives more instructions on how the citation should be included in the answer.
A few examples of wrong citations:
1 - Task: What is the molecule known to have the greatest solubility in water?
Answer: (...) Similarly, studies on aqueous solubility in drug discovery (e.g., Ishikawa and Hashimoto, 2011) discuss extremely low solubility values for particular organic compounds, but these systems are not directly comparable to the gas-phase solubility measurements in Hildebrand’s work. (...)
Issue: Ishikawa and Hashimoto, 2011 is not a citation key
2 - Task: What is the molecule known to have the greatest solubility in water?
Answer: (...) Therefore, based solely on the provided context, ammonia (NH₃) is the molecule known to have the greatest solubility in water (hildebrand1916solubility pages 14–17).
Issue: * Hildebrand’s 1916 paper (pages 14–17) * and hildebrand1916solubility should be this paper. It should have used "hildebrand1916solubility. pages 17-19". The difference is the period.
We need to use whatever the citation key is and avoid the LLM from changing it