Multilingual Indic Language Translation

In this use case, we aim to establish a language translation system from English to six prominent Indian languages: Hindi, Kannada, Telugu, Tamil, Punjabi, and Gujarati.

Let's build the stack

Step 1- Define your prompt

The initial component involves writing a prompt where the user input query and the desired language translation are specified. This component is invaluable as it ensures that the model understands the desired task on what language it need to generate accurate responses.

Prompt template, edit the template :

Translate the given TEXT into the given LANGUAGE. You are the only Indic language translator, you only support Hindi, Kannada, Telugu, Tamil, Punjabi and Gujarati LANGUAGE. If the LANGUAGE is not among languages, give a feedback to a user saying LANGUAGE is not supported. 

TEXT: {text}
LANGUAGE: {lang}

As you look in the stack, we get lang and text as input variables that need to be entered by the user.

Know more about Prompts: https://docs.aiplanet.com/components/prompts

Step 2- Define your LLM

Based on our requirements, we must determine the most suitable Large Language Model for our needs. Given that our use case involves developing a Multilingual Indic bot that must comprehend the language aligned with the prompt instructions, GPT models excel in this aspect. Hence, we have opted for the Azure ChatOpenAI model for this particular use case.

Note: Several Multilingual fine-tuned models are available on the HuggingFace Hub, providing an alternative option for utilizing open source Large Language Models in this use case.

Know more about LLM: https://docs.aiplanet.com/components/large-language-models

Step 3- Build Chain with Memory

In order to connect the prompt with LLM, we need a chain, this is where we use LLMChain. Just connect your Prompt Template, LLM directly to the LLM Chain along with the memory component being optional. This LLM Chain ensures your prompt is added as in-context learning to the LLM model so that it can return reasonable response.

Know more about Chains: https://docs.aiplanet.com/components/chains and Memory: https://docs.aiplanet.com/components/memories

Step 4- How to use Chat Interface for multiple prompts

Given that our prompt template comprises two input variables, it is crucial to specify the user input correctly. The Chat Interface defaults to selecting the first input variable as the user query, but this may not always be accurate. To address this, enter the language value under the "lang" input variable and utilize the text entry box to input your query.

Check out how to use Chat Interface: https://docs.aiplanet.com/quickstart/chat-interface-genai-stack-chat

NOTICE: In the above image, we write the language name under the lang input variable and then enable text as the chat input. Please make sure that we enter the language name and disable the chat input for lang.

Last updated