Sr. Content Developer at Microsoft, working remotely in PA, TechBash conference organizer, former Microsoft MVP, Husband, Dad and Geek.
165570 stories
·
33 followers

Reading Notes #723

1 Share

Time for another round of reading notes, with links I came across over the past few weeks. This edition covers a bit of everything: recovering from an accidental push to main, Azure Container Apps sandboxes in VS Code, a game developer's honest experiment with AI, and a fun Raspberry Pi retro gaming project.


There's also plenty on the AI front, so grab a coffee and enjoy the reads.

Cloud

AI

DevOps

Miscellaneous

~frank
Read the whole story
alvinashcraft
1 minute ago
reply
Pennsylvania, USA
Share this story
Delete

Finding slow requests with Aspire and an AI agent

1 Share
The previous posts in this series answered questions about one process at one moment: why it crashed, what it waits for, what holds its memory. "Which requests are slow?" is a different kind of question. The answer is spread over time and often over several processes, and no dump contains it. Distributed traces do. If your application runs under Aspire, every service already sends its traces, logs, and…
Read the whole story
alvinashcraft
2 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

What Is Productivity In A Learning Process?

1 Share

Just a quick post to pose a question that I increasingly believe highlights just how much most of us in software development have been wrong-headed about this thing we – very loosely – call “productivity”.

I think in terms of a hierarchy – a pyramid, if you like – of increasingly mature productivity measures:

At the base of the pyramid are measurements of stuff we do – a commit is an activity, as is a merge, or a pull request, or a code review, or a test run, or a release. Note that these are all nouns created from verbs – “commit”, “merge”, “pull”, “review”, “test”, “release”.

Folks boasting about doing more pull requests or more releases or – LOL – using more tokens (?) are boasting about being busier, not necessarily being more productive. It’s like a football team measuring their performance by how many times they kicked the ball.

A tale told by an idiot, full of sound and fury, signifying nothing.

One level up the pyramid, teams focus on what gets created by all this activity – lines of code, modules, features, “epics” and so on.

This, quite honestly, isn’t much of an improvement on treating activity as productivity. It’s very much “never mind the quality, feel the width”. A team shipping 10 features a week for an app that gains no users is more productive than a team shipping 1 feature that gains 10,000 users in the same week?

If output tells us anything, it’s a measure of how fast we accumulate total cost of ownership. Code is a liability. Every additional feature raises support costs and adds to the risk of failures and widens the surface area for cyber attacks.

Teams with a more mature outlook on productivity focus on outcomes – especially on user and business outcomes. What did we we gain from that release?

And this is where the whole process takes on a very different character, because the chances of us hitting the bullseye in a first pass are very small indeed. What we ship is at best an educated guess as to what will have the impact we desire.

We start with a hypothesis – a guess, basically – that a change to the software design will, say, reduce abandoned shopping carts and increase sales. But we can’t know that it will, even with a lot of analysis up-front. The only way to find out for sure is to put a working version of the change in front of real shoppers and see what happens.

Another word for this process is learning. We don’t “deliver” value in the form of working software, we discover it in the feedback we get from people using it – in particular by eliminating choices that didn’t work.

Information Theory characterises learning as the reduction of uncertainty through the acquisition of information. And this can give us a formalisation of productivity in those terms. In a learning process, productivity is the useful (actionable) information gained with each iteration of the software.

IG = Hbefore – Hafter

Where H is uncertainty about a choice we make in the design of the software.

Seen in these terms, productivity becomes untethered from both activity and output.

We do not necessarily reduce uncertainty faster by delivering software faster. Indeed, that can work against us.

To illustrate, let’s pit 6 imaginary teams against each other with the goal of guessing a random 6-digit number.

Team A guesses the number 1 digit at a time. Team B, 2 digits at a time (twice the output/activity), Team C, 3 digits at a time, and so on.

With their first guess, what is the information gained?

TeamDigits guessedPossibilities eliminatedPossibilities remainingReduction in uncertainty (bits)
A1100,000900,0000.152003
B210,000990,0000.014500
C31,000999,0000.001443
D4100999,9000.000144
E510999,9900.0000144
F61999,9990.00000144

Team A, working 6 times slower than team F, learns 100,000 times faster with their first wrong guess. They eliminate 100,000 times the wrong solutions.

If we call the number of digits in each guess “batch size”, we can see what effect it has on the signal-to-noise ratio in the feedback and therefore on the information gained in each cycle.

TeamDigits per guessSignal (eliminated)Noise (remaining)Signal-to-noise ratio
A1100,000900,0001:9
B210,000990,0001:99
C31,000999,0001:999
D4100999,9001:9,999
E510999,9901:99,999
F61999,9991:999,999

The emphasis in improving productivity in recent decades has been on accelerating feedback cycles, and fair enough – that makes a difference. But nowhere near as much difference as batch size.

Let’s speed up Team F’s delivery cycle 10x. For each guess Team A gets, Team F gets 10.

Team A still dramatically outlearns Team F. Even if we made Team F 100x faster, Team A would still very likely guess all 6 digits first.

This strongly indicates that the variable that has the most leverage in a learning process isn’t cycle time, it’s batch size. A team with slower delivery cycles, but smaller releases, will tend to converge on better solutions – by eliminating bad solutions – faster than a team releasing more changes at a time, even with much faster release cycles.

In this sense, productivity’s far less about how much and how often we deliver, and far more about how much we learn from each release.

What might it look like when we optimise for that? Counterintuitively, many teams could improve the rate at which they learn by slowing down – by doing less.

This has particular implications for teams attempting to speed up activity and output using coding agents. Far from accelerating learning, the famously larger change batches generated by agents are likely to have the opposite effect. And this is what I’ve been seeing – teams specifying, coding, and releasing more changes at a time.



Read the whole story
alvinashcraft
2 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

8 ways to reduce the cost of evals

1 Share

I was at an event last week, and spent a lot of time discussing the same objection to evals from different AI engineers. They all said evals cost too much to run, especially in these times where engineering management are becoming very cost conscious.

Some had stopped running evals against development builds, others were holding back on scoring production traffic. We all agreed that evals are important to not ship on vibes, but to ship tested, measurable changes, so I wanted to put together a guide with some ways to reduce your eval costs.

Most of what an eval costs comes from defaults: the largest judge, the whole trace as input, reasoning switched on, every trace scored. These defaults often have cheaper alternatives that hold their accuracy. Eval cost is mostly a design choice, not a fixed tax.

In this post I cover 8 ways you can reduce your eval costs. Every eval and agent is different, so review these suggestions, and see which ones will work for your use cases.

1. Use code where code fits

Defaulting to an LLM judge can be a quick way to rack up unnecessary costs. Some evals simply don’t need a model, and every one of those that goes to a judge is paying for a judgement no one needs.

Code costs nothing to run, so the question is which evals can it handle. A good litmus test is whether two people looking at the same span with the same rubric could ever disagree on the answer. If they couldn’t, use a code evaluator. Schema checks, format checks and comparisons against a known answer fall on the code side. Questions about meaning, such as whether a reply is a refusal or is concise, stay with an LLM judge. Arize AX ships pre-built code evals for the common cases, including JSON Parsable, Matches Regex and Exact Match, and you can write your own in Python.

Code also doesn’t have to replace the judge. The Arize AX docs recommend stacking the two: a code check validates the shape of the output or settles the clear-cut cases, and an LLM judge scores only what’s left. Two things to plan for: how you write the check matters as much as whether you use code, and code is only as good as the reference answers it compares against, so audit those first.

From my testing. I tried code two ways: on its own, and as a first check in front of an LLM judge.

Cost per 1,000 evals: Math-Verify is free at 99.8% against a $3.46 judge, and a schema check in front of the judge cuts tool-call cost by 38%

Code on its own. I graded 1,500 answers to MATH-500 problems against the known correct answer. Math-Verify, a library that checks whether two answers are mathematically equal, was 99.8% accurate and cost nothing. Sonnet 5.5 as the judge was 99.9% accurate and cost $3.46 per 1,000.

Code plus a judge. I checked 890 tool calls from the Berkeley Function Calling Leaderboard (BFCL), half correct and half with one thing broken. A schema check ran first and failed every call with a structural error, such as a missing argument or a wrong type. That settled 38% of calls for free. It can’t tell that the user asked for Paris and the call says Lyon, so the calls that passed it went to a Sonnet 5.5 judge. Judge cost fell from $2.17 to $1.34 per 1,000, and accuracy stayed about the same, going from 96.4% to 96.5%.

How much you save depends on how much code can settle. On PII leaks, simple pattern rules settled only 18% of documents, because spotting a name or an address is mostly a judgement call. Check your scenarios and see where code fits in.

2. Reduce your eval runs by sampling production and keeping datasets small

Scoring every production trace feels thorough, but past a certain point each extra trace adds cost without adding information. The same goes for development datasets that grow without limit: a large, stale dataset costs more per experiment run and tells you less about today’s traffic.

You don’t need every trace to know your pass rate, only enough of them. Arize AX sets this with a sampling rate on each online eval task. There is an exception: for guardrail-style evals that hunt rare failures, sampling defeats the purpose. You can combine sampling with code, with a code eval on every span for the objective checks, and an LLM judge on a smaller sample of the same traffic.

In development, a few hundred examples that reflect real traffic give more signal per dollar. The Arize AX Dataset Coverage agent compares recent production spans with a dataset and adds real spans that fill gaps, up to a size cap you set. That cap is what keeps each experiment run bounded, which matters most when experiments run as CI/CD regression gates on every pull request.

From my testing. In the RAGTruth test set, 35% of responses contain a hallucination.

Daily cost of scoring 10,000 traces with Opus 5 against a random sample of 500 with Opus 5 or Haiku 5.5

Treat a measure like this as the true rate in your production traffic, and score a random sample of traces:

Traces scored Measured rate, 95% of the time Cost with Opus 5 Cost with Haiku 5.5
100 35% ± 9 points $1.45 $0.02
500 35% ± 4 points $7.27 $0.09
1,000 35% ± 3 points $14.53 $0.17
10,000 35% ± 1 point $145.30 $1.70

Costs use my measured cost per 1,000 hallucination evals: $14.53 for Claude Opus 5 at high effort and $0.17 for Claude Haiku 5.5.

The range narrows with the square root of the sample size, so every extra trace buys less. Going from 1,000 traces to 10,000 costs 10x as much and only narrows the range from ±3 points to ±1.

For a service producing 10,000 traces a day, scoring all of them with Opus costs about $145 a day. Scoring a random 500 costs about $7.27, a 20th of that, and still gives the rate to within ±4 points. Sampling and a cheaper judge multiply: 500 traces scored by Haiku cost 9 cents.

Comparing two versions needs more traces than tracking one. To catch a rise from 35% to 40% hallucinations between versions, with 95% confidence and an 80% chance of spotting it, you need about 1,500 traces per version. A 10-point rise needs about 380 per version, and a 2-point rise about 9,000. Size the sample to the smallest change you need to catch, not to your total traffic.

3. Evaluate at the right session, trace, or span level

An eval scoped wider than its question pays for context it never uses. Asking whether an agent picked the right tool doesn’t need the whole trace, but if the eval runs at trace level, the judge reads it anyway.

The fix is to pick the narrowest evaluation level that can answer the question. A span evaluator typically sees a few hundred tokens of context, while a session evaluator can see tens of thousands.

“Did the agent pick the right tool?” is a span question. “Did the agent loop?” needs the trace. “Did the user’s problem get solved?” needs the session. In Arize AX, scope is a setting on each evaluator, span, trace or session, used by online evals on traces. Trace and session evals are there for the failures that only show up across a whole request or conversation. Scope decides which spans the judge sees, and the next section, trimming, decides which fields it gets.

From my testing. In 199 expert-labelled web-agent traces from AgentRewardBench, a typical trace had 18 LLM spans.

A span question answered from one span reads 7,700 tokens instead of 120,000 for the whole trace

One span’s input was about 7,700 tokens, and all 18 were about 120,000. A span question answered from one span costs about 1/16th of the same question answered from the whole trace. A trace question answered from a code-trimmed trace needed about 5,600 tokens, 21x fewer than every raw span.

4. Send the judge only what it needs

A common setup maps a whole trace into the judge’s prompt. In agent traces that input can be mostly noise: system prompts, tool schemas, repeated chat history and full page dumps at every step. You pay for every token of it, and the noise can make the judge worse.

The fix is to extract the fields the question needs before the judge sees anything. In Arize AX, two task settings do much of this without custom code. Variable mapping fills each template placeholder from one span attribute, so the judge gets the fields you name rather than the whole span. For trace and session evals, the evaluator data filter chooses which spans reach the prompt. Without it, every span in every qualifying session goes to the judge, including internal LLM calls, tool spans and retrieval spans, and you pay for all of them. For extraction that needs real logic, such as keeping only the final page, run your trimming code in a remote evaluator before it calls the judge. If you can’t write extraction code, a cheap model can summarise the input first.

There’s one rule to hold to: trim boilerplate, history and page dumps, never the evidence. A judge that can’t see the evidence can’t verify the claims it’s checking.

From my testing. On AgentRewardBench, a whole trace averaged about 155,000 tokens.

Code-trimmed agent traces cost 20x to 24x less to judge than full traces, for four judges, with the same or better accuracy

Code that kept only the user’s goal, the agent’s reasoning, action and any error at each step, and the final page brought that to about 6,500.

Judge (agent success task) Full trace Code-trimmed trace
Sonnet 5.5 56.0%, $154.84 70.0%, $6.58
Haiku 5.5 58.5%, $15.52 65.5%, $0.71
Kimi K3, reasoning off 77.0%, $20.80 78.5%, $1.04
DeepSeek V4.1 Flash, reasoning off 69.5%, $2.44 75.4%, $0.11

Accuracy is balanced accuracy against the expert labels.

Trimming cut cost by 20x to 24x, and every judge was as accurate or more accurate at its default cutoff. The page dumps made judges reluctant to call a run a success, matching the AgentRewardBench authors’ finding that more page data lowered judge performance.

5. Use a decision model

A generative judge writes its verdict out as text, and you pay for every output token, at the highest rate on the bill with output tokens typically 5x the cost of input tokens. For an eval with a fixed set of answers, such as pass or fail, that text adds cost and latency without adding anything.

A decision model returns a probability for each of a fixed set of options instead of generating text, so it produces no output tokens, with no output charge. Arize AX runs decision models directly as a Decision Judge. The JEV-as-a-Judge paper found decision models strong where the verdict can be read from the text, and weaker on maths, code and multi-step logic. They suit classification-style evals such as hallucination, relevance or tone.

From my testing. On the hallucination task, 1,338 labelled responses from the test half of RAGTruth (the split used in Arize’s Jev-as-a-Judge benchmark), Jev scored 85.4% at $0.046 per 1,000.

Jev decision model at $0.046 per 1,000 hallucination evals and 85.4% accuracy, against Opus 5 at $14.53 and 84.9%

My large-judge baseline, Claude Opus 5 at high effort, scored 84.9% at $14.53. Jev’s median latency was 82 milliseconds, against 3.2 seconds for Opus. Orders of magnitude cheaper and faster, with similar accuracy.

6. Use a cheaper judge

Where an eval does need a generative judge, many teams default to the largest model they have, on the assumption that a larger model is a better judge. For many evals a much smaller model is close enough, at a fraction of the price.

The most direct saving is to keep the eval prompt and change the model. Switching doesn’t always mean rewriting the evaluator, switch your model and test, then tune the eval prompt if needed.

Some of the gap between a small and a large judge is calibration rather than capability. A small judge can rank cases well but set its pass/fail line in the wrong place, so tune the cutoff against human labels before you write it off. And test each eval separately: a cheap judge that works on one eval tells you nothing about the next.

From my testing. On the hallucination task:

Cost per 1,000 hallucination evals and accuracy for Opus 5 and four cheaper judges

Judge (hallucination task) Accuracy Cost per 1,000 evals
Claude Opus 5, high effort 84.9% $14.53
Kimi K3, reasoning off 85.4% $0.44
Claude Haiku 5.5 82.3% $0.17
DeepSeek V4.1 Flash, reasoning off 83.1% $0.024
GPT-6 Luna 74.6% $0.14

DeepSeek V4.1 Flash, an open-weight model, came within 2 points of Opus for about 1/600th of the cost. It held up elsewhere too: 95.6% on tool calls for $0.018 per 1,000, against Claude Sonnet 5.5’s 96.4% for $2.17.

Haiku 5.5 ranked cases almost as well as Opus but flagged too many responses at its default cutoff. Tuning that cutoff against human labels, with two-fold cross-validation, lifted Haiku to 86.3%, level with Opus at about 1% of the cost.

GPT-6 Luna shows why each eval needs its own test: it was among the best on tool calls (96.5%) and maths (99.9%), and 10 points behind Opus on hallucination.

7. Change how you call the judge

Even with the right judge, the way you call it can multiply the bill. Reasoning tokens are billed as output, and output costs far more than input. A judge that thinks at length before a one-word verdict pays for an essay nobody reads. Standard real-time API pricing and repeated, uncached context add more.

Run judges with reasoning off by default, and turn it on only where a test shows it pays. If you need to keep a large judge, lower its effort setting, use the Anthropic Message Batches API or your provider’s equivalent (half the standard rate), and turn on prompt caching for the shared part of the prompt. If you run several evals over the same span, put the shared context first so it can be cached. Batch billing doesn’t suit online evals, but it fits development builds, nightly suites and CI experiments: the runs the engineers at the event had stopped doing.

In Arize AX, most of these levers sit on the evaluator itself. You choose the judge model and AI provider when you create the evaluator, and an LLM override on the task lets you swap in a cheaper model for one task without touching the template. The evaluator also stores invocation parameters and whether to include explanations. Invocation parameters are where you set reasoning effort and output limits, for providers that expose them. Explanations are output tokens, so they’re worth having while you check a new judge and worth turning off once you trust it. Batch pricing and prompt caching are different: AX calls the provider for you, so those depend on the provider. If you need batch pricing for a large offline suite, run the judge in your own code as an experiment from the SDK and log the results to AX.

Whichever settings you change, check the effect: Arize AX shows evaluation cost inline for Playground runs, and through cost tracking for production tasks.

From my testing. DeepSeek at its lowest reasoning setting still produced about 2,000 reasoning tokens per hallucination eval, which made it dearer than Haiku.

Lower effort, batch and caching cut Opus 5 cost 5x; turning reasoning off cuts Kimi K3 11x and DeepSeek 7x

Reasoning didn’t reliably buy accuracy:

  • Hallucination: DeepSeek fell from 83.1% to 75.5% with reasoning on, at 7x the cost. Kimi K3 went from $0.44 to $4.82 per 1,000 and lost 1.4 points.
  • Tool calls: DeepSeek rose about a point, from 95.6% to 96.7%, and cost 3x more.
  • PII: DeepSeek rose from 95.0% to 98.6%, catching 99.6% of leaks for $0.05 per 1,000. That matches Sonnet 5.5’s 98.8% at about 1/40th of the price.

I also reran Opus 5 on the hallucination task at low effort, through the Batch API, with caching on. Cost fell from $14.53 to $3.09 per 1,000, and accuracy went from 84.9% to 86.0%. Low effort cut Opus’s average output from 213 tokens to 46, because a verdict doesn’t need an essay.

8. Escalate only when the cheap judge is unsure

Running every case through an expensive judge pays the top price for cases a cheap judge would have got right. Most cases are clear-cut. The expensive judge earns its cost only on the hard ones.

A cascade runs a cheap judge first and sends a case to an expensive judge only when the cheap judge is unsure. Code checks from section 1 can sit in front of both. This matches published work: Trust or Escalate (ICLR 2025) uses cheaper models as the first judges and escalates to stronger ones only when needed, and Arize’s guide to LLM evaluation costs recommends keeping expensive judges and human review for uncertain or high-stakes cases.

The uncertainty band has to be set on data you hold out from your test set. To run escalation logic like this in Arize AX, host it as a remote evaluator: you keep the scoring logic, and Arize handles orchestration, retries and writing results back to traces.

From my testing. On the hallucination task I ran Jev first and escalated to Opus 5 when Jev’s probability fell inside a band chosen on the tuning half.

Jev first, escalating 8% of cases, costs 10x less than Opus 5 alone with Opus and 69x less with Sonnet 5.5

That sent 8% of cases to Opus. The cascade scored 86.8% at $1.40 per 1,000: more accurate than Opus alone, at about 1/10th of the cost. Escalating to Sonnet 5.5 instead scored 86.6% at $0.21.

Let Arize AX find the spend

Two Arize AX agents target eval cost:

  • The Eval Health agent reviews a project’s evaluators every six hours. Its “Optimize eval” recommendation moves an evaluator to a cheaper judge or replaces it with a code eval: techniques 6 and 1 above. It never creates or edits an eval on its own, so each change is yours to review and apply.
  • The Cost Agent looks for expensive models doing low-complexity work and recommends cheaper routing, with savings calculated from your span data rather than estimated. Its docs focus on application spend, but traced judge calls appear in the same data. Because the agent works from span data, set up cost tracking early: eval costs are only recorded from the point tracking is switched on, not backfilled.

Test on your own data before you switch

The spread in results is the reason you need to test on your own data. For example, GPT-6 Luna scored 74.6% on hallucination and 99.9% on maths. Reasoning helped on PII and hurt on hallucination. Trimming improved one eval and damaged another. A result on my data is a hypothesis about yours.

The check itself is cheap. Take a few hundred examples from one eval with known answers. Run your current judge and two or three candidates: a smaller model with reasoning off, the same judge on a trimmed input, and a code check if the eval has a structural part. Compare accuracy and cost per 1,000. In my experiments that cost between a few cents and a few dollars per eval, and an Arize AX experiment keeps the results side by side.

For development and CI, the best combination in my tests was a cheap judge with reasoning off, batch billing and a small dataset that tracks production. For production, it was code checks in front of a cheap judge, a cascade for uncertain cases, trimmed inputs at the narrowest level that answers the question, and a sample of traffic rather than all of it.

The cost of an eval comes from the choices made when it was set up. Each of those choices can be measured and changed, and once the cost is known, there’s no longer a reason not to run the eval.

Read the whole story
alvinashcraft
2 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Introducing the Syncfusion .NET Document Chunking Library for AI Applications

1 Share

Introducing the Syncfusion .NET Document Chunking Library for AI Applications

TL;DR: Learn to retrieve relevant information from large documents without processing entire files in AI applications. Explore how the new Syncfusion® .NET Document Chunking Library organizes Excel, Word, PDF, PowerPoint, and Markdown documents into meaningful, structure-aware chunks for embedding generation, semantic search, vector indexing, and Retrieval-Augmented Generation (RAG) workflows. Discover how to use it in an ASP.NET Core application to prepare content for semantic search and RAG solutions.

Building AI-powered applications often involves processing thousands of Word documents, PDFs, spreadsheets, and presentations. However, extracting text is only the first step. Preserving the context within headings, tables, worksheets, and slides is equally important for effective information retrieval.

The new Syncfusion® .NET Document Chunking Library, introduced in Essential Studio® 2026 Volume 3, addresses this challenge by dividing supported documents into meaningful chunks while retaining their structure, metadata, and citation details. The library is available across multiple platforms, including ASP.NET MVC, Blazor, Windows Forms, WPF, WinUI, and .NET MAUI.

In this blog, we’ll explore its key features and see how to use the .NET library in an ASP.NET Core application to upload documents, generate structured chunks, and retrieve their content and source information.

Meet the Syncfusion .NET Document Chunking Library

Traditional text splitters divide content primarily by character or token count. This approach can separate headings from their explanations or split tables into unrelated fragments.

The new Syncfusion .NET Document Chunking Library uses document structure to create meaningful chunks. It provides a unified processing workflow for:

  • Word documents
  • PDF files
  • Excel workbooks
  • PowerPoint presentations
  • Markdown files

The library also supports configurable chunk sizes, token overlap, metadata extraction, and citation generation.

These capabilities help developers prepare structured content for applications such as:

  • Retrieval-Augmented Generation (RAG)
  • Semantic search
  • Enterprise search
  • Knowledge assistants
  • Document intelligence platforms

How document chunking works

The library follows a straightforward processing workflow:

  1. Load a supported document from a file or stream.
  2. Configure the chunking options, including token limits, overlap, metadata, and citations.
  3. Process the document using format-specific rules.
  4. Generate chunks based on meaningful document boundaries.
  5. Review the extracted content, metadata, and citation details.
  6. Pass the generated chunks to embedding models or search services for indexing and retrieval.
Document Chunking Library workflow
Document Chunking workflow

For example, consider a quarterly report containing a heading, a paragraph explaining revenue growth, and a table showing revenue by region.

A basic text splitter may separate these elements based on its configured size limit. A structure-aware approach can use the selected chunking mode to preserve relevant content boundaries and source information.

This helps retrieval systems work with more meaningful content instead of disconnected text fragments.

Get started with the .NET Document Chunking Library in ASP.NET Core

Let’s integrate the library into an ASP.NET Core application and process supported documents.

Prerequisites

Before you begin, ensure your development environment includes:

  • Visual Studio 2022 (17.0 or later)
  • .NET 10 SDK or later
  • A supported Word, PDF, Excel, PowerPoint, or Markdown document

Install the required NuGet package

Create a new ASP.NET Core Web App (Model-View-Controller) project and select .NET 10 or a later target framework.

Install the following NuGet package:

dotnet add package Syncfusion.DocumentChunking.Net.Core

Add the required namespace to your controller:

using Syncfusion.DocumentChunking;

Create a document upload page

Add the following code to Views/Home/Index.cshtml to create a form that accepts supported document formats:

@{
    ViewData["Title"] = "Document Chunking";
}

<h1>Document Chunking</h1>

<form asp-controller="Home"
      asp-action="ChunkDocument"
      method="post"
      enctype="multipart/form-data">

    <div>
        <label for="document">Select a document</label>

        <input id="document"
               name="document"
               type="file"
               accept=".xlsx,.xls,.xlsm,.xlsb,.docx,.doc,.pdf,.ppt,.pptx,.pptm,.potx,.md"
               required />
    </div>

    <br />

    <button type="submit">Chunk Document</button>
</form>
Document chunking upload form
Document chunking upload form

The upload form accepts the following formats:

FormatSupported extensions
Excel.xlsx, .xls, .xlsm, .xlsb
Word.docx, .doc
PDF.pdf
PowerPoint.ppt, .pptx, .pptm, .potx
Markdown.md

The HTML accept attribute helps users select supported files in the browser. Always validate uploaded files on the server before processing them.

Generate chunks from uploaded documents

Once a document is uploaded, create a ChunkingService instance and configure the chunking options.

The following example detects the uploaded file format and selects the corresponding document-specific chunking options.

Add this action method to HomeController.cs:

public IActionResult ChunkDocument(IFormFile document)
{
    if (document == null || document.Length == 0)
    {
        return BadRequest("Select a document to chunk.");
    }

    string fileName = document.FileName;
    string extension = Path.GetExtension(fileName).ToLowerInvariant();

    ChunkingService chunkingService = new ChunkingService();

    using Stream fileStream = document.OpenReadStream();

    ChunkingOptions options =
        new ChunkingOptions
        {
            MaxTokens = 500,
            OverlapTokens = 0,
            IncludeMetadata = true,
            IncludeCitation = true
        };

    switch (extension)
    {
        case ".xlsx":
        case ".xls":
        case ".xlsm":
        case ".xlsb":
            options.SourceOptions =
                new ExcelChunkingOptions
                {
                    ChunkingMode = ExcelChunkingMode.Auto
                };
            break;

        case ".docx":
        case ".doc":
            options.SourceOptions =
                new WordChunkingOptions
                {
                    ChunkingMode = WordChunkingMode.Section
                };
            break;

        case ".pdf":
            options.SourceOptions =
                new PdfChunkingOptions
                {
                    ChunkingMode = PdfChunkingMode.Auto
                };
            break;

        case ".pptx":
        case ".ppt":
        case ".pptm":
        case ".potx":
            options.SourceOptions =
                new PowerPointChunkingOptions
                {
                    ChunkingMode = PowerPointChunkingMode.Auto
                };
            break;

        case ".md":
            options.SourceOptions =
                new MarkdownChunkingOptions
                {
                    ChunkingMode = MarkdownChunkingMode.Table
                };
            break;

        default:
            return BadRequest(
                $"The file format '{extension}' is not supported.");
    }

    IChunkingResult result =
        chunkingService.Chunk(fileStream, fileName, options);

    DisplayChunkingResult(result);

    return Content(
        "The document was chunked successfully. " +
        "See the application console for the chunking results.");
}

In this example:

  • MaxTokens sets the maximum token count for each chunk.
  • OverlapTokens determines how many tokens are shared between consecutive chunks.
  • IncludeMetadata enables source document and chunk metadata.
  • IncludeCitation enables source-location information.
  • SourceOptions selects the chunking mode for the uploaded document format.

Here, token overlap is disabled by setting OverlapTokens to 0. You can configure it based on how much context you want to retain between consecutive chunks.

The example uses Auto mode for Excel, PDF, and PowerPoint, Section mode for Word, and Table mode for Markdown. You can change these modes according to your document structure and application requirements.

Review generated chunks, metadata, and citations

The ChunkingService returns an IChunkingResult containing the generated chunks.

Each IChunk provides the extracted content and can include metadata and citation information, depending on the configured options.

Add the following helper method to display the generated results in the application console:

private static void DisplayChunkingResult(
    IChunkingResult result)
{
    Console.WriteLine(
        $"Chunk Count: {result.Chunks.Count}");

    foreach (IChunk chunk in result.Chunks)
    {
        Console.WriteLine("================================");

        Console.WriteLine($"Chunk ID: {chunk.ChunkId}");
        Console.WriteLine($"Chunk Index: {chunk.ChunkIndex}");

        Console.WriteLine(
            $"Content:{Environment.NewLine}{chunk.Content}");

        Console.WriteLine(
            $"Citation: {chunk.Citation?.DisplayText}");

        Console.WriteLine("Citation Location Details");

        if (chunk.Citation?.LocationDetails != null)
        {
            foreach (KeyValuePair<string, object> item
                in chunk.Citation.LocationDetails)
            {
                Console.WriteLine(
                    $"Location Key: {item.Key}, " +
                    $"Location Value: {item.Value}");
            }
        }

        Console.WriteLine(
            $"Metadata SourceDocumentId: " +
            $"{chunk.Metadata?.SourceDocumentId}");

        Console.WriteLine(
            $"Metadata File Name: " +
            $"{chunk.Metadata?.FileName}");

        Console.WriteLine(
            $"Metadata File Type: " +
            $"{chunk.Metadata?.FileType}");

        Console.WriteLine(
            $"Metadata Token Count: " +
            $"{chunk.Metadata?.TokenCount}");

        Console.WriteLine(
            $"Metadata Character Count: " +
            $"{chunk.Metadata?.CharacterCount}");
    }
}

This method displays the generated chunk content, identifiers, citation details, and metadata in the application console.

A typical chunking result can include:

  • Unique chunk identifiers and indexes
  • Extracted chunk content
  • Source document identifiers
  • File names and file types
  • Token and character counts
  • Citation text and source-location details
Generated document chunking output
Generated document chunking output

For detailed setup instructions and additional examples, refer to the official .NET Document Chunking Library documentation.

Explore document-specific chunking modes

Different document formats have different structures. The library provides format-specific chunking modes so developers can choose how content is divided.

Document typeAvailable chunking modes
WordAuto, Paragraph, Table, Section
PDFAuto, Paragraph, Table, Page
ExcelAuto, Table, Worksheet
PowerPointAuto, Table, Notes, Slide
MarkdownAuto, Paragraph, Table, Heading

For example:

  • Paragraph: Creates chunks based on paragraph boundaries in Word or PDF documents.
  • Table: Processes table content in supported document formats.
  • Worksheet: Organizes Excel content by worksheet.
  • Slide: Creates PowerPoint chunks based on individual slides.
  • Heading: Organizes Markdown content around its heading structure.

The Auto mode selects a suitable chunking approach based on the document’s content and structure.

These options help developers prepare content according to its source format rather than relying only on fixed-size text splitting.

Preserve metadata and citations for enterprise AI workflows

Enterprise AI applications often need to identify where retrieved information came from. The library supports metadata enrichment and citation generation to help maintain this traceability.

Metadata provides information about the source document and generated chunk, including:

  • Source document identifier
  • File name and file type
  • Token count
  • Character count
  • Format-specific document attributes
Chunk metadata with format-specific document attributes

Citation information identifies the original location of the extracted content. Depending on the document format, it can include:

Document formatExample source reference
ExcelWorksheet names and cell ranges
WordHeading paths and content types
PDFPage numbers and page ranges
PowerPointSlide numbers and titles
MarkdownHeading paths and line ranges

For example, a citation for an Excel chunk may identify a worksheet and cell range, while a Markdown citation may include its heading hierarchy and line numbers.

This information helps applications trace retrieved content to its original source and display relevant references to users.

The generated chunks can then be passed to embedding models and stored in search indexes or vector databases. Embedding generation, indexing, and AI model integrations are implemented separately within your application.

Frequently Asked Questions

How does the .NET Document Chunking Library differ from basic text splitting?

Traditional text splitters divide content primarily by character or token limits. The .NET Document Chunking Library processes documents based on their native structure and supports format-specific chunking modes. It can preserve relevant relationships between headings, paragraphs, tables, worksheets, slides, and pages while retaining metadata and citation information.

Does the .NET Document Chunking Library require Microsoft Office?

No. The library uses Syncfusion document-processing components and does not rely on Microsoft Office Interop for supported document-processing operations. This makes it suitable for server-side and cross-platform application scenarios.

Can the generated chunks be used with vector databases and RAG applications?

Yes. Generated chunks can be passed to embedding models and used in semantic search, vector indexing, document question answering, and RAG workflows. Metadata helps organize and filter indexed content, while citation information helps trace chunks to their original document locations. Integrations with embedding models, search services, vector databases, and AI models must be implemented separately in your application.

Why is document-aware chunking important for AI applications?

Enterprise documents often contain headings, tables, worksheets, sections, and slides that provide important context. Preserving these structural relationships during chunking helps retrieval systems work with more meaningful content and provides source information for traceability.

Syncfusion .NET Document Chunking Library for RAG and semantic search. Chunk Word, PDF, Excel, PowerPoint, and Markdown files.

Conclusion

Preparing enterprise documents for AI applications starts with preserving the context within them. The new Syncfusion .NET Document Chunking Library helps developers divide Word, PDF, Excel, PowerPoint, and Markdown documents into structured chunks with configurable chunking modes, metadata, and citation information.

Use the generated chunks as a foundation for semantic search, vector indexing, and RAG applications.

Explore the live demo and documentation to see how the library can simplify document preparation for your AI-powered applications.

You can also explore the What’s New and Release Notes to discover the latest document-processing features.

For existing Syncfusion customers, the latest version of Essential Studio is available from the License and Downloads page. New users can explore the library through the 30-day free trial.

If you have questions or feedback, reach out through our support forums, feedback portal, or support portal.

Read the whole story
alvinashcraft
2 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Add the Microsoft Learn MCP server for .NET in Claude Code

1 Share

Make Claude Code search the official docs before it writes C# 15 code, with one setup command, a CLAUDE.md rule and a test of what it knows without it.

Read the whole story
alvinashcraft
2 minutes ago
reply
Pennsylvania, USA
Share this story
Delete
Next Page of Stories