← Back to posts

Building a Multilingual AI Backend for Part Recognition

How to handle multi-language AI queries to provide accurate predictions and generate tailored localized search queries in a serverless environment.

Case Snapshot

Situation

During the development of an automotive maintenance application, a need arose to support users entering data in multiple languages (Spanish, English, French) while keeping backend logic unified.

Issue

The backend AI needed to recognize user intent and categorize vehicle parts accurately regardless of the input language, and subsequently generate both localized predictive maintenance responses and tailored affiliate search queries.

Solution

Implemented comprehensive multi-language keyword dictionaries, extracted user language context directly from client requests, and used mapping dictionaries to serve localized response templates.

Used In

Used in a serverless Node.js backend to manage AI-driven logic for a mobile application.

Impact

Allowed seamless scaling to new markets without duplicating the core predictive algorithms, maintaining a single source of truth for part categorization.

Situation

When building AI features that analyze user-provided text, supporting multiple languages often introduces immense complexity. For an automotive maintenance application, users could enter service records in Spanish, English, or French.

The backend needed to parse these records, identify exactly which parts were serviced (e.g., “spark plugs”, “bujías”, “bougies”), and provide predictive maintenance advice. It also needed to generate precise product search queries for an affiliate program—all matched perfectly to the user’s native language.

The Challenge

Directly translating user input on the fly is slow, expensive, and often inaccurate for technical automotive terms. Conversely, maintaining entirely separate backend logic branches for each language becomes a maintenance nightmare.

The core algorithm needed to be language-agnostic while the inputs and outputs remained language-specific.

Implementation Patterns

1. Unified Multilingual Keyword Dictionaries

Instead of translating on the fly, the solution involved creating a comprehensive dictionary mapping specific entities to their translations across all supported languages.

const PART_KEYWORDS = {
  SPARK_PLUGS: {
    es: ["bujía", "bujias", "encendido"],
    en: ["spark plug", "spark plugs", "ignition"],
    fr: ["bougie", "bougies", "allumage"]
  },
  // ... other parts
};

This allows the backend to cross-match any incoming text against all known variations, identifying the canonical part ID (SPARK_PLUGS) regardless of the input language.

2. Parameter Extraction and Defaulting

The client application was updated to include the user’s locale in every request payload. The serverless functions extract this parameter, falling back to a default if missing.

// Extract language from request with 'es' as default
const { question, vehicleContext, previousMessages, records, language = 'es' } = request.data;

3. Localized Response Mapping

Once the AI logic completes its assessment using the canonical part IDs, the final step is formatting the output. A response dictionary uses the canonical ID and the extracted language parameter to return the correct string.

ServiceSpanishEnglishFrench
Spark Plugs (due)“Cambiadas hace X km…""Changed X km ago…""Changées il y a X km…”
Timing Belt (critical)“⚠️ CRÍTICO: Último cambio…""⚠️ CRITICAL: Last change…""⚠️ CRITIQUE: Dernier changement…“

4. Dynamic Affiliate Queries

For monetization, the app dynamically generates search queries for automotive parts. Using the same localized dictionaries, the backend constructs highly targeted queries:

  • ES: "Bujías Ford Focus 2018"
  • EN: "Spark plugs Ford Focus 2018"
  • FR: "Bougies Ford Focus 2018"

This approach kept the core predictive logic clean and language-agnostic while delivering a fully localized experience to the end user.

Conceptual Diagram

Conceptual illustration of a Multilingual AI routing node

This diagram conceptually supports Building a Multilingual AI Backend for Part Recognition. It illustrates the core architectural concept: disparate language streams (EN, ES, FR) flowing into a central, unified intelligence node, which then parses them into a single canonical standard.

Post-Specific Engineering Lens

For this post, the primary objective is: Balance model quality with deterministic runtime constraints.

Implementation decisions for this case

  • Chose a staged approach centered on nodejs to avoid high-blast-radius rollouts.
  • Used multilingual checkpoints to make regressions observable before full rollout.
  • Treated llm documentation as part of delivery, not a post-task artifact.

Practical command path

These are representative execution checkpoints relevant to this post:

./llama-server --ctx-size <n> --cache-type-k q4_0 --cache-type-v q4_0
curl -s http://localhost:8080/health
python benchmark.py --profile edge

Validation Matrix

Validation goalWhat to baselineWhat confirms success
Functional stabilityinput quality, extraction accuracy, and processing latencyschema validation catches malformed payloads
Operational safetyrollback ownership + change windowconfidence/fallback policy routes low-quality outputs safely
Production readinessmonitoring visibility and handoff notesobservability captures latency + quality per request class

Failure Modes and Mitigations

Failure modeWhy it appears in this type of workMitigation used in this post pattern
Over-allocated contextMemory pressure causes latency spikes or OOMTune ctx + cache quantization from measured baseline
Silent quality driftOutputs degrade while latency appears fineTrack quality samples alongside perf metrics
Single-profile dependencyNo graceful behavior under loadDefine fallback profile and automatic failover rule

Recruiter-Readable Impact Summary

  • Scope: ship AI features with guardrails and measurable quality.
  • Execution quality: guarded by staged checks and explicit rollback triggers.
  • Outcome signal: repeatable implementation that can be handed over without hidden steps.