From e4fc57c3de6204ac66df75aa1752db1ec284f31f Mon Sep 17 00:00:00 2001 From: digger yu Date: Fri, 15 Sep 2023 14:18:22 +0800 Subject: [PATCH] Optimized some syntax errors in the documentation and code under applications/ (#4127) Co-authored-by: flybird11111 <1829166702@qq.com> --- applications/Chat/README.md | 6 ++---- applications/Chat/coati/experience_maker/base.py | 2 +- applications/Chat/coati/models/lora.py | 2 +- applications/Chat/coati/ray/detached_replay_buffer.py | 2 +- applications/Chat/coati/ray/utils.py | 2 +- applications/Chat/evaluate/README.md | 2 +- applications/Chat/evaluate/gpt_evaluate.py | 8 ++++---- applications/Chat/examples/community/peft/README.md | 2 +- 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/applications/Chat/README.md b/applications/Chat/README.md index 5a1187ab503d..59e2c4548365 100644 --- a/applications/Chat/README.md +++ b/applications/Chat/README.md @@ -200,7 +200,6 @@ We provide an online inference server and a benchmark. We aim to run inference o We support 8-bit quantization (RTN), 4-bit quantization (GPTQ), and FP16 inference. Online inference server scripts can help you deploy your own services. - For more details, see [`inference/`](https://github.com/hpcaitech/ColossalAI/tree/main/applications/Chat/inference). ## Coati7B examples @@ -428,7 +427,7 @@ Thanks so much to all of our amazing contributors! -- An open-source low cost solution for cloning [ChatGPT](https://openai.com/blog/chatgpt/) with a complete RLHF pipeline. [[demo]](https://chat.colossalai.org) +- An open-source low-cost solution for cloning [ChatGPT](https://openai.com/blog/chatgpt/) with a complete RLHF pipeline. [[demo]](https://chat.colossalai.org)

@@ -469,8 +468,7 @@ Coati is developed by ColossalAI Team: - [ofey404](https://github.com/ofey404) - [Wenhao Chen](https://github.com/CWHer) -The Phd student from [(HPC-AI) Lab](https://ai.comp.nus.edu.sg/) also contributed a lot to this project. - +The PhD student from [(HPC-AI) Lab](https://ai.comp.nus.edu.sg/) also contributed a lot to this project. - [Zangwei Zheng](https://github.com/zhengzangw) - [Xue Fuzhao](https://github.com/XueFuzhao) diff --git a/applications/Chat/coati/experience_maker/base.py b/applications/Chat/coati/experience_maker/base.py index ff75852576c8..b4646f282f0c 100644 --- a/applications/Chat/coati/experience_maker/base.py +++ b/applications/Chat/coati/experience_maker/base.py @@ -10,7 +10,7 @@ @dataclass class Experience: """Experience is a batch of data. - These data should have the the sequence length and number of actions. + These data should have the sequence length and number of actions. Left padding for sequences is applied. Shapes of each tensor: diff --git a/applications/Chat/coati/models/lora.py b/applications/Chat/coati/models/lora.py index 546f675d7d37..f1597da540a7 100644 --- a/applications/Chat/coati/models/lora.py +++ b/applications/Chat/coati/models/lora.py @@ -48,7 +48,7 @@ def __init__( def reset_parameters(self): if hasattr(self, 'lora_A'): - # initialize A the same way as the default for nn.Linear and B to zero + # Initialize A with the default values for nn.Linear and set B to zero. nn.init.kaiming_uniform_(self.lora_A, a=math.sqrt(5)) nn.init.zeros_(self.lora_B) diff --git a/applications/Chat/coati/ray/detached_replay_buffer.py b/applications/Chat/coati/ray/detached_replay_buffer.py index 7b9df2ee139b..e04bf5ccb881 100644 --- a/applications/Chat/coati/ray/detached_replay_buffer.py +++ b/applications/Chat/coati/ray/detached_replay_buffer.py @@ -16,7 +16,7 @@ class DetachedReplayBuffer: ''' Detached replay buffer. Share Experience across workers on the same node. - Therefore a trainer node is expected to have only one instance. + Therefore, a trainer node is expected to have only one instance. It is ExperienceMakerHolder's duty to call append(exp) method, remotely. Args: diff --git a/applications/Chat/coati/ray/utils.py b/applications/Chat/coati/ray/utils.py index 761186b95ee5..391ffe7a91a9 100644 --- a/applications/Chat/coati/ray/utils.py +++ b/applications/Chat/coati/ray/utils.py @@ -116,7 +116,7 @@ def get_model_numel(model: nn.Module) -> int: def get_receivers_per_sender(sender_idx: int, num_senders: int, num_receivers: int, allow_idle_sender: bool) -> list: target_receivers = [] if num_senders <= num_receivers or allow_idle_sender: - # a sender will send data to one or more than one receivers + # a sender will send data to one or more receivers # a receiver only has one sender for i in range(num_receivers): if i % num_senders == sender_idx: diff --git a/applications/Chat/evaluate/README.md b/applications/Chat/evaluate/README.md index 68b03be16a30..0a97ae72f9d0 100644 --- a/applications/Chat/evaluate/README.md +++ b/applications/Chat/evaluate/README.md @@ -348,7 +348,7 @@ For example, if you want to add a new metric `persuasiveness` into category `bra

How can I add a new UniEval evaluation metric? -For example, if you want to add a new metric `persuasiveness` into task `data2text`, you should add a Boolean QA question about the metric in function `add_question` in `unieval/utils.py`. Please do note that how effectively the model would evaluate this metric is unknown and you may need some experiments to test whether the model is capable of evaluating this metric. +For example, if you want to add a new metric `persuasiveness` into task `data2text`, you should add a Boolean QA question about the metric in function `add_question` in `unieval/utils.py`. Please do note that how effectively the model would evaluate this metric is unknown, and you may need some experiments to test whether the model is capable of evaluating this metric. ```python if task == 'data2text': diff --git a/applications/Chat/evaluate/gpt_evaluate.py b/applications/Chat/evaluate/gpt_evaluate.py index f8cfb8d0f7e5..6fcbe63d0253 100644 --- a/applications/Chat/evaluate/gpt_evaluate.py +++ b/applications/Chat/evaluate/gpt_evaluate.py @@ -576,7 +576,7 @@ def calculate_scores_form_logprobs(logprobs: Dict[str, Any]) -> float: for key, value in logprobs.items(): # Sometimes the key will be one byte of a unicode character which takes the form of "bytes:\\xe7". - # It is meaningless and thus we don't calculate probability. + # It is meaningless, and thus we don't calculate probability. if "bytes" in key: continue # results[0] is the score which corresponds to the key(predicted token). @@ -621,7 +621,7 @@ def save_gpt_evaluation_results(model_name: str, gpt_evaluation_results: Dict[st Args: model_name: name of the model for saving evaluation results. - gpt_evaluation_results: evaluations results for all of the model answers. + gpt_evaluation_results: evaluations results for all the model answers. save_path: path to save GPT evaluation statistics. """ @@ -641,7 +641,7 @@ def save_gpt_evaluation_statistics(model_name: str, evaluations: List[Dict], sav Args: model_name: name of the model for saving statistics. - evaluations: evaluations for all of the model answers. + evaluations: evaluations for all the model answers. save_path: path to save GPT evaluation statistics. """ @@ -663,7 +663,7 @@ def save_gpt_evaluation_statistics(model_name: str, evaluations: List[Dict], sav for evaluation in data: for metric in metrics: if evaluation["evaluation"][metric] == {}: - # This means after 3 retries, the server still returns an error and we set the score to 0. + # This means after 3 retries, the server still returns an error, and we set the score to 0. scores[metric].append(0) elif evaluation["evaluation"][metric]["logprobs"] is not None: scores[metric].append( diff --git a/applications/Chat/examples/community/peft/README.md b/applications/Chat/examples/community/peft/README.md index 8b2edc48cd99..ada3a16296af 100644 --- a/applications/Chat/examples/community/peft/README.md +++ b/applications/Chat/examples/community/peft/README.md @@ -20,7 +20,7 @@ pip install . For SFT training, just call train_peft_sft.py -Its arguments are almost identical to train_sft.py instead adding a new eval_dataset if you have a eval_dataset file. The data file is just a plain datafile, please check the format in the easy_dataset.py. +Its arguments are almost identical to train_sft.py instead adding a new eval_dataset if you have an eval_dataset file. The data file is just a plain datafile, please check the format in the easy_dataset.py. For stage-3 rlhf training, call train_peft_prompts.py. Its arguments are almost identical to train_prompts.py. The only difference is that I use text files to indicate the prompt and pretrained data file. The models are included in easy_models.py. Currently only bloom models are tested, but technically gpt2/opt/llama should be supported.