Production-Ready Question Generation System Using Fine-Tuned T5 Models

digits · Finance · 2023 · source Agentic: no · promotional bias: med · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Accounting transaction clarification question generation

Digits needed to reduce repetitive accountant-client communication by suggesting transaction clarification questions while preserving financial-data privacy, professional tone, safety, and deployment reliability.

Constraints:

Architecture

Digits fine-tunes a T5 encoder-decoder model on accounting-specific examples with transaction descriptions and persona/style inputs. A TFX pipeline on Vertex AI handles preprocessing with TensorFlow Transform, training, metadata, and evaluation. The exported model packages preprocessing, the fine-tuned T5 model, and detokenization so TensorFlow Serving can accept raw text. Generated questions pass toxicity screening, hallucination pattern matching, and mandatory human accountant review before reaching clients.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  transaction-description["Transaction description"] --> tfx-preprocessing-graph["TFX preprocessing graph"]
  persona-input["Persona input"] --> tfx-preprocessing-graph["TFX preprocessing graph"]
  tfx-preprocessing-graph["TFX preprocessing graph"] --> fine-tuned-t5-model["Fine-tuned T5 model"]
  tfx-preprocessing-graph["TFX preprocessing graph"] --> tfx-training-pipeline["TFX training pipeline"]
  tfx-training-pipeline["TFX training pipeline"] --> fine-tuned-t5-model["Fine-tuned T5 model"]
  tfx-training-pipeline["TFX training pipeline"] --> evaluation-component["Evaluation component"]
  tfx-training-pipeline["TFX training pipeline"] --> metadata-store["Metadata store"]
  fine-tuned-t5-model["Fine-tuned T5 model"] --> tensorflow-serving-signature["TensorFlow Serving signature"]
  tensorflow-serving-signature["TensorFlow Serving signature"] --> safety-filters["Safety filters"]
  safety-filters["Safety filters"] --> ml-team-alerts["ML team alerts"]
  safety-filters["Safety filters"] --> human-accountant-review["Human accountant review"]
  fine-tuned-t5-model["Fine-tuned T5 model"] --> evaluation-component["Evaluation component"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Transaction description Raw financial transaction text requiring clarification. TFX preprocessing graph
Persona input Style indicator such as professional/concise or casual/wordy. TFX preprocessing graph
TFX preprocessing graph Tokenizes, pads, creates masks, and converts raw inputs into tensors for T5. Transaction description, Persona input, Fine-tuned T5 model, TFX training pipeline
TFX training pipeline Runs preprocessing, training, evaluation, metadata tracking, and deployment recommendations on Vertex AI. TFX preprocessing graph, Fine-tuned T5 model, Evaluation component, Metadata store
Metadata store Centralized storage for raw data, preprocessed data, trained models, and evaluation results. TFX training pipeline
Fine-tuned T5 model Domain-adapted encoder-decoder model that generates accountant-client questions. TFX preprocessing graph, TFX training pipeline, TensorFlow Serving signature, Evaluation component
TensorFlow Serving signature Production package containing preprocessing, generation, and detokenization. Fine-tuned T5 model, Safety filters
Safety filters Toxicity, insult, obscenity, and hallucination-pattern screening before human review. TensorFlow Serving signature, ML team alerts, Human accountant review
ML team alerts Notifications for discarded unsafe outputs requiring investigation. Safety filters
Human accountant review Final human gate before a generated question reaches the client. Safety filters
Evaluation component Custom TFX component comparing model versions across five metrics before deployment recommendations. TFX training pipeline, Fine-tuned T5 model

Data flow

A transaction description and persona enter the preprocessing graph, which tokenizes, pads, creates attention masks, and converts tensors. The fine-tuned T5 model generates a candidate question and detokenizes it into readable text inside the served model. Safety checks discard toxic, insulting, obscene, or known hallucination-pattern outputs and alert the ML team. A human accountant then reviews, edits, or sends the suggested question to the client.

3 supporting quotes
“The training data is structured around two key inputs: • Transaction descriptions: The raw text from financial transactions”summary, stated
“By incorporating tokenization directly into the exported model using TensorFlow Text, they achieve a cleaner deployment architecture where the model accepts raw text inputs”summary, stated
“A human accountant always reviews and confirms any suggested question before it is sent to a client.”summary, stated

Why this architecture

Digits uses a fine-tuned T5 model rather than generic prompting because the task is narrow, repetitive, domain-specific, and privacy-sensitive. Packaging preprocessing and detokenization with the served model reduces training-serving skew and removes an extra Python layer. Layered safety plus accountant review acknowledges that generated business communications cannot be trusted blindly.

3 supporting quotes
“The fine-tuning approach allows them to maintain full control over the training data used for domain adaptation while leveraging the linguistic capabilities learned during pre-training.”summary, stated
“This all-in-one approach simplifies the inference pipeline and reduces the risk of inconsistencies between training and serving environments.”summary, stated
“This layered approach reflects a mature understanding that generative AI outputs cannot be trusted blindly”summary, stated

Models used: T5 · fine-tuned T5 · TensorFlow Text FastSentencePieceTokenizer · TensorFlow Serving

Scale

Alternatives considered (roads not taken)

Training a generative model from scratch

Rejected because: Training from scratch would require massive compute compared with fine-tuning a pretrained T5 model.

“Rather than training from scratch—which would require massive computational resources”summary, stated

Separate tokenization service at inference

Rejected because: Keeping preprocessing outside the served model increases deployment complexity and training-serving skew risk.

“By incorporating tokenization directly into the exported model using TensorFlow Text, they achieve a cleaner deployment architecture where the model accepts raw text inputs”summary, stated

Trusting generated questions after automated checks only

Rejected because: Professional accounting communications still require human confirmation before client delivery.

“Human Review: A human accountant always reviews and confirms any suggested question before it is sent to a client.”summary, stated

Patterns

fine-tuning-adaptation (model-adaptation)

Digits adapts a pretrained T5 model to accounting transaction clarification using domain-specific training data.

“Digits uses models from the T5 (Text-to-Text Transfer Transformer) family as their base model. The T5 architecture, pre-trained by Google Brain, follows the encoder-decoder transformer pattern that has become foundational for generative text tasks.”summary, stated

human-in-the-loop-gate (governance)

A human accountant must approve every generated question before it reaches a client.

“• Human Review: A human accountant always reviews and confirms any suggested question before it is sent to a client. This human-in-the-loop approach is essential for high-stakes business communications.”summary, stated

safety-policy-enforcement (safety)

The system discards outputs flagged for toxicity, insults, obscenity, or hallucination patterns before human review.

“• Toxicity Screening: Every generated message is automatically screened for toxicity, insults, and obscenity. Any detection triggers immediate discarding of the text and alerts to the ML team for investigation.”summary, stated

eval-driven-development (quality)

A custom TFX evaluation component compares versions using complementary metrics before deployment recommendations.

“Digits developed a custom TFX component for model evaluation that runs as part of every training pipeline. This component:”summary, stated

structured-output-contract (deployment)

The exported serving signature packages preprocessing, generation, and detokenization into one model contract that accepts raw text and returns readable questions.

“The serving signature shown in the code demonstrates how the trained model is packaged for production use. The model includes:”summary, stated

Tradeoffs

Fine-tune T5 rather than train from scratch

Chose Domain adaptation of a pretrained encoder-decoder model over Training a generative language model from zero.

Rationale: Fine-tuning gives accounting-domain control while avoiding the compute cost of pretraining.

“Rather than training from scratch—which would require massive computational resources (the article references that OpenAI's GPT-3 3B model required 50 petaflop/s-days of compute)—Digits fine-tunes these pre-trained models for their domain-specific accounting use case.”summary, stated

Embed preprocessing in the served model

Chose All-in-one TensorFlow Serving signature over Separate preprocessing/tokenization service.

Rationale: Packaging preprocessing and detokenization with the model reduces deployment complexity and skew risk.

“The model includes: • The TensorFlow Transform layer for preprocessing • The fine-tuned T5 model for generation • Built-in detokenization”summary, stated

Automate deployment recommendations with metrics

Chose Custom TFX evaluation component over Human-only release decisions.

Rationale: Quantitative gates make model version comparisons more consistent, while human review still gates client-facing content.

“• Makes automated recommendations about whether to deploy new versions”summary, stated

Gotchas (what bit them)

Autoregressive generation can loop into nonsense.

Root cause: Token-by-token generation can compound errors and fail to produce a stop token.

Resolution: Detect hallucination patterns and discard problematic outputs before review.

“the model got stuck generating "fil-a" repeatedly when processing a Chick-fil-A transaction, failing to produce a stop token.”summary, stated

Training-serving skew can break production behavior.

Root cause: Preprocessing during training may differ from preprocessing used at inference.

Resolution: Export the TensorFlow Transform preprocessing graph alongside the model.

“This is a best practice in MLOps that helps avoid training-serving skew—a common problem where the data processing applied during training differs from what's applied during inference.”summary, stated

Human review can become a throughput bottleneck.

Root cause: Every suggested question requires accountant confirmation before reaching a client.

Resolution: Keep the human gate for safety while using automation to reduce drafting effort rather than fully automate sending.

“• The human review step, while important for safety, may create a bottleneck in high-volume scenarios.”summary, stated

Evaluation must reward semantic correctness without rewarding memorization.

Root cause: A model can match references lexically without producing diverse, useful wording.

Resolution: Use high Levenshtein distance together with high semantic similarity and ROUGE/token checks.

“The tension between Levenshtein distance and semantic similarity is particularly clever—they want models that express the same meaning in diverse ways”summary, stated

Evaluation

Digits evaluates every training pipeline with a custom TFX component comparing the candidate model against the last released version using five metrics, plus a curated human-written evaluation dataset.

Metrics: Levenshtein distance · semantic similarity · ROUGE · must-have token scoring · optional token scoring · toxicity screening · hallucination pattern matching

3 supporting quotes
“• Checks model versions against five different metrics”summary, stated
“• Levenshtein Distance: Measures character-level differences between expected and generated questions. Interestingly, they want this to be high—indicating linguistic diversity rather than rote memorization of training examples.”summary, stated
“They maintain a curated evaluation dataset with human-written reference questions for each transaction type. This allows for consistent comparison across model versions, though the article doesn't specify the size or diversity of this evaluation set.”summary, stated

Outcomes

The case gives limited production-volume metrics; concrete anchors include March 2023 publication, five evaluation metrics, GPT-3 3B's 50 petaflop/s-days training reference, and mandatory human review for every client-facing question.

“This case study demonstrates a practical, production-focused approach to deploying generative AI in a domain-specific business context.”summary, stated
“The use of established tools (TFX, TensorFlow Serving, Vertex AI) rather than custom solutions suggests a pragmatic engineering culture focused on reliability over novelty.”summary, stated