In [92]:
## Handle secrets either from env vars or streamlit manager
import streamlit as st
import os
api_key = os.getenv("LITELLM_KEY")
if api_key is None:
api_key = st.secrets["LITELLM_KEY"]
cirrus_key = os.getenv("CIRRUS_KEY")
if cirrus_key is None:
cirrus_key = st.secrets["CIRRUS_KEY"]
In [93]:
import os
import requests
import zipfile
def download_and_unzip(url, output_dir):
response = requests.get(url)
zip_file_path = os.path.basename(url)
with open(zip_file_path, 'wb') as f:
f.write(response.content)
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
zip_ref.extractall(output_dir)
os.remove(zip_file_path)
download_and_unzip("https://minio.carlboettiger.info/public-data/hwc.zip", "hwc")
In [94]:
import pathlib
from langchain_community.document_loaders import PyPDFLoader
def pdf_loader(path):
all_documents = []
docs_dir = pathlib.Path(path)
for file in docs_dir.iterdir():
loader = PyPDFLoader(file)
documents = loader.load()
all_documents.extend(documents)
return all_documents
docs = pdf_loader('hwc/')
In [95]:
# NRP embedding model tends to throw errors
# embedding = OpenAIEmbeddings(model = "embed-mistral", api_key = api_key, base_url = "https://llm.nrp-nautilus.io")
In [96]:
## Use the model on Cirrus instead:
from langchain_openai import OpenAIEmbeddings
embedding = OpenAIEmbeddings(
model = "cirrus",
api_key = cirrus_key,
base_url = "https://llm.cirrus.carlboettiger.info/v1",
)
In [97]:
# Build a retrival agent
from langchain_text_splitters import RecursiveCharacterTextSplitter
text_splitter = RecursiveCharacterTextSplitter(chunk_size=5000, chunk_overlap=500)
splits = text_splitter.split_documents(docs)
In [98]:
# slow part here, runs on remote GPU
from langchain_core.vectorstores import InMemoryVectorStore
vectorstore = InMemoryVectorStore.from_documents(documents = splits, embedding = embedding)
retriever = vectorstore.as_retriever()
In [99]:
# Choose any of the models listed by their short-name:
# see `curl -H "Authorization: Bearer $OPENAI_API_KEY" https://llm.nrp-nautilus.io/v1/models`
"""
models = {"llama3": "llama3-sdsc",
"deepseek-small": "DeepSeek-R1-Distill-Qwen-32B",
"deepseek": "deepseek-r1-qwen-qualcomm",
"gemma3": "gemma3",
"phi3": "phi3",
"olmo": "olmo"
}
"""
from langchain_openai import ChatOpenAI
#llm = ChatOpenAI(model = models['gemma3'],
#api_key = api_key,
#base_url = "https://llm.nrp-nautilus.io",
#temperature=0)
from langchain.chains import create_retrieval_chain
from langchain.chains.combine_documents import create_stuff_documents_chain
from langchain_core.prompts import ChatPromptTemplate
"""
system_prompt = (
"You are an assistant for question-answering tasks. "
"Use the following scientific articles as the retrieved context to answer "
"the question. Appropriately cite the articles from the context on which your answer is based using (Author, Year) format. "
"Do not attempt to cite articles that are not in the context."
"If you don't know the answer, say that you don't know."
"Use up to five sentences maximum and keep the answer concise.\n\n"
"{context}"
)
prompt = ChatPromptTemplate.from_messages(
[
("system", system_prompt),
("human", "{input}"),
]
)
question_answer_chain = create_stuff_documents_chain(retriever, prompt)
rag_chain = create_retrieval_chain(retriever, question_answer_chain)
"""
def test_retriever_only(query: str, k: int = 2):
retriever.search_kwargs["k"] = k # restrict top-k results
retrieved_docs = retriever.invoke(query)
print(f"\n🔍 Query: {query}")
print(f"\n📄 Top {k} Retrieved Documents:\n" + "-"*60)
for i, doc in enumerate(retrieved_docs):
print(f"\n--- Document #{i+1} ---")
print(doc.page_content[:1000]) # preview first 1000 chars
if hasattr(doc, "metadata") and doc.metadata:
print("\n[Metadata]:", doc.metadata)
In [123]:
test_query = "I live in Tanzania and am having issues with lions breaking into my boma and preying on cattle. What are a few ways to help me prevent this from happening in the future? "
test_retriever_only(test_query, k=2)
test_retriever_only
🔍 Query: I live in Tanzania and am having issues with lions breaking into my boma and preying on cattle. What are a few ways to help me prevent this from happening in the future? 📄 Top 2 Retrieved Documents: ------------------------------------------------------------ --- Document #1 --- 23. Carbone C, Teacher A, Rowcliffe JM. The costs of carnivor y. PLoS Biol. 2007; 5: 0363–0368. https:// doi.org/10.13 71/journal.p bio.0050022 PMID: 17227145 24. Grant J, Hopcraft C, Sinclair ARE, Packer C. Planning for success: Serenget i lions seek prey accessib il- ity rather than abundance. J Anim Ecol. 2005; 74: 559–566. https://d oi.org/10.111 1/j.1365 -2656.2005. 00955.x 25. Tuqa. The Impact of Climate Variability on the Ecology of a Lion (Panthera leo Linnae us 1758) Popula- tion and Lion-Lives tock Conflicts in the Amboseli Ecosyste m-Kenya . University of Leiden . 2015. LED flashlight technique in reducing livestoc k depredation by Lions (Panthera leo) PLOS ONE | https://doi.or g/10.137 1/journal.po ne.01908 98 January 31, 2018 17 / 18 [Metadata]: {'producer': 'PDFlib+PDI 8.0.2p1 (C++/Win64); modified using iTextSharp™ 5.5.3 ©2000-2014 iText Group NV (AGPL-version)', 'creator': 'Arbortext Advanced Print Publisher 11.0.2857/W Unicode-x64', 'creationdate': '2018-01-10T21:11:13+05:30', 'title': 'Effectiveness of a LED flashlight technique in reducing livestock depredation by lions (Panthera leo) around Nairobi National Park, Kenya', 'eps_processor': 'PStill version 1.76.22', 'moddate': '2018-01-10T21:12:24+05:30', 'author': "Francis Lesilau, Myrthe Fonck, Maria Gatta, Charles Musyoki, Maarten van 't Zelfde, Gerard A. Persoon, Kees C. J. M. Musters, Geert R. de Snoo, Hans H. de Iongh", 'source': 'hwc\\Lesilau et al. 2018.pdf', 'total_pages': 18, 'page': 16, 'page_label': '17'} --- Document #2 --- Bomas constructed with high wooden post supported by chain-link (χ 2 = 8.1131, df = 1, p- value < 0.005) and barbed wire with post fence, were attacked less frequently than the other categories (p <0.05, Fig 8). None of the other deterrence variables (scare crow, dogs, spotlight, Table 1. GLMER showing the significance variables in relation to predation around the park using likeliho od ratio test. Variables Df AIC LRT Pr(Chi) Significa nce Flashlight 1 743.92 14.303 0.0001556 Years 1 742.83 13.220 0.0002770 Mean Rainfall 1 741.64 12.029 0.0005237 Park Distance 1 743.95 14.333 0.0001532 Significance codes: 0 ‘ ’, 0.001 ‘ ’, 0.01 ‘ ’, 0.05’.’, 0.1 ’ ’, 1[ ] represent s the reference variable. Model 1: Attnight ~ Flashlight + Year + Mean Rainfall + Park Distance+ (1 | Code) + (1 | Years) https://do i.org/10.1371/j ournal.pone .0190898.t001 Fig 6. Mean number of nocturnal and diurnal boma attacks around NNP between 2007 and 2016 at different dista [Metadata]: {'producer': 'PDFlib+PDI 8.0.2p1 (C++/Win64); modified using iTextSharp™ 5.5.3 ©2000-2014 iText Group NV (AGPL-version)', 'creator': 'Arbortext Advanced Print Publisher 11.0.2857/W Unicode-x64', 'creationdate': '2018-01-10T21:11:13+05:30', 'title': 'Effectiveness of a LED flashlight technique in reducing livestock depredation by lions (Panthera leo) around Nairobi National Park, Kenya', 'eps_processor': 'PStill version 1.76.22', 'moddate': '2018-01-10T21:12:24+05:30', 'author': "Francis Lesilau, Myrthe Fonck, Maria Gatta, Charles Musyoki, Maarten van 't Zelfde, Gerard A. Persoon, Kees C. J. M. Musters, Geert R. de Snoo, Hans H. de Iongh", 'source': 'hwc\\Lesilau et al. 2018.pdf', 'total_pages': 18, 'page': 10, 'page_label': '11'}
Out[123]:
<function __main__.test_retriever_only(query: str, k: int = 2)>
In [125]:
test_query = "What should I do if elephants are destroying my crops? And what are the most cost-effective prevention methods, if there are any you know of?"
test_retriever_only(test_query, k=2)
test_retriever_only
🔍 Query: What should I do if elephants are destroying my crops? And what are the most cost-effective prevention methods, if there are any you know of? 📄 Top 2 Retrieved Documents: ------------------------------------------------------------ --- Document #1 --- 242 Conflict Intervention Priorities helps foster more effective collaboration (Game et al. 2013; Lute et al. 2018). Third, both the survey results and feedback were consistent with recent scholarship (Redpath et al. 2017) that highlights participatory and stakeholder-first conflict interventions as best practice and advocates multipronged (Hazzah et al. 2014) and adaptive management strategies (Bunnefeld et al. 2017). Education and awareness programs were often cited in feedback as being necessary additions to any interven- tions. However, given the failures of many awareness- based conservation programs (Schultz 2011), a further exploration into why and where conservation decision makers deem them most appropriate is important. Ap- proaches that are specifically aimed at a particular au- dience, such as social marketing (Salazar et al. 2018), may be more effective than simple information provision or—often-problematic—enforcement (Duffy et al. 2019). However, how different interventio [Metadata]: {'producer': 'Acrobat Distiller 10.1.10 (Windows); modified using iText 4.2.0 by 1T3XT', 'creator': 'LaTeX with hyperref package', 'creationdate': '2020-01-16T12:33:42+05:30', 'keywords': '', 'moddate': '2025-05-27T12:12:25-07:00', 'subject': 'Conservation Biology 2020.34:232-243', 'wps-proclevel': '3', 'wps-journaldoi': '10.1111/(ISSN)1523-1739', 'author': '', 'title': 'Predicting intervention priorities for wildlife conflicts', 'wps-articledoi': '10.1111/cobi.13372', 'source': 'hwc\\Baynham-Herd et al. 2019.pdf', 'total_pages': 12, 'page': 10, 'page_label': '242'} --- Document #2 --- 3 Vol.:(0123456789)Scientific RepoRtS | (2020) 10:15341 | https://doi.org/10.1038/s41598-020-72343-6 www.nature.com/scientificreports/ numbers increase and more bears need more food26,43,44. Hence, the effectiveness of anti-bear interventions can be lower than expected when hungry bears become persistent and more aggressive in damaging behaviour. As high density may lead to more bears involved in conflicts, it also could increase the demand for bear removal45 and affect the effectiveness of removal techniques such as translocation and lethal control. In this paper, we compiled a global database of intervention effectiveness against bears and studied how it is related to bear species and densities, duration of intervention application, and intervention techniques. We attempted to find and describe the most effective and the least effective interventions against bears. Further, we tested several hypotheses: (1) lethal control and invasive management are less effective th [Metadata]: {'producer': 'Adobe PDF Library 15.0; modified using iText® 5.3.5 ©2000-2012 1T3XT BVBA (SPRINGER SBM; licensed version)', 'creator': 'Springer', 'creationdate': '2020-09-14T15:09:33+05:30', 'crossmarkdomains[1]': 'springer.com', 'moddate': '2020-09-14T15:58:07+02:00', 'crossmarkmajorversiondate': '2010-04-23', 'subject': 'Scientific Reports, https://doi.org/10.1038/s41598-020-72343-6', 'author': 'Igor Khorozyan', 'title': 'Variation and conservation implications of the effectiveness of anti-bear interventions', 'crossmarkdomainexclusive': 'true', 'robots': 'noindex', 'doi': '10.1038/s41598-020-72343-6', 'crossmarkdomains[2]': 'springerlink.com', 'source': 'hwc\\Khorozyan and Waltert 2020.pdf', 'total_pages': 9, 'page': 2, 'page_label': '3'}
Out[125]:
<function __main__.test_retriever_only(query: str, k: int = 2)>
In [127]:
test_query = "I know jaguars can prey on goats and cattle, which I have; what measures can I take to save them from getting harmed? Can you check these pdfs to see which ones might help?"
test_retriever_only(test_query, k=2)
test_retriever_only
🔍 Query: I know jaguars can prey on goats and cattle, which I have; what measures can I take to save them from getting harmed? Can you check these pdfs to see which ones might help? 📄 Top 2 Retrieved Documents: ------------------------------------------------------------ --- Document #1 --- hypothesis was that index of pre- and post-ban use was the same for both types of feeding sites. We calculated the average annual number of observed bears during pre- and post-ban periods for each feeding site. We then used these averages instead of raw data from individual counts. We calculated an annual index of feeding site use by pooling data from all feeding sites (average number of bears counted at feeding sites in post-ban period divided by average number of bears counted in pre- ban period). Subsequently, we used bootstrapping with 1,000 simulations to test for differences between SUPPLEMENTAL FEEDING AND BEAR DEPREDATIONS N Kavcˇicˇ et al. 113 Ursus 24(2):111–119 (2013) [Metadata]: {'producer': 'GPL Ghostscript 9.26', 'creator': '', 'creationdate': '2022-06-06T23:09:49-07:00', 'moddate': '2022-06-06T23:09:49-07:00', 'title': '', 'author': '', 'subject': '', 'keywords': '', 'source': 'hwc\\Kavcic et al. 2013.pdf', 'total_pages': 9, 'page': 2, 'page_label': '3'} --- Document #2 --- 1 Vol.:(0123456789)Scientific RepoRtS | (2020) 10:15341 | https://doi.org/10.1038/s41598-020-72343-6 www.nature.com/scientificreports Variation and conservation implications of the effectiveness of anti‑bear interventions igor Khorozyan* & Matthias Waltert Human-bear conflicts triggered by nuisance behaviour in public places and damage to livestock, crops, beehives and trees are among the main threats to bear populations globally. The effectiveness of interventions used to minimize bear-caused damage is insufficiently known and comparative reviews are lacking. We conducted a meta-analysis of 77 cases from 48 publications and used the relative risk of damage to compare the effectiveness of non-invasive interventions, invasive management (translocations) and lethal control (shooting) against bears. We show that the most effective interventions are electric fences (95% confidence interval = 79.2–100% reduction in damage), calving control (100%) and livestock replacement [Metadata]: {'producer': 'Adobe PDF Library 15.0; modified using iText® 5.3.5 ©2000-2012 1T3XT BVBA (SPRINGER SBM; licensed version)', 'creator': 'Springer', 'creationdate': '2020-09-14T15:09:33+05:30', 'crossmarkdomains[1]': 'springer.com', 'moddate': '2020-09-14T15:58:07+02:00', 'crossmarkmajorversiondate': '2010-04-23', 'subject': 'Scientific Reports, https://doi.org/10.1038/s41598-020-72343-6', 'author': 'Igor Khorozyan', 'title': 'Variation and conservation implications of the effectiveness of anti-bear interventions', 'crossmarkdomainexclusive': 'true', 'robots': 'noindex', 'doi': '10.1038/s41598-020-72343-6', 'crossmarkdomains[2]': 'springerlink.com', 'source': 'hwc\\Khorozyan and Waltert 2020.pdf', 'total_pages': 9, 'page': 0, 'page_label': '1'}
Out[127]:
<function __main__.test_retriever_only(query: str, k: int = 2)>
In [129]:
test_query = "I am trying to prevent coyotes from eating the calves of my free-range cattle. What may work best and incentivize them to stay away?"
test_retriever_only(test_query, k=2)
test_retriever_only
🔍 Query: I am trying to prevent coyotes from eating the calves of my free-range cattle. What may work best and incentivize them to stay away? 📄 Top 2 Retrieved Documents: ------------------------------------------------------------ --- Document #1 --- hypothesis was that index of pre- and post-ban use was the same for both types of feeding sites. We calculated the average annual number of observed bears during pre- and post-ban periods for each feeding site. We then used these averages instead of raw data from individual counts. We calculated an annual index of feeding site use by pooling data from all feeding sites (average number of bears counted at feeding sites in post-ban period divided by average number of bears counted in pre- ban period). Subsequently, we used bootstrapping with 1,000 simulations to test for differences between SUPPLEMENTAL FEEDING AND BEAR DEPREDATIONS N Kavcˇicˇ et al. 113 Ursus 24(2):111–119 (2013) [Metadata]: {'producer': 'GPL Ghostscript 9.26', 'creator': '', 'creationdate': '2022-06-06T23:09:49-07:00', 'moddate': '2022-06-06T23:09:49-07:00', 'title': '', 'author': '', 'subject': '', 'keywords': '', 'source': 'hwc\\Kavcic et al. 2013.pdf', 'total_pages': 9, 'page': 2, 'page_label': '3'} --- Document #2 --- depredation rates on domestic sheep (i.e. risk-taking behaviours) increased when coyotes were energetically challenged during whelping and provisioning of pups, and that removing pups from a territorial, depredating breeding pair reduced predation rates on sheep. In subsequent research, sterilized coyotes reduced predation rates on domestic lambs six- to eight-fold without affecting social behaviour and territory maintenance (Bromley & Gese, 2001a, 2001b). Thus, anticipating how carnivores might shift their behaviour in response to available resources and in relation to the relative costs associated with anthropogenic‘predatory stimuli’ is critical for carnivoreeconflict mitigation. Complementing management strategies intended to lessen the energetic reward associated with risk-taking behaviours are efforts designed to modify or interrupt a carnivore's predatory sequence (i.e. killing livestock;Knowlton, Gese,& Jaeger, 1999; Shivik, 2006). Here, we emphasize that the predatory sequence [Metadata]: {'producer': 'Acrobat Distiller 8.1.0 (Windows)', 'creator': 'Elsevier', 'creationdate': '2016-09-26T20:02:29+05:30', 'crossmarkdomains[2]': 'elsevier.com', 'crossmarkmajorversiondate': '2010-04-23', 'subject': 'Animal Behaviour, 120 (2016) 245-254. doi:10.1016/j.anbehav.2016.07.013', 'author': 'Bradley F. Blackwell', 'elsevierwebpdfspecifications': '6.5', 'crossmarkdomainexclusive': 'true', 'robots': 'noindex', 'moddate': '2016-09-26T20:03:01+05:30', 'doi': '10.1016/j.anbehav.2016.07.013', 'crossmarkdomains[1]': 'sciencedirect.com', 'title': 'No single solution: application of behavioural principles in mitigating human-wildlife conflict', 'source': 'hwc\\Blackwell et al. 2016.pdf', 'total_pages': 10, 'page': 5, 'page_label': '250'}
Out[129]:
<function __main__.test_retriever_only(query: str, k: int = 2)>
In [131]:
test_query = "Deers keep destroying and taking over our large agricultural fields. Is there anything I can try to prevent this that won’t break the bank?"
test_retriever_only(test_query, k=2)
test_retriever_only
🔍 Query: Deers keep destroying and taking over our large agricultural fields. Is there anything I can try to prevent this that won’t break the bank? 📄 Top 2 Retrieved Documents: ------------------------------------------------------------ --- Document #1 --- and among lethal interventions, 48.6% investigated culling (N =1 7 ) , 34.3% retaliatory killing (N = 12), and 17.1% trophy-hunting (N =6 ) . Contrary to the whole body of literature, most of these case studies were located in the Neartic (63.6%) followed by the Afrotropic (24.5%) and Paleartic (7.7%) (Fig. 3). Nonetheless, the species included in the case studies reflected the generalfindings, with most of the management experiments being conducted on wolves (29.4%) followed by bears (23.8%) and leopards (16.1%) (Fig. 2). Surprisingly, almost none of the experiments were con- ducted on tigers, despite their strong presence in the whole literature and their heavy impact, including attacks on humans (Dhungana et al., 2016). Fig. 2.Species prevalence in literature (black bars,N = 525) and case studies (gray bars, N = 143). Fig. 3.Geographic prevalence in literature (black bars, N = 525) and case studies (gray bars,N = 143), with species involved per geographic area. In circles, mean result [Metadata]: {'producer': 'PyPDF', 'creator': 'Elsevier', 'creationdate': '2022-06-07T02:40:21+00:00', 'author': 'Charlotte Lorand', 'crossmarkdomains[1]': 'elsevier.com', 'crossmarkdomains[2]': 'sciencedirect.com', 'crossmarkdomainexclusive': 'true', 'crossmarkmajorversiondate': '2010-04-23', 'elsevierwebpdfspecifications': '7.0', 'keywords': 'Human-carnivore coexistence; Lethal control; Non-lethal management; Conservation interventions; Effectiveness; Evidence-based', 'moddate': '2022-06-07T02:40:21+00:00', 'subject': 'Science of the Total Environment, 838 (2022) 156195. doi:10.1016/j.scitotenv.2022.156195', 'title': "Effectiveness of interventions for managing human-large carnivore conflicts worldwide: Scare them off, don't remove them", 'doi': '10.1016/j.scitotenv.2022.156195', 'robots': 'noindex', 'source': 'hwc\\Lorand et al. 2022.pdf', 'total_pages': 11, 'page': 5, 'page_label': '6'} --- Document #2 --- hypothesis was that index of pre- and post-ban use was the same for both types of feeding sites. We calculated the average annual number of observed bears during pre- and post-ban periods for each feeding site. We then used these averages instead of raw data from individual counts. We calculated an annual index of feeding site use by pooling data from all feeding sites (average number of bears counted at feeding sites in post-ban period divided by average number of bears counted in pre- ban period). Subsequently, we used bootstrapping with 1,000 simulations to test for differences between SUPPLEMENTAL FEEDING AND BEAR DEPREDATIONS N Kavcˇicˇ et al. 113 Ursus 24(2):111–119 (2013) [Metadata]: {'producer': 'GPL Ghostscript 9.26', 'creator': '', 'creationdate': '2022-06-06T23:09:49-07:00', 'moddate': '2022-06-06T23:09:49-07:00', 'title': '', 'author': '', 'subject': '', 'keywords': '', 'source': 'hwc\\Kavcic et al. 2013.pdf', 'total_pages': 9, 'page': 2, 'page_label': '3'}
Out[131]:
<function __main__.test_retriever_only(query: str, k: int = 2)>
In [133]:
test_query = "We live in a suburb and bears sometimes come into our town to eat from our fruit trees and trash. What are the best ways for us to prevent this as a community without removing our fruit trees? Can you check these pdfs to see which ones might help? https://minio.carlboettiger.info/public-data/hwc.zip"
test_retriever_only(test_query, k=2)
test_retriever_only
🔍 Query: We live in a suburb and bears sometimes come into our town to eat from our fruit trees and trash. What are the best ways for us to prevent this as a community without removing our fruit trees? Can you check these pdfs to see which ones might help? https://minio.carlboettiger.info/public-data/hwc.zip 📄 Top 2 Retrieved Documents: ------------------------------------------------------------ --- Document #1 --- 242 Conflict Intervention Priorities helps foster more effective collaboration (Game et al. 2013; Lute et al. 2018). Third, both the survey results and feedback were consistent with recent scholarship (Redpath et al. 2017) that highlights participatory and stakeholder-first conflict interventions as best practice and advocates multipronged (Hazzah et al. 2014) and adaptive management strategies (Bunnefeld et al. 2017). Education and awareness programs were often cited in feedback as being necessary additions to any interven- tions. However, given the failures of many awareness- based conservation programs (Schultz 2011), a further exploration into why and where conservation decision makers deem them most appropriate is important. Ap- proaches that are specifically aimed at a particular au- dience, such as social marketing (Salazar et al. 2018), may be more effective than simple information provision or—often-problematic—enforcement (Duffy et al. 2019). However, how different interventio [Metadata]: {'producer': 'Acrobat Distiller 10.1.10 (Windows); modified using iText 4.2.0 by 1T3XT', 'creator': 'LaTeX with hyperref package', 'creationdate': '2020-01-16T12:33:42+05:30', 'keywords': '', 'moddate': '2025-05-27T12:12:25-07:00', 'subject': 'Conservation Biology 2020.34:232-243', 'wps-proclevel': '3', 'wps-journaldoi': '10.1111/(ISSN)1523-1739', 'author': '', 'title': 'Predicting intervention priorities for wildlife conflicts', 'wps-articledoi': '10.1111/cobi.13372', 'source': 'hwc\\Baynham-Herd et al. 2019.pdf', 'total_pages': 12, 'page': 10, 'page_label': '242'} --- Document #2 --- 8 Figure A5. Silhouette width plot of the k-medoid partitions with k = 2 to 10 used to estimate the best number of clusters to describe livestock husbandry systems within the wolf range in northern Portugal (see the main text for details). 2 4 6 8 10 0.20 0.22 0.24 0.26 0.28 0.30 0.32 Number of clusters Silhouette Width [Metadata]: {'producer': 'PDF Architect 3', 'creator': 'PDF Architect 3', 'creationdate': '2017-01-25T14:50:41+00:00', 'author': 'V. Pimenta', 'moddate': '2017-01-25T14:52:31+00:00', 'source': 'hwc\\Pimenta et al. 2017.pdf', 'total_pages': 20, 'page': 17, 'page_label': '18'}
Out[133]:
<function __main__.test_retriever_only(query: str, k: int = 2)>
In [135]:
test_query = "If we live in an area with a lot of wolves, what cattle husbandry strategies should I employ to prevent any sort of wildlife-human conflict? Can you check these pdfs to see which ones might help? https://minio.carlboettiger.info/public-data/hwc.zip"
test_retriever_only(test_query, k=2)
test_retriever_only
🔍 Query: If we live in an area with a lot of wolves, what cattle husbandry strategies should I employ to prevent any sort of wildlife-human conflict? Can you check these pdfs to see which ones might help? https://minio.carlboettiger.info/public-data/hwc.zip 📄 Top 2 Retrieved Documents: ------------------------------------------------------------ --- Document #1 --- 242 Conflict Intervention Priorities helps foster more effective collaboration (Game et al. 2013; Lute et al. 2018). Third, both the survey results and feedback were consistent with recent scholarship (Redpath et al. 2017) that highlights participatory and stakeholder-first conflict interventions as best practice and advocates multipronged (Hazzah et al. 2014) and adaptive management strategies (Bunnefeld et al. 2017). Education and awareness programs were often cited in feedback as being necessary additions to any interven- tions. However, given the failures of many awareness- based conservation programs (Schultz 2011), a further exploration into why and where conservation decision makers deem them most appropriate is important. Ap- proaches that are specifically aimed at a particular au- dience, such as social marketing (Salazar et al. 2018), may be more effective than simple information provision or—often-problematic—enforcement (Duffy et al. 2019). However, how different interventio [Metadata]: {'producer': 'Acrobat Distiller 10.1.10 (Windows); modified using iText 4.2.0 by 1T3XT', 'creator': 'LaTeX with hyperref package', 'creationdate': '2020-01-16T12:33:42+05:30', 'keywords': '', 'moddate': '2025-05-27T12:12:25-07:00', 'subject': 'Conservation Biology 2020.34:232-243', 'wps-proclevel': '3', 'wps-journaldoi': '10.1111/(ISSN)1523-1739', 'author': '', 'title': 'Predicting intervention priorities for wildlife conflicts', 'wps-articledoi': '10.1111/cobi.13372', 'source': 'hwc\\Baynham-Herd et al. 2019.pdf', 'total_pages': 12, 'page': 10, 'page_label': '242'} --- Document #2 --- Fig 1. The effects of AC programs on three metrics of black bear wariness, Whistler BC, 2007–2008. A and B show the average observed percent change in overt reaction distance and displace ment distance among bears in the AC Group and the Control Group. Error bars represent standard error. C shows the predicted effect of the number of AC events conduc ted during the previous 30 days on the likeliho od that a bear will flee from research ers prior to their beginning AC treatm ent. https://d oi.org/10.1371/j ournal.pon e.0295989.g0 01 PLOS ONE Aversive condition ing of conflict black bears PLOS ONE | https://doi.or g/10.137 1/journal.po ne.02959 89 January 2, 2024 8 / 19 [Metadata]: {'producer': 'PDFlib+PDI 9.3.1p2 (C++/Win64)', 'creator': 'PTC Arbortext Layout Developer 12.1.6180/W-x64', 'creationdate': '2023-12-25T16:46:13+05:30', 'title': 'Aversive conditioning increases short-term wariness but does not change habitat use in black bears associated with conflict', 'epsprocessor': 'PStill version 1.84.42', 'author': 'Lori Homstol, Sage Raymond, Claire Edwards, Anthony N. Hamilton, Colleen Cassady St. Clair', 'moddate': '2023-12-25T16:46:13+05:30', 'source': 'hwc\\Homstol et al. 2024.pdf', 'total_pages': 19, 'page': 7, 'page_label': '8'}
Out[135]:
<function __main__.test_retriever_only(query: str, k: int = 2)>
In [ ]: