nashsu / FreeAskInternet

FreeAskInternet is a completely free, PRIVATE and LOCALLY running search aggregator & answer generate using MULTI LLMs, without GPU needed. The user can ask a question and the system will make a multi engine search and combine the search result to LLM and generate the answer based on search results. It's all FREE to use.
Apache License 2.0
8.45k stars 879 forks source link

Conflicting Prompts Lead to Chinese-Only Answers #16

Open joeyame opened 5 months ago

joeyame commented 5 months ago

Here is a summary of the issue: image

In English, explain the rocket equation Chinese answer supplied

When I looked through the code to see what might cause this, I saw two main portions of the prompt written in Chinese.

If Google translate is correct, the first prompt states:

Unless it's a code, a specific name, or a reference number, the language of the answer should be the same as the question.

I agree with this

The second prompt states:

Responses must be in Chinese Simplified

In the end, the second prompt wins because all responses are in Chinese Simplified. Which, if you want to open up this project to the larger community, keeping the same language as the question should be preferred.

ibrahimkettaneh commented 5 months ago

Yes please

alok-debnath commented 5 months ago

is there any workaround for now?

joeyame commented 5 months ago

@alok-debnath - not for free, but with a small amount of work, yeah it's possible. Follow these steps:

  1. In the docker-compose.yaml file, set it to build the image instead of pulling from dockerhub:

    backend:
    # image: docker.io/nashsu/free_ask_internet:latest
    image: joey/free_ask_internet
    build: .
    depends_on:
      - freegpt35
    restart: on-failure

    The name of the image really does not matter.

  2. In free_ask_internet.py:127 replace:

    记住,不要一字不差的重复上下文内容. 回答必须使用简体中文,如果回答很长,请尽量结构化、分段落总结。 下面是用户问题

with

Remember, don't repeat contextual content word for word. If the answers are long, try to be structured and summarized in paragraphs. Here is the user's question:

  1. Now you'll run docker-compose up --build. Rerun with any other changes that you make.

    You can put whatever you want into the prompt, but I just translated the Chinese into English and removed the phrase that said "answers must be in Chinese Simplified"

Myzel394 commented 5 months ago

Also make sure to replace in free_ask_internet.py:114:

        您是一位由 nash_su 开发的基于搜索引擎返回内容的AI问答助手。您将被提供一个用户问题,并需要撰写一个清晰、简洁且准确的答案。答案必须正确、精确,并以专家的中立和职业语气撰写。请将答案限制在2000个标记内。不要提供与问题无关的信息,也不要重复。如果给出的上下文信息不足,请在相关主题后写上“信息缺失:”。除非是代码、特定的名称或引用编号,答案的语言应与问题相同。以下是上下文的内容集:

with:

        You are an AI quiz assistant based on content returned by a search engine. You will be provided with a user question and will be required to write a clear, concise and accurate answer. The answer must be correct, precise and written in an expert neutral and professional tone. Please limit your answer to 2000 markers. Do not provide information that is not relevant to the question and do not repeat yourself. If insufficient contextual information is given, write "Information missing:" after the relevant topic. The language of the answer should be the same as the question, unless it is a code, a specific name, or a citation number. Below is the content set for the context:

(note that I used deepl.com to translate this)

alok-debnath commented 5 months ago

@joeyame @Myzel394 Thanks it worked