diff --git a/applications/ColossalQA/colossalqa/chain/retrieval_qa/base.py b/applications/ColossalQA/colossalqa/chain/retrieval_qa/base.py index e80befdac..a6e87e6be 100644 --- a/applications/ColossalQA/colossalqa/chain/retrieval_qa/base.py +++ b/applications/ColossalQA/colossalqa/chain/retrieval_qa/base.py @@ -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}) diff --git a/applications/ColossalQA/colossalqa/prompt/prompt.py b/applications/ColossalQA/colossalqa/prompt/prompt.py index 533f0bd55..d62249ba9 100644 --- a/applications/ColossalQA/colossalqa/prompt/prompt.py +++ b/applications/ColossalQA/colossalqa/prompt/prompt.py @@ -75,7 +75,7 @@ Assistant: 我认识一个叫张三的人 # Below are English retrieval qa prompts _EN_RETRIEVAL_QA_PROMPT = """[INST] <>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.".<> +If the answer cannot be inferred based on the given context, please say "I cannot answer the question based on the information given.".<> 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} diff --git a/applications/ColossalQA/colossalqa/retrieval_conversation_en.py b/applications/ColossalQA/colossalqa/retrieval_conversation_en.py index d2626321d..96bce82b9 100644 --- a/applications/ColossalQA/colossalqa/retrieval_conversation_en.py +++ b/applications/ColossalQA/colossalqa/retrieval_conversation_en.py @@ -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, diff --git a/applications/ColossalQA/colossalqa/retrieval_conversation_universal.py b/applications/ColossalQA/colossalqa/retrieval_conversation_universal.py index 76bec715f..b23058d6d 100644 --- a/applications/ColossalQA/colossalqa/retrieval_conversation_universal.py +++ b/applications/ColossalQA/colossalqa/retrieval_conversation_universal.py @@ -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 diff --git a/applications/ColossalQA/colossalqa/retrieval_conversation_zh.py b/applications/ColossalQA/colossalqa/retrieval_conversation_zh.py index 484be21c1..4eef41947 100644 --- a/applications/ColossalQA/colossalqa/retrieval_conversation_zh.py +++ b/applications/ColossalQA/colossalqa/retrieval_conversation_zh.py @@ -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, diff --git a/applications/ColossalQA/examples/retrieval_conversation_chatgpt.py b/applications/ColossalQA/examples/retrieval_conversation_chatgpt.py index 00b920d27..1042adbf2 100644 --- a/applications/ColossalQA/examples/retrieval_conversation_chatgpt.py +++ b/applications/ColossalQA/examples/retrieval_conversation_chatgpt.py @@ -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: diff --git a/applications/ColossalQA/examples/retrieval_conversation_en.py b/applications/ColossalQA/examples/retrieval_conversation_en.py index e0fe46ae6..fe2b9b4db 100644 --- a/applications/ColossalQA/examples/retrieval_conversation_en.py +++ b/applications/ColossalQA/examples/retrieval_conversation_en.py @@ -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] diff --git a/applications/ColossalQA/examples/retrieval_conversation_en_customer_service.py b/applications/ColossalQA/examples/retrieval_conversation_en_customer_service.py index d98a75592..d4ba73b94 100644 --- a/applications/ColossalQA/examples/retrieval_conversation_en_customer_service.py +++ b/applications/ColossalQA/examples/retrieval_conversation_en_customer_service.py @@ -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] diff --git a/applications/ColossalQA/examples/retrieval_conversation_universal.py b/applications/ColossalQA/examples/retrieval_conversation_universal.py index 361aa9833..5d13a63c3 100644 --- a/applications/ColossalQA/examples/retrieval_conversation_universal.py +++ b/applications/ColossalQA/examples/retrieval_conversation_universal.py @@ -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, diff --git a/applications/ColossalQA/examples/retrieval_conversation_zh.py b/applications/ColossalQA/examples/retrieval_conversation_zh.py index cbbbefad7..b143b9baa 100644 --- a/applications/ColossalQA/examples/retrieval_conversation_zh.py +++ b/applications/ColossalQA/examples/retrieval_conversation_zh.py @@ -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}") diff --git a/applications/ColossalQA/examples/webui_demo/RAG_ChatBot.py b/applications/ColossalQA/examples/webui_demo/RAG_ChatBot.py index c58be9c33..526328dda 100644 --- a/applications/ColossalQA/examples/webui_demo/RAG_ChatBot.py +++ b/applications/ColossalQA/examples/webui_demo/RAG_ChatBot.py @@ -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 diff --git a/colossalai/inference/README.md b/colossalai/inference/README.md index dfac7cfd9..287853a86 100644 --- a/colossalai/inference/README.md +++ b/colossalai/inference/README.md @@ -89,7 +89,7 @@ docker pull hpcaitech/colossalai-inference:v2 docker run -it --gpus all --name ANY_NAME -v $PWD:/workspace -w /workspace hpcaitech/colossalai-inference:v2 /bin/bash # enter into docker container -cd /path/to/CollossalAI +cd /path/to/ColossalAI pip install -e . ``` diff --git a/colossalai/legacy/inference/README.md b/colossalai/legacy/inference/README.md index f466f46c1..63b5f2a75 100644 --- a/colossalai/legacy/inference/README.md +++ b/colossalai/legacy/inference/README.md @@ -86,7 +86,7 @@ docker pull hpcaitech/colossalai-inference:v2 docker run -it --gpus all --name ANY_NAME -v $PWD:/workspace -w /workspace hpcaitech/colossalai-inference:v2 /bin/bash # enter into docker container -cd /path/to/CollossalAI +cd /path/to/ColossalAI pip install -e . # install lightllm diff --git a/colossalai/legacy/inference/hybridengine/engine.py b/colossalai/legacy/inference/hybridengine/engine.py index bb0b4c77a..bc4e4fd19 100644 --- a/colossalai/legacy/inference/hybridengine/engine.py +++ b/colossalai/legacy/inference/hybridengine/engine.py @@ -46,7 +46,7 @@ class CaiInferEngine: model = LlamaForCausalLM.from_pretrained("your_path_to_model") tokenizer = LlamaTokenizer.from_pretrained("/home/lczyh/share/models/llama-7b-hf") - # assume the model is infered with 2 pipeline stages + # assume the model is inferred with 2 pipeline stages inferengine = CaiInferEngine(pp_size=2, model=model, model_policy=LlamaModelInferPolicy()) input = ["Introduce a landmark in China ","Introduce a landmark in China "] @@ -70,7 +70,7 @@ class CaiInferEngine: max_input_len: int = 32, max_output_len: int = 32, verbose: bool = False, - # TODO: implement early_stopping, and various gerneration options + # TODO: implement early_stopping, and various generation options early_stopping: bool = False, do_sample: bool = False, num_beams: int = 1, diff --git a/colossalai/nn/optimizer/README.md b/colossalai/nn/optimizer/README.md index e89e6217d..d3f8badc7 100644 --- a/colossalai/nn/optimizer/README.md +++ b/colossalai/nn/optimizer/README.md @@ -47,7 +47,7 @@ be optimized jointly to further speed up training. 2. Model Accuracy - Communication Efficiency - - Reduce Volumn of Comm. + - Reduce Volume of Comm. - Reduce Frequency of Comm. - Memory Efficiency - Mix-Precision Training diff --git a/colossalai/pipeline/schedule/generate.py b/colossalai/pipeline/schedule/generate.py index d6a6aec63..48ae54c1f 100644 --- a/colossalai/pipeline/schedule/generate.py +++ b/colossalai/pipeline/schedule/generate.py @@ -164,7 +164,7 @@ class GenerateSchedule(PipelineSchedule): self.timestamps[self.mb_manager.idx].append(time.time()) assert ( "logits" in logits - ), f"When first stage in GENERATE phase, the ouput should have attribute `logits`, but has {logits.keys()}" + ), f"When first stage in GENERATE phase, the output should have attribute `logits`, but has {logits.keys()}" new_token = self._get_token_id(logits["logits"]) self.mb_manager.step(new_token) @@ -401,7 +401,7 @@ class GenerateSchedule(PipelineSchedule): self.timestamps[self.mb_manager.idx].append(time.time()) assert ( "logits" in logits - ), f"When first stage in GENERATE phase, the ouput should have attribute `logits`, but has {logits.keys()}" + ), f"When first stage in GENERATE phase, the output should have attribute `logits`, but has {logits.keys()}" new_token = self._get_token_id(logits["logits"]) self.mb_manager.step(new_token) # If the current micro batch is not DONE, go through blocks diff --git a/examples/images/diffusion/ldm/modules/diffusionmodules/openaimodel.py b/examples/images/diffusion/ldm/modules/diffusionmodules/openaimodel.py index 614fe510f..6c80f3229 100644 --- a/examples/images/diffusion/ldm/modules/diffusionmodules/openaimodel.py +++ b/examples/images/diffusion/ldm/modules/diffusionmodules/openaimodel.py @@ -338,7 +338,7 @@ def count_flops_attn(model, _x, y): class QKVAttentionLegacy(nn.Module): """ - A module which performs QKV attention. Matches legacy QKVAttention + input/ouput heads shaping + A module which performs QKV attention. Matches legacy QKVAttention + input/output heads shaping """ def __init__(self, n_heads):