Rasa 3.7 CALM support korean - Rasa CALM - Rasa Community Forum

👋 Introducing the Rasa Playground

Rasa 3.7 CALM support korean

post by Rrrriaa on Feb 22, 2024

How can I support koean in rasa chatbot? (3.7.0)
I want Rasa chatbot to reply in korean, but I couldn’t.
I’m using LLMCommandGenerator which is using openai, FlowPolicy.
Setting "language: “ko” doesn’t works. (in config.yml)
HELP ME!

post by Balowen on Feb 22, 2024

Hi @Rrrriaa.
Help me understand your usecase a little bit, before we think about solutions 🙂
Do you want to develop your chatbot in English and then translate the responses to Korean using LLMs, or will your chatbot be built in Korean?

post by Rrrriaa on Feb 22, 2024

Hi @Balowen! I want my chatbot be bulit in Korean!
I found that changing “utter_free_chitchat_response” can help building chatbot in Korean. Default “utter_free_chitchat_response” was set in English so that chatbot spoke English only.

  utter_free_chitchat_response:
    - text: "안녕하세요! 무엇을 도와드릴까요?"
      metadata:
        rephrase: True
        rephrase_prompt: |
          You are an incredibly friendly assistant. Generate a short
          response to the user's comment in simple korean.

User: {{current_input}}
          Response:

So problem is solved! By the way, Thanks for replying!

post by Balowen on Feb 23, 2024

Hi @Rrrriaa, Happy to hear that you solved the problem! In case you want to rephrase all responses in Korean, it is possible too. Here is an example way how you could achieve that:

  1. Enable the ContextualResponseRephraser in your endpoints.yml file for all responses: docs
  2. Configure the Rephraser to use a customized prompt like so:
nlg:
  type: rasa_plus.ml.ContextualResponseRephraser
  rephrase_all: True
  prompt: prompts/response-rephraser-template.jinja2
  1. Create a response-rephraser-template.jinja2 file in prompts folder.
  2. Customize the prompt in that file, eg.:
The following is a conversation with
an AI assistant. The assistant is helpful, creative, clever, and very friendly.
Rephrase the suggested AI response staying close to the original message and retaining
its meaning. Use simple korean.
Context / previous conversation with the user:
{{history}}
{{current_input}}
Suggested AI Response: {{suggested_response}}
Rephrased AI Response:

Please check the Security Considerations page to learn about possible threats and limitations of using LLMs to generate rephrased responses.

post by geeta.m.desai on Apr 13, 2024

For this to work the response needs to be generated in the target language? I tried with Hindi language, it did not convert entire text in Hindi

The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly. Rephrase the suggest AI response staying close to the original message and retaining its meaning. Use simple Hindi language as target language. Context / previous conversation with the user: {{history}} {{current_input}} Suggested AI Response: {{suggested_response}} Rephrased AI Response:

Currently I am using Google translator for translating for each response. But the response time is very slow

post by Balowen on Apr 17, 2024

Your results will depend on the LLM translation abilities to Hindi. By default it is set to use gpt-3.5 and you can configure it here: Contextual Response Rephraser.

post by geeta.m.desai on Apr 17, 2024

I have tried with both GPT 3.5 and GPT 4. Here is the log

Conversation: USER: हवामान
AI: Weather updates: overcast clouds with temperature 308.04 Kelvin

Summary: summarization=The user asked for the weather update and the AI responded that there are overcast clouds with a temperature of 308.04 Kelvin.

post by Balowen on Apr 23, 2024

It looks like your prompt is a bit wrong – you shouldn’t add anything to the prompt after the Rephrased AI Response:. Could you please try with the following prompt?

The following is a conversation with an AI assistant.
The assistant is helpful, creative, clever, and very friendly.
Rephrase the suggested AI response staying close to the original message and retaining its meaning.
Use simple Hindi.
Context / previous conversation with the user:
{{history}}
{{current_input}}
Suggested AI Response: {{suggested_response}}
Rephrased AI Response:

post by geeta.m.desai on Apr 24, 2024

Thanks. I have figured out that setting rephrase to False as below

utter_can_do_something_else:
  - text: "Is there anything else I can assist you with?"
    metadata:
      rephrase: False

reduces my Rasa response times significantly (I have voice bot so I am sending request to Rasa Rest API)

INFO:root:Conversion took -1(STT) -->: 1.13 seconds
INFO:root:Recognized  हेलो
INFO:root:Conversion took -2(Rasa Response) -->: 0.05 seconds
INFO:root:response_content -->  [{'recipient_id': 'cG9SWHts9cqxb-19AAAL', 'text': "Warm greetings from MitramCares! I'm your friendly helper. How can I make things easier for you today?"}, {'recipient_id': 'cG9SWHts9cqxb-19AAAL', 'text': 'Is there anything else I can assist you with?'}]
INFO:root:Conversion took -3 (Translation)-->: 0.60 seconds
INFO:root:Conversion took -4(TTS) -->: 0.74 seconds

I am better to be with Google translation. Can we please have a further disucssion on a call, please let me know.

Thanks,  
Geeta

## post by Balowen on Apr 24, 2024

As you’ve noticed, adding a step to rephrase responses with a large language model (LLM) increases response time, as each rephrasing requires a separate call to your LLM provider. Considering the performance needs of your voicebot, continuously using an LLM for rephrasing might not be practical. It’s good to hear you found an alternative solution.

For optimizing the rephraser component, I recommend trying a smaller and faster model like GPT-3.5. This should help reduce latency without significantly sacrificing quality. Using a more powerful and resource-intensive model like GPT-4 might be overkill for this application.

## post by geeta.m.desai on Apr 24, 2024

I am planning to use rephraser for responses where needed, even if it has to be small model like GPT 3.5 .

Because earlier I had GPT3.5 in rephraser then also I had performance issues.

I want to understand your view on this strategy of selective rephraser enabling and avoiding rephraser for responses like utter_can_do_something_else.

Should this be an Okay pattern?

## post by Balowen on Apr 24, 2024

Yes, I believe it’s very sensible to selectively choose which responses to rephrase. Being explicit about when to employ rephrasing can help manage performance while maintaining quality where it’s most needed.