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

AI agents drive up telemetry costs, complicate network observability

“A production agent emits 4-5x more data as telemetry,” said Kamal Hathi, senior vice president and general manager of Splunk at Cisco, in an interview with Network World. Beyond traditional application traces, agents generate telemetry about workflows, tool calls, retrieved context, model interactions, and authentication. As agents interact with other

Read More »

Adura gets NSTA consent to develop Jackdaw North Sea gas field

Adura Energy has received North Sea Transition Authority (NSTA) consent to develop Jackdaw natural gas and condensate field, off the coast of northeast Scotland, following consideration of the company’s environmental statement and agreement to the grant of consent.  NSTA originally granted development consent for Jackdaw to Shell UK in June 2022. But this consent was deemed unlawful and overturned by the Scottish courts in January 2025, following findings that initial environmental approvals had failed to account for the impact of secondary emissions. Estimated reserves at Jackdaw are 72-200 MMboe. The new approval clears the way for Jackdaw to start supplying gas to British homes, power stations, and businesses within weeks, according to Adura, substantially all of the project’s physical infrastructure already having been completed. Alongside Jackdaw’s reapproval, the UK government announced it will launch a £2-billion ($2.7-billion) energy wealth fund fueled by North Sea oil and gas tax revenues to reinvest directly into renewable projects. Adura is a joint venture formed when Shell and Equinor ASA merged their UK offshore oil and gas businesses. The associated Rosebank oil field is following Jackdaw in the regulatory process. An NSTA decision on it is anticipated in the coming weeks. A spokesperson for INEOS Group Ltd. said that “Jackdaw approval is welcome, but the government must stop taxing the North Sea into decline. Approving Jackdaw is the right decision, but this does not stop the damage being done to the North Sea. And it appears Rosebank remains stuck in political limbo.”

Read More »

Energy Department Authorizes Exchange from Northeast Home Heating Oil Reserve

WASHINGTON— The U.S. Department of Energy today announced a Request for Proposal for an exchange of up to 315,000 barrels of ultra-low sulfur distillate (fuel oil) from the Northeast Home Heating Oil Reserve (NEHHOR). This solicitation is structured to mitigate supply chain challenges disrupting fuel oil supply. The announced exchange underscores the Trump Administration’s commitment to reliable energy access and lowering costs. Under the terms of the exchange, borrowing companies must return the same volume of fuel oil plus a premium, ensuring that NEHHOR is refilled ahead of the 2027–2028 heating season. “The Trump Administration is committed to doing everything in our power to lower energy costs for the American people,” said U.S. Secretary of Energy Chris Wright. “After receiving Senators Collins’ and Kings’ letter and extensive discussions with Senator Collins, I have directed the Department to exchange barrels from our Northeast Home Heating Oil Reserve to mitigate heightened home heating oil costs during the upcoming winter. Of course, this is a temporary measure to solve a temporary supply disruption. I encourage the governors of New York and New England to work with the Trump Administration to build the Constitution Pipeline and replace home heating oil with low-cost natural gas. Doing so would save their residents billions of dollars in home heating and electricity costs.” DOE will exchange up to 315,000 barrels of fuel oil from NEHHOR storage sites in South Portland, Maine; Boston, Massachusetts; and New Haven, Connecticut. Fuel transfers or deliveries are scheduled to be completed by November 13, 2026. The minimum offer quantity is 25,000 barrels, but not to exceed 30,000, and the volume available per site shall not exceed 150,000. Offerors may submit multiple offers. This approach ensures a competitive bidding process in which both fuel retailers and terminal holders can participate and that product can

Read More »

Shell plans well intervention, drilling campaign to extract more gas from Ormen Lange

A/S Norske Shell and its license partners are investing in a new drilling and well intervention campaign at Ormen Lange in the Norwegian Sea. An investment figure was not disclosed. The campaign, which follows the 2025 start of subsea compression to compensate for the natural pressure drop in the reservoir, includes two sidetracks from existing wells to access additional gas volumes, as well as an option for modifications to a third well. First production is expected in 2029, the operator said in an early October release. The campaign is expected to increase recovery by about 3.5 billion cu m of gas over the life of the field. “Ormen Lange has been producing for almost 20 years, but there is still room for further resources. This investment will enable us to produce gas volumes that today’s wells cannot reach efficiently, thereby creating additional value from the field while contributing to reliable gas supplies to Europe,” said Claire Richardson-Dissel, asset manager for Ormen Lange at Norske Shell. Ormen Lange  Norway’s second largest developed gas field, Ormen Lange was Norway’s first deepwater field development. The field is developed without a platform, with all production from subsea installations installed at depths of up to 1,100 m. Gas from sandstone at a depth of almost 3,000 m is piped up the Storeggakanten peninsula to the onshore plant at Nyhamna in Aukra municipality, where it is processed before export to the UK and the EU.  Shell is operator of Ormen Lange with 17.8% interest. License partners are Petoro AS (36.5%), Equinor Energy AS (25.4%), Orlen Upstream Norway AS (14%), and Vår Energi AS (6.3%).

Read More »

Saturn Oil & Gas adds light, oil-weighted assets of Corex Resources

Saturn Oil & Gas Inc., Calgary, has agreed to acquire privately held Corex Resources Ltd. for $302 million (Can.) through a plan of arrangement, expanding its light oil position from southeast Saskatchewan into southwest Manitoba. The acquisition adds about 7,000 b/d of 100% light oil-weighted production and increases Saturn’s forecast 2026 exit production rate to 54,000-56,000 boe/d from its previous outlook, the company said Oct. 19. Corex’s assets lie adjacent to Saturn’s existing southeast Saskatchewan operations. The company said the transaction adds 323 gross (279 net) identified drilling locations, including booked and unbooked development opportunities, as well as potential open-hole multilateral targets. The acquired asset base is characterized by an average working interest of about 96% and includes operated production infrastructure, pipelines, and other infrastructure. Saturn said it has identified about $6 million/year in operating and efficiency synergies. The addition of Corex’s production is not expected to affect Saturn’s full-year 2026 average production guidance of 43,000-44,000 boe/d, but, Saturn said, the deal, along with Saturn’s expanded 2026 capital program, positions the company to exit 2026 with production of 54,000-56,000 boe/d, establishing a base for 2027. The transaction is expected to close in December 2026, subject to customary conditions.

Read More »

Energy Department Announces New Investments to Strengthen America’s Power Grid and Lower Electricity Costs

WASHINGTON— The U.S. Department of Energy (DOE) today announced approximately $967 million in additional funding through its Grid Resilience State and Tribal Formula Grant program to modernize critical energy infrastructure, lower electricity costs and strengthen America’s power grid. The funding will support locally driven projects across states, territories, and tribes to upgrade critical infrastructure, prevent power disruptions, and meet growing electricity demand while helping lower costs for American families and businesses. The investment advances President Trump’s American energy dominance agenda. Projects funded through the program will help states, territories, and tribes invest in infrastructure improvements that protect against disruptive events, improve system performance, and ensure communities and businesses have dependable power when they need it most. “Lowering costs and unleashing prosperity are top priorities for President Trump,” said U.S. Secretary of Energy Chris Wright. “These commonsense investments provide resources directly to states, territories, and tribes to lower electricity costs and strengthen grid reliability for American businesses and families.” “A strong and dependable grid is the backbone of American economic prosperity,” said Office of Electricity Assistant Secretary Katie Jereza. “This funding will help Americans across the country, including our tribal partners, optimize their electricity systems and prepare for future growth while strengthening energy security and deploying technologies that can lower the long-term cost of delivering reliable power.” States, tribes, and U.S. territories can view their funding allocations and application instructions here.

Read More »

Eni, EGPC launch Meleiha Phase 2 gas project in Egypt

Agiba Petroleum Co.—a 50-50 joint venture of Eni SPA subsidiary IEOC Production BV and Egyptian General Petroleum Corp. (EGPC)—has initiated startup activities for its Meleiha Phase 2 project in Egypt’s Western Desert, advancing development of a gas hub in the Merged Meleiha concession. Part of the operator’s development of a new gas hub within the Merged Meleiha concession and designed to increase processing capacity for from the area’s natural gas fields to support growth of Egypt’s domestic output, the planned installation will be equipped to process up to 100 MMcfd of gas production, Eni said in a release Oct. 20. Planned infrastructure at the site includes development wells, gathering systems, trunklines, and a dedicated gas-export pipeline connecting new production to Egypt’s existing gas network. Eni did not reveal a schedule for completing full startup and commissioning activities for Meleiha Phase 2, but—once completed—the company said the project will help enable the rapid monetization of Egypt’s natural resources and enhanced operational efficiency. Western Desert development Meleiha Phase 2 builds on Agiba’s ongoing exploration and development in the Western Desert concession. In April 2022, Eni reported that three discoveries in the Meleiha concessions had been tied into production, adding an estimated 8,500 boe/d. The Nada E Deep 1X well encountered 60 m of net hydrocarbon pay in the Alam El Bueib and Khatatba formations. Meleiha SE Deep 1X found 30 m in the Matruh and Khatatba formations, while Emry Deep 21 encountered 35 m in Alam El Bueib. Including discoveries made in 2021, Eni said the results brought the exploration total to eight wells, with a 75% success rate. Agiba operates the Meleiha concession, in which it holds a 76% interest alongside partner Lukoil PJSC (24%), according to Eni’s website.

Read More »

AI’s Fragmented Regulatory Landscape Becomes a Data Center Design Challenge

Designing for Verifiable Operations For an operator serving tenants across jurisdictions, a claim about where a workload runs must be one that the responsible service provider can substantiate. That means identifying who can administer the workload, how data moves between regions, where backups are maintained, and which records document those arrangements. A tenant promising to run a workload within a particular jurisdiction needs assurance that its data, backups, and access arrangements satisfy the applicable requirements. Workload placement alone cannot establish where a backup resides or from where an administrator can access a system. Those questions must be addressed across compute, storage, network paths, security controls, and third-party access, with responsibilities established during procurement and verified before service begins. Not all of those controls necessarily reside with the data center operator. A colocation provider may be responsible for physical access, facility security, and designated infrastructure services, while a tenant or cloud provider controls the applications, storage configuration, backup locations, and logical access to workloads. The operating agreement must distinguish between what the facility provider can verify directly and what remains within the tenant’s systems. The EU AI Act makes that division of responsibility particularly important. Its requirements for covered high-risk AI systems include logging, documentation, human oversight, robustness, and cybersecurity, subject to the law’s applicable implementation dates. These obligations attach to the relevant providers and deployers of AI systems, rather than automatically to every company hosting them. A data center operator may nevertheless be required by contract to provide physical-access records, security evidence, or information about infrastructure location so that a tenant can substantiate its own compliance. A further distinction concerns data residency. The AI Act is not itself a general requirement to keep all AI workloads or associated data within the European Union. Geographic restrictions may instead arise from data-protection

Read More »

Microsoft exits UK AI data center project over electricity delays

“We remain committed to both the Loughton project and the UK, and we are exploring alternative power sources for the site, as well ​as other expansion sites in the UK,” Nscale added. “This decision relates to a single ​site,” a Microsoft spokesperson said of its termination of an agreement for the data ​center in Loughton, Essex, where Nscale had faced delays, with electricity grid ⁠officials telling the AI company they did not expect to supply power to the site ​until the 2030s. “Our relationship with Microsoft remains strong and long-term, and this unfortunate London-wide grid ​issue has no impact on our other contracts,” a spokesperson for Nscale told Reuters.

Read More »

AI networks drive SONiC boom

Aviz Networks: Aviz, which received early funding help from Cisco, offers a pre-tested, multi-ASIC, hardware agnostic, enterprise-ready SONiC distro with added features such as bug fixes, telemetry and support. Hedgehog Networks: Founded by former Cisco exec Marc Austin in 2022 to bring SONiC-based disaggregated networking to the enterprise, Hedgehog’s mission is to simplify the deployment of private cloud AI networks with automation and orchestration based on Kubernetes. Upscale AI: This startup has raised $500 million with the goal of building a new networking platform from ground up, starting with its own silicon. The company is targeting AI data centers as its sole market and is using SONiC as the NOS. Most recently, Upscale introduced Token Fabric architecture, which combines the company’s own SkyFabriX scale-up silicon, scale-out systems built on Nvidia Spectrum-X Ethernet, and a common software layer for operations. General availability is planned for early 2027. The announcement builds on two earlier milestones. Upscale, based in Santa Clara, Calif., emerged from stealth in September 2025 with a $100 million seed round. In June, it raised an additional $190 million  4. SONiC expands beyond the data center Community support is the lifeblood of any open-source project. Under the Linux Foundation, the SONiC community has grown to more than 4,300 contributors. Heavyweight members include Alibaba, Arista, Broadcom, Cisco, Dell, Google, Microsoft, Nokia, and Nvidia. The SONiC community is currently working to extend the technology from the data center to the network edge. The PoE Edge Networks with SONiC (PENS) workgroup, led by Aviz, Wistron, Cisco and Celestica, is working to adapt SONiC for edge LANs. Specifically, the group is integrating protocols consistent with Wi-Fi networks and IoT devices, such as Power Over Ethernet (PoE) and 802.1x.

Read More »

SONiC momentum continues at OCP Global Summit

This will complete SONiC integration across the Cisco multi-silicon Nexus switching portfolio, according to a blog post by Surbhi Paul, director, product management, for data center AI networking at Cisco.  “For organizations deploying Cisco 8000 Series across WAN backbones and core transport, extending Cisco-validated SONiC to the Nexus switches creates a unified, end-to-end, open network fabric,” Cisco stated. “Customers eliminate vendor silos, leveraging a single supply chain, shared FRR routing tools, and one Technical Assistance Center (TAC) contract from the WAN edge deep into the data center core.” “Built for AI infrastructure providers scaling 8000 to 32,000+ GPU clusters. High-density 400G/800G Cisco Nexus (N9100) switches (NVIDIA Spectrum-X) and Cisco Nexus (Cloud Scale) switches allow architects to tune RoCEv2 congestion algorithms (PFC/ECN) within SONiC, maximizing GPU training efficiency without risking multi-vendor support fragmentation,” Cisco stated.

Read More »

AI’s GPU Refresh Cycle Is Becoming a Stranded-Capital Problem

The AI infrastructure buildout is measured in gigawatts and successive generations of accelerators. But as operators bring new compute capacity online, a less visible question is gaining financial urgency: What happens to GPU systems when their first production assignment ends? For hardware that remains functional but no longer meets the performance or efficiency requirements of a leading-edge AI cluster, retirement need not mean obsolescence. Equipment may be redeployed, resold, harvested for components or processed to recover materials. The outcome depends on decisions made long before a system leaves its rack. That was the central argument advanced by Linda Li, chief strategy officer of Re-Teck and its parent company, Li Tong Group, in the latest onsite installment of the DCF Show podcast, hosted by Data Center Frontier Contributing Editor Doug Black at the DCF Trends Summit 2026 in Northern Virginia. For Li, the acceleration of GPU refresh cycles is making lifecycle management a question of capital preservation, facilities design and executive governance—not merely IT asset disposition. Plan for the Exit Before the Equipment Arrives Li draws on more than two decades of her company’s work in reverse supply chains for consumer electronics and telecommunications equipment. Both sectors have managed rapid generational shifts without assuming that every displaced device had exhausted its useful life. “We are dealing with a totally different organism,” she said, describing the combination of rapid accelerator iterations, rising rack power density and increasingly sophisticated thermal requirements. The response, in her view, has two levels. The first is physical infrastructure: facilities designed to accommodate successive generations of servers without extensive reconstruction. Scalable power distribution, adaptable raceways, modular rack systems and high-capacity air and liquid cooling can create room for hardware transitions that may arrive sooner than originally expected. The second is the network of partners and contracts around the

Read More »

Beyond Colossus: 5C Advances $575M Memphis AI Factory Expansion

Memphis has emerged as a major center of AI infrastructure development, driven largely by the extraordinary scale of xAI’s Colossus supercomputing operations. But the city’s growing AI computing market extends beyond Elon Musk’s flagship project. At the former headquarters and distribution complex of discount retailer Fred’s, 5C Data Centers is developing another substantial AI computing facility, combining industrial adaptive reuse with a phased expansion strategy and plans for behind-the-meter power generation. On October 6, 2026, a $575 million commercial alteration permit application was filed for the fourth phase of 5C’s MEM01 data center at 4300 Getwell Road. The application covers approximately 504,000 square feet of the property’s 1.1 million-square-foot building, representing the largest construction phase yet proposed at the site. MEM01 is already operating. According to September reporting from The Daily Memphian, 5C had established operations in approximately 200,000 square feet of the former Fred’s property, leaving substantial additional space available for conversion. The latest permit application marks a significant escalation in the scope of the development. The expansion also introduces a major new element to 5C’s power strategy. On October 11, 5C Group Chief Revenue Officer Brad Nimri told The Daily Memphian that the company plans to increase available power at MEM01 from approximately 20 MW to 84 MW over the next six months, using fuel cell technology to supply the additional capacity rather than relying on a corresponding increase in electricity from Memphis Light, Gas and Water (MLGW). Like Colossus, which began with the conversion of a former Electrolux manufacturing facility, 5C’s development reflects the growing role of industrial adaptive reuse in AI infrastructure. The projects differ considerably in scale and their approaches to on-site power generation, but both illustrate the challenge of transforming existing industrial properties into high-density computing environments with substantial electrical requirements. As Memphis considers

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 »

We can do impossible things

I’d wager everyone has a rehearsed response to what’s absolutely one of the world’s worst interview questions: “What’s your biggest weakness?” Whenever I’ve gotten it,

Read More »