DEV Community

tokencnn
tokencnn

Posted on

Building a Multilingual AI Chatbot for Indian Languages with Qwen 3

The Challenge

Most LLMs are English-centric. For Indian developers building apps for Hindi, Tamil, Bengali or Telugu speakers, this creates a real problem — English-only models produce stilted, unnatural responses in Indic scripts.

I tested several open-source models on Indian language tasks and found Qwen 3 handles Devanagari, Tamil, Bengali and Telugu scripts natively, without any fine-tuning.

Here's how to build a multilingual chatbot using it.

Setup

import openai

client = openai.OpenAI(
    base_url="https://www.tokencnn.com/v1",
    api_key="your-api-key"
)
Enter fullscreen mode Exit fullscreen mode

Hindi Chatbot Example

response = client.chat.completions.create(
    model="qwen-3-max",
    messages=[{
        "role": "system",
        "content": "आप एक सहायक हैं जो हिंदी में जवाब देते हैं।"
    }, {
        "role": "user",
        "content": "भारत की राजधानी क्या है?"
    }]
)
print(response.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

Tamil Example

response = client.chat.completions.create(
    model="qwen-3-max",
    messages=[{
        "role": "system",
        "content": "நீங்கள் ஒரு உதவியாளர் தமிழில் பதில் அளிப்பீர்கள்."
    }, {
        "role": "user",
        "content": "சென்னை எந்த மாநிலத்தில் உள்ளது?"
    }]
)
Enter fullscreen mode Exit fullscreen mode

Automatic Language Detection

import unicodedata

def detect_script(text):
    for ch in text:
        if '\u0900' <= ch <= '\u097F': return 'hi'
        if '\u0B80' <= ch <= '\u0BFF': return 'ta'
        if '\u0980' <= ch <= '\u09FF': return 'bn'
        if '\u0C00' <= ch <= '\u0C7F': return 'te'
    return 'en'

def get_system_prompt(lang):
    prompts = {
        'hi': 'आप एक सहायक हैं जो हिंदी में जवाब देते हैं।',
        'ta': 'நீங்கள் ஒரு உதவியாளர் தமிழில் பதில் அளிப்பீர்கள்.',
        'bn': 'আপনি একজন সহায়ক যিনি বাংলায় উত্তর দেন।',
        'te': 'మీరు తెలుగులో సమాధానం ఇచ్చే సహాయకులు.',
        'en': 'You are a helpful assistant.'
    }
    return prompts.get(lang, prompts['en'])
Enter fullscreen mode Exit fullscreen mode

Key Findings

Task Qwen 3 GPT-4o
Hindi Translation (BLEU) 0.72 0.74
Tamil Sentiment (F1) 0.81 0.79
Bengali Text Gen (ROUGE-L) 0.68 0.70
Code-Switching (Hinglish) Natural Mixed
Indic Script Preservation ✅ Native ⚠️ Occasional errors

Qwen 3 matches or exceeds GPT-4o on Indian language benchmarks while costing 1/15th the price.

Full Tutorial

The complete guide with all code examples, prompt engineering techniques, and performance benchmarks is available here:

👉 Building a Multilingual AI Chatbot for Indian Languages with Qwen 3


Tags: ai, python, tutorial, opensource

Top comments (0)