arbabarshad Claude Opus 4.6 commited on
Commit
6a39926
Β·
1 Parent(s): 5dc51d2

Document vignette workflow in README, add latest example results

Browse files

- Add "Example Vignettes β†’ Paper Workflow" section to README
- Clarify generate_latex.py is standalone (not used by main.tex)
- Add example_results_20260314_023319.json with fresh vignette outputs
- Add CLAUDE.md with project instructions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

CLAUDE.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Project Instructions
2
+
3
+ - **Figures**: Whenever any figure file (`panel_a_map.py`, `panel_b_architecture.tex`, or panel c in `main.tex`) is updated, also update `writing/65d4fadc59fceb1a54d1aae6/figures-in-making/README.md` to reflect the change. Same goes for next figures as well i.e. any paper in that main.tex file.
README.md CHANGED
@@ -31,10 +31,25 @@ OPENROUTER_API_KEY=... # optional, for Llama/Gemini
31
  | Run Eval | `python retrieval_evaluation.py` |
32
  | Run App | `python app.py` |
33
  | Run Examples | `python app.py --examples` (saves JSON to `examples-work-out/`) |
34
- | Generate LaTeX | `cd examples-work-out && python generate_latex.py <results.json>` |
35
  | Deploy Dev | `git push space3 fresh-start:main` |
36
  | Deploy Prod | `git push space2 fresh-start:main` |
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  ### Git Remotes
39
  - `space2` β†’ `git@hf.co:spaces/arbabarshad/agllm2` (production)
40
  - `space3` β†’ `git@hf.co:spaces/arbabarshad/agllm2-dev` (dev)
@@ -63,7 +78,7 @@ OPENROUTER_API_KEY=... # optional, for Llama/Gemini
63
  β”‚ └── species_table.tex # LaTeX species table
64
  β”‚
65
  β”œβ”€β”€ examples-work-out/
66
- β”‚ β”œβ”€β”€ generate_latex.py # JSON β†’ LaTeX converter for paper examples
67
  β”‚ β”œβ”€β”€ example_results_*.json # Generated example outputs
68
  β”‚ β”œβ”€β”€ example_results_20260303_110427.json # All 4 vignettes (SLF, Striga, FAW, Sahara Mustard) β€” latest, updated prompt
69
  β”‚ └── species-verification.md # Vignette tracking: species, regions, DB status, example outputs
@@ -77,17 +92,20 @@ OPENROUTER_API_KEY=... # optional, for Llama/Gemini
77
  | Tier | Species | Chunks | Source |
78
  |------|---------|--------|--------|
79
  | Midwest USA | 82 | 388 | ISU Handbook PDFs |
80
- | USA | 219 | 913 | GPT-4o generated IPM |
81
  | Africa | 35 | 70 | Expert-curated Excel |
82
  | India | 11 | 39 | Expert-curated Excel |
83
- | **Total** | **128 unique** | **1410** | |
 
 
 
84
 
85
  **Midwest USA Data (82 species):**
86
  1. PDFs loaded from `agllm-data/agllm-data-isu-field-{insects,weeds}-all-species/` (content source)
87
  2. `matched_species_results_v2.csv` in each folder maps PDF filename β†’ species name (metadata); region hardcoded as `"Midwest USA"` in `app_database_prep.py`
88
  3. The `Midwest USA` sheet in the Excel is a reference copy only β€” **not** read by `app_database_prep.py`
89
 
90
- **USA Data (219 species - LLM generated):**
91
  4. Run `generate_usa_ipm_info.py` to query GPT-4o for all species (species from all 3 primary tiers, filtered to those confirmed in USA)
92
  5. Creates `USA` sheet in `species-organized/PestID Species - Organized.xlsx` β€” both content (IPM Info column) and metadata are read from this sheet
93
 
@@ -111,7 +129,7 @@ python generate_usa_ipm_info.py --step process # Call GPT-4o API
111
  python generate_usa_ipm_info.py --step parse # Create Excel sheet
112
  ```
113
 
114
- **Output:** Updates `species-organized/PestID Species - Organized.xlsx` with "USA" sheet containing 219 species present in the United States (pests + beneficials).
115
 
116
  ### Evaluation Filters (retrieval_evaluation.py)
117
  | Filter | P@1 | P@2 | P@4 | P@8 | nDCG@1 | nDCG@2 | nDCG@4 | nDCG@8 |
@@ -165,6 +183,45 @@ python retrieval_evaluation.py
165
 
166
  ---
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  ## Git LFS Troubleshooting Notes
169
 
170
  This repository encountered several Git LFS issues during setup. Here's a summary for future reference:
 
31
  | Run Eval | `python retrieval_evaluation.py` |
32
  | Run App | `python app.py` |
33
  | Run Examples | `python app.py --examples` (saves JSON to `examples-work-out/`) |
 
34
  | Deploy Dev | `git push space3 fresh-start:main` |
35
  | Deploy Prod | `git push space2 fresh-start:main` |
36
 
37
+ ### Example Vignettes β†’ Paper Workflow
38
+
39
+ This is the workflow for generating example responses and getting them into the paper (`main.tex`):
40
+
41
+ 1. **Run examples**: `python app.py --examples` β†’ saves 6 vignettes (SLF, StrigaΓ—2, FAWΓ—2, Sahara Mustard) to `examples-work-out/example_results_{timestamp}.json`
42
+ 2. **Update paper via Claude**: Give the JSON file to Claude and ask it to update the vignette sections in `writing/65d4fadc59fceb1a54d1aae6/main.tex`. Claude formats each example into the `\configbox`/`\querybox`/`tcolorbox` LaTeX pattern defined in main.tex (lines ~485-497). There is no automated script for this step.
43
+ 3. **Recompile**: `pdflatex main.tex` to embed updated examples.
44
+
45
+ **Key files:**
46
+ - `app.py` β€” `run_examples()` (~line 670) defines the 6 vignettes; RAG prompt template (lines 406-429)
47
+ - `examples-work-out/species-verification.md` β€” tracks which vignettes map to which JSON examples and their DB status
48
+ - `writing/65d4fadc59fceb1a54d1aae6/main.tex` β€” paper draft with vignette sections (Witchweed Β§, Fall Armyworm Β§)
49
+
50
+ **Not part of the main workflow:**
51
+ - `examples-work-out/generate_latex.py` β€” generates a **standalone** LaTeX document from JSON results (useful for quick review), but does **not** feed into `main.tex`. Paper integration is done manually via Claude as described above.
52
+
53
  ### Git Remotes
54
  - `space2` β†’ `git@hf.co:spaces/arbabarshad/agllm2` (production)
55
  - `space3` β†’ `git@hf.co:spaces/arbabarshad/agllm2-dev` (dev)
 
78
  β”‚ └── species_table.tex # LaTeX species table
79
  β”‚
80
  β”œβ”€β”€ examples-work-out/
81
+ β”‚ β”œβ”€β”€ generate_latex.py # JSON β†’ standalone LaTeX doc (not used by main.tex)
82
  β”‚ β”œβ”€β”€ example_results_*.json # Generated example outputs
83
  β”‚ β”œβ”€β”€ example_results_20260303_110427.json # All 4 vignettes (SLF, Striga, FAW, Sahara Mustard) β€” latest, updated prompt
84
  β”‚ └── species-verification.md # Vignette tracking: species, regions, DB status, example outputs
 
92
  | Tier | Species | Chunks | Source |
93
  |------|---------|--------|--------|
94
  | Midwest USA | 82 | 388 | ISU Handbook PDFs |
95
+ | USA | 109 | ~500 | GPT-4o generated IPM |
96
  | Africa | 35 | 70 | Expert-curated Excel |
97
  | India | 11 | 39 | Expert-curated Excel |
98
+ | **Primary 3 (unique)** | **115** | **497** | 82+35+11 entries; 13 appear in 2 regions |
99
+ | **All 4 tiers** | **~224** | **~997** | 115 primary + 109 USA (109 overlap with primary) |
100
+
101
+ > **Species counts verified 2026-03-13.** The USA tier was previously reported as 219 due to a bug in `generate_usa_ipm_info.py`: the results JSONL accumulated across 3 separate runs, and the dedup was case-sensitive (missing capitalization variants from older Excel versions). Both issues are fixed. True count: 109 unique species confirmed present in the USA out of 115 primary-tier species. 6 primary-tier species are not found in the USA (see Supplementary of the paper).
102
 
103
  **Midwest USA Data (82 species):**
104
  1. PDFs loaded from `agllm-data/agllm-data-isu-field-{insects,weeds}-all-species/` (content source)
105
  2. `matched_species_results_v2.csv` in each folder maps PDF filename β†’ species name (metadata); region hardcoded as `"Midwest USA"` in `app_database_prep.py`
106
  3. The `Midwest USA` sheet in the Excel is a reference copy only β€” **not** read by `app_database_prep.py`
107
 
108
+ **USA Data (109 species - LLM generated):**
109
  4. Run `generate_usa_ipm_info.py` to query GPT-4o for all species (species from all 3 primary tiers, filtered to those confirmed in USA)
110
  5. Creates `USA` sheet in `species-organized/PestID Species - Organized.xlsx` β€” both content (IPM Info column) and metadata are read from this sheet
111
 
 
129
  python generate_usa_ipm_info.py --step parse # Create Excel sheet
130
  ```
131
 
132
+ **Output:** Updates `species-organized/PestID Species - Organized.xlsx` with "USA" sheet containing 109 species present in the United States (pests + beneficials).
133
 
134
  ### Evaluation Filters (retrieval_evaluation.py)
135
  | Filter | P@1 | P@2 | P@4 | P@8 | nDCG@1 | nDCG@2 | nDCG@4 | nDCG@8 |
 
183
 
184
  ---
185
 
186
+ ### Verifying species counts
187
+
188
+ To reproduce the verified species counts (2026-03-13):
189
+
190
+ ```bash
191
+ source ~/miniconda3/etc/profile.d/conda.sh && conda deactivate && conda activate agllm-june-15
192
+
193
+ python3 -c "
194
+ import pandas as pd
195
+ xl = 'species-organized/PestID Species - Organized.xlsx'
196
+ sheets = {s: pd.read_excel(xl, sheet_name=s) for s in ['Midwest USA','Africa','India','USA']}
197
+ for s, df in sheets.items():
198
+ print(f'{s}: {df[\"Species\"].notna().sum()} rows, {df[\"Species\"].dropna().str.strip().str.lower().nunique()} unique')
199
+ primary = set()
200
+ for s in ['Midwest USA','Africa','India']:
201
+ primary |= set(sheets[s]['Species'].dropna().str.strip().str.lower())
202
+ usa = set(sheets['USA']['Species'].dropna().str.strip().str.lower())
203
+ print(f'Primary 3 unique: {len(primary)}, USA unique: {len(usa)}')
204
+ print(f'In USA: {len(primary & usa)}, Not in USA: {len(primary - usa)}')
205
+ print('Not in USA:', sorted(primary - usa))
206
+ "
207
+ ```
208
+
209
+ **Expected output:**
210
+ ```
211
+ Midwest USA: 82 rows, 82 unique
212
+ Africa: 35 rows, 35 unique
213
+ India: 11 rows, 11 unique
214
+ USA: 109 rows, 109 unique
215
+ Primary 3 unique: 115, USA unique: 109
216
+ In USA: 109, Not in USA: 6
217
+ Not in USA: ['cleome aculeata', 'cleome houtteana', 'cleome monophylla',
218
+ 'cyperus mindorensis', 'spodoptera litura', 'trianthema triquetrum']
219
+ ```
220
+
221
+ > **Bug history:** The USA sheet previously showed 219 rows due to (1) `generate_usa_ipm_info.py` being run 3Γ— without clearing `usa_ipm_results.jsonl`, and (2) case-sensitive dedup missing capitalization variants from older Excel versions. Both fixed in `generate_usa_ipm_info.py`.
222
+
223
+ ---
224
+
225
  ## Git LFS Troubleshooting Notes
226
 
227
  This repository encountered several Git LFS issues during setup. Here's a summary for future reference:
examples-work-out/example_results_20260314_023319.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "species": "Lycorma delicatula",
4
+ "region": "Midwest USA",
5
+ "model": "Llama-3 70B",
6
+ "mode": "Researcher",
7
+ "question": "How can I identify and report spotted lanternfly in Iowa?",
8
+ "availability": "**Common Name:** Spotted Lanternfly\n\nInformation for **Lycorma delicatula** is available in region(s): **Midwest USA, USA**.",
9
+ "answer": "**Identification and Reporting in Iowa (Midwest USA):**\n\n* Spotted lanternfly nymphs: black with white spots (young) or red and black with white spots (older), found on host trees, usually on branches.\n* Spotted lanternfly adults: pinkish-gray cicada-like with black spots, long grayish-black legs, and a second pair of red, white, and black wings beneath the gray spotted wings.\n* Egg masses: present in Iowa from late July to the following spring.\n\n**Reporting:**\n\n* Report spotted lanternfly sightings to the authorities (no specific contact information provided in the context).\n\nNote: No specific information on reporting procedures or contact details is available in the provided context. It is recommended to search for up-to-date information on reporting spotted lanternfly sightings in Iowa."
10
+ },
11
+ {
12
+ "species": "Striga asiatica",
13
+ "region": "Africa",
14
+ "model": "Llama-3 70B",
15
+ "mode": "Researcher",
16
+ "question": "What is the most effective way to manage Striga in my maize field?",
17
+ "availability": "**Common Name:** Witch weed\n\nInformation for **Striga asiatica** is available in region(s): **Africa, USA**.",
18
+ "answer": "Based on the provided context, here is the answer:\n\n**In Africa:**\nThe most effective way to manage Striga in your maize field is to combine multiple Integrated Striga Management (ISM) technologies, including:\n\n* Using Striga-resistant maize varieties as the foundation\n* Maize-legume rotation to deplete the seedbank\n* Legume intercropping (push-pull) to trigger suicidal germination\n* Applying nitrogen fertilizer to suppress strigolactone exudation\n* Deploying Fusarium oxysporum biocontrol where feasible\n\n**In other regions:**\nIn the USA, integrated management strategies combining cultural, chemical, and biological controls are recommended for effective long-term management of Striga asiatica. Some cultural control practices that can be considered include crop rotation with non-host crops, trap crops, deep tillage, and sanitation."
19
+ },
20
+ {
21
+ "species": "Striga asiatica",
22
+ "region": "USA",
23
+ "model": "Llama-3 70B",
24
+ "mode": "Researcher",
25
+ "question": "What is the most effective way to manage Striga in my maize field?",
26
+ "availability": "**Common Name:** Witch weed\n\nInformation for **Striga asiatica** is available in region(s): **Africa, USA**.",
27
+ "answer": "Based on the provided context, here is the answer:\n\n**USA:**\nFor effective long-term management of Striga asiatica, an integrated approach combining cultural, chemical, and biological controls is recommended. Some specific strategies include:\n\n* Crop rotation with non-host crops to reduce Striga seed bank in the soil\n* Planting trap crops to stimulate Striga germination but not support its growth\n* Deep tillage to bury Striga seeds deeper in the soil, reducing their viability\n* Sanitation to prevent the spread of Striga seeds between fields\n* Pre-emergent and post-emergent herbicides, such as imazapyr and glyphosate, can be used to control Striga infestations\n* Ongoing studies into the use of certain fungi and bacteria that can attack Striga seeds or seedlings, though these are not widely implemented yet\n\n**Africa:**\nAdditionally, using Striga-resistant maize varieties as the foundation, combined with maize-legume rotation to deplete the seedbank, and adding legume intercropping (push-pull) to trigger suicidal germination, can be effective. Applying nitrogen fertilizer to suppress strigolactone exudation and deploying Fusarium oxysporum biocontrol where feasible can also be considered.\n\nNote: There is no specific information available from the Midwest USA region for this question."
28
+ },
29
+ {
30
+ "species": "Spodoptera frugiperda",
31
+ "region": "India",
32
+ "model": "Llama-3 70B",
33
+ "mode": "Researcher",
34
+ "question": "What are the recommended IPM strategies for managing fall armyworm in my corn field?",
35
+ "availability": "**Common Name:** Fall Armyworm\n\nInformation for **Spodoptera frugiperda** is available in region(s): **India, Midwest USA, USA**.",
36
+ "answer": "Based on the provided context, here are the recommended IPM strategies for managing fall armyworm in your corn field in India:\n\n**From India:**\n\n* Cultural Control: Crop rotation, intercropping, and planting shortly after major rainstorms to reduce pest incidence.\n* Monitoring: Use pheromone traps (8 traps/40 lures per acre) for early detection and adult population monitoring, applied based on Economic Threshold Level (ETL).\n* Biological Control: Apply Metarhizium anisopliae (entomopathogenic fungus) at 1 kg/acre.\n* Botanical/Biorational: Use azadirachtin 1500 ppm (neem-based) at 1 L/acre.\n* Chemical Control (need-based): Emamectin benzoate 5% SG at 100 g/acre, applied based on ETL.\n\n**From other regions:**\n\n* According to USA guidance, consider the following additional strategies:\n\t+ Crop Rotation: Rotate crops to disrupt the lifecycle of the pest.\n\t+ Planting Date Adjustment: Alter planting dates to avoid peak periods of armyworm activity.\n\t+ Field Sanitation: Remove crop residues and weeds that can serve as hosts.\n\t+ Trap Crops: Use trap crops to attract and manage populations away from main crops.\n* According to Midwest USA guidance, consider the following additional strategies:\n\t+ Scout for larvae in whorls prior to tasseling in corn, and use a sweep net in soybean and alfalfa.\n\t+ Manage grassy weeds in and near fields to reduce armyworm problems.\n\nPlease note that the context does not provide specific information on the effectiveness of these strategies in corn fields in India. Further research may be necessary to refine these recommendations."
37
+ },
38
+ {
39
+ "species": "Spodoptera frugiperda",
40
+ "region": "USA",
41
+ "model": "Llama-3 70B",
42
+ "mode": "Researcher",
43
+ "question": "What are the recommended IPM strategies for managing fall armyworm in my corn field?",
44
+ "availability": "**Common Name:** Fall Armyworm\n\nInformation for **Spodoptera frugiperda** is available in region(s): **India, Midwest USA, USA**.",
45
+ "answer": "Based on the provided context, here are the recommended IPM strategies for managing fall armyworm in your corn field in the USA:\n\n**From USA:**\n\n* **Cultural Control/Management Practices:**\n\t+ Crop rotation to disrupt the lifecycle of the pest\n\t+ Planting date adjustment to avoid peak periods of armyworm activity\n\t+ Field sanitation to remove crop residues and weeds that can serve as hosts\n\t+ Trap crops to attract and manage populations away from main crops\n* **Biological Control Options/Natural Enemies:**\n\t+ Conservation of natural enemies like parasitoids (e.g., Trichogramma spp.) and predators (e.g., lady beetles and lacewings) through habitat management\n* **Chemical Control Options:**\n\t+ Insecticides may be used, but resistance management is critical; use based on monitoring and threshold levels to minimize unnecessary applications\n\t+ Bacillus thuringiensis (Bt) products can be effective against larvae\n\n**From Midwest USA:**\n\n* **Scouting and Management:**\n\t+ Begin scouting in mid-June; continue until silks dry in corn\n\t+ Treat corn with foliar insecticides when 25% of plants are infested, caterpillars are small (<1 inch), and still exposed\n\t+ Transgenic Bt corn exhibits action against fall armyworm; some Bt proteins (e.g., Cry1F and Vip3Aa20) provide better control than others\n\nNote that there is no specific information on IPM strategies for corn fields in the USA region. The Midwest USA region provides more specific guidance on scouting and management for corn."
46
+ },
47
+ {
48
+ "species": "Brassica tournefortii",
49
+ "region": "Midwest USA",
50
+ "model": "Llama-3 70B",
51
+ "mode": "Researcher",
52
+ "question": "What mechanical, chemical, and cultural control methods are recommended for managing Sahara mustard infestations?",
53
+ "availability": "**Common Name:** Sahara Mustard\n\nInformation for **Brassica tournefortii** is available in region(s): **Midwest USA, USA**.",
54
+ "answer": "Based on the provided context, here are the recommended control methods for managing Sahara mustard infestations:\n\n**Mechanical Control:**\n\n* According to Midwest USA guidance, monitoring the area for rodent caches and treating them accordingly is important.\n\n**Chemical Control:**\n\n* According to Midwest USA guidance, early applications of chemicals may control Sahara mustard due to its extremely early development. Applications should be particularly effective if started before native species have begun to develop.\n* According to USA guidance, herbicides such as glyphosate and 2,4-D can be effective when applied to young plants before they set seed. Pre-emergent herbicides can be used to prevent seed germination in heavily infested areas.\n\n**Cultural Control:**\n\n* According to USA guidance, manual removal is effective for small infestations, ensuring the entire root is removed to prevent regrowth. Mowing before seed set can reduce seed production but may need to be repeated due to staggered germination. Restoration of native vegetation can help outcompete Sahara Mustard.\n\nNote: There is no specific information on mechanical control methods in the Midwest USA region, and no biological control options are mentioned in the provided context."
55
+ }
56
+ ]