mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-01 01:06:00 +00:00
[hotfix] fix typo s/keywrods/keywords etc. (#5429)
This commit is contained in:
@@ -117,8 +117,8 @@ class CustomBaseRetrievalQA(BaseRetrievalQA):
|
||||
) = copy.deepcopy(buffered_history_backup), copy.deepcopy(summarized_history_temp_backup)
|
||||
|
||||
# if rejection_trigger_keywords is not given, return the response from LLM directly
|
||||
rejection_trigger_keywrods = inputs.get('rejection_trigger_keywrods', [])
|
||||
answer = answer if all([rej not in answer for rej in rejection_trigger_keywrods]) else None
|
||||
rejection_trigger_keywords = inputs.get('rejection_trigger_keywords', [])
|
||||
answer = answer if all([rej not in answer for rej in rejection_trigger_keywords]) else None
|
||||
if answer is None:
|
||||
answer = inputs.get('rejection_answer', "抱歉,根据提供的信息无法回答该问题。")
|
||||
if self.combine_documents_chain.memory is not None:
|
||||
@@ -161,8 +161,8 @@ class CustomBaseRetrievalQA(BaseRetrievalQA):
|
||||
input_documents=docs, question=question, callbacks=_run_manager.get_child(), **kwargs
|
||||
)
|
||||
# if rejection_trigger_keywords is not given, return the response from LLM directly
|
||||
rejection_trigger_keywrods = inputs.get('rejection_trigger_keywrods', [])
|
||||
answer = answer if all([rej not in answer for rej in rejection_trigger_keywrods]) or len(rejection_trigger_keywrods)==0 else None
|
||||
rejection_trigger_keywords = inputs.get('rejection_trigger_keywords', [])
|
||||
answer = answer if all([rej not in answer for rej in rejection_trigger_keywords]) or len(rejection_trigger_keywords)==0 else None
|
||||
if answer is None:
|
||||
answer = inputs.get('rejection_answer', "抱歉,根据提供的信息无法回答该问题。")
|
||||
self.combine_documents_chain.memory.save_context({"question": question}, {"output": answer})
|
||||
|
@@ -75,7 +75,7 @@ Assistant: 我认识一个叫张三的人
|
||||
# Below are English retrieval qa prompts
|
||||
|
||||
_EN_RETRIEVAL_QA_PROMPT = """[INST] <<SYS>>Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist content.
|
||||
If the answer cannot be infered based on the given context, please say "I cannot answer the question based on the information given.".<</SYS>>
|
||||
If the answer cannot be inferred based on the given context, please say "I cannot answer the question based on the information given.".<</SYS>>
|
||||
Use the context and chat history to answer the question.
|
||||
|
||||
context:
|
||||
@@ -97,8 +97,8 @@ Chat history:
|
||||
Human: I have a friend, Mike. Do you know him?
|
||||
Assistant: Yes, I know a person named Mike
|
||||
|
||||
sentence: What's his favorate food?
|
||||
disambiguated sentence: What's Mike's favorate food?
|
||||
sentence: What's his favorite food?
|
||||
disambiguated sentence: What's Mike's favorite food?
|
||||
[/INST]
|
||||
Chat history:
|
||||
{chat_history}
|
||||
|
@@ -80,7 +80,7 @@ class EnglishRetrievalConversation:
|
||||
self.retrieval_chain.run(
|
||||
query=user_input,
|
||||
stop=[self.memory.human_prefix + ": "],
|
||||
rejection_trigger_keywrods=["cannot answer the question"],
|
||||
rejection_trigger_keywords=["cannot answer the question"],
|
||||
rejection_answer="Sorry, this question cannot be answered based on the information provided.",
|
||||
).split("\n")[0],
|
||||
self.memory,
|
||||
|
@@ -103,7 +103,7 @@ class UniversalRetrievalConversation:
|
||||
break
|
||||
data_name = input("Enter a short description of the data:")
|
||||
separator = input(
|
||||
"Enter a separator to force separating text into chunks, if no separator is given, the defaut separator is '\\n\\n', press ENTER directly to skip:"
|
||||
"Enter a separator to force separating text into chunks, if no separator is given, the default separator is '\\n\\n', press ENTER directly to skip:"
|
||||
)
|
||||
separator = separator if separator != "" else "\n\n"
|
||||
retriever_data = DocumentLoader([[file, data_name.replace(" ", "_")]]).all_data
|
||||
|
@@ -87,7 +87,7 @@ class ChineseRetrievalConversation:
|
||||
query=user_input,
|
||||
stop=["</答案>"],
|
||||
doc_prefix="支持文档",
|
||||
rejection_trigger_keywrods=["无法回答该问题"],
|
||||
rejection_trigger_keywords=["无法回答该问题"],
|
||||
rejection_answer="抱歉,根据提供的信息无法回答该问题。",
|
||||
).split("\n")[0],
|
||||
self.memory,
|
||||
|
@@ -61,7 +61,7 @@ if __name__ == "__main__":
|
||||
information_retriever.add_documents(docs=documents, cleanup="incremental", mode="by_source", embedding=embedding)
|
||||
|
||||
prompt_template = """Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
|
||||
If the answer cannot be infered based on the given context, please don't share false information.
|
||||
If the answer cannot be inferred based on the given context, please don't share false information.
|
||||
Use the context and chat history to respond to the human's input at the end or carry on the conversation. You should generate one response only. No following up is needed.
|
||||
|
||||
context:
|
||||
|
@@ -67,7 +67,7 @@ if __name__ == "__main__":
|
||||
break
|
||||
data_name = input("Enter a short description of the data:")
|
||||
separator = input(
|
||||
"Enter a separator to force separating text into chunks, if no separator is given, the defaut separator is '\\n\\n'. Note that"
|
||||
"Enter a separator to force separating text into chunks, if no separator is given, the default separator is '\\n\\n'. Note that"
|
||||
+ "we use neural text spliter to split texts into chunks, the seperator only serves as a delimiter to force split long passage into"
|
||||
+ " chunks before passing to the neural network. Press ENTER directly to skip:"
|
||||
)
|
||||
@@ -112,7 +112,7 @@ if __name__ == "__main__":
|
||||
agent_response = retrieval_chain.run(
|
||||
query=user_input,
|
||||
stop=["Human: "],
|
||||
rejection_trigger_keywrods=EN_RETRIEVAL_QA_TRIGGER_KEYWORDS,
|
||||
rejection_trigger_keywords=EN_RETRIEVAL_QA_TRIGGER_KEYWORDS,
|
||||
rejection_answer=EN_RETRIEVAL_QA_REJECTION_ANSWER,
|
||||
)
|
||||
agent_response = agent_response.split("\n")[0]
|
||||
|
@@ -142,7 +142,7 @@ if __name__ == "__main__":
|
||||
agent_response = retrieval_chain.run(
|
||||
query=user_input,
|
||||
stop=["Human: "],
|
||||
rejection_trigger_keywrods=EN_RETRIEVAL_QA_TRIGGER_KEYWORDS,
|
||||
rejection_trigger_keywords=EN_RETRIEVAL_QA_TRIGGER_KEYWORDS,
|
||||
rejection_answer=EN_RETRIEVAL_QA_REJECTION_ANSWER,
|
||||
)
|
||||
agent_response = agent_response.split("\n")[0]
|
||||
|
@@ -11,7 +11,7 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--sql_file_path', type=str, default=None, help='path to the a empty folder for storing sql files for indexing')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Will ask for documents path in runnning time
|
||||
# Will ask for documents path in running time
|
||||
session = UniversalRetrievalConversation(files_en=None,
|
||||
files_zh=None,
|
||||
zh_model_path=args.zh_model_path, en_model_path=args.en_model_path,
|
||||
|
@@ -107,7 +107,7 @@ if __name__ == "__main__":
|
||||
query=user_input,
|
||||
stop=["</答案>"],
|
||||
doc_prefix="支持文档",
|
||||
rejection_trigger_keywrods=ZH_RETRIEVAL_QA_TRIGGER_KEYWORDS,
|
||||
rejection_trigger_keywords=ZH_RETRIEVAL_QA_TRIGGER_KEYWORDS,
|
||||
rejection_answer=ZH_RETRIEVAL_QA_REJECTION_ANSWER,
|
||||
)
|
||||
print(f"Agent: {agent_response}")
|
||||
|
@@ -140,7 +140,7 @@ class RAG_ChatBot:
|
||||
result = self.rag_chain.run(
|
||||
query=user_input,
|
||||
stop=[memory.human_prefix + ": "],
|
||||
rejection_trigger_keywrods=ZH_RETRIEVAL_QA_TRIGGER_KEYWORDS,
|
||||
rejection_trigger_keywords=ZH_RETRIEVAL_QA_TRIGGER_KEYWORDS,
|
||||
rejection_answer=ZH_RETRIEVAL_QA_REJECTION_ANSWER,
|
||||
)
|
||||
return result, memory
|
||||
|
Reference in New Issue
Block a user