Skip to content

More Examples

Question Answering flow with Translation

In some cases, we may want to support user asking question in a non-English language. In this case, the question needs to be translated to English before answering it. Additionally, the answer needs to be given in the same language as the original question.

To add translation to the question answering flow, one method is to add a translation model to the flow in this way:

Before:

graph LR
  Input --> EmbeddingsModel --> VectorStoreRetriever --> LLM --> Output

After:

graph LR
  Input --> LLM(LLM for translation) --> EmbeddingsModel --> VectorStoreRetriever --> LLM2(LLM for answering) --> Output

While there are other methods such as calling Google Translate API, we will use the above method in this example.

Here is how it looks like in LaunchPad Studio: qna-flow-o-qna-translation-complete.png

The prompt for translation is simply this:

Translate this to English, return only the result:
{{ inputs.question }}

Note

You can use this JSON file and import it into LaunchPad Studio to get the same flow.


Document Parser

Refer to Document Parser Example.

... Stay tuned for more examples!