Skip to content

Commit b7a017c

Browse files
committed
Moved used_images to only be opted into via summary_json_multimodal_system_prompt
1 parent e071423 commit b7a017c

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,12 @@ When creating contextual summaries on a given chunk (a `Text`),
751751
the summary LLM is passed both the chunk's text and the chunk's associated media,
752752
but the output contextual summary itself remains text-only.
753753

754+
If you would like,
755+
specifying the prompt `paperqa.prompts.summary_json_multimodal_system_prompt`
756+
to `prompt.summary_json_system`
757+
will include a `used_images` flag attributing
758+
usage of images in any contextual summarizations.
759+
754760
### Using External DB/Vector DB and Caching
755761

756762
You may want to cache parsed texts and embeddings in an external database or file.

src/paperqa/prompts.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,19 @@
112112
" Your summary, combined with many others,"
113113
" will be given to the model to generate an answer."
114114
" Respond with the following JSON format:"
115-
'\n\n{{\n "summary": "...",\n "relevance_score": 0-10,\n "used_images"\n}}'
115+
'\n\n{{\n "summary": "...",\n "relevance_score": 0-10\n}}'
116+
"\n\nwhere `summary` is relevant information from the text - {summary_length} words."
117+
" `relevance_score` is an integer 0-10 for the relevance of `summary` to the question."
118+
"\n\nThe excerpt may or may not contain relevant information."
119+
" If not, leave `summary` empty, and make `relevance_score` be 0."
120+
)
121+
summary_json_multimodal_system_prompt = (
122+
"Provide a summary of the relevant information"
123+
" that could help answer the question based on the excerpt."
124+
" Your summary, combined with many others,"
125+
" will be given to the model to generate an answer."
126+
" Respond with the following JSON format:"
127+
'\n\n{{\n "summary": "...",\n "relevance_score": 0-10,\n "used_images": "..."\n}}'
116128
"\n\nwhere `summary` is relevant information from the text - {summary_length} words."
117129
" `relevance_score` is an integer 0-10 for the relevance of `summary` to the question."
118130
" `used_images` is a boolean flag indicating"

tests/test_paperqa.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
llm_parse_json,
6262
map_fxn_summary,
6363
)
64-
from paperqa.prompts import CANNOT_ANSWER_PHRASE
64+
from paperqa.prompts import CANNOT_ANSWER_PHRASE, summary_json_multimodal_system_prompt
6565
from paperqa.prompts import qa_prompt as default_qa_prompt
6666
from paperqa.readers import PDFParserFn, parse_image, read_doc
6767
from paperqa.settings import AsyncContextSerializer
@@ -1592,6 +1592,7 @@ async def test_images(stub_data_dir: Path) -> None:
15921592
# We don't support image embeddings yet, so disable embedding
15931593
settings.answer.evidence_retrieval = False
15941594
settings.parsing.defer_embedding = True
1595+
settings.prompts.summary_json_system = summary_json_multimodal_system_prompt
15951596

15961597
docs = Docs()
15971598
districts_docname = await docs.aadd(
@@ -1634,6 +1635,7 @@ async def test_images_corrupt(stub_data_dir: Path) -> None:
16341635
# We don't support image embeddings yet, so disable embedding
16351636
settings.answer.evidence_retrieval = False
16361637
settings.parsing.defer_embedding = True
1638+
settings.prompts.summary_json_system = summary_json_multimodal_system_prompt
16371639

16381640
docs = Docs()
16391641
districts_docname = await docs.aadd(

0 commit comments

Comments
 (0)