Skip to content

Multi-language support #4

Description

@vanguard-hack

[FEATURE TICKET] End-to-End Multilingual Support (English, Hindi, Kannada)


1. Executive Summary & Business Scope

1.1 Context & Objective

To support multi-jurisdiction and regional law enforcement personnel as well as citizens, the entire platform—including the web application interface, chat assistant widget, query processing pipeline, and response generation—must natively support English (en), Hindi (hi), and Kannada (kn).

1.2 Core Scope Areas

  • Website & Chat UI Internationalization (i18n): Static UI localization, localized screen metadata, RTL/LTR styling, and dynamic language switcher.
  • Multimodal & Query Preprocessing: Automatic language detection (LID), cross-lingual query normalization, and query reformulation into English for backend index retrieval while preserving target language for response generation.
  • RAG & Vector DB Cross-Lingual Search: Support for multilingual embeddings (e.g., text-embedding-3-large or intfloat/multilingual-e5-large) and translated chunk references.
  • Text2ZCQL Pipeline: Translation of non-English entity queries (e.g., Kannada/Hindi vehicle types, crime descriptions) to standard schema values and ZCQL tokens.
  • Agentic & Vision Pipelines: Multilingual OCR support (Zia Vision / Qwen2.5-VL) for Kannada and Devanagari script signboards, ID cards, and number plates.
  • Final Generation & Redaction: Native, fluent generation in the user's selected/detected language with localized citations and compliant redactions.

2. End-to-End System Architecture Flow

[User: Hindi / Kannada / English Input]
                  │
                  ▼
   ┌────────────────────────────────────────────────────────┐
   │         Client Layer (UI + Chatbot Widget)             │
   │  - Language Selector: [EN | HI | KN]                   │
   │  - i18n Dictionary Loaded (Static UI strings)          │
   │  - Attaches `preferred_lang` + `detected_lang` in req  │
   └────────────────────────────────────────────────────────┘
                  │
                  ▼
   ┌────────────────────────────────────────────────────────┐
   │         Request Orchestrator & LID Preprocessor        │
   │  - Language Identification (fastText / CLD3 / Zia LID) │
   │  - Query Rewriter (Normalizes to EN for DB/Search)     │
   │  - Retains Original Query + Target Response Language   │
   └────────────────────────────────────────────────────────┘
                  │
                  ▼
   ┌────────────────────────────────────────────────────────┐
   │                 Enhanced Intent Router                 │
   │  Routes normalized English query to RAG / ZCQL / Agent │
   └────────────────────────────────────────────────────────┘
         │                           │                    │
         ▼                           ▼                    ▼
┌──────────────────┐       ┌──────────────────┐  ┌──────────────────┐
│   RAG Pipeline   │       │  Text2ZCQL Pipe  │  │ Agentic Fallback │
│ Multilingual E5  │       │ Entity & Schema  │  │ Tool Execution   │
│ Vector Search    │       │ Value Canonical  │  │ Multilingual OCR │
└──────────────────┘       └──────────────────┘  └──────────────────┘
         │                           │                    │
         └───────────────────────────┼────────────────────┘
                                     ▼
   ┌────────────────────────────────────────────────────────┐
   │         Response Aggregator & Multilingual LLM         │
   │  - Generates final answer in [EN / HI / KN]            │
   │  - Role-based PII redaction across all scripts         │
   │  - Localizes source citation labels & metadata         │
   └────────────────────────────────────────────────────────┘
                  │
                  ▼
   ┌────────────────────────────────────────────────────────┐
   │            Immutable Audit Layer (Catalyst)            │
   │ Logs: user_lang, raw_query, normalized_en_query,       │
   │ response_lang, source citations, timestamp             │
   └────────────────────────────────────────────────────────┘

3. Detailed Technical Requirements

3.1 Frontend Web App & Chat Widget (i18n)

  • i18n Framework: Integrate i18next (React/Vue/vanilla JS) with JSON namespaces (common.json, chat.json, fir_module.json).
  • Language Switcher: Persistent header dropdown with language persistence in localStorage and user session profile.
  • Font Rendering: Load high-legibility Unicode fonts for Indian scripts:
    • Kannada: Noto Sans Kannada / Baloo Tamma 2
    • Hindi: Noto Sans Devanagari / Tiro Devanagari Hindi
  • Dynamic Chat UI Localization: Localize placeholder text, upload buttons, error prompts, citation tags, and system warnings.

3.2 Language Identification & Request Orchestration

  • Language Detection Engine: Run fast-path LID on incoming query text. If confidence < 0.85 or query is code-mixed (e.g., Hinglish / Kanglish), fallback to the client-selected preferred_lang.
  • Query Normalization: Translate domain-specific entities (names of IPC sections, vehicle numbers, names) while creating a normalized English retrieval query for vector and structured queries.

3.3 RAG Pipeline (Multilingual Semantic Search)

  • Multilingual Vector Space: Utilize a cross-lingual embedding model (e.g., text-embedding-3-large with multilingual support or multilingual-e5-large).
  • Cross-Lingual Retrieval: Allow queries in Kannada or Hindi to match English SOP documents and vice-versa.
  • Context Translation: Pass retrieved English chunks to the LLM with explicit system instructions to formulate the final answer in the user's target language without losing legal precision.

3.4 Text2ZCQL Pipeline (Structured Database Querying)

  • Entity Canonicalization: Translate natural language filter terms (e.g., Hindi: "चोरी हुई बाइक" or Kannada: "ಕಳವಾದ ಬೈಕ್") into exact database enum values (crime_type = 'VEHICLE_THEFT').
  • Read-Only Guardrails: Retain ZCQL AST parser security rules across all localized queries.

3.5 Multilingual Vision & OCR Engine

  • Configure Zia Vision OCR and Qwen2.5-VL to parse Devanagari (Hindi) and Kannada script on official certificates, vehicle registration cards, and state ID documents.

4. API Contract & Schema Definitions

4.1 Unified Chat Request Payload

{
  "session_id": "sess_882910_knd",
  "badge_id": "OFFICER_4482",
  "preferred_lang": "kn",
  "message": {
    "text": "ಎಫ್‌ಐಆರ್ #4029 ರ ಪ್ರಕಾರ ವಾಹನ ಜಪ್ತಿ ಮಾಡಿದ ವಿವರಗಳನ್ನು ನೀಡಿ",
    "image_data": null
  },
  "page_context": {
    "current_module": "fir_management",
    "active_fir_id": "4029"
  }
}

4.2 Multilingual API Response Schema

{
  "response_id": "resp_987421_a4b9",
  "badge_id": "OFFICER_4482",
  "detected_lang": "kn",
  "response_lang": "kn",
  "text": "ಎಫ್‌ಐಆರ್ #4029 ಮತ್ತು ಎಸ್‌ಒಪಿ ಸೆಕ್ಷನ್ 3.2 ರ ಪ್ರಕಾರ, ಕೆಎ01ಎಬಿ1234 ನೋಂದಣಿ ಸಂಖ್ಯೆಯ ವಾಹನವನ್ನು ಮಧ್ಯಾಹ್ನ 14:30 ಕ್ಕೆ ಜಪ್ತಿ ಮಾಡಲಾಗಿದೆ...",
  "sources": [
    {
      "source_id": "src_01",
      "source_type": "rag_document",
      "display_name": "SOP_Arrest_and_Impound_v3.pdf",
      "display_label_localized": "ಎಸ್‌ಒಪಿ ಬಂಧನ ಮತ್ತು ಜಪ್ತಿ ಪ್ರಕ್ರಿಯೆ v3",
      "location": "Page 12, Paragraph 4",
      "uri": "catalyst://filestore/sops/SOP_Arrest_and_Impound_v3.pdf",
      "mime_type": "application/pdf"
    },
    {
      "source_id": "src_02",
      "source_type": "database_record",
      "display_name": "FIR_Records",
      "display_label_localized": "ಎಫ್‌ಐಆರ್ ದಾಖಲೆಗಳು",
      "identifier": "FIR #4029",
      "scope": "Catalyst DataStore (ZCQL Read-Only)"
    }
  ],
  "metrics": {
    "pipeline_route": "HYBRID_RAG_ZCQL",
    "lid_confidence": 0.98,
    "latency_ms": 840
  }
}

5. i18n Translation Dictionary Schema Sample

// locales/kn/chat.json
{
  "chat": {
    "header_title": "ಸ್ಮಾರ್ಟ್ ತನಿಖಾ ಸಹಾಯಕ",
    "input_placeholder": "ನಿಮ್ಮ ಪ್ರಶ್ನೆಯನ್ನು ಇಲ್ಲಿ ಟೈಪ್ ಮಾಡಿ...",
    "send_button": "ಕಳುಹಿಸಿ",
    "upload_tooltip": "ಚಿತ್ರ ಅಥವಾ ದಾಖಲೆ ಅಪ್‌ಲೋಡ್ ಮಾಡಿ",
    "source_citations_title": "ಮಾಹಿತಿ ಮೂಲಗಳು:",
    "disclaimer": "ಈ ಪ್ರತಿಕ್ರಿಯೆಯು ಅಧಿಕೃತ ಪೊಲೀಸ್ ಡೇಟಾಬೇಸ್ ಮತ್ತು ಎಸ್‌ಒಪಿ ಆಧಾರಿತವಾಗಿದೆ."
  }
}

// locales/hi/chat.json
{
  "chat": {
    "header_title": "स्मार्ट जांच सहायक",
    "input_placeholder": "अपना प्रश्न यहाँ दर्ज करें...",
    "send_button": "भेजें",
    "upload_tooltip": "छवि या दस्तावेज़ अपलोड करें",
    "source_citations_title": "सूचना स्रोत:",
    "disclaimer": "यह प्रतिक्रिया आधिकारिक पुलिस डेटाबेस और एसओपी पर आधारित है।"
  }
}

6. Security, Redaction & Compliance in Multilingual Environments

  • Cross-Lingual Named Entity Recognition (NER) for Redaction: PII redaction filters must recognize Indian names, phone numbers, Aadhaar numbers, and addresses in Devanagari, Kannada, and Latin scripts prior to rendering.
  • Audit Logging: The immutable audit layer must store both the original raw prompt (in native script) and the normalized English query alongside translation metadata.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions