How to split work between an LLM and deterministic code A developer outlined an approach for splitting extraction work between a language model and deterministic code when building an RDF graph of company acquisitions, having the model return only subject-predicate-object facts while code assigns stable entity IDs from document version and position. The writeup argues that fields the application already knows, such as document IDs, should be filled in by code rather than generated by the model to avoid errors, and recommends building labeled dev, validation and test sets to compare a full-graph prompt against a facts-only JSON prompt. Suppose we’re building a graph database of company acquisitions. Each company is a node, and an arrow points from the buyer to the company it bought. We’re already asking a language model to read the announcements. Why not ask for the finished database record while we’re at it? Take the source document ID. If the model changes one digit, the right acquisition ends up attached to the wrong announcement. We already have the ID, so we can fill in that field ourselves. What else can we take out of the prompt? Let’s make up an announcement about two fictional companies. North Pier acquired Alder Labs. Finding “North Pier” and “Alder Labs” and marking both as companies is named entity recognition https://aclanthology.org/W03-0419/ NER . Working out which company bought the other is relation extraction . That gives us the direction of the arrow. I made up the document number and the ID format for this example. The application already knows which document version and chunk it sends to the model. An RDF graph https://www.w3.org/TR/rdf11-concepts/ section-rdf-graph stores each fact as a triple with a subject, a predicate, and an object. We can ask the model for just the facts it finds in the sentence. { "facts": "North Pier", "type", "Company" , "Alder Labs", "type", "Company" , "North Pier", "acquired", "Alder Labs" } Change the sentence to “North Pier was acquired by Alder Labs.” The two company rows stay the same. The last row becomes "Alder Labs", "acquired", "North Pier" . Code assigns each mention an ID from the document version and its position within that document. On a retry, the same occurrence of “North Pier” gets the same ID. Here’s the resulting graph in TriG format. The last line links the extracted facts to their source chunk. @prefix :