Archive
The Daily Org

A Salesforce NewspaperCurated by Abhinav

Use custom Python chunking to improve Agentforce retrieval accuracy in Data 360

Default character or token splitters fracture complex enterprise documents like financial reports and call transcripts, causing Agentforce to retrieve contextless chunks. The article explains how Data 360 Code Extension functions allow developers to run custom Python scripts within the Salesforce trust boundary to implement tailored chunking logic.

For fragmented data tables, standard chunking strips column headers, leaving raw numbers meaningless to the model. A custom function detects table boundaries and repeats header rows across sub-chunks, enabling the agent to correctly map values to metrics like revenue and operating margins.

Multispeaker dialogues suffer when speaker turns merge into massive unstructured blocks. By applying a sliding window approach with defined turn counts and character limits, adjacent chunks overlap to preserve conversational context. The author validates these techniques by querying both native and custom vector indexes and comparing the resulting Agentforce answers against identical user prompts.

Tracing retrieval-augmented generation accuracy failures backward through the context pipeline

The engineering team discovered that standard benchmarks masked severe accuracy drops when processing complex enterprise documents. They resolved this by treating end-to-end accuracy as an opaque metric and instead debugging the pipeline backward. By isolating each stage from source ingestion to answer generation, they identified where meaning was lost during parsing or chunking rather than blaming the large language model.

The solution required routing simple text through fast deterministic parsers while using model-based processing for pages containing tables, charts, or diagrams. Chunking strategies shifted from fixed token limits to semantic boundaries that preserve headers, diagrams, and procedural sequences. Enriching chunks with metadata and question representations, combined with the extended context capacity of SFR Embedding v3, significantly improved retrieval fidelity.

Retrieval accuracy increased by applying dynamic metadata pre-filters before semantic ranking and preparing for GraphRAG to handle multi-hop questions across connected facts. The team also replaced batch indexing with a Just-in-Time architecture to reduce latency for smaller payloads. Continuous staged evaluations allowed them to attribute accuracy gains to specific changes, ultimately raising enterprise document accuracy above ninety percent.