-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_database_workflow.sh
More file actions
executable file
·211 lines (184 loc) · 10.4 KB
/
Copy pathexample_database_workflow.sh
File metadata and controls
executable file
·211 lines (184 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/bash
# Example workflow demonstrating the new database feature in CuraLit v0.3.1
set -e
echo "════════════════════════════════════════════════════════════════════════════════"
echo " CuraLit v0.3.1 - Database Feature Demonstration"
echo "════════════════════════════════════════════════════════════════════════════════"
echo ""
# Colors
GREEN='\033[0;32m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Step 1: Build database from keywords
echo -e "${CYAN}Step 1: Building SQLite database from PubMed XML files${NC}"
echo "─────────────────────────────────────────────────────────────────────────────"
echo ""
echo "Command:"
echo " curalit db-build -k \"cancer\" -k \"immunotherapy\" -d ./data -o 0_out -n cancer_research"
echo ""
echo -e "${YELLOW}This will:${NC}"
echo " • Parse all XML files in ./data directory"
echo " • Filter articles matching keywords (AND logic)"
echo " • Create SQLite database: 0_out/cancer_research_27May2026_143045.db"
echo " • Index PMID, authors, and DOI for fast lookups"
echo " • Enable full-text search on titles and abstracts"
echo ""
# Uncomment to run:
# ./target/release/curalit db-build -k "cancer" -k "immunotherapy" -d ./data -o 0_out -n cancer_research
echo ""
echo -e "${GREEN}✓ Database created${NC}"
echo ""
# Step 2: Regular article search (for comparison)
echo -e "${CYAN}Step 2: Performing regular article search (for RAG)${NC}"
echo "─────────────────────────────────────────────────────────────────────────────"
echo ""
echo "Command:"
echo " curalit search -k \"cancer\" -k \"immunotherapy\" -d ./data -o cancer_articles"
echo ""
echo -e "${YELLOW}This creates:${NC}"
echo " • 0_out/cancer_articles_27May2026_143045.csv"
echo ""
# Uncomment to run:
# ./target/release/curalit search -k "cancer" -k "immunotherapy" -d ./data -o cancer_articles
echo ""
echo -e "${GREEN}✓ Articles extracted${NC}"
echo ""
# Step 3: Build RAG index
echo -e "${CYAN}Step 3: Building RAG index from articles${NC}"
echo "─────────────────────────────────────────────────────────────────────────────"
echo ""
echo "Command:"
echo " curalit rag-build -c 0_out/cancer_articles_27May2026_143045.csv"
echo ""
echo -e "${YELLOW}This creates:${NC}"
echo " • 0_out/qdrant_storage/ (vector database)"
echo ""
# Uncomment to run:
# ./target/release/curalit rag-build -c 0_out/cancer_articles_27May2026_143045.csv
echo ""
echo -e "${GREEN}✓ RAG index built${NC}"
echo ""
# Step 4: Generate statistics with HTML visualizations
echo -e "${CYAN}Step 4: Generating statistics and visualizations${NC}"
echo "─────────────────────────────────────────────────────────────────────────────"
echo ""
echo "Command:"
echo " curalit stats -c 0_out/cancer_articles_27May2026_143045.csv"
echo ""
echo -e "${YELLOW}This creates (NEW):${NC}"
echo " • 0_out/html/cancer_articles_27May2026_143045_dashboard.html"
echo " • 0_out/html/cancer_articles_27May2026_143045_year_distribution.html"
echo " • 0_out/html/cancer_articles_27May2026_143045_mesh_terms.html"
echo " • 0_out/html/cancer_articles_27May2026_143045_authors.html"
echo " • 0_out/html/cancer_articles_27May2026_143045_journals.html"
echo " • 0_out/html/cancer_articles_27May2026_143045_summary.html"
echo ""
echo -e "${YELLOW}Note: All HTML files now in 'html/' subdirectory!${NC}"
echo ""
# Uncomment to run:
# ./target/release/curalit stats -c 0_out/cancer_articles_27May2026_143045.csv
echo ""
echo -e "${GREEN}✓ Visualizations generated${NC}"
echo ""
# Step 5: Query RAG WITHOUT database verification
echo -e "${CYAN}Step 5: RAG query WITHOUT database verification (standard)${NC}"
echo "─────────────────────────────────────────────────────────────────────────────"
echo ""
echo "Command:"
echo " curalit rag-generate -q \"What are the mechanisms?\" -m llama3"
echo ""
echo -e "${YELLOW}Behavior:${NC}"
echo " • RAG retrieves relevant passages"
echo " • LLM generates answer"
echo " • No fact verification"
echo " • May include incorrect PMIDs/authors"
echo ""
# Uncomment to run:
# ./target/release/curalit rag-generate -q "What are the mechanisms of cancer immunotherapy?" -m llama3
echo ""
# Step 6: Query RAG WITH database verification (NEW FEATURE)
echo -e "${CYAN}Step 6: RAG query WITH database verification (NEW!)${NC}"
echo "─────────────────────────────────────────────────────────────────────────────"
echo ""
echo "Command:"
echo " curalit rag-generate \\"
echo " -q \"What are the mechanisms discussed in PMID 12345678?\" \\"
echo " -m llama3 \\"
echo " --use-db 0_out/cancer_research_27May2026_143045.db"
echo ""
echo -e "${YELLOW}Behavior (NEW):${NC}"
echo " • RAG retrieves relevant passages"
echo " • LLM generates answer"
echo " • Extracts PMIDs from answer"
echo " • Verifies each PMID against database"
echo " • Displays correct citation information"
echo " • Warns about incorrect/missing PMIDs"
echo ""
echo -e "${GREEN}✓ Prevents hallucinated references!${NC}"
echo ""
# Uncomment to run:
# ./target/release/curalit rag-generate \
# -q "What are the mechanisms discussed in PMID 12345678?" \
# -m llama3 \
# --use-db 0_out/cancer_research_27May2026_143045.db
echo ""
echo "════════════════════════════════════════════════════════════════════════════════"
echo -e "${GREEN} Example Output with Database Verification:${NC}"
echo "════════════════════════════════════════════════════════════════════════════════"
echo ""
cat << 'EOF'
Answer:
The article PMID 12345678 discusses checkpoint inhibitor mechanisms targeting
PD-1 and CTLA-4 pathways in T-cell activation...
════════════════════════════════════════════════════════════════════════════════
Database Verification (PMID/DOI Fact-Checking)
════════════════════════════════════════════════════════════════════════════════
✓ Verified PMID: 12345678
Verified Citations:
────────────────────────────────────────────────────────────────────────────────
PMID: 12345678
Title: Checkpoint inhibitors in cancer immunotherapy
Authors: Smith, J.; Johnson, A.; Brown, K.
Journal: Nature Medicine
Date: 2024-03-15
DOI: 10.1038/nm.1234
────────────────────────────────────────────────────────────────────────────────
EOF
echo ""
echo "════════════════════════════════════════════════════════════════════════════════"
echo ""
# Summary of new features
echo -e "${CYAN}Summary of New Features in CuraLit v0.3.1:${NC}"
echo "─────────────────────────────────────────────────────────────────────────────"
echo ""
echo -e "${GREEN}1. Database Creation (db-build command):${NC}"
echo " • Build SQLite databases from PubMed XML files"
echo " • Filter by keywords with AND/OR logic"
echo " • Store complete article metadata"
echo " • Enable fast PMID/author/DOI lookups"
echo " • Support full-text search"
echo ""
echo -e "${GREEN}2. RAG Fact Verification (--use-db flag):${NC}"
echo " • Verify PMIDs mentioned in AI answers"
echo " • Display accurate citation information"
echo " • Catch hallucinated references"
echo " • Improve literature review accuracy"
echo ""
echo -e "${GREEN}3. Improved Output Organization:${NC}"
echo " • All HTML visualizations in html/ subdirectory"
echo " • Cleaner output directory structure"
echo ""
echo -e "${GREEN}4. Human-Readable Timestamps:${NC}"
echo " • Format: DDMmmYYYY_HHMMSS"
echo " • Example: cancer_27May2026_143045.db"
echo " • Easier file identification"
echo ""
echo "════════════════════════════════════════════════════════════════════════════════"
echo ""
echo "For more information, see:"
echo " • DATABASE_FEATURE.md - Complete feature documentation"
echo " • IMPLEMENTATION_SUMMARY.md - Technical details"
echo " • README.md - General usage"
echo ""
echo "════════════════════════════════════════════════════════════════════════════════"