NLP and Data EngineeringSelected technical experience

Designing an NLP Pipeline from Raw Conversations to Structured Signals

How a batch text-processing workflow can evolve into an event-driven, containerised and observable language-data platform.

A pipeline design for cleaning conversational data, integrating multiple language-analysis services and retaining predictions with confidence and history.

6 minute read

Business challenge

Technology must translate complexity into a dependable service

Conversation data contains valuable signals, but it arrives as unstructured text. Before an organisation can analyse it, the system must collect, clean, segment, process and store the text while preserving confidence, history and appropriate privacy controls.

The challenge involves more than deploying a model. The platform must:

  • Collect and validate text
  • Apply consent and purpose controls
  • Clean, compile and segment messages
  • Run suitable language analysis
  • Preserve confidence and model history
  • Route uncertain results to human review

Original implementation

Architecture appropriate to its original scope

The source material describes a focused implementation built with the available tools and delivery requirements of its time.

  1. 01Conversation records in a relational database
  2. 02Batch data collection
  3. 03Text cleaning
  4. 04Message compilation
  5. 05Text segmentation
  6. 06External NLP requests
  7. 07Predictions and confidence scores
  8. 08Dedicated result tables
  9. 09Historical result retention
  10. 10Downstream analysis

Original technical capabilities

  • Python and statistical-computing workflows
  • SQL extraction and chunked collection
  • Punctuation cleaning
  • Message compilation by user
  • Text segmentation
  • Separate endpoints for age, language, sentiment, education and gender-related signals
  • Confidence values and dedicated relational tables
  • Historical predictions retained rather than overwritten
  • Manual processing steps, external request limits and proposed automation

Why modernise it

Scaling considerations

These are architecture considerations for future growth, not confirmed failures in the historical implementation.

    Higher data volume, lower latency and stronger deployment independence can justify separating the workflow into smaller services.

    Responsible use

    Predictions require boundaries and review

    A predicted attribute is a model output, not a verified personal fact. Confidence scores do not remove the need for governance, validation and appropriate limitations on use.
    • Consent and privacy
    • Accuracy, bias and language variation
    • Incorrect identity assumptions
    • Inappropriate downstream decisions
    • Data retention
    • Human review

    Modern AWS reference architecture

    A possible cloud-native design

    This reference architecture describes how an organisation could modernise the workflow. It does not describe the historical implementation.

    1. 01Conversation channels
    2. 02Secure ingestion API or event stream
    3. 03Raw encrypted storage
    4. 04Validation and consent checks
    5. 05Text-cleaning service
    6. 06Compilation and segmentation service
    7. 07NLP inference services
    8. 08Prediction-validation service
    9. 09Versioned result storage
    10. 10Analytics and monitoring

    Service responsibilities

    Separating the workflow

    Batch ingestion

    Secure file upload to Amazon S3 can trigger Lambda and Step Functions. This pattern suits scheduled processing and large historical datasets.

    • Encrypted S3 landing area
    • S3 event notifications
    • Schema validation
    • Workflow status and controlled retries

    Streaming ingestion

    Amazon Kinesis Data Streams or Amazon Managed Streaming for Apache Kafka becomes relevant when events arrive continuously and low-latency processing matters. Streaming is unnecessary for many scheduled workloads.

    • Stream consumers
    • S3 archival
    • Real-time monitoring
    • Back-pressure planning

    NLP microservices

    Services can separate ingestion, consent policy, cleaning, compilation, segmentation, language detection, sentiment, orchestration, validation, results and audit responsibilities.

    • One clear responsibility
    • Versioned input and output contracts
    • Health checks and structured logs
    • Idempotency keys
    • Retry rules, timeouts and error queues
    • Independent tests

    Serverless coordination

    Lambda handles short events such as file arrival, schema validation, small cleaning tasks, routing, metadata and notifications. Step Functions coordinates parallel model calls, retries, timeouts, manual-review branches and workflow status.

    • Amazon SQS for back-pressure and decoupling
    • Safe retries
    • Dead-letter queues
    • Independent inference workers

    Docker and Kubernetes

    Docker packages each processing component consistently. Kubernetes manages where those containers run, replaces failed instances and adjusts capacity as demand changes.

    • Large text-processing workers
    • Custom NLP model and tokenisation services
    • Batch inference workers
    • Language-specific processing services
    • Images stored in Amazon ECR

    Container orchestration

    Where Amazon EKS becomes useful

    Amazon EKS becomes useful when scale, custom runtimes or deployment independence justify the added operational complexity.

    When to consider EKS

    • Several independently scaling NLP services
    • Custom model runtimes and long-running workers
    • CPU- or memory-intensive inference
    • Autoscaling from queue depth or request volume
    • Controlled rolling, blue-green or canary deployments

    Kubernetes components

    • Deployments and internal Kubernetes Services
    • Jobs and CronJobs
    • Horizontal Pod Autoscaler
    • Pod disruption budgets
    • Readiness and liveness probes
    • Resource limits
    • Secrets Manager integration and IAM roles for workloads

    Big-data foundation

    Services that become useful as data grows

    Amazon S3 data lake

    Use durable prefixes for raw, validated, cleaned, segmented, predictions, quarantine and audit data. Parquet reduces storage and scan costs for large analytical datasets.

    AWS Glue

    Glue supports schema discovery, cataloguing, ETL and partition management across the data lake.

    Amazon EMR Serverless

    PySpark becomes useful for high-volume text cleaning, long-period message joins, user-level compilation, language-distribution analysis, batch feature generation and historical reprocessing.

    Analytics

    Athena supports exploratory SQL over S3. Redshift Serverless is appropriate only when frequent business-intelligence queries justify a warehouse.

    Inference patterns

    Synchronous inference

    Use for small requests that need an immediate response and a fast model. API Gateway can invoke Lambda, a SageMaker real-time endpoint or an EKS model service.

    Asynchronous inference

    Use for larger payloads or longer processing when an immediate response is unnecessary. S3, SQS and Step Functions can coordinate SageMaker asynchronous inference or EKS workers.

    Batch inference

    Use for historical reprocessing or scheduled recomputation after a model update. EMR Serverless, SageMaker batch processing or Kubernetes Jobs can run the workload.

    Prediction storage

    Each retained prediction should preserve enough context for controlled comparison and review.

    • Pseudonymous record or subject identifier
    • Prediction type and predicted value
    • Confidence
    • Model name and version
    • Preprocessing version
    • Event time and processing time
    • Consent or lawful-purpose reference where appropriate
    • Review status
    • Idempotency key

    Previous predictions can support controlled model comparison, subject to an approved retention policy. Personal data should not be retained indefinitely.

    Architecture comparison

    Original scope and a modern reference design

    The original design suited its context. Modern services become relevant when operating scale and reliability requirements change.

    Original implementationModern AWS reference architecture
    More tightly coupled workflowIndependently deployable services
    Manual or batch-heavy processingEvent-driven orchestration
    Relational operational storageS3 data lake plus fit-for-purpose stores
    Limited stage-level visibilityCentralised logs, metrics and tracing
    Shared runtime dependenciesDocker-packaged components
    Primarily vertical scalingServerless or Kubernetes-based scaling

    Shared technical controls

    Observability, security and deployment

    Security
    • IAM least-privilege access
    • AWS KMS encryption and TLS
    • AWS Secrets Manager
    • Private networking where appropriate
    • Audit logs, data minimisation and approved retention policies
    • Environment separation, container-image scanning and dependency scanning
    Observability
    • Amazon CloudWatch logs and metrics
    • AWS X-Ray or OpenTelemetry tracing
    • Correlation IDs across service calls
    • Queue depth, processing latency and error rate
    • Model-confidence distributions and data-quality failures
    • Kubernetes pod health plus model and rules versions
    Infrastructure and deployment
    • Docker for repeatable packaging and Amazon ECR for image storage
    • Terraform for infrastructure as code
    • Automated tests and CI/CD pipelines
    • Separate development, staging and production environments
    • Rolling or canary releases
    • Automated rollback based on health checks

    What organisations could achieve

    Customer possibilities

    These are careful, non-quantified outcomes that a suitable implementation could support.

    • Organise high-volume conversation data for analysis
    • Choose batch, streaming or request-response inference by latency need
    • Preserve model and preprocessing history
    • Scale heavy language processing independently
    • Monitor data quality and uncertainty
    • Route sensitive or uncertain results to human review

    Architecture must match data volume, response-time requirements, model complexity, available engineering capacity, privacy risk, budget and expected growth.

    Could this architecture solve a challenge in your organisation?

    Theunet can help assess the use case, design an appropriate cloud architecture and define a practical path from prototype to production.