File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -751,6 +751,12 @@ When creating contextual summaries on a given chunk (a `Text`),
751
751
the summary LLM is passed both the chunk's text and the chunk's associated media,
752
752
but the output contextual summary itself remains text-only.
753
753
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
+
754
760
### Using External DB/Vector DB and Caching
755
761
756
762
You may want to cache parsed texts and embeddings in an external database or file.
Original file line number Diff line number Diff line change 112
112
" Your summary, combined with many others,"
113
113
" will be given to the model to generate an answer."
114
114
" 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 \n where `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 \n The 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 }}'
116
128
"\n \n where `summary` is relevant information from the text - {summary_length} words."
117
129
" `relevance_score` is an integer 0-10 for the relevance of `summary` to the question."
118
130
" `used_images` is a boolean flag indicating"
Original file line number Diff line number Diff line change 61
61
llm_parse_json ,
62
62
map_fxn_summary ,
63
63
)
64
- from paperqa .prompts import CANNOT_ANSWER_PHRASE
64
+ from paperqa .prompts import CANNOT_ANSWER_PHRASE , summary_json_multimodal_system_prompt
65
65
from paperqa .prompts import qa_prompt as default_qa_prompt
66
66
from paperqa .readers import PDFParserFn , parse_image , read_doc
67
67
from paperqa .settings import AsyncContextSerializer
@@ -1592,6 +1592,7 @@ async def test_images(stub_data_dir: Path) -> None:
1592
1592
# We don't support image embeddings yet, so disable embedding
1593
1593
settings .answer .evidence_retrieval = False
1594
1594
settings .parsing .defer_embedding = True
1595
+ settings .prompts .summary_json_system = summary_json_multimodal_system_prompt
1595
1596
1596
1597
docs = Docs ()
1597
1598
districts_docname = await docs .aadd (
@@ -1634,6 +1635,7 @@ async def test_images_corrupt(stub_data_dir: Path) -> None:
1634
1635
# We don't support image embeddings yet, so disable embedding
1635
1636
settings .answer .evidence_retrieval = False
1636
1637
settings .parsing .defer_embedding = True
1638
+ settings .prompts .summary_json_system = summary_json_multimodal_system_prompt
1637
1639
1638
1640
docs = Docs ()
1639
1641
districts_docname = await docs .aadd (
You can’t perform that action at this time.
0 commit comments