From 41086059b12ecb7827eb390294e315068ff9c2e6 Mon Sep 17 00:00:00 2001 From: hiyouga <467089858@qq.com> Date: Tue, 25 Jun 2024 01:15:19 +0800 Subject: [PATCH] tiny fix --- .dockerignore | 5 +++-- README.md | 10 ++++++---- README_zh.md | 6 ++++-- src/llamafactory/data/formatter.py | 2 +- src/llamafactory/data/template.py | 6 +++--- src/llamafactory/hparams/data_args.py | 8 ++++---- src/llamafactory/webui/components/train.py | 2 +- src/llamafactory/webui/runner.py | 2 +- 8 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.dockerignore b/.dockerignore index 2ac0e11d..75cd2209 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,10 +4,11 @@ .venv cache data +docker +examples +saves hf_cache output -examples .dockerignore .gitattributes .gitignore -Dockerfile diff --git a/README.md b/README.md index a20b848b..e1b45236 100644 --- a/README.md +++ b/README.md @@ -360,7 +360,7 @@ To enable FlashAttention-2 on the Windows platform, you need to install the prec
For Ascend NPU users -To install LLaMA Factory on Ascend NPU devices, please specify extra dependencies: `pip install -e '.[torch-npu,metrics]'`. Additionally, you need to install the **[Ascend CANN Toolkit and Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**. Please follow the [installation tutorial](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/600alphaX/softwareinstall/instg/atlasdeploy_03_0031.html) or use the following commands: +To install LLaMA Factory on Ascend NPU devices, please specify extra dependencies: `pip install -e ".[torch-npu,metrics]"`. Additionally, you need to install the **[Ascend CANN Toolkit and Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**. Please follow the [installation tutorial](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/600alphaX/softwareinstall/instg/atlasdeploy_03_0031.html) or use the following commands: ```bash # replace the url according to your CANN version and devices @@ -422,14 +422,16 @@ llamafactory-cli webui For CUDA users: ```bash -docker-compose -f ./docker/docker-cuda/docker-compose.yml up -d +cd docker/docker-cuda/ +docker-compose up -d docker-compose exec llamafactory bash ``` For Ascend NPU users: ```bash -docker-compose -f ./docker/docker-npu/docker-compose.yml up -d +cd docker/docker-npu/ +docker-compose up -d docker-compose exec llamafactory bash ``` @@ -461,7 +463,7 @@ docker exec -it llamafactory bash For Ascend NPU users: ```bash -# Change docker image upon your environment +# Choose docker image upon your environment docker build -f ./docker/docker-npu/Dockerfile \ --build-arg INSTALL_DEEPSPEED=false \ --build-arg PIP_INDEX=https://pypi.org/simple \ diff --git a/README_zh.md b/README_zh.md index 3bed0846..32edb1f7 100644 --- a/README_zh.md +++ b/README_zh.md @@ -422,14 +422,16 @@ llamafactory-cli webui CUDA 用户: ```bash -docker-compose -f ./docker/docker-cuda/docker-compose.yml up -d +cd docker/docker-cuda/ +docker-compose up -d docker-compose exec llamafactory bash ``` 昇腾 NPU 用户: ```bash -docker-compose -f ./docker/docker-npu/docker-compose.yml up -d +cd docker/docker-npu/ +docker-compose up -d docker-compose exec llamafactory bash ``` diff --git a/src/llamafactory/data/formatter.py b/src/llamafactory/data/formatter.py index b5dc57ff..88ebf682 100644 --- a/src/llamafactory/data/formatter.py +++ b/src/llamafactory/data/formatter.py @@ -216,7 +216,7 @@ class ToolFormatter(Formatter): self._tool_formatter = glm4_tool_formatter self._tool_extractor = glm4_tool_extractor else: - raise ValueError("Tool format was not found.") + raise NotImplementedError("Tool format {} was not found.".format(self.tool_format)) def apply(self, **kwargs) -> SLOTS: content = kwargs.pop("content") diff --git a/src/llamafactory/data/template.py b/src/llamafactory/data/template.py index 3a72a858..193ff482 100644 --- a/src/llamafactory/data/template.py +++ b/src/llamafactory/data/template.py @@ -387,8 +387,9 @@ def get_template_and_fix_tokenizer( template = TEMPLATES.get(name, None) if template is None: raise ValueError("Template {} does not exist.".format(name)) - - if tool_format: + + if tool_format is not None: + logger.info("Using tool format: {}.".format(tool_format)) template.format_tools = ToolFormatter(tool_format=tool_format) stop_words = template.stop_words @@ -625,7 +626,6 @@ _register_template( _register_template( name="empty", - format_prefix=EmptyFormatter(slots=[{"bos_token"}]), efficient_eos=True, ) diff --git a/src/llamafactory/hparams/data_args.py b/src/llamafactory/hparams/data_args.py index 959742e3..dad13820 100644 --- a/src/llamafactory/hparams/data_args.py +++ b/src/llamafactory/hparams/data_args.py @@ -29,10 +29,6 @@ class DataArguments: default=None, metadata={"help": "Which template to use for constructing prompts in training and inference."}, ) - tool_format: Optional[str] = field( - default=None, - metadata={"help": "Specifies the tool format template for function calling ."}, - ) dataset: Optional[str] = field( default=None, metadata={"help": "The name of provided dataset(s) to use. Use commas to separate multiple datasets."}, @@ -105,6 +101,10 @@ class DataArguments: "help": "Whether or not to pack the sequences in training. Will automatically enable in pre-training." }, ) + tool_format: Optional[str] = field( + default=None, + metadata={"help": "Tool format to use for constructing function calling examples."}, + ) tokenized_path: Optional[str] = field( default=None, metadata={"help": "Path to save or load the tokenized datasets."}, diff --git a/src/llamafactory/webui/components/train.py b/src/llamafactory/webui/components/train.py index 874f3c5e..f33c37ee 100644 --- a/src/llamafactory/webui/components/train.py +++ b/src/llamafactory/webui/components/train.py @@ -291,7 +291,7 @@ def create_train_tab(engine: "Engine") -> Dict[str, "Component"]: with gr.Column(scale=1): loss_viewer = gr.Plot() - input_elems.update({output_dir, config_path, device_count, ds_stage, ds_offload}) + input_elems.update({output_dir, config_path, ds_stage, ds_offload}) elem_dict.update( dict( cmd_preview_btn=cmd_preview_btn, diff --git a/src/llamafactory/webui/runner.py b/src/llamafactory/webui/runner.py index 6cd21b07..549ec765 100644 --- a/src/llamafactory/webui/runner.py +++ b/src/llamafactory/webui/runner.py @@ -306,7 +306,7 @@ class Runner: def _form_config_dict(self, data: Dict["Component", Any]) -> Dict[str, Any]: config_dict = {} - skip_ids = ["top.lang", "top.model_path", "train.output_dir", "train.config_path", "train.device_count"] + skip_ids = ["top.lang", "top.model_path", "train.output_dir", "train.config_path"] for elem, value in data.items(): elem_id = self.manager.get_id_by_elem(elem) if elem_id not in skip_ids: