How to control the count of relevant papers and the words of answer?
Opened this issue · 1 comments
``I got 800 papers and I want the paperqa can read most of them to give me a answer. But the paperqa usually answer that with less than 30 paper and 15 relevant paper.
So, the question is how can I control these thing like relevant paper?
import os
from paperqa import Docs,ask
from paperqa import Settings
from paperqa.settings import Settings, AgentSettings, AnswerSettings
local_llm_config = {
"model_list": [
{
"model_name": "ollama/llama3.1",
"litellm_params": {
"model": "ollama/llama3.1",
"api_base": "http://localhost:11434"},
"answer": {
"evidence_k": 20,
"evidence_detailed_citations": True,
"evidence_summary_length": "about 100 words",
"answer_max_sources": 5,
"answer_length": "about 200 words, but can be longer",
"max_concurrent_requests": 4,
"answer_filter_extra_background": False
}
}
]
}
settings = Settings(
llm="ollama/llama3.1",
llm_config=local_llm_config,
summary_llm="ollama/llama3.1",
summary_llm_config=local_llm_config,
paper_directory="D:\zotero\storage",
# agent=AgentSettings(agent_llm_config=local_llm_config,
# agent_llm="ollama/llama3.1",
# agent_type="ToolSelector"),
answer=AnswerSettings(evidence_k=40), # optional
embedding="ollama/mxbai-embed-large:335m",
fast= True
)
query = "How the distribution of texture affects the mechanical properties of the material?"
response = ask(query, settings)
(paperqa) PS D:\Programing\paper-qa> & C:/Users/20171006/.conda/envs/paperqa/python.exe d:/Programing/paper-qa/Main.py
[16:36:48] Starting paper search for 'Here are three unique keyword searches with varying levels of specificity:'.
[16:36:49] paper_search for query 'Here are three unique keyword searches with varying levels of specificity:' and offset 0 returned 8 papers.
Starting paper search for 'Material texture, 2010-2024'.
[16:36:50] paper_search for query 'Material texture, 2010-2024' and offset 0 returned 8 papers.
Status: Paper Count=14 | Relevant Papers=0 | Current Evidence=0 | Current Cost=$0.0000
Starting paper search for 'Texture microstructure relationships in materials science, 2005-'.
paper_search for query 'Texture microstructure relationships in materials science, 2005-' and offset 0 returned 8 papers.
Status: Paper Count=21 | Relevant Papers=0 | Current Evidence=0 | Current Cost=$0.0000
Starting paper search for 'Nano-scale texture effects on mechanical properties, 2015-2022'.
[16:36:51] paper_search for query 'Nano-scale texture effects on mechanical properties, 2015-2022' and offset 0 returned 8 papers.
Status: Paper Count=29 | Relevant Papers=0 | Current Evidence=0 | Current Cost=$0.0000
gather_evidence starting for question 'How the distribution of texture affects the mechanical properties of the material?'.
Status: Paper Count=29 | Relevant Papers=0 | Current Evidence=0 | Current Cost=$0.0000
gather_evidence starting for question 'How the distribution of texture affects the mechanical properties of the material?'.
[16:38:11] Status: Paper Count=29 | Relevant Papers=13 | Current Evidence=26 | Current Cost=$0.0000
[16:38:11] Status: Paper Count=29 | Relevant Papers=13 | Current Evidence=26 | Current Cost=$0.0000
Generating answer for 'How the distribution of texture affects the mechanical properties of the material?'.
[16:38:19] Status: Paper Count=29 | Relevant Papers=13 | Current Evidence=26 | Current Cost=$0.0000
Answer: ### Distribution of Texture Affects Mechanical Properties:
The distribution of texture significantly affects the mechanical properties of materials due to crystalline anisotropy. This is because texture is a measure of the orientation-dependent behavior of each grain and
boundary conditions of the crystals, influencing strength, shape change, strain hardening, surface roughening, and damage.
Texture influences mechanical properties by affecting the rate of twinning and detwinning in materials like magnesium alloys (Wu2010 pages 7-7). The presence of twins and their subsequent reversal lead to
post-detwinning deformation, which must be accommodated by elastic deformation or harder non-basal dislocation slip. This affects the hardening and softening behavior during cyclic loading.
In addition, texture distribution impacts the Taylor factor (Marattukalam2020 pages 8-9), with materials having higher Taylor factors requiring greater axial stress to be plastically deformed. The Taylor factor is an orientation factor that depends on the texture of the materials and on the crystallographic nature of the assumed slip systems.
Furthermore, texture can influence mechanical properties by affecting deformation twinning (gaag2023anovelapproach pages 10-10). A higher Co content may increase the work hardening rate in a TRIP effect, while
deformation twinning may appear due to low stacking fault energy.
To control the number of relevant papers and the length of the answer in paperqa, you can adjust the following parameters in your configuration:
-
Number of Relevant Papers: Increase the
evidence_k
parameter. This parameter determines how many relevant papers are processed. For example, settingevidence_k
to 40 will allow the system to consider up to 40 relevant papers. -
Length of the Answer: Adjust the
answer_length
parameter. This controls the length of the generated answer. You can specify a longer or shorter answer by changing this setting, such as "about 300 words" if you want a more detailed response.
Here's how you can modify your configuration:
local_llm_config = {
"model_list": [
{
"model_name": "ollama/llama3.1",
"litellm_params": {
"model": "ollama/llama3.1",
"api_base": "http://localhost:11434"},
"answer": {
"evidence_k": 40, # Increase to process more papers
"evidence_detailed_citations": True,
"evidence_summary_length": "about 100 words",
"answer_max_sources": 5,
"answer_length": "about 300 words, but can be longer", # Adjust for longer answers
"max_concurrent_requests": 4,
"answer_filter_extra_background": False
}
}
]
}
By increasing evidence_k
and adjusting answer_length
, you can better control the number of papers considered and the detail level of the answers provided [1].