mirror of
				https://github.com/hiyouga/LLaMA-Factory.git
				synced 2025-11-04 18:02:19 +08:00 
			
		
		
		
	[assets] update readme (#8529)
This commit is contained in:
		
							parent
							
								
									bede213da7
								
							
						
					
					
						commit
						906b31fd47
					
				
							
								
								
									
										19
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								README.md
									
									
									
									
									
								
							@ -5,7 +5,7 @@
 | 
			
		||||
[](https://github.com/hiyouga/LLaMA-Factory/graphs/contributors)
 | 
			
		||||
[](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml)
 | 
			
		||||
[](https://pypi.org/project/llamafactory/)
 | 
			
		||||
[](https://scholar.google.com/scholar?cites=12620864006390196564)
 | 
			
		||||
[](https://scholar.google.com/scholar?cites=12620864006390196564)
 | 
			
		||||
[](https://hub.docker.com/r/hiyouga/llamafactory/tags)
 | 
			
		||||
 | 
			
		||||
[](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             |
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								README_zh.md
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								README_zh.md
									
									
									
									
									
								
							@ -5,7 +5,7 @@
 | 
			
		||||
[](https://github.com/hiyouga/LLaMA-Factory/graphs/contributors)
 | 
			
		||||
[](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml)
 | 
			
		||||
[](https://pypi.org/project/llamafactory/)
 | 
			
		||||
[](https://scholar.google.com/scholar?cites=12620864006390196564)
 | 
			
		||||
[](https://scholar.google.com/scholar?cites=12620864006390196564)
 | 
			
		||||
[](https://hub.docker.com/r/hiyouga/llamafactory/tags)
 | 
			
		||||
 | 
			
		||||
[](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             |
 | 
			
		||||
 | 
			
		||||
@ -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]<sop>"]),
 | 
			
		||||
    stop_words=["<|user|>", "<|observation|>"],
 | 
			
		||||
    stop_words=["<|user|>", "<|observation|>", "</answer>"],
 | 
			
		||||
    efficient_eos=True,
 | 
			
		||||
    mm_plugin=get_mm_plugin(name="glm4v", image_token="<|image|>", video_token="<|video|>"),
 | 
			
		||||
    template_class=ReasoningTemplate,
 | 
			
		||||
    thought_words=("<think>", "</think>"),
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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 = (
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
 | 
			
		||||
@ -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):
 | 
			
		||||
 | 
			
		||||
@ -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 格式表示调用的参数。"
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user