Spaces:
Sleeping
Sleeping
Commit ·
e96f60e
1
Parent(s): 47c87cd
Add SLF reporting sources to knowledge base, increase retriever k to 8
Browse filesAdded Iowa Dept of Agriculture and ISU Extension PDFs for spotted
lanternfly reporting guidance. Rebuilt vector DB with clean sources.
Increased retriever k from 3 to 8 to match paper's evaluation range
and capture both identification and reporting chunks.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- app.py +2 -2
- examples-work-out/example5_slf_rerun_20260331_121826.json +9 -0
- examples-work-out/example5_slf_rerun_20260331_122154.json +9 -0
- examples-work-out/example5_slf_rerun_20260331_122315.json +9 -0
- examples-work-out/example5_slf_rerun_20260331_122623.json +9 -0
- examples-work-out/example5_slf_rerun_20260331_122846.json +9 -0
- generate_usa_ipm_info.py +14 -3
- runtime.yml +0 -1
- species-organized/PestID Species - Organized.xlsx +2 -2
- vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/ba4b6a9d-5012-4456-8635-7ea7d6cb7a71/index_metadata.pickle +0 -3
- vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/ba4b6a9d-5012-4456-8635-7ea7d6cb7a71/link_lists.bin +0 -3
- vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/{ba4b6a9d-5012-4456-8635-7ea7d6cb7a71 → c91cad1d-966e-4715-84ef-dcf238664025}/data_level0.bin +1 -1
- vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/{ba4b6a9d-5012-4456-8635-7ea7d6cb7a71 → c91cad1d-966e-4715-84ef-dcf238664025}/header.bin +1 -1
- vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/{ba4b6a9d-5012-4456-8635-7ea7d6cb7a71 → c91cad1d-966e-4715-84ef-dcf238664025}/length.bin +1 -1
- vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/c91cad1d-966e-4715-84ef-dcf238664025/link_lists.bin +0 -0
- vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/chroma.sqlite3 +2 -2
app.py
CHANGED
|
@@ -98,7 +98,7 @@ langchain.debug=False # TODO: DOUBLE CHECK
|
|
| 98 |
from langchain import globals
|
| 99 |
globals.set_debug(False)
|
| 100 |
|
| 101 |
-
retriever_k_value=
|
| 102 |
embedding = OpenAIEmbeddings()
|
| 103 |
print("Started....")
|
| 104 |
class ChatOpenRouter(ChatOpenAI):
|
|
@@ -347,7 +347,7 @@ def initialize_qa_chain(specie_selector, application_mode, model_name, region, d
|
|
| 347 |
|
| 348 |
# --- Create multi-region retrieval chain --- #
|
| 349 |
class MultiRegionRetriever:
|
| 350 |
-
def __init__(self, vectordb, species_filter, selected_region, other_regions, k=
|
| 351 |
self.vectordb = vectordb
|
| 352 |
self.species_filter = species_filter
|
| 353 |
self.selected_region = selected_region
|
|
|
|
| 98 |
from langchain import globals
|
| 99 |
globals.set_debug(False)
|
| 100 |
|
| 101 |
+
retriever_k_value=8
|
| 102 |
embedding = OpenAIEmbeddings()
|
| 103 |
print("Started....")
|
| 104 |
class ChatOpenRouter(ChatOpenAI):
|
|
|
|
| 347 |
|
| 348 |
# --- Create multi-region retrieval chain --- #
|
| 349 |
class MultiRegionRetriever:
|
| 350 |
+
def __init__(self, vectordb, species_filter, selected_region, other_regions, k=8):
|
| 351 |
self.vectordb = vectordb
|
| 352 |
self.species_filter = species_filter
|
| 353 |
self.selected_region = selected_region
|
examples-work-out/example5_slf_rerun_20260331_121826.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"species": "Lycorma delicatula",
|
| 3 |
+
"region": "Midwest USA",
|
| 4 |
+
"model": "Llama-3 70B",
|
| 5 |
+
"mode": "Researcher",
|
| 6 |
+
"question": "How can I identify and report spotted lanternfly in Iowa?",
|
| 7 |
+
"availability": "**Common Name:** Spotted Lanternfly\n\nInformation for **Lycorma delicatula** is available in region(s): **Midwest USA, USA**.",
|
| 8 |
+
"answer": "According to Midwest USA guidance:\n\n* The Iowa Department of Agriculture and Land Stewardship (IDALS) urges Iowans to be on the lookout for spotted lanternfly (SLF) insects.\n* For identification and reporting, refer to the Iowa Department of Natural Resources (DNR) resource: https://www.iowadnr.gov/Conservation/Forestry/Forest-Health/Spotted-Lanternfly\n* Additionally, Iowa State University Extension provides information on spotted lanternfly identification and reporting: https://www.extension.iastate.edu/dallas/spotted-lanternfly\n\nNo further information is available in the provided context."
|
| 9 |
+
}
|
examples-work-out/example5_slf_rerun_20260331_122154.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"species": "Lycorma delicatula",
|
| 3 |
+
"region": "Midwest USA",
|
| 4 |
+
"model": "Llama-3 70B",
|
| 5 |
+
"mode": "Researcher",
|
| 6 |
+
"question": "How can I identify and report spotted lanternfly in Iowa?",
|
| 7 |
+
"availability": "**Common Name:** Spotted Lanternfly\n\nInformation for **Lycorma delicatula** is available in region(s): **Midwest USA, USA**.",
|
| 8 |
+
"answer": "According to Midwest USA guidance:\n\n* The Iowa Department of Agriculture and Land Stewardship (IDALS) urges Iowans to be on the lookout for spotted lanternfly (SLF) insects.\n* For identification and reporting, refer to the Iowa Department of Natural Resources (DNR) resource: https://www.iowadnr.gov/Conservation/Forestry/Forest-Health/Spotted-Lanternfly\n* Additionally, Iowa State University Extension provides information on spotted lanternfly identification and management: https://www.extension.iastate.edu/dallas/spotted-lanternfly\n\nNo further information is available in the provided context regarding specific identification and reporting procedures in Iowa."
|
| 9 |
+
}
|
examples-work-out/example5_slf_rerun_20260331_122315.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"species": "Lycorma delicatula",
|
| 3 |
+
"region": "Midwest USA",
|
| 4 |
+
"model": "Llama-3 70B",
|
| 5 |
+
"mode": "Researcher",
|
| 6 |
+
"question": "How can I identify and report spotted lanternfly in Iowa?",
|
| 7 |
+
"availability": "**Common Name:** Spotted Lanternfly\n\nInformation for **Lycorma delicatula** is available in region(s): **Midwest USA, USA**.",
|
| 8 |
+
"answer": "According to Midwest USA guidance:\n\n* The Iowa Department of Agriculture and Land Stewardship (IDALS) urges Iowans to be on the lookout for spotted lanternfly (SLF) insects.\n* For identification and reporting, refer to the Iowa Department of Natural Resources (DNR) resource: https://www.iowadnr.gov/Conservation/Forestry/Forest-Health/Spotted-Lanternfly\n* Iowa State University Extension also provides information on identifying and managing spotted lanternfly: https://www.extension.iastate.edu/dallas/spotted-lanternfly\n\nNo additional information is available in the provided context regarding specific identification and reporting procedures in Iowa."
|
| 9 |
+
}
|
examples-work-out/example5_slf_rerun_20260331_122623.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"species": "Lycorma delicatula",
|
| 3 |
+
"region": "Midwest USA",
|
| 4 |
+
"model": "Llama-3 70B",
|
| 5 |
+
"mode": "Researcher",
|
| 6 |
+
"question": "How can I identify and report spotted lanternfly in Iowa?",
|
| 7 |
+
"availability": "**Common Name:** Spotted Lanternfly\n\nInformation for **Lycorma delicatula** is available in region(s): **Midwest USA, USA**.",
|
| 8 |
+
"answer": "According to Midwest USA guidance, to identify and report spotted lanternfly in Iowa:\n\n* Be on the lookout for the eye-catching, destructive insect, which is native to Asia and was unintentionally introduced into the region.\n* Refer to the Iowa State University Extension resources, such as the Yard and Garden Encyclopedia, for identification and reporting guidelines.\n* Report any spotted lanternfly sightings to the Iowa Department of Agriculture and Land Stewardship (IDALS).\n\nNo specific identification characteristics or reporting procedures are mentioned in the provided context. If you need more information, please consult the Iowa State University Extension resources or contact IDALS directly."
|
| 9 |
+
}
|
examples-work-out/example5_slf_rerun_20260331_122846.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"species": "Lycorma delicatula",
|
| 3 |
+
"region": "Midwest USA",
|
| 4 |
+
"model": "Llama-3 70B",
|
| 5 |
+
"mode": "Researcher",
|
| 6 |
+
"question": "How can I identify and report spotted lanternfly in Iowa?",
|
| 7 |
+
"availability": "**Common Name:** Spotted Lanternfly\n\nInformation for **Lycorma delicatula** is available in region(s): **Midwest USA, USA**.",
|
| 8 |
+
"answer": "**Identification and Reporting in Iowa:**\n\n* According to Midwest USA guidance, spotted lanternfly (SLF) can be identified in its different life stages:\n\t+ Egg masses: present in Iowa from late July to the following spring\n\t+ Nymphs: black with white spots (young) or red and black with white spots (older), fond of host trees, usually on branches\n\t+ Adults: pinkish-gray cicada-like with black spots, long grayish-black legs, and a second pair of red, white, and black wings beneath\n* If you suspect you've spotted a SLF in Iowa:\n\t+ Take a picture\n\t+ Collect the insect (it can be preserved in hand sanitizer)\n\t+ Note the location\n\t+ Submit photos through the Iowa Invasive Species Tracking website (https://www.eddmaps.org/reportform/test.cfm?formid=206) for confirmation\n\nNo additional information is available in the provided context from other regions."
|
| 9 |
+
}
|
generate_usa_ipm_info.py
CHANGED
|
@@ -41,8 +41,8 @@ def get_all_unique_species() -> list[dict]:
|
|
| 41 |
for df, source in [(df_midwest, "Midwest USA"), (df_africa, "Africa"), (df_india, "India")]:
|
| 42 |
for _, row in df.iterrows():
|
| 43 |
species = row.get("Species")
|
| 44 |
-
if pd.notna(species) and species not in seen_species:
|
| 45 |
-
seen_species.add(species)
|
| 46 |
species_list.append({
|
| 47 |
"species": species,
|
| 48 |
"common_name": row.get("Common Name", ""),
|
|
@@ -217,8 +217,15 @@ def parse_results_and_create_excel(results_path: str, output_excel_path: str):
|
|
| 217 |
print(f"Error parsing result: {e}")
|
| 218 |
continue
|
| 219 |
|
| 220 |
-
# Create DataFrame
|
|
|
|
| 221 |
df = pd.DataFrame(results)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
print(f"\nCreated DataFrame with {len(df)} US species")
|
| 223 |
print(df.head())
|
| 224 |
|
|
@@ -287,6 +294,10 @@ def main():
|
|
| 287 |
|
| 288 |
if args.step in ["process", "all"]:
|
| 289 |
print("\n=== Step 2: Processing API requests ===")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
if os.path.exists(REQUESTS_FILEPATH):
|
| 291 |
# Check if there are requests to process
|
| 292 |
with open(REQUESTS_FILEPATH, "r") as f:
|
|
|
|
| 41 |
for df, source in [(df_midwest, "Midwest USA"), (df_africa, "Africa"), (df_india, "India")]:
|
| 42 |
for _, row in df.iterrows():
|
| 43 |
species = row.get("Species")
|
| 44 |
+
if pd.notna(species) and str(species).strip().lower() not in seen_species:
|
| 45 |
+
seen_species.add(str(species).strip().lower())
|
| 46 |
species_list.append({
|
| 47 |
"species": species,
|
| 48 |
"common_name": row.get("Common Name", ""),
|
|
|
|
| 217 |
print(f"Error parsing result: {e}")
|
| 218 |
continue
|
| 219 |
|
| 220 |
+
# Create DataFrame — deduplicate by species name, case-insensitively
|
| 221 |
+
# (results JSONL may accumulate across runs AND across capitalization variants)
|
| 222 |
df = pd.DataFrame(results)
|
| 223 |
+
before = len(df)
|
| 224 |
+
df['_species_lower'] = df['Species'].str.strip().str.lower()
|
| 225 |
+
df = df.drop_duplicates(subset=['_species_lower'], keep='last')
|
| 226 |
+
df = df.drop(columns=['_species_lower'])
|
| 227 |
+
if before != len(df):
|
| 228 |
+
print(f"Deduplicated {before - len(df)} entries (multiple runs + capitalization variants)")
|
| 229 |
print(f"\nCreated DataFrame with {len(df)} US species")
|
| 230 |
print(df.head())
|
| 231 |
|
|
|
|
| 294 |
|
| 295 |
if args.step in ["process", "all"]:
|
| 296 |
print("\n=== Step 2: Processing API requests ===")
|
| 297 |
+
# Clear results file before a new run to prevent duplicate accumulation
|
| 298 |
+
if os.path.exists(RESULTS_FILEPATH) and args.force:
|
| 299 |
+
os.remove(RESULTS_FILEPATH)
|
| 300 |
+
print(f"Cleared {RESULTS_FILEPATH} (--force run)")
|
| 301 |
if os.path.exists(REQUESTS_FILEPATH):
|
| 302 |
# Check if there are requests to process
|
| 303 |
with open(REQUESTS_FILEPATH, "r") as f:
|
runtime.yml
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
python_version: "3.9"
|
|
|
|
|
|
species-organized/PestID Species - Organized.xlsx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:529c38f5fe3530c1b78256ad464ca51e53cff761fff08726d1a1ce2bddf7340a
|
| 3 |
+
size 62345
|
vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/ba4b6a9d-5012-4456-8635-7ea7d6cb7a71/index_metadata.pickle
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:dd94800fffc4e1b3aca003062b6cf6e8eb3c4683b77ed4eae5f2d378cd41d183
|
| 3 |
-
size 129852
|
|
|
|
|
|
|
|
|
|
|
|
vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/ba4b6a9d-5012-4456-8635-7ea7d6cb7a71/link_lists.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:38d6d79326a1813390ce0d391cfa648cb550eba165548e079e7dd1f6ea240ef6
|
| 3 |
-
size 12508
|
|
|
|
|
|
|
|
|
|
|
|
vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/{ba4b6a9d-5012-4456-8635-7ea7d6cb7a71 → c91cad1d-966e-4715-84ef-dcf238664025}/data_level0.bin
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 62840000
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bb76ae0f6ca830a9a048b0cf53962a78c88c5c7fcda63fc846077d3456eb3890
|
| 3 |
size 62840000
|
vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/{ba4b6a9d-5012-4456-8635-7ea7d6cb7a71 → c91cad1d-966e-4715-84ef-dcf238664025}/header.bin
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 100
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ec666c9828420c69fc6b597461d8c18487becec1527c7d1cff9b898cbb393c2d
|
| 3 |
size 100
|
vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/{ba4b6a9d-5012-4456-8635-7ea7d6cb7a71 → c91cad1d-966e-4715-84ef-dcf238664025}/length.bin
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 40000
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:23cba9764296419b54a051be0156c6daa10cd2b84f1561bcfdd19719dbb86f7f
|
| 3 |
size 40000
|
vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/c91cad1d-966e-4715-84ef-dcf238664025/link_lists.bin
ADDED
|
File without changes
|
vector-databases-deployed/db5-agllm-data-isu-field-insects-all-species/chroma.sqlite3
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fa868d69f3fc0a6acd546c9c8f32c4fb45980dc7d4803736e584491e78b437c6
|
| 3 |
+
size 12128256
|