diff --git a/README.md b/README.md index 6e6e2c2b..3ba18238 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![GitHub contributors](https://img.shields.io/github/contributors/hiyouga/LLaMA-Factory?color=orange)](https://github.com/hiyouga/LLaMA-Factory/graphs/contributors) [![GitHub workflow](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml/badge.svg)](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml) [![PyPI](https://img.shields.io/pypi/v/llamafactory)](https://pypi.org/project/llamafactory/) -[![Citation](https://img.shields.io/badge/citation-614-green)](https://scholar.google.com/scholar?cites=12620864006390196564) +[![Citation](https://img.shields.io/badge/citation-651-green)](https://scholar.google.com/scholar?cites=12620864006390196564) [![Docker Pulls](https://img.shields.io/docker/pulls/hiyouga/llamafactory)](https://hub.docker.com/r/hiyouga/llamafactory/tags) [![Twitter](https://img.shields.io/twitter/follow/llamafactory_ai)](https://twitter.com/llamafactory_ai) @@ -51,7 +51,8 @@ https://github.com/user-attachments/assets/3991a3a8-4276-4d30-9cab-4cb0c4b9b99e Choose your path: -- **Documentation**: https://llamafactory.readthedocs.io/en/latest/ +- **Documentation (WIP)**: https://llamafactory.readthedocs.io/en/latest/ +- **Documentation (AMD GPU)**: https://rocm.docs.amd.com/projects/ai-developer-hub/en/latest/notebooks/fine_tune/llama_factory_llama3.html - **Colab (free)**: https://colab.research.google.com/drive/1eRTPn37ltBbYsISy9Aw2NuI2Aq5CQrD9?usp=sharing - **Local machine**: Please refer to [usage](#getting-started) - **PAI-DSW (free trial)**: https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory @@ -98,10 +99,10 @@ Choose your path: ### Day-N Support for Fine-Tuning Cutting-Edge Models -| Support Date | Model Name | -| ------------ | ------------------------------------------------------------------ | -| Day 0 | Qwen3 / Qwen2.5-VL / Gemma 3 / GLM4.1V / InternLM 3 / MiniCPM-o-2.6| -| Day 1 | Llama 3 / GLM-4 / Mistral Small / PaliGemma2 / Llama 4 | +| Support Date | Model Name | +| ------------ | -------------------------------------------------------------------- | +| Day 0 | Qwen3 / Qwen2.5-VL / Gemma 3 / GLM-4.1V / InternLM 3 / MiniCPM-o-2.6 | +| Day 1 | Llama 3 / GLM-4 / Mistral Small / PaliGemma2 / Llama 4 | ## Blogs @@ -121,6 +122,8 @@ Choose your path: ## Changelog +[25/07/02] We supported fine-tuning the **[GLM-4.1V-9B-Thinking](https://github.com/THUDM/GLM-4.1V-Thinking)** model. Please install transformers from **main** branch to use. + [25/04/28] We supported fine-tuning the **[Qwen3](https://qwenlm.github.io/blog/qwen3/)** model family. [25/04/21] We supported the **[Muon](https://github.com/KellerJordan/Muon)** optimizer. See [examples](examples/README.md) for usage. Thank [@tianshijing](https://github.com/tianshijing)'s PR. @@ -264,9 +267,9 @@ Choose your path: | [Falcon](https://huggingface.co/tiiuae) | 7B/11B/40B/180B | falcon | | [Falcon-H1](https://huggingface.co/tiiuae) | 0.5B/1.5B/3B/7B/34B | falcon_h1 | | [Gemma/Gemma 2/CodeGemma](https://huggingface.co/google) | 2B/7B/9B/27B | gemma/gemma2 | -| [Gemma 3/Gemma 3n](https://huggingface.co/google) | 1B/4B/6B/8B/12B/27B | gemma3(n)/gemma (1B)| +| [Gemma 3/Gemma 3n](https://huggingface.co/google) | 1B/4B/6B/8B/12B/27B | gemma3/gemma3n | | [GLM-4/GLM-4-0414/GLM-Z1](https://huggingface.co/THUDM) | 9B/32B | glm4/glmz1 | -| [GLM-4.1V](https://huggingface.co/THUDM) | 9B | glm4v | +| [GLM-4.1V](https://huggingface.co/THUDM)* | 9B | glm4v | | [GPT-2](https://huggingface.co/openai-community) | 0.1B/0.4B/0.8B/1.5B | - | | [Granite 3.0-3.3](https://huggingface.co/ibm-granite) | 1B/2B/3B/8B | granite3 | | [Hunyuan](https://huggingface.co/tencent/) | 7B | hunyuan | diff --git a/README_zh.md b/README_zh.md index ddd4df3b..35d63d1e 100644 --- a/README_zh.md +++ b/README_zh.md @@ -5,7 +5,7 @@ [![GitHub contributors](https://img.shields.io/github/contributors/hiyouga/LLaMA-Factory?color=orange)](https://github.com/hiyouga/LLaMA-Factory/graphs/contributors) [![GitHub workflow](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml/badge.svg)](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml) [![PyPI](https://img.shields.io/pypi/v/llamafactory)](https://pypi.org/project/llamafactory/) -[![Citation](https://img.shields.io/badge/citation-614-green)](https://scholar.google.com/scholar?cites=12620864006390196564) +[![Citation](https://img.shields.io/badge/citation-651-green)](https://scholar.google.com/scholar?cites=12620864006390196564) [![Docker Pulls](https://img.shields.io/docker/pulls/hiyouga/llamafactory)](https://hub.docker.com/r/hiyouga/llamafactory/tags) [![Twitter](https://img.shields.io/twitter/follow/llamafactory_ai)](https://twitter.com/llamafactory_ai) @@ -52,6 +52,7 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc 选择你的打开方式: - **入门教程**:https://zhuanlan.zhihu.com/p/695287607 +- **微调视频教程**:https://www.bilibili.com/video/BV1djgRzxEts/ - **框架文档**:https://llamafactory.readthedocs.io/zh-cn/latest/ - **框架文档(昇腾 NPU)**:https://ascend.github.io/docs/sources/llamafactory/ - **Colab(免费)**:https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing @@ -100,10 +101,10 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc ### 最新模型的 Day-N 微调适配 -| 适配时间 | 模型名称 | -| ------------ | ------------------------------------------------------------------ | -| Day 0 | Qwen3 / Qwen2.5-VL / Gemma 3 / GLM4.1V / InternLM 3 / MiniCPM-o-2.6| -| Day 1 | Llama 3 / GLM-4 / Mistral Small / PaliGemma2 / Llama 4 | +| 适配时间 | 模型名称 | +| ------------ | -------------------------------------------------------------------- | +| Day 0 | Qwen3 / Qwen2.5-VL / Gemma 3 / GLM-4.1V / InternLM 3 / MiniCPM-o-2.6 | +| Day 1 | Llama 3 / GLM-4 / Mistral Small / PaliGemma2 / Llama 4 | ## 官方博客 @@ -123,6 +124,8 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc ## 更新日志 +[25/07/02] 我们支持了 **[GLM-4.1V-9B-Thinking](https://github.com/THUDM/GLM-4.1V-Thinking)** 模型的微调。请安装 transformers 的 main 分支版本以使用。 + [25/04/28] 我们支持了 **[Qwen3](https://qwenlm.github.io/blog/qwen3/)** 系列模型的微调。 [25/04/21] 我们支持了 **[Muon](https://github.com/KellerJordan/Muon)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。感谢 [@tianshijing](https://github.com/tianshijing) 的 PR。 @@ -266,9 +269,9 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc | [Falcon](https://huggingface.co/tiiuae) | 7B/11B/40B/180B | falcon | | [Falcon-H1](https://huggingface.co/tiiuae) | 0.5B/1.5B/3B/7B/34B | falcon_h1 | | [Gemma/Gemma 2/CodeGemma](https://huggingface.co/google) | 2B/7B/9B/27B | gemma/gemma2 | -| [Gemma 3/Gemma 3n](https://huggingface.co/google) | 1B/4B/6B/8B/12B/27B | gemma3(n)/gemma (1B)| +| [Gemma 3/Gemma 3n](https://huggingface.co/google) | 1B/4B/6B/8B/12B/27B | gemma3/gemma3n | | [GLM-4/GLM-4-0414/GLM-Z1](https://huggingface.co/THUDM) | 9B/32B | glm4/glmz1 | -| [GLM-4.1V](https://huggingface.co/THUDM) | 9B | glm4v | +| [GLM-4.1V](https://huggingface.co/THUDM)* | 9B | glm4v | | [GPT-2](https://huggingface.co/openai-community) | 0.1B/0.4B/0.8B/1.5B | - | | [Granite 3.0-3.3](https://huggingface.co/ibm-granite) | 1B/2B/3B/8B | granite3 | | [Hunyuan](https://huggingface.co/tencent/) | 7B | hunyuan | diff --git a/assets/wechat.jpg b/assets/wechat.jpg index 6e692cde..597ed8f2 100644 Binary files a/assets/wechat.jpg and b/assets/wechat.jpg differ diff --git a/src/llamafactory/data/template.py b/src/llamafactory/data/template.py index d8fae09d..56deb84e 100644 --- a/src/llamafactory/data/template.py +++ b/src/llamafactory/data/template.py @@ -1014,7 +1014,7 @@ register_template( ) -# part copied from glm4 template +# copied from glm4 template register_template( name="glm4v", format_user=StringFormatter(slots=["<|user|>\n{{content}}<|assistant|>"]), @@ -1024,11 +1024,10 @@ register_template( format_observation=StringFormatter(slots=["<|observation|>\n{{content}}<|assistant|>"]), format_tools=ToolFormatter(tool_format="glm4"), format_prefix=EmptyFormatter(slots=["[gMASK]"]), - stop_words=["<|user|>", "<|observation|>"], + stop_words=["<|user|>", "<|observation|>", ""], efficient_eos=True, mm_plugin=get_mm_plugin(name="glm4v", image_token="<|image|>", video_token="<|video|>"), template_class=ReasoningTemplate, - thought_words=("", ""), ) diff --git a/src/llamafactory/data/tool_utils.py b/src/llamafactory/data/tool_utils.py index 37856151..ee0245c4 100644 --- a/src/llamafactory/data/tool_utils.py +++ b/src/llamafactory/data/tool_utils.py @@ -38,8 +38,8 @@ DEFAULT_TOOL_PROMPT = ( ) GLM4_TOOL_PROMPT = ( - "你是一个名为 ChatGLM 的人工智能助手。你是基于智谱AI训练的语言模型 GLM-4 模型开发的," - "你的任务是针对用户的问题和要求提供适当的答复和支持。# 可用工具{tool_text}" + "你是一个名为 ChatGLM 的人工智能助手。你是基于智谱 AI 公司训练的语言模型 GLM-4 模型开发的," + "你的任务是针对用户的问题和要求提供适当的答复和支持。\n\n# 可用工具{tool_text}" ) LLAMA3_TOOL_PROMPT = ( diff --git a/src/llamafactory/extras/constants.py b/src/llamafactory/extras/constants.py index d57115a7..ac399a73 100644 --- a/src/llamafactory/extras/constants.py +++ b/src/llamafactory/extras/constants.py @@ -860,14 +860,14 @@ register_model_group( register_model_group( models={ - "GLM-4.1V-9B-Thinking": { - DownloadSource.DEFAULT: "THUDM/GLM-4.1V-9B-Thinking", - DownloadSource.MODELSCOPE: "ZhipuAI/GLM-4.1V-9B-Thinking", - }, "GLM-4.1V-9B-Base": { DownloadSource.DEFAULT: "THUDM/GLM-4.1V-9B-Base", DownloadSource.MODELSCOPE: "ZhipuAI/GLM-4.1V-9B-Base", }, + "GLM-4.1V-9B-Thinking": { + DownloadSource.DEFAULT: "THUDM/GLM-4.1V-9B-Thinking", + DownloadSource.MODELSCOPE: "ZhipuAI/GLM-4.1V-9B-Thinking", + }, }, template="glm4v", multimodal=True, diff --git a/src/llamafactory/webui/components/chatbot.py b/src/llamafactory/webui/components/chatbot.py index 53ac3e4e..b5ff5492 100644 --- a/src/llamafactory/webui/components/chatbot.py +++ b/src/llamafactory/webui/components/chatbot.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import inspect import json from typing import TYPE_CHECKING @@ -50,7 +51,14 @@ def create_chat_box( ) -> tuple["Component", "Component", dict[str, "Component"]]: lang = engine.manager.get_elem_by_id("top.lang") with gr.Column(visible=visible) as chat_box: - chatbot = gr.Chatbot(type="messages", show_copy_button=True) + kwargs = {} + if "show_copy_button" in inspect.signature(gr.Chatbot.__init__).parameters: + kwargs["show_copy_button"] = True + + if "resizable" in inspect.signature(gr.Chatbot.__init__).parameters: + kwargs["resizable"] = True + + chatbot = gr.Chatbot(type="messages", **kwargs) messages = gr.State([]) with gr.Row(): with gr.Column(scale=4): diff --git a/tests/data/test_formatter.py b/tests/data/test_formatter.py index 00b8c649..3ccb8bb3 100644 --- a/tests/data/test_formatter.py +++ b/tests/data/test_formatter.py @@ -110,8 +110,8 @@ def test_glm4_function_formatter(): def test_glm4_tool_formatter(): formatter = ToolFormatter(tool_format="glm4") assert formatter.apply(content=json.dumps(TOOLS)) == [ - "你是一个名为 ChatGLM 的人工智能助手。你是基于智谱AI训练的语言模型 GLM-4 模型开发的," - "你的任务是针对用户的问题和要求提供适当的答复和支持。# 可用工具\n\n" + "你是一个名为 ChatGLM 的人工智能助手。你是基于智谱 AI 公司训练的语言模型 GLM-4 模型开发的," + "你的任务是针对用户的问题和要求提供适当的答复和支持。\n\n# 可用工具\n\n" f"## test_tool\n\n{json.dumps(TOOLS[0], indent=4, ensure_ascii=False)}\n" "在调用上述函数时,请使用 Json 格式表示调用的参数。" ]