Merge branch 'main' of https://huggingface.co/spaces/Ekimetrics/climate-question-answering
Browse files- .gitattributes +4 -0
- app.py +50 -28
- climate_gpt.db β climate_gpt_v2.db +2 -2
- climate_gpt_only_giec.db β climate_gpt_v2_only_giec.db +2 -2
- documents/climate_gpt.json +0 -7
- documents/climate_gpt_only_giec.json +0 -1
- documents/{climate_gpt.faiss β climate_gpt_v2.faiss} +2 -2
- documents/climate_gpt_v2.json +1 -0
- documents/{climate_gpt_only_giec.faiss β climate_gpt_v2_only_giec.faiss} +2 -2
- documents/climate_gpt_v2_only_giec.json +1 -0
.gitattributes
CHANGED
@@ -38,3 +38,7 @@ climate_gpt.db filter=lfs diff=lfs merge=lfs -text
|
|
38 |
background.png filter=lfs diff=lfs merge=lfs -text
|
39 |
documents/climate_gpt_only_giec.faiss filter=lfs diff=lfs merge=lfs -text
|
40 |
climate_gpt_only_giec.db filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
38 |
background.png filter=lfs diff=lfs merge=lfs -text
|
39 |
documents/climate_gpt_only_giec.faiss filter=lfs diff=lfs merge=lfs -text
|
40 |
climate_gpt_only_giec.db filter=lfs diff=lfs merge=lfs -text
|
41 |
+
climate_gpt_v2_only_giec.db filter=lfs diff=lfs merge=lfs -text
|
42 |
+
climate_gpt_v2.db filter=lfs diff=lfs merge=lfs -text
|
43 |
+
documents/climate_gpt_v2_only_giec.faiss filter=lfs diff=lfs merge=lfs -text
|
44 |
+
documents/climate_gpt_v2.faiss filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -39,9 +39,11 @@ def get_reformulation_prompt(query: str) -> str:
|
|
39 |
---
|
40 |
query: La technologie nous sauvera-t-elle ?
|
41 |
standalone question: Can technology help humanity mitigate the effects of climate change?
|
|
|
42 |
---
|
43 |
query: what are our reserves in fossil fuel?
|
44 |
standalone question: What are the current reserves of fossil fuels and how long will they last?
|
|
|
45 |
---
|
46 |
query: {query}
|
47 |
standalone question:"""
|
@@ -59,8 +61,8 @@ openai.api_version = "2022-12-01"
|
|
59 |
|
60 |
retrieve_all = EmbeddingRetriever(
|
61 |
document_store=FAISSDocumentStore.load(
|
62 |
-
index_path="./documents/
|
63 |
-
config_path="./documents/
|
64 |
),
|
65 |
embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
|
66 |
model_format="sentence_transformers",
|
@@ -69,8 +71,8 @@ retrieve_all = EmbeddingRetriever(
|
|
69 |
|
70 |
retrieve_giec = EmbeddingRetriever(
|
71 |
document_store=FAISSDocumentStore.load(
|
72 |
-
index_path="./documents/
|
73 |
-
config_path="./documents/
|
74 |
),
|
75 |
embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
|
76 |
model_format="sentence_transformers",
|
@@ -122,18 +124,18 @@ def chat(
|
|
122 |
stop=["\n---\n", "<|im_end|>"],
|
123 |
)
|
124 |
reformulated_query = reformulated_query["choices"][0]["text"]
|
|
|
|
|
125 |
docs = [d for d in retriever.retrieve(query=reformulated_query, top_k=10) if d.score > threshold]
|
126 |
messages = history + [{"role": "user", "content": query}]
|
127 |
|
128 |
if docs:
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
)
|
136 |
-
messages.append({"role": "system", "content": f"{sources_prompt}\n\n{sources}"})
|
137 |
|
138 |
response = openai.Completion.create(
|
139 |
engine="climateGPT",
|
@@ -320,7 +322,7 @@ Version 0.2-beta - This tool is under active development
|
|
320 |
- ClimateQ&A retrieves specific passages from the IPCC reports to help answer your question accurately.
|
321 |
- Source information, including page numbers and passages, is displayed on the right side of the screen for easy verification.
|
322 |
- Feel free to ask follow-up questions within the chatbot for a more in-depth understanding.
|
323 |
-
- ClimateQ&A integrates multiple sources (IPCC, IPBES, IEA,
|
324 |
"""
|
325 |
)
|
326 |
with gr.Column(scale=1):
|
@@ -329,7 +331,6 @@ Version 0.2-beta - This tool is under active development
|
|
329 |
### β οΈ Limitations
|
330 |
<div class="warning-box">
|
331 |
<ul>
|
332 |
-
<li>Currently available in English only.</li>
|
333 |
<li>Please note that, like any AI, the model may occasionally generate an inaccurate or imprecise answer. Always refer to the provided sources to verify the validity of the information given. If you find any issues with the response, kindly provide feedback to help improve the system.</li>
|
334 |
<li>ClimateQ&A is specifically designed for climate-related inquiries. If you ask a non-environmental question, the chatbot will politely remind you that its focus is on climate and environmental issues.</li>
|
335 |
</div>
|
@@ -381,20 +382,41 @@ Version 0.2-beta - This tool is under active development
|
|
381 |
## π Sources
|
382 |
| Source | Report | URL | Number of pages | Release date |
|
383 |
| --- | --- | --- | --- | --- |
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
|
389 |
-
|
|
390 |
-
|
|
391 |
-
|
|
392 |
-
|
|
393 |
-
|
|
394 |
-
|
|
395 |
-
|
|
396 |
-
|
|
397 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
|
399 |
## π’οΈ Carbon Footprint
|
400 |
|
|
|
39 |
---
|
40 |
query: La technologie nous sauvera-t-elle ?
|
41 |
standalone question: Can technology help humanity mitigate the effects of climate change?
|
42 |
+
language: French
|
43 |
---
|
44 |
query: what are our reserves in fossil fuel?
|
45 |
standalone question: What are the current reserves of fossil fuels and how long will they last?
|
46 |
+
language: English
|
47 |
---
|
48 |
query: {query}
|
49 |
standalone question:"""
|
|
|
61 |
|
62 |
retrieve_all = EmbeddingRetriever(
|
63 |
document_store=FAISSDocumentStore.load(
|
64 |
+
index_path="./documents/climate_gpt_v2.faiss",
|
65 |
+
config_path="./documents/climate_gpt_v2.json",
|
66 |
),
|
67 |
embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
|
68 |
model_format="sentence_transformers",
|
|
|
71 |
|
72 |
retrieve_giec = EmbeddingRetriever(
|
73 |
document_store=FAISSDocumentStore.load(
|
74 |
+
index_path="./documents/climate_gpt_v2_only_giec.faiss",
|
75 |
+
config_path="./documents/climate_gpt_v2_only_giec.json",
|
76 |
),
|
77 |
embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
|
78 |
model_format="sentence_transformers",
|
|
|
124 |
stop=["\n---\n", "<|im_end|>"],
|
125 |
)
|
126 |
reformulated_query = reformulated_query["choices"][0]["text"]
|
127 |
+
reformulated_query, language = reformulated_query.split("\n")
|
128 |
+
language = language.split(":")[1].strip()
|
129 |
docs = [d for d in retriever.retrieve(query=reformulated_query, top_k=10) if d.score > threshold]
|
130 |
messages = history + [{"role": "user", "content": query}]
|
131 |
|
132 |
if docs:
|
133 |
+
docs_string = []
|
134 |
+
for i, d in enumerate(docs, 1):
|
135 |
+
content = d.content.replace("\r\n", "")
|
136 |
+
docs_string.append(f"π doc {i}: {d.meta['file_name']} page {d.meta['page_number']}\n{content}")
|
137 |
+
sources = "\n\n".join([f"Query used for retrieval:\n{reformulated_query}"] + docs_string)
|
138 |
+
messages.append({"role": "system", "content": f"{sources_prompt}\n\n{sources}\n\nAnswer in {language}:"})
|
|
|
|
|
139 |
|
140 |
response = openai.Completion.create(
|
141 |
engine="climateGPT",
|
|
|
322 |
- ClimateQ&A retrieves specific passages from the IPCC reports to help answer your question accurately.
|
323 |
- Source information, including page numbers and passages, is displayed on the right side of the screen for easy verification.
|
324 |
- Feel free to ask follow-up questions within the chatbot for a more in-depth understanding.
|
325 |
+
- ClimateQ&A integrates multiple sources (IPCC, IPBES, IEA, β¦ ) to cover various aspects of environmental science, such as climate change, biodiversity, energy, economy, and pollution. See all sources used below.
|
326 |
"""
|
327 |
)
|
328 |
with gr.Column(scale=1):
|
|
|
331 |
### β οΈ Limitations
|
332 |
<div class="warning-box">
|
333 |
<ul>
|
|
|
334 |
<li>Please note that, like any AI, the model may occasionally generate an inaccurate or imprecise answer. Always refer to the provided sources to verify the validity of the information given. If you find any issues with the response, kindly provide feedback to help improve the system.</li>
|
335 |
<li>ClimateQ&A is specifically designed for climate-related inquiries. If you ask a non-environmental question, the chatbot will politely remind you that its focus is on climate and environmental issues.</li>
|
336 |
</div>
|
|
|
382 |
## π Sources
|
383 |
| Source | Report | URL | Number of pages | Release date |
|
384 |
| --- | --- | --- | --- | --- |
|
385 |
+
IPCC | Summary for Policymakers. In: Climate Change 2021: The Physical Science Basis. Contribution of the WGI to the AR6 of the IPCC. | https://www.ipcc.ch/report/ar6/wg1/downloads/report/IPCC_AR6_WGI_SPM.pdf | 32 | 2021
|
386 |
+
IPCC | Full Report. In: Climate Change 2021: The Physical Science Basis. Contribution of the WGI to the AR6 of the IPCC. | https://report.ipcc.ch/ar6/wg1/IPCC_AR6_WGI_FullReport.pdf | 2409 | 2021
|
387 |
+
IPCC | Technical Summary. In: Climate Change 2021: The Physical Science Basis. Contribution of the WGI to the AR6 of the IPCC. | https://www.ipcc.ch/report/ar6/wg1/downloads/report/IPCC_AR6_WGI_TS.pdf | 112 | 2021
|
388 |
+
IPCC | Summary for Policymakers. In: Climate Change 2022: Impacts, Adaptation and Vulnerability. Contribution of the WGII to the AR6 of the IPCC. | https://www.ipcc.ch/report/ar6/wg2/downloads/report/IPCC_AR6_WGII_SummaryForPolicymakers.pdf | 34 | 2022
|
389 |
+
IPCC | Technical Summary. In: Climate Change 2022: Impacts, Adaptation and Vulnerability. Contribution of the WGII to the AR6 of the IPCC. | https://www.ipcc.ch/report/ar6/wg2/downloads/report/IPCC_AR6_WGII_TechnicalSummary.pdf | 84 | 2022
|
390 |
+
IPCC | Full Report. In: Climate Change 2022: Impacts, Adaptation and Vulnerability. Contribution of the WGII to the AR6 of the IPCC. | https://report.ipcc.ch/ar6/wg2/IPCC_AR6_WGII_FullReport.pdf | 3068 | 2022
|
391 |
+
IPCC | Summary for Policymakers. In: Climate Change 2022: Mitigation of Climate Change. Contribution of the WGIII to the AR6 of the IPCC. | https://www.ipcc.ch/report/ar6/wg3/downloads/report/IPCC_AR6_WGIII_SummaryForPolicymakers.pdf | 50 | 2022
|
392 |
+
IPCC | Technical Summary. In: Climate Change 2022: Mitigation of Climate Change. Contribution of the WGIII to the AR6 of the IPCC. | https://www.ipcc.ch/report/ar6/wg3/downloads/report/IPCC_AR6_WGIII_TechnicalSummary.pdf | 102 | 2022
|
393 |
+
IPCC | Full Report. In: Climate Change 2022: Mitigation of Climate Change. Contribution of the WGIII to the AR6 of the IPCC. | https://www.ipcc.ch/report/ar6/wg3/downloads/report/IPCC_AR6_WGIII_FullReport.pdf | 2258 | 2022
|
394 |
+
IPCC | Summary for Policymakers. In: Global Warming of 1.5ΓΒ°C. An IPCC Special Report on the impacts of global warming of 1.5ΓΒ°C above pre-industrial levels and related global greenhouse gas emission pathways, in the context of strengthening the global response to the threat of climate change, sustainable development, and efforts to eradicate poverty. | https://www.ipcc.ch/site/assets/uploads/sites/2/2022/06/SPM_version_report_LR.pdf | 24 | 2018
|
395 |
+
IPCC | Summary for Policymakers. In: Climate Change and Land: an IPCC special report on climate change, desertification, land degradation, sustainable land management, food security, and greenhouse gas fluxes in terrestrial ecosystems. | https://www.ipcc.ch/site/assets/uploads/sites/4/2022/11/SRCCL_SPM.pdf | 36 | 2019
|
396 |
+
IPCC | Summary for Policymakers. In: IPCC Special Report on the Ocean and Cryosphere in a Changing Climate. | https://www.ipcc.ch/site/assets/uploads/sites/3/2022/03/01_SROCC_SPM_FINAL.pdf | 36 | 2019
|
397 |
+
IPCC | Technical Summary. In: IPCC Special Report on the Ocean and Cryosphere in a Changing Climate. | https://www.ipcc.ch/site/assets/uploads/sites/3/2022/03/02_SROCC_TS_FINAL.pdf | 34 | 2019
|
398 |
+
IPCC | Chapter 1 - Framing and Context of the Report. In: IPCC Special Report on the Ocean and Cryosphere in a Changing Climate. | https://www.ipcc.ch/site/assets/uploads/sites/3/2022/03/03_SROCC_Ch01_FINAL.pdf | 60 | 2019
|
399 |
+
IPCC | Chapter 2 - High Mountain Areas. In: IPCC Special Report on the Ocean and Cryosphere in a Changing Climate. | https://www.ipcc.ch/site/assets/uploads/sites/3/2022/03/04_SROCC_Ch02_FINAL.pdf | 72 | 2019
|
400 |
+
IPCC | Chapter 3 - Polar Regions. In: IPCC Special Report on the Ocean and Cryosphere in a Changing Climate. | https://www.ipcc.ch/site/assets/uploads/sites/3/2022/03/05_SROCC_Ch03_FINAL.pdf | 118 | 2019
|
401 |
+
IPCC | Chapter 4 - Sea Level Rise and Implications for Low-Lying Islands, Coasts and Communities. In: IPCC Special Report on the Ocean and Cryosphere in a Changing Climate. | https://www.ipcc.ch/site/assets/uploads/sites/3/2022/03/06_SROCC_Ch04_FINAL.pdf | 126 | 2019
|
402 |
+
IPCC | Chapter 5 - Changing Ocean, Marine Ecosystems, and Dependent Communities. In: IPCC Special Report on the Ocean and Cryosphere in a Changing Climate. | https://www.ipcc.ch/site/assets/uploads/sites/3/2022/03/07_SROCC_Ch05_FINAL.pdf | 142 | 2019
|
403 |
+
IPCC | Chapter 6 - Extremes, Abrupt Changes and Managing Risk. In: IPCC Special Report on the Ocean and Cryosphere in a Changing Climate. | https://www.ipcc.ch/site/assets/uploads/sites/3/2022/03/08_SROCC_Ch06_FINAL.pdf | 68 | 2019
|
404 |
+
IPCC | Cross-Chapter Box 9: Integrative Cross-Chapter Box on Low-Lying Islands and Coasts. In: IPCC Special Report on the Ocean and Cryosphere in a Changing Climate. | https://www.ipcc.ch/site/assets/uploads/sites/3/2019/11/11_SROCC_CCB9-LLIC_FINAL.pdf | 18 | 2019
|
405 |
+
IPCC | Annex I: Glossary [Weyer, N.M. (ed.)]. In: IPCC Special Report on the Ocean and Cryosphere in a Changing Climate. | https://www.ipcc.ch/site/assets/uploads/sites/3/2022/03/10_SROCC_AnnexI-Glossary_FINAL.pdf | 28 | 2019
|
406 |
+
IPBES | Full Report. Global assessment report on biodiversity and ecosystem services of the IPBES. | https://zenodo.org/record/6417333/files/202206_IPBES%20GLOBAL%20REPORT_FULL_DIGITAL_MARCH%202022.pdf | 1148 | 2019
|
407 |
+
IPBES | Summary for Policymakers. Global assessment report on biodiversity and ecosystem services of the IPBES (Version 1). | https://zenodo.org/record/3553579/files/ipbes_global_assessment_report_summary_for_policymakers.pdf | 60 | 2019
|
408 |
+
IPBES | Full Report. Thematic assessment of the sustainable use of wild species of the IPBES. | https://zenodo.org/record/7755805/files/IPBES_ASSESSMENT_SUWS_FULL_REPORT.pdf | 1008 | 2022
|
409 |
+
IPBES | Summary for Policymakers. Summary for policymakers of the thematic assessment of the sustainable use of wild species of the IPBES. | https://zenodo.org/record/7411847/files/EN_SPM_SUSTAINABLE%20USE%20OF%20WILD%20SPECIES.pdf | 44 | 2022
|
410 |
+
IPBES | Full Report. Regional Assessment Report on Biodiversity and Ecosystem Services for Africa. | https://zenodo.org/record/3236178/files/ipbes_assessment_report_africa_EN.pdf | 494 | 2018
|
411 |
+
IPBES | Summary for Policymakers. Regional Assessment Report on Biodiversity and Ecosystem Services for Africa. | https://zenodo.org/record/3236189/files/ipbes_assessment_spm_africa_EN.pdf | 52 | 2018
|
412 |
+
IPBES | Full Report. Regional Assessment Report on Biodiversity and Ecosystem Services for the Americas. | https://zenodo.org/record/3236253/files/ipbes_assessment_report_americas_EN.pdf | 660 | 2018
|
413 |
+
IPBES | Summary for Policymakers. Regional Assessment Report on Biodiversity and Ecosystem Services for the Americas. | https://zenodo.org/record/3236292/files/ipbes_assessment_spm_americas_EN.pdf | 44 | 2018
|
414 |
+
IPBES | Full Report. Regional Assessment Report on Biodiversity and Ecosystem Services for Asia and the Pacific. | https://zenodo.org/record/3237374/files/ipbes_assessment_report_ap_EN.pdf | 616 | 2018
|
415 |
+
IPBES | Summary for Policymakers. Regional Assessment Report on Biodiversity and Ecosystem Services for Asia and the Pacific. | https://zenodo.org/record/3237383/files/ipbes_assessment_spm_ap_EN.pdf | 44 | 2018
|
416 |
+
IPBES | Full Report. Regional Assessment Report on Biodiversity and Ecosystem Services for Europe and Central Asia. | https://zenodo.org/record/3237429/files/ipbes_assessment_report_eca_EN.pdf | 894 | 2018
|
417 |
+
IPBES | Summary for Policymakers. Regional Assessment Report on Biodiversity and Ecosystem Services for Europe and Central Asia. | https://zenodo.org/record/3237468/files/ipbes_assessment_spm_eca_EN.pdf | 52 | 2018
|
418 |
+
IPBES | Full Report. Assessment Report on Land Degradation and Restoration. | https://zenodo.org/record/3237393/files/ipbes_assessment_report_ldra_EN.pdf | 748 | 2018
|
419 |
+
IPBES | Summary for Policymakers. Assessment Report on Land Degradation and Restoration. | https://zenodo.org/record/3237393/files/ipbes_assessment_report_ldra_EN.pdf | 48 | 2018
|
420 |
|
421 |
## π’οΈ Carbon Footprint
|
422 |
|
climate_gpt.db β climate_gpt_v2.db
RENAMED
@@ -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:dd1721b717f9c216c7cc5d5f9a0e25c81365988d33f0d23dc133248282058eda
|
3 |
+
size 144551936
|
climate_gpt_only_giec.db β climate_gpt_v2_only_giec.db
RENAMED
@@ -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:2d07f301213df87b25ec0df87562fd96394f676bfc9889d9376ef99886f82d3e
|
3 |
+
size 89505792
|
documents/climate_gpt.json
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"sql_url": "sqlite:///climate_gpt.db",
|
3 |
-
"faiss_index_factory_str": "Flat",
|
4 |
-
"index": "climate_gpt",
|
5 |
-
"similarity": "dot_product",
|
6 |
-
"embedding_dim": 768
|
7 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
documents/climate_gpt_only_giec.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{"sql_url": "sqlite:///climate_gpt_only_giec.db", "faiss_index_factory_str": "Flat", "index": "climate_gpt_only_giec", "similarity": "dot_product", "embedding_dim": 768}
|
|
|
|
documents/{climate_gpt.faiss β climate_gpt_v2.faiss}
RENAMED
@@ -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:027a24bcbc3fc349e78a5db80b525273da5d05046a8fdf55faa1512eb2142c83
|
3 |
+
size 215138349
|
documents/climate_gpt_v2.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"sql_url": "sqlite:///climate_gpt_v2.db", "faiss_index_factory_str": "Flat", "index": "climate_gpt_v2", "similarity": "dot_product", "embedding_dim": 768}
|
documents/{climate_gpt_only_giec.faiss β climate_gpt_v2_only_giec.faiss}
RENAMED
@@ -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:bc507b49387005c8c60a3471dab1beff9198960ed492b76cb23bd1557789ef8a
|
3 |
+
size 130351149
|
documents/climate_gpt_v2_only_giec.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"sql_url": "sqlite:///climate_gpt_v2_only_giec.db", "faiss_index_factory_str": "Flat", "index": "climate_gpt_v2", "similarity": "dot_product", "embedding_dim": 768}
|