Page MenuHomePhabricator

Enable multilingual prompting and responses based on wiki content language
Closed, ResolvedPublic

Description

Enable multilingual prompting and responses based on wiki content language.
There should be a config variable like

wgWandaUseContentLang = true;

which will let user decide whether to use content language.

A fallback logic should also be implemented to handle cases where the LLM does not have sufficient knowledge in the selected language.

Event Timeline

Techwizzie triaged this task as Medium priority.Oct 23 2025, 4:02 AM
Techwizzie updated the task description. (Show Details)

Change #1201076 had a related patch set uploaded (by Sanjai Siddharthan; author: Sanjai Siddharthan):

[mediawiki/extensions/Wanda@master] Enable multilingual prompting and responses based on wiki content language

https://gerrit.wikimedia.org/r/1201076

sanjaisid changed the task status from Open to In Progress.Nov 3 2025, 3:22 PM

Maybe there's no need for this setting, i.e. the additional LLM prompt "Please provide your answer in the language with code ..." should just always be added? I don't know if there would be a case where it's not a good idea to add this.

@Yaron_Koren Sounds good to me, I will work on the same to make it a default behaviour without that setting.

@Yaron_Koren I think we should use the user's interface language instead of the wiki's content language. If someone views the wiki with uselang=fr, they want everything in French including the chatbot and the response using content language would ignore the user's language preference. Can we use (useLang) or go with the ContentLang (MediaWikiServices::getInstance()->getContentLanguage()->getCode())

I do wonder about that. Given that, right now, Wanda is just basically doing a text search rather than using a vector database, is it even possible for the LLM to read and answer questions in language A about content that's in language B?

@Yaron_Koren
Let's assume we use user's language preference as discussed above,

Can: If the content is in Language A, indexed in Language A, and the question is asked in Language A, the response can be provided in Language B (the user's preferred language).

Cannot: If the content is in Language A, indexed in Language A, and the question is asked in Language B, the response cannot directly be given in Language B (the user's preferred language).

But we can achieve the "Cannot" case by instructing the LLM to translate the question from Language B (the user's preferred language) into Language A( contentLang) , text search the content in Language A, and then we can provide the response in Language B.

That translation thing sounds interesting! Could/should a prompt be added for that, if the user's language is different from the content language?

@Yaron_Koren Can i proceed with the translation approach ??

Sorry, that's really a question for @Techwizzie - it's his extension, I'm just a fan. :) From my perspective, though, I think this makes sense.

@sanjaisid Translation sounds like a good idea. If we have the patch with updated code, then we can test with edge cases and see if this works well.

@Techwizzie The translation approach works fine for English-script languages, but it doesn’t handle non-English scripts (contentLang in "ta" and questions are in "en" ). To resolve this issue, we can try on Multilingual vector search

Ref: https://www.elastic.co/search-labs/blog/multilingual-vector-search-e5-embedding-model

Sure, multilingual embedding is a good shot - but it might require embedding search support to be added separately for a general case. If you are interested in implementing embedding search support, you can work on T409851 before this maybe!

@Techwizzie The translation approach works fine for English-script languages, but it doesn’t handle non-English scripts (contentLang in "ta" and questions are in "en" ). To resolve this issue, we can try on Multilingual vector search

Ref: https://www.elastic.co/search-labs/blog/multilingual-vector-search-e5-embedding-model

Since T409851 is checked in now, I think it is the best time to iter back to this feature -it might be much easier with the updated code than earlier.

Change #1201076 abandoned by Sanjai Siddharthan:

[mediawiki/extensions/Wanda@master] Enable multilingual prompting and responses based on wiki content language

Reason:

New PR will be raised

https://gerrit.wikimedia.org/r/1201076

Change #1224138 had a related patch set uploaded (by Sanjai Siddharthan; author: Sanjai Siddharthan):

[mediawiki/extensions/Wanda@master] Enable Multilingual prompting and responses

https://gerrit.wikimedia.org/r/1224138

Change #1224138 merged by jenkins-bot:

[mediawiki/extensions/Wanda@master] Enable Multilingual prompting and responses

https://gerrit.wikimedia.org/r/1224138

Thanks for the patch!