Build Your First RAG with Bigdata SDK¶
Introduction¶
Retrival Augmented Generation (RAG for short) has reached a high demand in different industries and use cases. In a RAG pipeline your large language model (LLM) of choice consults with the most relevant data you bring (augment) to guide the LLM generation. The augmented data can be of different forms or shape, from your firm’s knowledge base, internal documents, customer calls, or even news documents! Using this arrangement, the final generated response is more than just a generic answer and is informed by the data you add.
In this tutorial, we walk through building your RAG using news retrieved from Bigdata, and you can chat with the news!
Setup¶
The two major components of a RAG pipeline are the Retrieval which finds the most relevant piece of data (documents) to the query (prompt) and the Generation which is all about the language model to generate the final response. Bigdata SDK addresses two challenges, first, providing the data (documents), second, finding the most relevant data document (news chunks). For our tutorial we use OpenAI’s GPT-4o-mini as the generative model. Let’s install the required libraries and dependencies:
$ pip install -U bigdata openai
Then import the required libraries, initialize a few constants, and instantiate the classes:
import re
from collections import OrderedDict
from typing import List, Dict, Any
from xml.dom import minidom
from xml.etree import ElementTree as ET
import openai
from IPython.display import Markdown, display
from bigdata_client import Bigdata
from bigdata_client.document import Document
from bigdata_client.models.search import DocumentType
from bigdata_client.query import Similarity
Make sure you have entered your Bigdata.com’s credential in order to authenticate with the Bigdata SDK:
BIGDATA_USERNAME = 'YOUR_BIGDATA_USERNAME'
BIGDATA_PASSWORD = 'YOUR_BIGDATA_PASSWORD'
OPENAI_API_KEY = 'YOUR_OPENAI_API_KEY'
MODEL_NAME = 'gpt-4o-mini'
SYSTEM_PROMPT = '''
You are a helpful assistant to answer questions using the provided chunks of news information. Ensure your responses are well-structured, clear, and easy to read. Your goal is to provide an accurate answer while citing your sources using a specific markdown format.
Formatting Instructions:
1. Use markdown formatting to structure your response.
2. Use headers (##, ###) to separate main sections or ideas.
3. Use bullet points or numbered lists where appropriate.
4. Add line breaks between paragraphs and sections for better readability.
5. Bold important terms or key points using **bold**.
6. If providing a list of items, consider using a numbered list with brief explanations.
7. Ensure that your response is well-formatted and easy to read.
'''
bigdata = Bigdata(username=BIGDATA_USERNAME, password=BIGDATA_PASSWORD)
llm = openai.OpenAI(api_key=OPENAI_API_KEY)
Retrieve Documents¶
We will use Bigdata to augment our RAG pipeline with the retrieved documents. The news data is stored in chunks, and we can search and get the chunks using the Bigdata SDK. We first run a search for the given question (query). Based on similarity of the query and the news documents, the SDK return the news chunks matching our query. With all being said, let’s define a function to get the documents:
def retrieve_news_data(query_text: str,
limit: int = 5) -> List[Document]:
# Create a similarity search query
query = Similarity(query_text)
# Create a search and run it
search = bigdata.search.new(query=query,
scope=DocumentType.NEWS)
results = search.run(limit)
return results
In the get_news_data
function, we pass the query text and the limit
(maximum number) of news chunks we want to retrieve. The function
returns a list of news documents. Let’s test the function with a sample
query:
query_text = 'What is the role of climate change in the 2024 US election?'
search_results = retrieve_news_data(query_text)
for result in search_results:
print(f'{result.headline}\n\n{result.chunks[0].text}\n\n')
Impact of US election outcomes on global climate change efforts 'overblown', Olver says
Fears around what the outcome of the upcoming US Presidential elections will mean for the green energy transition and fight against climate change are somewhat overblown, Presidential Climate Commission executive director Crispian Olver has said.
Hurricane Helene brings climate change to forefront of the presidential campaign
"The solution for us is to continue to move forward, (accept) that climate change is real" and reduce reliance on fossil fuels, Walz said, adding that the administration is doing exactly that. "We are seeing us becoming an energy superpower for the future, not just the current'' time, he said.
"Every story can be a climate story" - elevating the climate crisis in media election coverage
Time magazine this week declared that the next US president "will play a critical role in addressing the world's most pressing challenges: climate change, global health, and international cooperation".
The US elections will have a big impact on the climate change fight
Every US presidential election is consequential, but American voters face an unusually weighty decision in 2024. The outcome will have implications for US foreign policy, social policy and the integrity of the political system itself. But none of its consequences will be more profound or far-reaching than on global efforts to combat climate change.
Climate Change's Role on Voter Decisions for the 2024 Presidential Election
As the 2024 presidential election approaches, climate change will likely continue to be a pivotal issue for voters. Understanding the diverse perspectives and concerns across generations and political affiliations can help shape more effective climate policies and political strategies.
From the retrieved headlines, we can say there are significant mentions of the “climate change” in the news related to the US election. As we now have our data ready, we can move on to preparing the LLM to generate responses. But before that, we can tag our data for the LLM to have a better understanding of the nature of each data part. Here is a function to generate XML from the retrieved news documents:
def convert_to_xml(documents: List[Document]) -> str:
root_elem = ET.Element("documents")
for doc in documents:
document_elem = ET.SubElement(root_elem, "document")
# Date tag
date_elem = ET.SubElement(document_elem, "date")
timestamp = doc.timestamp
if timestamp:
date_elem.text = timestamp.strftime("%Y-%m-%d")
# Document ID tag
doc_id_elem = ET.SubElement(document_elem, "document_id")
doc_id_elem.text = doc.id
# Add chunk tags
for chunk in doc.chunks:
chunk_elem = ET.SubElement(document_elem, "chunk")
# Chunk number
chunk_num_elem = ET.SubElement(chunk_elem, "chunk_num")
chunk_num_elem.text = str(chunk.chunk)
# Text
text_elem = ET.SubElement(chunk_elem, "text")
text_elem.text = chunk.text
# Generate string representation of the XML elements
xml_string = ET.tostring(root_elem, encoding="unicode", method="xml")
# Prettify the XML string
parsed_xml_string = minidom.parseString(xml_string)
pretty_xml_string = parsed_xml_string.toprettyxml(indent=" ")
return pretty_xml_string
Let’s test the function with the search results we got earlier:
search_results_xml_string = convert_to_xml(search_results)
print(search_results_xml_string)
<?xml version="1.0" ?>
<documents>
<document>
<date>2024-10-01</date>
<document_id>43CE65FB8CA2D8D99F82BF40C8BBA374</document_id>
<chunk>
<chunk_num>1</chunk_num>
<text>Fears around what the outcome of the upcoming US Presidential elections will mean for the green energy transition and fight against climate change are somewhat overblown, Presidential Climate Commission executive director Crispian Olver has said.</text>
</chunk>
<chunk>
<chunk_num>2</chunk_num>
<text>"We're all on tenterhooks for the outcome of the US elections. We don't know. It's basically neck and neck between [Kamala] Harris and [Donald] Trump. I think in the climate space, the outcome is maybe a little bit overblown. I'm not sure America's ever going to reverse the Inflation Reduction Act investments, but certainly the signals that get sent into the global community are going to be radically different," he said at the fourth yearly Climate Summit, in Johannesburg, on October 1.</text>
</chunk>
<chunk>
<chunk_num>3</chunk_num>
<text>He did however note that a Trump regime in the US could perpetuate what he called "Republican-driven winds" blowing against environmental, social and governance (ESG), which were felt across the globe.</text>
</chunk>
<chunk>
<chunk_num>6</chunk_num>
<text>Olver noted that the US impact, while important, needed to be seen in the context of worldwide fragmented geopolitics, particularly among the US, China and Russia, which has led to a highly protectionist set of trade regimes that appear to transcend political leaning.</text>
</chunk>
<chunk>
<chunk_num>9</chunk_num>
<text>Standard Bank chief economist and research head Goolam Balim pointed out the potential impact of the US pulling out of the Paris 2050 agreement, which Trump would reportedly see to if he came to power.</text>
</chunk>
<chunk>
<chunk_num>8</chunk_num>
<text>Nyati hoped that, regardless of the US election outcomes, many private US companies would do what they believed was right. "We know that the individuals in companies do not necessarily follow. They are independent. But it will certainly influence how they think about our geography. We need to pay attention to what is going on [in the US], and it will certainly have an impact, one way or the other, on us," he said.</text>
</chunk>
<chunk>
<chunk_num>4</chunk_num>
<text>He said ESG has "lost a little bit of the shine" it had two years ago. "[Then], it was all any of us spoke about. Now it's a little bit more of an uphill battle. In the climate space, leaders across the board - political and corporate and other institutional leaders - continue to irrationally discount the future. That means that we're radically underestimating the cost that we're going to play pay in terms of loss, damage and adaptation. We're not taking account of the fact that those costs are orders of magnitude bigger than the mitigation investment that we could make today to avoid those costs," Olver said.</text>
</chunk>
<chunk>
<chunk_num>10</chunk_num>
<text>"The US has committed to Paris 2050 and, when assembled with the other partners that have also so subscribed, effectively 89% of the world's economies, when measured by greenhouse emissions, are committed. If the US withdraws, it's clearly a very substantial withdrawal at a political level.</text>
</chunk>
<chunk>
<chunk_num>11</chunk_num>
<text>"However, there is some level of mitigation in the sense that multinational corporate America will be more sensitive to climate dynamics. So, we could get a constructive fissure between headline political tote and corporate America's subscription to the idea of climate responsibility," he said.</text>
</chunk>
<chunk>
<chunk_num>7</chunk_num>
<text>"We've seen how these carbon border adjustment mechanisms are now pushing a carbon price a little bit inequitably into the global economy and linked to that there is a level of resource nationalism, particularly around this new green energy transition," Olver said.</text>
</chunk>
<chunk>
<chunk_num>5</chunk_num>
<text>State-owned utility Eskom chairperson Mteto Nyati, however, said a Trump Presidency would certainly represent a negative outcome for South Africa and the rest of Africa. "If we can end up with Trump as US President, we'll have a US that is more focused on itself and less focused externally. That [holds] implications for economies like South Africa and for regions like Africa, because we need to continue to be driving this agenda of growth, and to do that, you need partnerships. You need the investments that are related to that. If you have less of that, and more of an economy that is looking at itself inwardly, that is going to be negative for us," he said.</text>
</chunk>
</document>
<document>
<date>2024-10-03</date>
<document_id>88D7E3F3B68CCC64995E01DB7B4DA0C2</document_id>
<chunk>
<chunk_num>20</chunk_num>
<text>"The solution for us is to continue to move forward, (accept) that climate change is real" and reduce reliance on fossil fuels, Walz said, adding that the administration is doing exactly that. "We are seeing us becoming an energy superpower for the future, not just the current'' time, he said.</text>
</chunk>
</document>
<document>
<date>2024-10-02</date>
<document_id>9D34395B611E5A4D6FF2B5F5E9F66937</document_id>
<chunk>
<chunk_num>2</chunk_num>
<text>Time magazine this week declared that the next US president "will play a critical role in addressing the world's most pressing challenges: climate change, global health, and international cooperation".</text>
</chunk>
<chunk>
<chunk_num>41</chunk_num>
<text>"We're working with a disenfranchised population that is facing issues that supersede any election inequities, that are hundreds of years in the making," he said. "Those issues - about just putting food on your table, having a roof over your head - are always going to be number one on the docket" but the climate connections "are there, and obvious, whether we're thinking about the [property] insurance crisis in the Gulf Coast right now... or even our food map in the way that that has been impacted by contamination and storms."</text>
</chunk>
<chunk>
<chunk_num>49</chunk_num>
<text>It has launched a series called The Stakes, which dives into the possible consequences of a second Trump presidency, opening with an article by US author and environmentalist Bill McKibbon, talking about the climate risk of a Trump win.</text>
</chunk>
<chunk>
<chunk_num>21</chunk_num>
<text>Echoing the experience of Australia's 2022 election, she said that, post-election, "there was maybe recognition that there are voters out there who really care about this and it can be an electoral win for a campaign to focus on it".</text>
</chunk>
<chunk>
<chunk_num>53</chunk_num>
<text>The Stakes vs. The Horse Race The World's Climate Elections Joseph Stiglitz: The Climate Stakes of the US Election CBS News: The majority of Americans support climate reforms. Why won't Congress deliver?</text>
</chunk>
<chunk>
<chunk_num>12</chunk_num>
<text>"The climate crisis isn't a fringe issue that only a few voters care about," Hanman said. "It's completely central to all of the decisions that politicians are making right now, and it will affect everyone around the world, it will affect every sector of how we live."</text>
</chunk>
<chunk>
<chunk_num>14</chunk_num>
<text>She had been inspired, she said, by the 2023 call on media by New York University.journalism professor Jay Rosen's to focus in the US election on 'stakes not odds'. The summit heard repeatedly that climate should and could be a lens on every issue - cost of living, housing, racism, justice, migration, health and beyond.</text>
</chunk>
<chunk>
<chunk_num>3</chunk_num>
<text>It said the choice between Kamala Harris and Donald Trump could not be clearer. "Their opposing views on climate action, pandemic preparedness, and infectious disease prevention, among other challenges, will significantly influence not just the daily lives of Americans but the trajectory of millions of lives around the world."</text>
</chunk>
</document>
<document>
<date>2024-08-18</date>
<document_id>17F7B7E3537DE5E4BC8F8D3E81263374</document_id>
<chunk>
<chunk_num>1</chunk_num>
<text>Every US presidential election is consequential, but American voters face an unusually weighty decision in 2024. The outcome will have implications for US foreign policy, social policy and the integrity of the political system itself. But none of its consequences will be more profound or far-reaching than on global efforts to combat climate change.</text>
</chunk>
</document>
<document>
<date>2024-06-28</date>
<document_id>921953534D5EB5BE940FEE64F582623F</document_id>
<chunk>
<chunk_num>16</chunk_num>
<text>As the 2024 presidential election approaches, climate change will likely continue to be a pivotal issue for voters. Understanding the diverse perspectives and concerns across generations and political affiliations can help shape more effective climate policies and political strategies.</text>
</chunk>
<chunk>
<chunk_num>1</chunk_num>
<text>Research this year from CU Boulder's Center for Environmental Futures (C-SEF) has highlighted the significant role that climate change concerns played in voter decisions during the 2016 and 2020 presidential elections. The findings suggest that climate-related views may have contributed to the Republican loss in 2020.</text>
</chunk>
<chunk>
<chunk_num>2</chunk_num>
<text>Political Implications of Climate Change Concerns The C-SEF report emphasizes the importance of understanding how climate change perceptions impact voter behavior, especially with the 2024 election approaching. Matthew Burgess, CIRES Fellow and C-SEF director, noted that reducing political polarization on climate change is a critical area of interest for their research group, and these insights provide valuable information for politicians and advocates across the political spectrum.</text>
</chunk>
<chunk>
<chunk_num>10</chunk_num>
<text>Shifts in Climate Change Beliefs The belief that human activities drive climate change rebounded in 2024, with 54% of respondents to an University of Chicago Energy Policy Institute (EPIC) Poll agreeing with this view. Notably, this increase was driven by younger Republicans, with 40% now acknowledging human-driven climate change, up from 26% in 2017.</text>
</chunk>
<chunk>
<chunk_num>11</chunk_num>
<text>Experiencing extreme climate events significantly influences belief in climate change. The 2024 poll found that those who have faced extreme weather are more likely to see climate change as a critical issue and support actions to mitigate its effects. This is evident as the gap in belief between those who have and have not experienced such events has widened significantly.</text>
</chunk>
<chunk>
<chunk_num>13</chunk_num>
<text>There is a shift in the perceived responsibility for addressing climate change. More Americans now believe that rapidly developing countries like India and China have a greater responsibility than developed nations. This view aligns more with Republican perspectives, whereas Democrats tend to hold corporations and the federal government more accountable.</text>
</chunk>
<chunk>
<chunk_num>4</chunk_num>
<text>Make your voice heard - take the survey here! Despite the strong influence of climate change on voting patterns in 2020, it is not the top concern for most voters. Less than 5% of adults rank climate change as their most important issue, with priorities such as the economy, health care, education, and crime taking precedence.</text>
</chunk>
<chunk>
<chunk_num>8</chunk_num>
<text>A global survey of 10,000 young people aged 16-25, conducted in December 2021, revealed widespread anxiety about climate change. The survey reported high levels of worry and negative emotions such as sadness, anger, and guilt across all countries involved.</text>
</chunk>
</document>
</documents>
Generate Response¶
Now that we have our data ready, we can generate the response using the
LLM. The function generate_response
takes the LLM, query, and the
chunks of news as input and returns the response generated by the LLM
along with the usage statistics:
def generate_response(llm,
query: str,
chunks: str) -> tuple[str, Dict[str, int]]:
prompt = f"""You are tasked with answering a question using provided chunks of information. Your goal is to provide an accurate answer while citing your sources using a specific markdown format.
Here is the query you need to answer:
<question>
{query}
</question>
Below are chunks of information that you can use to answer the question. Each chunk is preceded by a source identifier in the format [document_id=X&chunk_num=Y&date=Z]. You can use this identifier to cite the source of the information in your answer:
{chunks}
Your task is to answer the question using the information provided in these chunks. When you use information from a specific chunk in your answer, you must cite it using a markdown link format. The citation should appear at the end of the sentence or phrase where the information is used. The citation format should be as follows: [document_id=X&chunk_num=Y&date=Z]
For example, if you're using information from the chunk labeled [document_id=ed34hgyt6723lssdh&chunk_num=2&date=2014-02-06], your citation would look like this: This is a sentence using information from [document_id=ed34hgyt6723lssdh&chunk_num=2&date=2014-02-06].
If there are more than one source for a particular piece of information, your citation would look like this: This is a sentence using information from ([document_id=ed34hgyt6723lssdh&chunk_num=2&date=2014-02-06]], [document_id=yur56wekshsgdn&chunk_num=4&date=2022-02-21])
Answer the question using the information provided in the chunks. Remember to cite your sources accurately.
"""
response = llm.chat.completions.create(model=MODEL_NAME,
messages=[{"role": "system",
"content": SYSTEM_PROMPT},
{"role": "user",
"content": prompt}])
return response.choices[0].message.content, response.usage
We are now able to generate a response for our query and the search results we have:
response, usage = generate_response(llm, query_text, search_results_xml_string)
To calculate the cost of using the OpenAI API, we easily can do the math using the pricing details provided by OpenAI as of early October 2024. The cost is calculated based on the number of tokens used in the generation process. The cost per token is \$0.15 for a million input tokens and \$0.60 for a million output tokens. Here is a function to calculate the cost:
def calculate_usage_cost(usage) -> float:
total_cost = ((usage.prompt_tokens * 0.15 / 1_000_000) +
(usage.completion_tokens * 0.60 / 1_000_000))
return total_cost
total_cost = calculate_usage_cost(usage)
print('Total cost: $', total_cost)
Total cost: $ 0.00097845
Extremely affordable, right!
With having the response generated, we can display it in Markdown format right here in the notebook:
display(Markdown(response))
The Role of Climate Change in the 2024 US Election
--------------------------------------------------
Climate change is emerging as a **critical issue** in the **2024 US
presidential election**, influencing various aspects of the electoral
landscape. Here’s how it is shaping the election:
Key Factors
~~~~~~~~~~~
1. **Voter Concerns and Political Implications**:
- Climate change concerns have significantly impacted voter behavior
in previous elections, particularly in 2016 and 2020. Research
suggests that these concerns contributed to the Republican loss in
2020, signaling that climate change perception may play a pivotal
role in the upcoming election
([document_id=921953534D5EB5BE940FEE64F582623F&chunk_num=1&date=2024-06-28]).
- Despite **climate change not being the top concern** for most
voters (with less than 5% ranking it as their primary issue), it
remains influential across various demographics. Issues like the
economy and healthcare currently take precedence, but climate
connections are increasingly recognized in discussions about
broader challenges
([document_id=921953534D5EB5BE940FEE64F582623F&chunk_num=4&date=2024-06-28]).
2. **Diverging Views Between Candidates**:
- The choice between candidates, such as Kamala Harris and Donald
Trump, represents two starkly different approaches to climate
policy. Their opposing stances on climate action and related issues
will likely have significant implications for daily life in America
and global climate initiatives
([document_id=9D34395B611E5A4D6FF2B5F5E9F66937&chunk_num=3&date=2024-10-02]).
- A potential Trump presidency could reverse progress made in
international climate agreements, such as pulling the US out of the
**Paris 2050 agreement**, which would have substantial political
repercussions
([document_id=43CE65FB8CA2D8D99F82BF40C8BBA374&chunk_num=9&date=2024-10-01]).
3. **Impacts of Public and Corporate Sentiment**:
- Climate action is increasingly seen as a central issue by the
public, with a majority of Americans expressing support for climate
reforms. This public sentiment is shaping electoral strategies and
may encourage both candidates to prioritize climate-related topics
in their platforms
([document_id=9D34395B611E5A4D6FF2B5F5E9F66937&chunk_num=12&date=2024-10-02]).
- Moreover, despite potential political shifts, many private
companies in the US are expected to continue their commitment to
sustainability and climate responsibility, irrespective of who wins
the election
([document_id=43CE65FB8CA2D8D99F82BF40C8BBA374&chunk_num=11&date=2024-10-01]).
Global Context
~~~~~~~~~~~~~~
- The climate policies of the US have implications beyond national
borders. The interplay between climate action and geopolitical
relationships, especially with major players like **China** and
**Russia**, indicates that the US election outcome will affect global
trade regimes and environmental efforts
([document_id=43CE65FB8CA2D8D99F82BF40C8BBA374&chunk_num=6&date=2024-10-01]).
Conclusion
~~~~~~~~~~
In summary, climate change is poised to be a **deciding factor** in the
**2024 US presidential elections**. Its significance extends from
influencing voter behavior and candidate platforms to impacting global
climate initiatives and foreign policy. As the election approaches, both
voter concerns and the candidates’ positions on climate issues will
become increasingly critical to watch.
The generation looks good except the citations are not yet linked. Let’s process the citations and add the links to the references at the end of the response:
def process_links(text):
# Regular expression to match the links
pattern = r'\[document_id=([^&]+)&chunk_num=(\d+)&date=(\d{4}-\d{2}-\d{2})\]'
# Find all matches
matches = re.findall(pattern, text)
# Create an ordered dictionary to store unique links
links = OrderedDict()
# Process each match
for doc_id, chunk_num, date in matches:
key = (doc_id, chunk_num, date)
if key not in links:
links[key] = len(links) + 1
# Create HTML for references
references_html = "<ol>"
for (doc_id, chunk_num, date), num in links.items():
url = f"https://app.bigdata.com/files#?document={doc_id}"
references_html += f'<li><a href="{url}" target="_blank">Document {doc_id}, Chunk {chunk_num}, Date {date}</a></li>'
references_html += "</ol>"
# Replace links in the text with numbered superscripts
def replace_link(match):
doc_id, chunk_num, date = match.groups()
num = links[(doc_id, chunk_num, date)]
url = f"https://app.bigdata.com/files#?document={doc_id}"
return f'<a href="{url}" target="_blank" rel="noopener noreferrer">[{num}]</a>'
processed_text = re.sub(pattern, replace_link, text)
return processed_text, references_html
Let’s process the citations and display the response with the references:
processed_response, references_html = process_links(response)
display(Markdown(processed_response))
display(Markdown(references_html))
The Role of Climate Change in the 2024 US Election
--------------------------------------------------
Climate change is emerging as a **critical issue** in the **2024 US
presidential election**, influencing various aspects of the electoral
landscape. Here’s how it is shaping the election:
Key Factors
~~~~~~~~~~~
1. **Voter Concerns and Political Implications**:
- Climate change concerns have significantly impacted voter behavior
in previous elections, particularly in 2016 and 2020. Research
suggests that these concerns contributed to the Republican loss in
2020, signaling that climate change perception may play a pivotal
role in the upcoming election ([1]).
- Despite **climate change not being the top concern** for most
voters (with less than 5% ranking it as their primary issue), it
remains influential across various demographics. Issues like the
economy and healthcare currently take precedence, but climate
connections are increasingly recognized in discussions about
broader challenges ([2]).
2. **Diverging Views Between Candidates**:
- The choice between candidates, such as Kamala Harris and Donald
Trump, represents two starkly different approaches to climate
policy. Their opposing stances on climate action and related issues
will likely have significant implications for daily life in America
and global climate initiatives ([3]).
- A potential Trump presidency could reverse progress made in
international climate agreements, such as pulling the US out of the
**Paris 2050 agreement**, which would have substantial political
repercussions ([4]).
3. **Impacts of Public and Corporate Sentiment**:
- Climate action is increasingly seen as a central issue by the
public, with a majority of Americans expressing support for climate
reforms. This public sentiment is shaping electoral strategies and
may encourage both candidates to prioritize climate-related topics
in their platforms ([5]).
- Moreover, despite potential political shifts, many private
companies in the US are expected to continue their commitment to
sustainability and climate responsibility, irrespective of who wins
the election ([6]).
Global Context
~~~~~~~~~~~~~~
- The climate policies of the US have implications beyond national
borders. The interplay between climate action and geopolitical
relationships, especially with major players like **China** and
**Russia**, indicates that the US election outcome will affect global
trade regimes and environmental efforts ([7]).
Conclusion
~~~~~~~~~~
In summary, climate change is poised to be a **deciding factor** in the
**2024 US presidential elections**. Its significance extends from
influencing voter behavior and candidate platforms to impacting global
climate initiatives and foreign policy. As the election approaches, both
voter concerns and the candidates’ positions on climate issues will
become increasingly critical to watch.
Document 921953534D5EB5BE940FEE64F582623F, Chunk 1, Date 2024-06-28
Document 921953534D5EB5BE940FEE64F582623F, Chunk 4, Date 2024-06-28
Document 9D34395B611E5A4D6FF2B5F5E9F66937, Chunk 3, Date 2024-10-02
Document 43CE65FB8CA2D8D99F82BF40C8BBA374, Chunk 9, Date 2024-10-01
Document 9D34395B611E5A4D6FF2B5F5E9F66937, Chunk 12, Date 2024-10-02
Document 43CE65FB8CA2D8D99F82BF40C8BBA374, Chunk 11, Date 2024-10-01
Document 43CE65FB8CA2D8D99F82BF40C8BBA374, Chunk 6, Date 2024-10-01
The response is now well-structured and includes the references at the end. The references provide a way to access the original news documents on Bigdata website for further reading or verification.
Conclusion¶
In this tutorial, we have successfully built an AI RAG pipeline using documents retrieved via the Bigdata SDK. The pipeline is capable of generating responses to questions using the retrieved documents and providing citations to the sources.
You can further enhance this pipeline by customizing the retrieval process or using different language models.
Happy Searching! 🚀