Stay Ahead, Stay ONMINE

LLM + RAG: Creating an AI-Powered File Reader Assistant

Introduction AI is everywhere.  It is hard not to interact at least once a day with a Large Language Model (LLM). The chatbots are here to stay. They’re in your apps, they help you write better, they compose emails, they read emails…well, they do a lot. And I don’t think that that is bad. In fact, my opinion is the other way – at least so far. I defend and advocate for the use of AI in our daily lives because, let’s agree, it makes everything much easier. I don’t have to spend time double-reading a document to find punctuation problems or type. AI does that for me. I don’t waste time writing that follow-up email every single Monday. AI does that for me. I don’t need to read a huge and boring contract when I have an AI to summarize the main takeaways and action points to me! These are only some of AI’s great uses. If you’d like to know more use cases of LLMs to make our lives easier, I wrote a whole book about them. Now, thinking as a data scientist and looking at the technical side, not everything is that bright and shiny.  LLMs are great for several general use cases that apply to anyone or any company. For example, coding, summarizing, or answering questions about general content created until the training cutoff date. However, when it comes to specific business applications, for a single purpose, or something new that didn’t make the cutoff date, that is when the models won’t be that useful if used out-of-the-box – meaning, they will not know the answer. Thus, it will need adjustments. Training an LLM model can take months and millions of dollars. What is even worse is that if we don’t adjust and tune the model to our purpose, there will be unsatisfactory results or hallucinations (when the model’s response doesn’t make sense given our query). So what is the solution, then? Spending a lot of money retraining the model to include our data? Not really. That’s when the Retrieval-Augmented Generation (RAG) becomes useful. RAG is a framework that combines getting information from an external knowledge base with large language models (LLMs). It helps AI models produce more accurate and relevant responses. Let’s learn more about RAG next. What is RAG? Let me tell you a story to illustrate the concept. I love movies. For some time in the past, I knew which movies were competing for the best movie category at the Oscars or the best actors and actresses. And I would certainly know which ones got the statue for that year. But now I am all rusty on that subject. If you asked me who was competing, I would not know. And even if I tried to answer you, I would give you a weak response.  So, to provide you with a quality response, I will do what everybody else does: search for the information online, obtain it, and then give it to you. What I just did is the same idea as the RAG: I obtained data from an external database to give you an answer. When we enhance the LLM with a content store where it can go and retrieve data to augment (increase) its knowledge base, that is the RAG framework in action. RAG is like creating a content store where the model can enhance its knowledge and respond more accurately. User prompt about Content C. LLM retrieves external content to aggregate to the answer. Image by the author. Summarizing: Uses search algorithms to query external data sources, such as databases, knowledge bases, and web pages. Pre-processes the retrieved information. Incorporates the pre-processed information into the LLM. Why use RAG? Now that we know what the RAG framework is let’s understand why we should be using it. Here are some of the benefits: Enhances factual accuracy by referencing real data. RAG can help LLMs process and consolidate knowledge to create more relevant answers  RAG can help LLMs access additional knowledge bases, such as internal organizational data  RAG can help LLMs create more accurate domain-specific content  RAG can help reduce knowledge gaps and AI hallucination As previously explained, I like to say that with the RAG framework, we are giving an internal search engine for the content we want it to add to the knowledge base. Well. All of that is very interesting. But let’s see an application of RAG. We will learn how to create an AI-powered PDF Reader Assistant. Project This is an application that allows users to upload a PDF document and ask questions about its content using AI-powered natural language processing (NLP) tools.  The app uses Streamlit as the front end. Langchain, OpenAI’s GPT-4 model, and FAISS (Facebook AI Similarity Search) for document retrieval and question answering in the backend. Let’s break down the steps for better understanding: Loading a PDF file and splitting it into chunks of text. This makes the data optimized for retrieval Present the chunks to an embedding tool. Embeddings are numerical vector representations of data used to capture relationships, similarities, and meanings in a way that machines can understand. They are widely used in Natural Language Processing (NLP), recommender systems, and search engines. Next, we put those chunks of text and embeddings in the same DB for retrieval. Finally, we make it available to the LLM. Data preparation Preparing a content store for the LLM will take some steps, as we just saw. So, let’s start by creating a function that can load a file and split it into text chunks for efficient retrieval. # Imports from langchain_community.document_loaders import PyPDFLoader from langchain.text_splitter import RecursiveCharacterTextSplitter def load_document(pdf): # Load a PDF “”” Load a PDF and split it into chunks for efficient retrieval. :param pdf: PDF file to load :return: List of chunks of text “”” loader = PyPDFLoader(pdf) docs = loader.load() # Instantiate Text Splitter with Chunk Size of 500 words and Overlap of 100 words so that context is not lost text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=100) # Split into chunks for efficient retrieval chunks = text_splitter.split_documents(docs) # Return return chunks Next, we will start building our Streamlit app, and we’ll use that function in the next script. Web application We will begin importing the necessary modules in Python. Most of those will come from the langchain packages. FAISS is used for document retrieval; OpenAIEmbeddings transforms the text chunks into numerical scores for better similarity calculation by the LLM; ChatOpenAI is what enables us to interact with the OpenAI API; create_retrieval_chain is what actually the RAG does, retrieving and augmenting the LLM with that data; create_stuff_documents_chain glues the model and the ChatPromptTemplate. Note: You will need to generate an OpenAI Key to be able to run this script. If it’s the first time you’re creating your account, you get some free credits. But if you have it for some time, it is possible that you will have to add 5 dollars in credits to be able to access OpenAI’s API. An option is using Hugging Face’s Embedding.  # Imports from langchain_community.vectorstores import FAISS from langchain_openai import OpenAIEmbeddings from langchain.chains import create_retrieval_chain from langchain_openai import ChatOpenAI from langchain.chains.combine_documents import create_stuff_documents_chain from langchain_core.prompts import ChatPromptTemplate from scripts.secret import OPENAI_KEY from scripts.document_loader import load_document import streamlit as st This first code snippet will create the App title, create a box for file upload, and prepare the file to be added to the load_document() function. # Create a Streamlit app st.title(“AI-Powered Document Q&A”) # Load document to streamlit uploaded_file = st.file_uploader(“Upload a PDF file”, type=”pdf”) # If a file is uploaded, create the TextSplitter and vector database if uploaded_file :     # Code to work around document loader from Streamlit and make it readable by langchain     temp_file = “./temp.pdf”     with open(temp_file, “wb”) as file:         file.write(uploaded_file.getvalue())         file_name = uploaded_file.name     # Load document and split it into chunks for efficient retrieval.     chunks = load_document(temp_file)     # Message user that document is being processed with time emoji     st.write(“Processing document… :watch:”) Machines understand numbers better than text, so in the end, we will have to provide the model with a database of numbers that it can compare and check for similarity when performing a query. That’s where the embeddings will be useful to create the vector_db, in this next piece of code. # Generate embeddings     # Embeddings are numerical vector representations of data, typically used to capture relationships, similarities,     # and meanings in a way that machines can understand. They are widely used in Natural Language Processing (NLP),     # recommender systems, and search engines.     embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_KEY,                                   model=”text-embedding-ada-002″)     # Can also use HuggingFaceEmbeddings     # from langchain_huggingface.embeddings import HuggingFaceEmbeddings     # embeddings = HuggingFaceEmbeddings(model_name=”sentence-transformers/all-MiniLM-L6-v2″)     # Create vector database containing chunks and embeddings     vector_db = FAISS.from_documents(chunks, embeddings) Next, we create a retriever object to navigate in the vector_db. # Create a document retriever     retriever = vector_db.as_retriever()     llm = ChatOpenAI(model_name=”gpt-4o-mini”, openai_api_key=OPENAI_KEY) Then, we will create the system_prompt, which is a set of instructions to the LLM on how to answer, and we will create a prompt template, preparing it to be added to the model once we get the input from the user. # Create a system prompt     # It sets the overall context for the model.     # It influences tone, style, and focus before user interaction starts.     # Unlike user inputs, a system prompt is not visible to the end user.     system_prompt = (         “You are a helpful assistant. Use the given context to answer the question.”         “If you don’t know the answer, say you don’t know. ”         “{context}”     )     # Create a prompt Template     prompt = ChatPromptTemplate.from_messages(         [             (“system”, system_prompt),             (“human”, “{input}”),         ]     )     # Create a chain     # It creates a StuffDocumentsChain, which takes multiple documents (text data) and “stuffs” them together before passing them to the LLM for processing.     question_answer_chain = create_stuff_documents_chain(llm, prompt) Moving on, we create the core of the RAG framework, pasting together the retriever object and the prompt. This object adds relevant documents from a data source (e.g., a vector database) and makes it ready to be processed using an LLM to generate a response. # Creates the RAG      chain = create_retrieval_chain(retriever, question_answer_chain) Finally, we create the variable question for the user input. If this question box is filled with a query, we pass it to the chain, which calls the LLM to process and return the response, which will be printed on the app’s screen. # Streamlit input for question     question = st.text_input(“Ask a question about the document:”)     if question:         # Answer         response = chain.invoke({“input”: question})[‘answer’]         st.write(response) Here is a screenshot of the result. Screenshot of the final app. Image by the author. And this is a GIF for you to see the File Reader Ai Assistant in action! File Reader AI Assistant in action. Image by the author. Before you go In this project, we learned what the RAG framework is and how it helps the Llm to perform better and also perform well with specific knowledge. AI can be powered with knowledge from an instruction manual, databases from a company, some finance files, or contracts, and then become fine-tuned to respond accurately to domain-specific content queries. The knowledge base is augmented with a content store. To recap, this is how the framework works: 1️⃣ User Query → Input text is received. 2️⃣ Retrieve Relevant Documents → Searches a knowledge base (e.g., a database, vector store). 3️⃣ Augment Context → Retrieved documents are added to the input. 4️⃣ Generate Response → An LLM processes the combined input and produces an answer. GitHub repository https://github.com/gurezende/Basic-Rag About me If you liked this content and want to learn more about my work, here is my website, where you can also find all my contacts. https://gustavorsantos.me References https://cloud.google.com/use-cases/retrieval-augmented-generation https://www.ibm.com/think/topics/retrieval-augmented-generation https://python.langchain.com/docs/introduction https://www.geeksforgeeks.org/how-to-get-your-own-openai-api-key

Introduction

AI is everywhere. 

It is hard not to interact at least once a day with a Large Language Model (LLM). The chatbots are here to stay. They’re in your apps, they help you write better, they compose emails, they read emails…well, they do a lot.

And I don’t think that that is bad. In fact, my opinion is the other way – at least so far. I defend and advocate for the use of AI in our daily lives because, let’s agree, it makes everything much easier.

I don’t have to spend time double-reading a document to find punctuation problems or type. AI does that for me. I don’t waste time writing that follow-up email every single Monday. AI does that for me. I don’t need to read a huge and boring contract when I have an AI to summarize the main takeaways and action points to me!

These are only some of AI’s great uses. If you’d like to know more use cases of LLMs to make our lives easier, I wrote a whole book about them.

Now, thinking as a data scientist and looking at the technical side, not everything is that bright and shiny. 

LLMs are great for several general use cases that apply to anyone or any company. For example, coding, summarizing, or answering questions about general content created until the training cutoff date. However, when it comes to specific business applications, for a single purpose, or something new that didn’t make the cutoff date, that is when the models won’t be that useful if used out-of-the-box – meaning, they will not know the answer. Thus, it will need adjustments.

Training an LLM model can take months and millions of dollars. What is even worse is that if we don’t adjust and tune the model to our purpose, there will be unsatisfactory results or hallucinations (when the model’s response doesn’t make sense given our query).

So what is the solution, then? Spending a lot of money retraining the model to include our data?

Not really. That’s when the Retrieval-Augmented Generation (RAG) becomes useful.

RAG is a framework that combines getting information from an external knowledge base with large language models (LLMs). It helps AI models produce more accurate and relevant responses.

Let’s learn more about RAG next.

What is RAG?

Let me tell you a story to illustrate the concept.

I love movies. For some time in the past, I knew which movies were competing for the best movie category at the Oscars or the best actors and actresses. And I would certainly know which ones got the statue for that year. But now I am all rusty on that subject. If you asked me who was competing, I would not know. And even if I tried to answer you, I would give you a weak response. 

So, to provide you with a quality response, I will do what everybody else does: search for the information online, obtain it, and then give it to you. What I just did is the same idea as the RAG: I obtained data from an external database to give you an answer.

When we enhance the LLM with a content store where it can go and retrieve data to augment (increase) its knowledge base, that is the RAG framework in action.

RAG is like creating a content store where the model can enhance its knowledge and respond more accurately.

Diagram: User prompts and content using LLM + RAG
User prompt about Content C. LLM retrieves external content to aggregate to the answer. Image by the author.

Summarizing:

  1. Uses search algorithms to query external data sources, such as databases, knowledge bases, and web pages.
  2. Pre-processes the retrieved information.
  3. Incorporates the pre-processed information into the LLM.

Why use RAG?

Now that we know what the RAG framework is let’s understand why we should be using it.

Here are some of the benefits:

  • Enhances factual accuracy by referencing real data.
  • RAG can help LLMs process and consolidate knowledge to create more relevant answers 
  • RAG can help LLMs access additional knowledge bases, such as internal organizational data 
  • RAG can help LLMs create more accurate domain-specific content 
  • RAG can help reduce knowledge gaps and AI hallucination

As previously explained, I like to say that with the RAG framework, we are giving an internal search engine for the content we want it to add to the knowledge base.

Well. All of that is very interesting. But let’s see an application of RAG. We will learn how to create an AI-powered PDF Reader Assistant.

Project

This is an application that allows users to upload a PDF document and ask questions about its content using AI-powered natural language processing (NLP) tools. 

  • The app uses Streamlit as the front end.
  • Langchain, OpenAI’s GPT-4 model, and FAISS (Facebook AI Similarity Search) for document retrieval and question answering in the backend.

Let’s break down the steps for better understanding:

  1. Loading a PDF file and splitting it into chunks of text.
    1. This makes the data optimized for retrieval
  2. Present the chunks to an embedding tool.
    1. Embeddings are numerical vector representations of data used to capture relationships, similarities, and meanings in a way that machines can understand. They are widely used in Natural Language Processing (NLP), recommender systems, and search engines.
  3. Next, we put those chunks of text and embeddings in the same DB for retrieval.
  4. Finally, we make it available to the LLM.

Data preparation

Preparing a content store for the LLM will take some steps, as we just saw. So, let’s start by creating a function that can load a file and split it into text chunks for efficient retrieval.

# Imports
from  langchain_community.document_loaders import PyPDFLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter

def load_document(pdf):
    # Load a PDF
    """
    Load a PDF and split it into chunks for efficient retrieval.

    :param pdf: PDF file to load
    :return: List of chunks of text
    """

    loader = PyPDFLoader(pdf)
    docs = loader.load()

    # Instantiate Text Splitter with Chunk Size of 500 words and Overlap of 100 words so that context is not lost
    text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=100)
    # Split into chunks for efficient retrieval
    chunks = text_splitter.split_documents(docs)

    # Return
    return chunks

Next, we will start building our Streamlit app, and we’ll use that function in the next script.

Web application

We will begin importing the necessary modules in Python. Most of those will come from the langchain packages.

FAISS is used for document retrieval; OpenAIEmbeddings transforms the text chunks into numerical scores for better similarity calculation by the LLM; ChatOpenAI is what enables us to interact with the OpenAI API; create_retrieval_chain is what actually the RAG does, retrieving and augmenting the LLM with that data; create_stuff_documents_chain glues the model and the ChatPromptTemplate.

Note: You will need to generate an OpenAI Key to be able to run this script. If it’s the first time you’re creating your account, you get some free credits. But if you have it for some time, it is possible that you will have to add 5 dollars in credits to be able to access OpenAI’s API. An option is using Hugging Face’s Embedding. 

# Imports
from langchain_community.vectorstores import FAISS
from langchain_openai import OpenAIEmbeddings
from langchain.chains import create_retrieval_chain
from langchain_openai import ChatOpenAI
from langchain.chains.combine_documents import create_stuff_documents_chain
from langchain_core.prompts import ChatPromptTemplate
from scripts.secret import OPENAI_KEY
from scripts.document_loader import load_document
import streamlit as st

This first code snippet will create the App title, create a box for file upload, and prepare the file to be added to the load_document() function.

# Create a Streamlit app
st.title("AI-Powered Document Q&A")

# Load document to streamlit
uploaded_file = st.file_uploader("Upload a PDF file", type="pdf")

# If a file is uploaded, create the TextSplitter and vector database
if uploaded_file :

    # Code to work around document loader from Streamlit and make it readable by langchain
    temp_file = "./temp.pdf"
    with open(temp_file, "wb") as file:
        file.write(uploaded_file.getvalue())
        file_name = uploaded_file.name

    # Load document and split it into chunks for efficient retrieval.
    chunks = load_document(temp_file)

    # Message user that document is being processed with time emoji
    st.write("Processing document... :watch:")

Machines understand numbers better than text, so in the end, we will have to provide the model with a database of numbers that it can compare and check for similarity when performing a query. That’s where the embeddings will be useful to create the vector_db, in this next piece of code.

# Generate embeddings
    # Embeddings are numerical vector representations of data, typically used to capture relationships, similarities,
    # and meanings in a way that machines can understand. They are widely used in Natural Language Processing (NLP),
    # recommender systems, and search engines.
    embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_KEY,
                                  model="text-embedding-ada-002")

    # Can also use HuggingFaceEmbeddings
    # from langchain_huggingface.embeddings import HuggingFaceEmbeddings
    # embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")

    # Create vector database containing chunks and embeddings
    vector_db = FAISS.from_documents(chunks, embeddings)

Next, we create a retriever object to navigate in the vector_db.

# Create a document retriever
    retriever = vector_db.as_retriever()
    llm = ChatOpenAI(model_name="gpt-4o-mini", openai_api_key=OPENAI_KEY)

Then, we will create the system_prompt, which is a set of instructions to the LLM on how to answer, and we will create a prompt template, preparing it to be added to the model once we get the input from the user.

# Create a system prompt
    # It sets the overall context for the model.
    # It influences tone, style, and focus before user interaction starts.
    # Unlike user inputs, a system prompt is not visible to the end user.

    system_prompt = (
        "You are a helpful assistant. Use the given context to answer the question."
        "If you don't know the answer, say you don't know. "
        "{context}"
    )

    # Create a prompt Template
    prompt = ChatPromptTemplate.from_messages(
        [
            ("system", system_prompt),
            ("human", "{input}"),
        ]
    )

    # Create a chain
    # It creates a StuffDocumentsChain, which takes multiple documents (text data) and "stuffs" them together before passing them to the LLM for processing.

    question_answer_chain = create_stuff_documents_chain(llm, prompt)

Moving on, we create the core of the RAG framework, pasting together the retriever object and the prompt. This object adds relevant documents from a data source (e.g., a vector database) and makes it ready to be processed using an LLM to generate a response.

# Creates the RAG
     chain = create_retrieval_chain(retriever, question_answer_chain)

Finally, we create the variable question for the user input. If this question box is filled with a query, we pass it to the chain, which calls the LLM to process and return the response, which will be printed on the app’s screen.

# Streamlit input for question
    question = st.text_input("Ask a question about the document:")
    if question:
        # Answer
        response = chain.invoke({"input": question})['answer']
        st.write(response)

Here is a screenshot of the result.

Screenshot of the AI-Powered Document Q&A
Screenshot of the final app. Image by the author.

And this is a GIF for you to see the File Reader Ai Assistant in action!

GIF of the File Reader AI Assistant in action
File Reader AI Assistant in action. Image by the author.

Before you go

In this project, we learned what the RAG framework is and how it helps the Llm to perform better and also perform well with specific knowledge.

AI can be powered with knowledge from an instruction manual, databases from a company, some finance files, or contracts, and then become fine-tuned to respond accurately to domain-specific content queries. The knowledge base is augmented with a content store.

To recap, this is how the framework works:

1️⃣ User Query → Input text is received.

2️⃣ Retrieve Relevant Documents → Searches a knowledge base (e.g., a database, vector store).

3️⃣ Augment Context → Retrieved documents are added to the input.

4️⃣ Generate Response → An LLM processes the combined input and produces an answer.

GitHub repository

https://github.com/gurezende/Basic-Rag

About me

If you liked this content and want to learn more about my work, here is my website, where you can also find all my contacts.

https://gustavorsantos.me

References

https://cloud.google.com/use-cases/retrieval-augmented-generation

https://www.ibm.com/think/topics/retrieval-augmented-generation

https://youtu.be/T-D1OfcDW1M?si=G0UWfH5-wZnMu0nw

https://python.langchain.com/docs/introduction

https://www.geeksforgeeks.org/how-to-get-your-own-openai-api-key

Shape
Shape
Stay Ahead

Explore More Insights

Stay ahead with more perspectives on cutting-edge power, infrastructure, energy,  bitcoin and AI solutions. Explore these articles to uncover strategies and insights shaping the future of industries.

Shape

Broadcom issues fixes for 23 new VMware flaws, three critical

The company said that the advisory covers a total of 23 issues, seven of which are in vCenter: an authentication bypass and three denial-of-service issues in the VMware Directory Service, an arbitrary file write while processing certain archives, a local privilege escalation in a vpxd service script, and a security

Read More »

EIA: US crude oil inventories up 1.1 million bbl

US crude oil inventories for the week ended Nov. 20, excluding the Strategic Petroleum Reserve, increased by 1.1 million bbl from the previous week, according to data from the US Energy Information Administration (EIA). At 418.9 million bbl, US crude oil inventories are 3% below the 5-year average for this time of year, the EIA report indicated. Gasoline inventories increased 1.7 million bbl, 3% above the 5-year average. Propane-propylene inventories decreased 1.0 million bbl, 11% above the 5-year average. Total commercial petroleum inventories decreased by 2.4 million bbl for the week. Distillate inventories increased by 700,000 bbl and are 6% below the 5-year average. US crude oil refinery inputs averaged 17.3 million b/d for the week ended Nov. 20, which was 428,000 b/d more than the previous week’s average. Refineries operated at 97.5% of capacity. Gasoline output averaged 9.7 million b/d, and distillate production decreased to 5.2 million b/d. Crude oil imports increased 673,000 b/d to 6.2 million b/d. The 4-week average of 6.2 million b/d is 5.8% above the year-ago level. Gasoline imports averaged 314,000 b/d; distillate decreased and averaged 103,000 b/d. Over the past four weeks, total product supplied averaged 20.8 million b/d, up 2.2% year over year. The 4-week average for gasoline product supplied decreased 0.2% year over year to 8.8 million b/d, while the 4-week average for distillate product supplied increased 3.9% to 3.9 million b/d. The 4-week average for jet fuel product supplied increased 5.2% year over year.  

Read More »

Alby PtX advances proposed 66,000-tpy Swedish e-SAF plant

Alby PtX AB has signed license and engineering agreements with Sasol Ltd. and Topsoe AS for the core fuel-production process at its planned synthetic sustainable aviation fuel (e-SAF) plant in Alby, Sweden. The agreements cover an integrated gas-to-liquids (G2L) process that— combining Topsoe’s proprietary eREACT electrified reverse water-gas shift and hydroprocessing technologies with Sasol’s low-temperature Fischer-Tropsch (LTFT) technology—will ultimately produce about 66,000 tonnes/year (tpy) of e-SAF, Sasol, Topsoe, and PtX said in a series of separate releases between Nov. 12-24. The process is designed to convert renewable hydrogen and captured carbon dioxide (CO2) into synthesis gas, then synthetic hydrocarbons for upgrading into aviation fuel. Alby PtX said the configuration will recycle hydrocarbon streams such as naphtha into additional aviation fuel. Topsoe’s eREACT technology will also enable reduced use of renewable hydrogen and power during synthesis-gas production. In addition to technology licensing and technical expertise to be provided under the contracts, the engineering packages delivered by Sasol and Topsoe also will support process integration during front-end engineering design (FEED) and provide a technical basis for the project to advance toward a final investment decision (FID), Sasol said Nov. 24. Alby PtX revealed the technology selection of Sasol and Topsoe technologies on Nov. 12, with Topsoe’s separate same-day release confirming Alby PtX’s plan to take FID on the development in 2028 for a targeted start of operations in 2031. The project’s proposed unit will use renewable electricity to produce hydrogen from water in an electrolyzer. Hydrogen will then react with captured CO2 to form synthesis gas, which the FT process converts into liquid hydrocarbons. Hydroprocessing will upgrade those hydrocarbons into e-SAF. Alby PtX’s project description identifies biogenic and industrial sources as potential sources of captured CO2. The technology awards follow Alby PtX’s Nov. 19 agreement with Siemens Energy for the planned supply

Read More »

2026 Q3 earnings roundup: Utilities seek to reassure investors amid election fallout

Utilities that were counting on data center-fueled anger dying down and a return to business as usual after the midterm elections now face the likelihood of prolonged scrutiny of their AI-fueled growth plans. The election, which fell in the middle of third-quarter earnings season, saw historic gains for Democrats up and down the ballot, with many promising to rein in data centers. It also prompted a shift in tone among executives, who went from touting data center pipelines to emphasizing the diversity of sources driving load growth, their shared concern over energy affordability and their good relations with incoming officials. Get caught up on how utilities and manufacturers are adapting to a new political landscape and shifting market dynamics with Utility Dive’s roundup of third-quarter earnings coverage. 

Read More »

Masirah Oil reaches TD in Block 50 well

@import url(‘https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap’); .ebm-page__main h1, .ebm-page__main h2, .ebm-page__main h3, .ebm-page__main h4, .ebm-page__main h5, .ebm-page__main h6 { font-family: Inter; } body { line-height: 150%; letter-spacing: 0.025em; } button, .ebm-button-wrapper { font-family: Inter; } .label-style { text-transform: uppercase; color: var(–color-grey); font-weight: 600; font-size: 0.75rem; } .caption-style { font-size: 0.75rem; color: color-mix(in srgb, currentColor 60%, transparent); } Masirah Oil Ltd. (MOL) reached target depth in the first well in the current offshore Yumna field campaign in Block 50, offshore Oman. Drilling operations will now move forward to the second well in the campaign, MOL said. While first production will be delayed, MOL will continue to provide updates as the project progresses. MOL, an indirect 87.5% subsidiary of Jasmine Energy Ltd. (JEL), acts as operator for and holds 100% interest in Block 50.

Read More »

Petrobras targets refining, renewable fuels growth in new 2027-31 business plan

Petróleo Brasileiro SA (Petrobras) has outlined an ambitious downstream expansion strategy in its newly approved 2027-31 business plan, targeting higher refining capacity, increased low-sulfur diesel production, growth in renewable fuels, and new investments in petrochemicals, fertilizers, and gas infrastructure. The Brazilian state-controlled producer plans to invest $23 billion in its refining, transportation, marketing, petrochemicals, and fertilizers segment through 2031, with an additional $1 billion allocated to projects still under evaluation, the company said in separate releases Nov. 23. The investments are designed to expand production of higher-value, lower-carbon products, strengthen logistics infrastructure, and diversify revenue streams beyond crude oil production. A central objective of the operator’s 2027-31 plan is increasing its system-wide conventional processing capacity by 2031 to 2.173 million b/d from a current 1.813 million b/d capability. Rather than undertaking construction of a new refinery, Petrobras said it will achieve the additional 360,000 b/d in fresh capacity via upgrades to its existing refineries. Among the flagship projects are expansions at the Boaventura energy complex (BEC) in Itaborai, Rio de Janeiro, and the completion of a second 130,000-b/d Train 2 as part of the long-planned expansion and upgrade of the 130,000-b/d single-train Refinaria Abreu e Lima (RNEST) refinery in Ipojuca, Pernambuco, in northeast Brazil, both scheduled to start operations in 2029. Petrobras said the Boaventura project will enable increased yields of S-10 diesel and jet fuel while adding production of higher-value Group II base oils. At RNEST, startup of Train 2 will double existing capacity of the site as well as allow the refinery to maintain a high-diesel conversion rate, according to the operator. System-wide, Petrobras is also continuing to pursue expanded diesel output, targeting a 405,000-b/d increase in overall S-10 diesel production capacity by 2031. Of that total, 293,000 b/d will be added during the 2027-31 period via a

Read More »

Equinor signs 18-year natural gas supply contract with German VNG

Equinor ASA and VNG AG have signed a long-term agreement for the supply of natural gas to Germany. The 18-year contract is the longest gas sales agreement since the Troll agreements signed in 1986, the operator said in a release Nov. 24. Under the agreement, Equinor will deliver up to 1.4 billion cu m/year of natural gas to VNG. Deliveries will start on Jan. 1, 2027, and continue until yearend 2044, with gas delivered at Trading Hub Europe, the German gas market area. Equinor said pricing will reflect market terms, with other commercial details to remain confidential between the parties. The Leipzig-based gas trader VNG Handel & Vertrieb GmbH (VNG H&V), a 100% subsidiary of VNG AG, and the Norwegian energy company signed the deal in Oslo, Norway, at the Equinor Autumn Conference. Natural gas is expected to remain a key part of Europe’s energy mix as more renewable power and low carbon solutions are developed.

Read More »

5 Things You Didn’t Know About BAAJA and Data Centers

For an industry increasingly accustomed to measuring its growth prospects in gigawatts, the most consequential development in American data center infrastructure this November may have come not from a hyperscaler, a semiconductor manufacturer or an electric utility, but from the floor of the U.S. Senate. On Nov. 19, the Senate passed the Bipartisan American Affordability and Jobs Act of 2026, better known as BAAJA, by a vote of 62-33. The sweeping legislative package seeks to accelerate the development of American energy and transmission infrastructure through changes to federal permitting, environmental review, judicial proceedings and electricity regulation. The legislation now faces consideration in the House. For the data center industry, the appeal of permitting reform is readily apparent. As DCF has reported, transmission infrastructure is emerging as a defining constraint on AI data center development, with the timelines required to construct new electrical infrastructure increasingly at odds with the deployment schedules envisioned by AI infrastructure investors and developers. But a closer reading of the Senate-passed legislation reveals something more consequential than an attempt to accelerate the construction of power plants and transmission lines. BAAJA is also an attempt to establish the economic and regulatory terms under which America’s rapidly expanding computational infrastructure will interact with the nation’s electricity system and the communities that host it. Here are five provisions that warrant particularly close attention from data center developers, operators, investors and technology suppliers. 1. BAAJA is no longer just about hyperscale data centers One of the more significant changes between the legislation introduced on Sept. 30 and the version passed by the Senate concerns the size of the data centers subject to its ratepayer protection provisions. The original legislation established a 20-megawatt threshold for its retail ratepayer protections, as outlined in an October analysis by attorneys at Foley Hoag. That threshold

Read More »

The Real Economics of AI Infrastructure: Power, Cooling and the Price of Growth

A data center can have an excellent power usage effectiveness (PUE) rating and still be a poor infrastructure investment. It may be located on a grid that cannot deliver additional power, rely on increasingly contested water supplies, or require extensive reconstruction to accommodate the next generation of AI hardware. None of those shortcomings will necessarily register in conventional facility-efficiency metrics. That is the argument underlying the World Economic Forum’s September 21 report, Data Centre Sustainability and Resilience: A Decision Playbook for AI Infrastructure, developed in collaboration with Marsh. Rather than defining sustainability primarily through the performance of an individual facility, the report examines an AI campus in the context of the power generation, transmission, cooling, water, land, fiber, supply chains and communities on which it depends. The scale of the challenge was reinforced by the International Energy Agency’s November release of its World Energy Outlook 2026, which projects that global data center electricity consumption will approximately double to 1,000 terawatt-hours (TWh) by 2030 under its Stated Policies Scenario. Since the WEF report’s publication, announcements from hyperscalers, utilities and infrastructure suppliers have begun to put its recommendations to the test. Google has entered into a major nuclear uprate agreement and a separate set of power arrangements in Wyoming, while Amazon is supporting the evaluation of nearly a gigawatt of advanced nuclear generation in Indiana. NVIDIA is placing greater emphasis on computational output relative to power consumption and the ability to dynamically manage an AI factory’s electrical load. OpenAI has outlined a program intended to make future campuses responsive to grid constraints. Meanwhile, regulators, communities and utility customers are increasingly questioning who should bear the costs and risks of AI infrastructure expansion. A Trillion-Dollar Opportunity, With an Important Qualification The WEF estimates that more sustainable and resilient development practices could help unlock

Read More »

It’s the Roaring 2020’s for the HPC-AI Data Center Industry, But It Comes with Costs

It has been, and will very likely continue to be, the “Roaring 2020’s” for the HPC-AI data center industry. But similar to the generally healthy U.S. economy, affordability is a problem. Driven by demand for advanced computing technology, the HPC-AI data center infrastructure industry is generating tremendous growth, according to the latest market update figures released by industry analyst firm Hyperion Research. But with high demand come strains on supply chains that result in higher costs that restrain even higher growth. This is the picture presented this week by Hyperion at their annual breakfast at the SC26 Supercomputing Conference in Chicago. The customary large crowd turned out to hear Hyperion CEO Earl Joseph and colleagues discuss the state of the industry, some sectors of which are expanding at a clip Joseph said has never before been seen. “2025 was an extremely high growth year for the market…,” said Hyperion CEO Earl Joseph of on-premises servers for HPC, AI and data centers. “The first half of this year is growing at 20 percent… This is more than a doubling of historic growth. And then looking at the overall market in addition to servers, the storage, middleware, application services and spending for running HPC and AI for science workloads in the cloud…the market has just grown tremendously.” Among Hyperion’s key findings:         Overall HPC spending grew by just under 17 percent in 2025 reaching a total of more than $70 billion, including nearly 30 percent growth in cloud usage. Worldwide sales of on-prem for HPC and AI-for-science servers reached $29.4 billion, an increase of nearly 15 percent, with the EMEA region growing by roughly 10 percent. For the combination of HPC and AI-for-science on-prem servers plus cloud, the overall market is expected to double over the next five years,

Read More »

The Data Center Backlash Has a Playbook

The data center industry’s next development constraint may have less to do with megawatts than with the politics of where those megawatts are deployed. The warning became difficult to ignore on November 3, when American voters approved 33 local ballot measures restricting data center development or expressing opposition to it, according to Ballotpedia’s analysis of the 2026 midterm elections. The results included outright bans, partial prohibitions, temporary moratoriums, and new requirements for community oversight. Voters also rejected 13 measures that would have favored development or expressed support for it. For an industry accustomed to evaluating prospective sites through the availability of power, land, fiber, capital, and construction resources, the election results reinforced another increasingly consequential consideration: whether the communities hosting digital infrastructure are willing to accept its growing physical and economic footprint. As Data Center Frontier recently examined in its post-election assessment of the industry’s political future, the national push to accelerate AI infrastructure construction is colliding with a more complicated political reality at the state and local levels. Opposition crosses party lines, while questions surrounding utility rates, water, environmental impacts, and local economic benefits have moved from planning commission meetings into broader electoral debate. That changing environment was the subject of a conversation recorded at the DCF Trends Summit 2026 in Reston, Virginia, where DCF contributing editor Doug Black sat down with Adam Waitkunas, president of Milldam Public Relations, and Julia Chuang, founder of LocalQ Labs and an associate professor of sociology at the University of Maryland. Their discussion explored a fundamental shift in the development equation: community opposition is becoming more organized and politically consequential, but also more observable through data. The challenge for developers is to understand that risk early enough to influence site selection and project design, while recognizing that public trust cannot be manufactured through

Read More »

Oak Ridge’s AI Factory Moment: Lux, Nuclear Power, and the Next Data Center Frontier

For much of its history, Oak Ridge has been associated with the Manhattan Project and the subsequent development of America’s nuclear research and production capabilities. Established during World War II, the community became home to major facilities for uranium enrichment, nuclear materials processing, scientific research, and ultimately high-performance computing. Today, that legacy is being repurposed for a new generation of industrial development. The former K-25 uranium enrichment complex, once a critical part of the nation’s atomic weapons program, has been transformed into the East Tennessee Technology Park (ETTP), where extensive environmental cleanup and redevelopment have made former federal property available for commercial use. At an October 27 gathering in Oak Ridge, federal officials and nuclear industry representatives highlighted more than $15 billion in announced nuclear-related projects across the region, an investment wave subsequently documented in a November 17 DOE report on Oak Ridge’s emerging energy hub. The investment figure largely represents planned private-sector development rather than completed capital spending. Regional officials also anticipate demand for thousands of construction workers over the next five years, with additional permanent manufacturing and operating positions potentially following as projects advance. In March, DOE completed its largest Oak Ridge land transfer to date, conveying more than 700 acres for economic reuse. The transfer included a 624-acre parcel designated for Orano USA’s planned uranium enrichment complex and a 77-acre parcel associated with Oklo’s proposed nuclear fuel recycling development. Overall, more than 2,500 acres have been transferred from federal ownership for redevelopment, following decades of cleanup and the demolition of hundreds of former industrial structures. For nuclear developers, the appeal is straightforward: large industrial sites, existing utility and transportation infrastructure, proximity to federal laboratories, and an established community of nuclear engineers, technicians, researchers, and specialized manufacturers. For data center developers, the implications are somewhat different but no

Read More »

Dell and Microsoft drive private AI as enterprises seek greater data control

Dell Technologies and Microsoft are expanding their private cloud partnership with a new set of infrastructure offerings designed to let enterprises run AI models closer to their data, reduce reliance on public cloud services and maintain control over sensitive information. The announcement, made during Microsoft’s Ignite conference, extends Dell’s AI Factory with Nvidia initiative to Dell Private Cloud environments. It also reflects a growing industry push toward internally deployed AI inferencing, particularly among organizations dealing with sensitive corporate information, regulatory requirements and data residency restrictions, Dell stated. The expanded offering combines Dell Private Cloud, Microsoft Azure Local, Microsoft Foundry Local and Nvidia acceleration. The objective is to provide organizations with an integrated infrastructure for deploying heavy AI workloads inside their own data centers and firewalls, the companies said.

Read More »

Microsoft will invest $80B in AI data centers in fiscal 2025

And Microsoft isn’t the only one that is ramping up its investments into AI-enabled data centers. Rival cloud service providers are all investing in either upgrading or opening new data centers to capture a larger chunk of business from developers and users of large language models (LLMs).  In a report published in October 2024, Bloomberg Intelligence estimated that demand for generative AI would push Microsoft, AWS, Google, Oracle, Meta, and Apple would between them devote $200 billion to capex in 2025, up from $110 billion in 2023. Microsoft is one of the biggest spenders, followed closely by Google and AWS, Bloomberg Intelligence said. Its estimate of Microsoft’s capital spending on AI, at $62.4 billion for calendar 2025, is lower than Smith’s claim that the company will invest $80 billion in the fiscal year to June 30, 2025. Both figures, though, are way higher than Microsoft’s 2020 capital expenditure of “just” $17.6 billion. The majority of the increased spending is tied to cloud services and the expansion of AI infrastructure needed to provide compute capacity for OpenAI workloads. Separately, last October Amazon CEO Andy Jassy said his company planned total capex spend of $75 billion in 2024 and even more in 2025, with much of it going to AWS, its cloud computing division.

Read More »

John Deere unveils more autonomous farm machines to address skill labor shortage

Join our daily and weekly newsletters for the latest updates and exclusive content on industry-leading AI coverage. Learn More Self-driving tractors might be the path to self-driving cars. John Deere has revealed a new line of autonomous machines and tech across agriculture, construction and commercial landscaping. The Moline, Illinois-based John Deere has been in business for 187 years, yet it’s been a regular as a non-tech company showing off technology at the big tech trade show in Las Vegas and is back at CES 2025 with more autonomous tractors and other vehicles. This is not something we usually cover, but John Deere has a lot of data that is interesting in the big picture of tech. The message from the company is that there aren’t enough skilled farm laborers to do the work that its customers need. It’s been a challenge for most of the last two decades, said Jahmy Hindman, CTO at John Deere, in a briefing. Much of the tech will come this fall and after that. He noted that the average farmer in the U.S. is over 58 and works 12 to 18 hours a day to grow food for us. And he said the American Farm Bureau Federation estimates there are roughly 2.4 million farm jobs that need to be filled annually; and the agricultural work force continues to shrink. (This is my hint to the anti-immigration crowd). John Deere’s autonomous 9RX Tractor. Farmers can oversee it using an app. While each of these industries experiences their own set of challenges, a commonality across all is skilled labor availability. In construction, about 80% percent of contractors struggle to find skilled labor. And in commercial landscaping, 86% of landscaping business owners can’t find labor to fill open positions, he said. “They have to figure out how to do

Read More »

2025 playbook for enterprise AI success, from agents to evals

Join our daily and weekly newsletters for the latest updates and exclusive content on industry-leading AI coverage. Learn More 2025 is poised to be a pivotal year for enterprise AI. The past year has seen rapid innovation, and this year will see the same. This has made it more critical than ever to revisit your AI strategy to stay competitive and create value for your customers. From scaling AI agents to optimizing costs, here are the five critical areas enterprises should prioritize for their AI strategy this year. 1. Agents: the next generation of automation AI agents are no longer theoretical. In 2025, they’re indispensable tools for enterprises looking to streamline operations and enhance customer interactions. Unlike traditional software, agents powered by large language models (LLMs) can make nuanced decisions, navigate complex multi-step tasks, and integrate seamlessly with tools and APIs. At the start of 2024, agents were not ready for prime time, making frustrating mistakes like hallucinating URLs. They started getting better as frontier large language models themselves improved. “Let me put it this way,” said Sam Witteveen, cofounder of Red Dragon, a company that develops agents for companies, and that recently reviewed the 48 agents it built last year. “Interestingly, the ones that we built at the start of the year, a lot of those worked way better at the end of the year just because the models got better.” Witteveen shared this in the video podcast we filmed to discuss these five big trends in detail. Models are getting better and hallucinating less, and they’re also being trained to do agentic tasks. Another feature that the model providers are researching is a way to use the LLM as a judge, and as models get cheaper (something we’ll cover below), companies can use three or more models to

Read More »

OpenAI’s red teaming innovations define new essentials for security leaders in the AI era

Join our daily and weekly newsletters for the latest updates and exclusive content on industry-leading AI coverage. Learn More OpenAI has taken a more aggressive approach to red teaming than its AI competitors, demonstrating its security teams’ advanced capabilities in two areas: multi-step reinforcement and external red teaming. OpenAI recently released two papers that set a new competitive standard for improving the quality, reliability and safety of AI models in these two techniques and more. The first paper, “OpenAI’s Approach to External Red Teaming for AI Models and Systems,” reports that specialized teams outside the company have proven effective in uncovering vulnerabilities that might otherwise have made it into a released model because in-house testing techniques may have missed them. In the second paper, “Diverse and Effective Red Teaming with Auto-Generated Rewards and Multi-Step Reinforcement Learning,” OpenAI introduces an automated framework that relies on iterative reinforcement learning to generate a broad spectrum of novel, wide-ranging attacks. Going all-in on red teaming pays practical, competitive dividends It’s encouraging to see competitive intensity in red teaming growing among AI companies. When Anthropic released its AI red team guidelines in June of last year, it joined AI providers including Google, Microsoft, Nvidia, OpenAI, and even the U.S.’s National Institute of Standards and Technology (NIST), which all had released red teaming frameworks. Investing heavily in red teaming yields tangible benefits for security leaders in any organization. OpenAI’s paper on external red teaming provides a detailed analysis of how the company strives to create specialized external teams that include cybersecurity and subject matter experts. The goal is to see if knowledgeable external teams can defeat models’ security perimeters and find gaps in their security, biases and controls that prompt-based testing couldn’t find. What makes OpenAI’s recent papers noteworthy is how well they define using human-in-the-middle

Read More »