LangChain RAG on SEC 10-K Filings with Claude

LangChain RAG on SEC 10-K Filings with Claude
NVIDIA's 10-K filed February 25, 2026, loaded through Edgrapi's /v1/sections endpoint, tested November 30, 2026.

NVIDIA's latest 10-K never mentions TSMC by name. Ask a LangChain RAG pipeline how dependent NVIDIA is on TSMC, and it comes back with the wrong paragraphs.

A LangChain RAG pipeline over a 10-K has five parts: load the sections you care about as clean text, split them into chunks sized for your embedding model, embed and store the chunks, retrieve the closest ones for each question, and hand those to Claude with instructions to answer only from them. This guide builds that pipeline on NVIDIA's fiscal 2026 10-K, with code I ran, and shows where it fails.

Key takeaway: LangChain RAG over a 10-K: load Risk Factors and MD&A as clean text, split them in the embedding model's tokens (all-MiniLM-L6-v2 truncates past 256), embed locally, retrieve the top five chunks, and have Claude answer only from them. Ask in the filing's words: NVIDIA's 10-K never names TSMC, so that question misses.
Edgrapi serves SEC filings and US federal data as clean JSON, plus an MCP server for AI agents. Free key, no card.Get a free API key

How do you build a LangChain RAG pipeline over a 10-K?

Load the 10-K sections you want (Risk Factors, MD&A) as LangChain Documents, split them with a text splitter sized in your embedding model's tokens, embed the chunks into a vector store, and wrap the store as a retriever. Then chain the retriever, a prompt that says to answer only from the excerpts, and ChatAnthropic for Claude. About 75 lines of Python does all of it.

The pieces, and what I picked for each:

StepLangChain pieceWhat I used
LoadDocumentEdgrapi's /v1/sections endpoint (Items 1A and 7 as clean text)
SplitRecursiveCharacterTextSplitterSized in tokens, 240 per chunk, 30 overlap
EmbedHuggingFaceEmbeddingsall-MiniLM-L6-v2, free, runs on a laptop CPU
StoreInMemoryVectorStoreFine for a few filings; swap for pgvector or Chroma later
AnswerChatAnthropicclaude-opus-5-5 through langchain-anthropic

The sections endpoint is my own API (Edgrapi), so weigh that, but the splitting, embedding and prompting below work the same with any source that hands you clean section text. The thing to avoid is feeding the raw filing HTML into the splitter.

I ran everything here on November 30, 2026, against NVIDIA's 10-K filed February 25, 2026, everything except the final call to Claude, which I'll get to, since that's the one step I couldn't test.

LangChain RAG pipeline over a 10-K
Load, split, embed, retrieve, answer.

Why load 10-K sections instead of the whole filing?

A full 10-K is mostly text you don't want to retrieve: the cover page, the table of contents, exhibit lists, signatures and hundreds of pages of financial tables. Loading only the narrative sections you'll ask about, such as Item 1A (Risk Factors) and Item 7 (MD&A), gives the retriever less noise to wade through and every chunk a clear label you can cite.

NVIDIA's Risk Factors came back as 114,973 characters and its MD&A as 34,215. That's about 149,000 characters of text a person would actually read.

Each section becomes one LangChain Document, with the ticker, item, title, filing date and filing URL as metadata. That metadata is what lets the final answer say "Item 1A, filed February 25, 2026" instead of "somewhere in the 10-K."

import os
import requests
from langchain_core.documents import Document

API = "https://api.edgrapi.com/v1/sections/"


def load_sections(ticker, items=("1A", "7"), form="10-K"):
    """One LangChain Document per 10-K section, with the filing details as metadata."""
    docs = []
    for item in items:
        r = requests.get(API + ticker, params={"form": form, "item": item},
                         headers={"X-API-Key": os.environ["EDGRAPI_KEY"]}, timeout=120)
        r.raise_for_status()
        s = r.json()
        if not s.get("found") or len(s["text"]) < 1000:   # missing, or a one-line pointer to an exhibit
            print("skipping %s item %s: not in this filing" % (ticker, item))
            continue
        docs.append(Document(page_content=s["text"], metadata={
            "ticker": s["ticker"], "item": s["item"], "title": s["title"],
            "filed": s["filed"], "url": s["filing_url"]}))
    return docs


docs = load_sections("NVDA")

Each section costs 5 credits, so NVIDIA's two sections cost 10. The free tier's 50 credits load five companies' worth.

The length check matters more than it looks. Some companies keep MD&A in an exhibit rather than in the 10-K itself, so Item 7 exists but is a one-line pointer. ExxonMobil's Item 7 comes back as 267 characters that send you elsewhere, so the loader skips it and keeps the 35,828 characters of Risk Factors, which is what I saw when I ran it on ExxonMobil. Embedding a sentence that says "see the Financial Section" would only give the retriever another wrong answer to pick.

If you want the endpoint details first, the 10-K sections API guide covers every item code.

10-K section sizes the loader keeps
Stubs that point to an exhibit get skipped.

How should you split a 10-K with LangChain's text splitter?

Size chunks in your embedding model's tokens, not characters. LangChain's RecursiveCharacterTextSplitter measures characters by default, but all-MiniLM-L6-v2 truncates anything past 256 word pieces, so a long chunk loses its end without any error. Building the splitter with from_huggingface_tokenizer and a 240-token chunk size keeps every chunk under the model's limit, which the default can't promise.

The splitter itself is a good choice for filings. Per LangChain's docs, it tries to split on paragraph breaks first, then line breaks, then spaces, then characters. 10-K text from the sections endpoint keeps its paragraph breaks, so most chunks end at a paragraph.

The problem is the unit, because the all-MiniLM-L6-v2 model card says plainly: "By default, input text longer than 256 word pieces is truncated."

I tested what that costs, and splitting NVIDIA's two sections into 1,500-character chunks gave 162 chunks, and 39 of them, 24%, ran past the limit. Those lost about 8% of their text on average, and the longest, at 381 tokens, lost a third.

So build the splitter from the model's own tokenizer instead:

from langchain_text_splitters import RecursiveCharacterTextSplitter
from transformers import AutoTokenizer

# Size chunks in the embedding model's own tokens: all-MiniLM-L6-v2 truncates anything past 256
# word pieces, so a chunk measured in characters can silently lose its end.
MODEL = "sentence-transformers/all-MiniLM-L6-v2"
tokenizer = AutoTokenizer.from_pretrained(MODEL)
splitter = RecursiveCharacterTextSplitter.from_huggingface_tokenizer(
    tokenizer, chunk_size=240, chunk_overlap=30)
chunks = splitter.split_documents(docs)

That produced 188 chunks, averaging 152 tokens, none over 240. The 30-token overlap carries a sentence or two across each boundary, so a risk factor split in half still has its subject in both pieces.

Character-sized vs token-sized chunks
Size chunks in the embedding model's tokens.

Which embeddings and vector store should you use?

For a first build, use a small local embedding model and LangChain's InMemoryVectorStore. all-MiniLM-L6-v2 is free, runs on a CPU, needs no API key, and turns each chunk into a 384-number vector. InMemoryVectorStore keeps those vectors in a Python list. Building the store for NVIDIA's 188 chunks took about 30 seconds on my laptop with the model already downloaded.

from langchain_core.vectorstores import InMemoryVectorStore
from langchain_huggingface import HuggingFaceEmbeddings

embeddings = HuggingFaceEmbeddings(model_name=MODEL)
store = InMemoryVectorStore.from_documents(chunks, embeddings)
retriever = store.as_retriever(search_kwargs={"k": 5})

The first run downloads the model, about 90 MB, from Hugging Face. After that it loads from disk.

A small model is fast and free, but it's weaker at matching a question to text that uses different words, which you'll see in a minute. A paid embedding API or a bigger open model does better on that, at a cost.

The in-memory store disappears when the script ends. For more than a handful of filings, persist the vectors in pgvector, Chroma or similar, so you embed each 10-K once instead of on every run.

How do you connect Claude with langchain-anthropic?

Install langchain-anthropic, set ANTHROPIC_API_KEY, and create a ChatAnthropic with a model ID and max_tokens. Then build the chain with LangChain's pipe syntax: the retriever fills the context, the prompt adds the question, Claude answers, and a parser returns plain text. The prompt does the important work by telling Claude to answer only from the excerpts and to quote them.

from langchain_anthropic import ChatAnthropic
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough


def format_docs(found):
    return "\n\n".join("[%s Item %s, filed %s]\n%s" % (
        d.metadata["ticker"], d.metadata["item"], d.metadata["filed"], d.page_content) for d in found)


prompt = ChatPromptTemplate.from_messages([
    ("system", "Answer only from the 10-K excerpts below. Quote the excerpt you rely on and name "
               "its item. If the excerpts don't answer the question, say so.\n\n{context}"),
    ("human", "{question}"),
])


def answer(question):
    llm = ChatAnthropic(model="claude-opus-5-5", max_tokens=2048)
    chain = ({"context": retriever | format_docs, "question": RunnablePassthrough()}
             | prompt | llm | StrOutputParser())
    return chain.invoke(question)


print(answer("What does NVIDIA say about US export controls on its China sales?"))

The model ID claude-opus-5-5 is the current Opus, per Anthropic's models overview, with a 1M-token context window.

Leave temperature out. Anthropic's Opus 5.5 migration guide says to omit temperature, top_p and top_k, and ChatAnthropic leaves temperature unset unless you pass one. I checked the request it builds: it carries only the model, max_tokens, the system prompt and the messages.

I didn't send the request to Claude, because I didn't have an Anthropic API key on the test machine. Everything up to that call ran, including the exact prompt Claude would receive, so the retrieval results below are real, but check Claude's first answer yourself before you trust the wiring.

Try it on real data. A company's SEC filings, each with its document URL:
curl -H "X-API-Key: edgr_your_key" "https://api.edgrapi.com/v1/filings/AAPL"
Get a free API key  50 free credits, no card.

What does the retriever actually find in a 10-K?

For questions that use the filing's own wording, the retriever does well. Asked about US export controls on China sales, all five chunks it returned came from Risk Factors passages on export controls. Asked what drove NVIDIA's fiscal 2026 revenue growth, it returned the MD&A paragraph that reports revenue of $215.9 billion, up 65%, alongside the segment table.

Here's what came back, trimmed to the first words of each chunk:

QuestionTop chunks retrieved
What does NVIDIA say about US export controls on its China sales?"Export controls have and are likely in the future to have a disproportionate impact on NVIDIA..." and four more export-control passages, all Item 1A
What drove NVIDIA's revenue growth in fiscal 2026?"Revenue for fiscal year 2026 was $215.9 billion, up 65% from a year ago. Data Center revenue... was up 68%", plus the segment table, Item 7
How dependent is NVIDIA on TSMC and other suppliers?An export-controls passage, the MD&A overview and a revenue-concentration paragraph. Not what I asked for.

For the export-controls question, the prompt Claude would have received was about 5,600 characters: the instruction plus five labeled excerpts. That's roughly 1,400 tokens, or about half a cent of input at Claude Opus 5.5's $4 per million input tokens. Output is $20 per million, and Opus 5.5 always thinks before it answers, with thinking billed as output, so a short answer should land around a cent or two. That's my estimate, not a measured bill.

Why did the TSMC question fail?

Because the 10-K never says TSMC. NVIDIA's Risk Factors talk about "third-party suppliers" and "foundries," and a small embedding model doesn't know those mean TSMC here. When I asked the same question in the filing's own words, "Which risks come from relying on third-party foundries and suppliers to manufacture our products?", every top result was the right Risk Factors passage.

I counted: "TSMC" appears 0 times in NVIDIA's Risk Factors. "Manufactur" appears 42 times, "third-party" 21 times and "foundries" 6 times.

So the pipeline wasn't broken, it was answering from the document, and the document uses different words than the person asking.

I tried maximal marginal relevance (MMR) retrieval too, which spreads results across different passages. It didn't help; the right passage just wasn't close to the question in the model's vector space.

Three fixes work, cheapest first:

And one rule that no fix changes: a RAG pipeline over a 10-K can only tell you what the 10-K says. If you need to know who NVIDIA's foundry is, the filing alone won't name it.

Filing vocabulary vs question vocabulary
The filing says foundries and third-party suppliers, never TSMC.

Can you compare two companies' 10-K filings?

Yes. Load both companies' sections into the same store, keep the ticker in each chunk's metadata, and filter on it at search time. InMemoryVectorStore accepts a filter function, so one store can answer "what does NVIDIA say" and "what does AMD say" separately. Then pass both sets of excerpts to Claude and ask it to compare them.

amd = splitter.split_documents(load_sections("AMD", items=("1A",)))
store.add_documents(amd)

q = "Which risks come from export controls on sales to China?"
for tk in ("NVDA", "AMD"):
    hits = store.similarity_search(q, k=3, filter=lambda d, tk=tk: d.metadata["ticker"] == tk)
    print(tk, [h.page_content[:80] for h in hits])

When I ran it, AMD's Risk Factors (131,897 characters, 190 chunks) went into the same store. The NVIDIA filter returned NVIDIA's export-control passages, and the AMD filter returned AMD's, starting with "Additional export restrictions imposed in the future may not only impact our ability to serve China..."

The tk=tk default in the lambda matters. Without it, Python binds the loop variable late and both filters search for AMD.

For comparing the same company across years, use form and filing date the same way. Each filing's filed date is already in the metadata.

Comparing two companies in one vector store
A ticker filter keeps each company's answers separate.

How do you check that retrieval is working?

Print the retrieved chunks before you send anything to Claude. Write a handful of questions whose answers you can find in the filing yourself, run each through the retriever, and look at the item labels and first lines that come back. If the right passage isn't in the top five, no prompt will fix the answer, so tune the chunking, the wording or the embedding model first.

for q in ["What does NVIDIA say about US export controls on its China sales?",
          "What drove NVIDIA's revenue growth in fiscal 2026?"]:
    print(q)
    for d in retriever.invoke(q):
        print("  Item", d.metadata["item"], "|", d.page_content[:100])

That loop is how I found the TSMC miss, in about a minute, without spending anything on Claude. It costs nothing to run, since the embeddings are local and the sections are already loaded.

I'd keep those questions in a file and rerun them whenever you change the chunk size, the overlap or the embedding model, because each of those changes what comes back.

What are the limits of RAG over SEC filings?

A RAG pipeline answers from the excerpts it retrieves, so it inherits every gap in the filing and every miss in retrieval. It can't name things the 10-K doesn't name, it can't do math across tables reliably from text chunks, and it reads one filing as of one date. Use it for "what does the company say about X," not for numbers you'd put in a model.

A few specifics from building this one:

Start with one company and two sections

Load one company's Risk Factors and MD&A, split them in your embedding model's tokens, and ask five questions you already know the answers to. Check that the retrieved chunks contain those answers before you look at Claude's response, because if the right passage isn't retrieved, Claude has nothing correct to quote. Once retrieval holds up, add a second company with a ticker filter, and only then move the vectors to a persistent store.

Loading two sections costs 10 credits, so the free tier covers five companies before you pay anything, and you can get a key here.

Frequently asked questions

How do I use LangChain for RAG on SEC filings?

Load the filing's narrative sections as LangChain Documents, split them with RecursiveCharacterTextSplitter sized in your embedding model's tokens, embed them into a vector store, and use it as a retriever. Chain the retriever, a prompt that says to answer only from the excerpts, and a chat model such as ChatAnthropic. Clean section text works far better than raw filing HTML.

What chunk size should I use for 10-K filings?

Match your embedding model's limit. all-MiniLM-L6-v2 truncates input past 256 word pieces, so I used 240-token chunks with a 30-token overlap, built with from_huggingface_tokenizer. Splitting by 1,500 characters instead pushed 24% of NVIDIA's chunks past the limit, and those lost about 8% of their text to truncation.

How do I use Claude with LangChain?

Install langchain-anthropic, set ANTHROPIC_API_KEY, and create ChatAnthropic(model="claude-opus-5-5", max_tokens=2048). It works anywhere LangChain expects a chat model, including the pipe syntax for retrieval chains. Leave temperature unset, since Anthropic's Opus 5.5 migration guide says to omit temperature, top_p and top_k.

Why does my RAG pipeline return irrelevant chunks?

Usually because the question uses different words than the document. NVIDIA's 10-K never names TSMC, so a TSMC question retrieved unrelated text, while the same question phrased as "third-party foundries" found the right passage. Rewrite questions into the document's vocabulary, try a stronger embedding model, and check retrieval before blaming the chat model.

Do I need an API key for embeddings?

No. HuggingFaceEmbeddings with all-MiniLM-L6-v2 runs locally on a CPU after a one-time download of about 90 MB, and it costs nothing per call. You need keys only for the data source and the chat model. Paid embedding APIs can retrieve better, so test both on your own questions.

Which 10-K sections are most useful for RAG?

Item 1A, Risk Factors, and Item 7, MD&A, carry most of what people ask about: risks, strategy and what drove results. Item 1, Business, adds products and competition. For NVIDIA's latest 10-K, Risk Factors ran to about 115,000 characters and MD&A to about 34,000.

Related guides: SEC EDGAR data and filings

Get a free API key