Maki Nishikino commited on
Commit
41d8852
·
1 Parent(s): 50ccb6b
Files changed (4) hide show
  1. app.py +82 -0
  2. data/README_zh-CN.md +304 -0
  3. data/c.html +94 -0
  4. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
4
+ from llama_index.embeddings.huggingface import HuggingFaceEmbedding
5
+ from llama_index.legacy.callbacks import CallbackManager
6
+ from llama_index.llms.openai_like import OpenAILike
7
+
8
+ # Create an instance of CallbackManager
9
+ callback_manager = CallbackManager()
10
+
11
+ api_base_url = "https://internlm-chat.intern-ai.org.cn/puyu/api/v1/"
12
+ model = "internlm2.5-latest"
13
+ api_key = os.environ.get('API_KEY')
14
+
15
+
16
+ llm =OpenAILike(model=model, api_base=api_base_url, api_key=api_key, is_chat_model=True,callback_manager=callback_manager)
17
+
18
+ os.system('git lfs install')
19
+ os.system('git clone https://www.modelscope.cn/Ceceliachenen/paraphrase-multilingual-MiniLM-L12-v2.git')
20
+
21
+ st.set_page_config(page_title="llama_index_demo", page_icon="🦜🔗")
22
+ st.title("llama_index_demo")
23
+
24
+ # 初始化模型
25
+ @st.cache_resource
26
+ def init_models():
27
+ embed_model = HuggingFaceEmbedding(
28
+ model_name="/root/model/sentence-transformer"
29
+ )
30
+ Settings.embed_model = embed_model
31
+
32
+ #用初始化llm
33
+ Settings.llm = llm
34
+
35
+ documents = SimpleDirectoryReader("/root/llamaindex_demo/data").load_data()
36
+ index = VectorStoreIndex.from_documents(documents)
37
+ query_engine = index.as_query_engine()
38
+
39
+ return query_engine
40
+
41
+ # 检查是否需要初始化模型
42
+ if 'query_engine' not in st.session_state:
43
+ st.session_state['query_engine'] = init_models()
44
+
45
+ def greet2(question):
46
+ response = st.session_state['query_engine'].query(question)
47
+ return response
48
+
49
+
50
+ # Store LLM generated responses
51
+ if "messages" not in st.session_state.keys():
52
+ st.session_state.messages = [{"role": "assistant", "content": "你好,我是你的助手,有什么我可以帮助你的吗?"}]
53
+
54
+ # Display or clear chat messages
55
+ for message in st.session_state.messages:
56
+ with st.chat_message(message["role"]):
57
+ st.write(message["content"])
58
+
59
+ def clear_chat_history():
60
+ st.session_state.messages = [{"role": "assistant", "content": "你好,我是你的助手,有什么我可以帮助你的吗?"}]
61
+
62
+ st.sidebar.button('Clear Chat History', on_click=clear_chat_history)
63
+
64
+ # Function for generating LLaMA2 response
65
+ def generate_llama_index_response(prompt_input):
66
+ return greet2(prompt_input)
67
+
68
+ # User-provided prompt
69
+ if prompt := st.chat_input():
70
+ st.session_state.messages.append({"role": "user", "content": prompt})
71
+ with st.chat_message("user"):
72
+ st.write(prompt)
73
+
74
+ # Gegenerate_llama_index_response last message is not from assistant
75
+ if st.session_state.messages[-1]["role"] != "assistant":
76
+ with st.chat_message("assistant"):
77
+ with st.spinner("Thinking..."):
78
+ response = generate_llama_index_response(prompt)
79
+ placeholder = st.empty()
80
+ placeholder.markdown(response)
81
+ message = {"role": "assistant", "content": response}
82
+ st.session_state.messages.append(message)
data/README_zh-CN.md ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+ <img src="https://github.com/InternLM/lmdeploy/assets/36994684/0cf8d00f-e86b-40ba-9b54-dc8f1bc6c8d8" width="600"/>
3
+ <br /><br />
4
+
5
+ [![GitHub Repo stars](https://img.shields.io/github/stars/InternLM/xtuner?style=social)](https://github.com/InternLM/xtuner/stargazers)
6
+ [![license](https://img.shields.io/github/license/InternLM/xtuner.svg)](https://github.com/InternLM/xtuner/blob/main/LICENSE)
7
+ [![PyPI](https://img.shields.io/pypi/v/xtuner)](https://pypi.org/project/xtuner/)
8
+ [![Downloads](https://static.pepy.tech/badge/xtuner)](https://pypi.org/project/xtuner/)
9
+ [![issue resolution](https://img.shields.io/github/issues-closed-raw/InternLM/xtuner)](https://github.com/InternLM/xtuner/issues)
10
+ [![open issues](https://img.shields.io/github/issues-raw/InternLM/xtuner)](https://github.com/InternLM/xtuner/issues)
11
+
12
+ 👋 加入我们:[![Static Badge](https://img.shields.io/badge/-grey?style=social&logo=wechat&label=微信)](https://cdn.vansin.top/internlm/xtuner.jpg)
13
+ [![Static Badge](https://img.shields.io/badge/-grey?style=social&logo=twitter&label=推特)](https://twitter.com/intern_lm)
14
+ [![Static Badge](https://img.shields.io/badge/-grey?style=social&logo=discord&label=Discord)](https://discord.gg/xa29JuW87d)
15
+
16
+ 🔍 探索我们的模型:
17
+ [![Static Badge](https://img.shields.io/badge/-gery?style=social&label=🤗%20Huggingface)](https://huggingface.co/xtuner)
18
+ [![Static Badge](https://img.shields.io/badge/-gery?style=social&label=🤖%20ModelScope)](https://www.modelscope.cn/organization/xtuner)
19
+ [![Static Badge](https://img.shields.io/badge/-gery?style=social&label=🧰%20OpenXLab)](https://openxlab.org.cn/usercenter/xtuner)
20
+ [![Static Badge](https://img.shields.io/badge/-gery?style=social&label=🧠%20WiseModel)](https://www.wisemodel.cn/organization/xtuner)
21
+
22
+ [English](README.md) | 简体中文
23
+
24
+ </div>
25
+
26
+ ## 🚀 Speed Benchmark
27
+
28
+ - XTuner 与 LLaMA-Factory 在 Llama2-7B 模型上的训练效率对比
29
+
30
+ <div align=center>
31
+ <img src="https://github.com/InternLM/xtuner/assets/41630003/9c9dfdf4-1efb-4daf-84bf-7c379ae40b8b" style="width:80%">
32
+ </div>
33
+
34
+ - XTuner 与 LLaMA-Factory 在 Llama2-70B 模型上的训练效率对比
35
+
36
+ <div align=center>
37
+ <img src="https://github.com/InternLM/xtuner/assets/41630003/5ba973b8-8885-4b72-b51b-c69fa1583bdd" style="width:80%">
38
+ </div>
39
+
40
+ ## 🎉 更新
41
+ - **\[2024/07\]** 支持 [MiniCPM](xtuner/configs/minicpm/) 模型!
42
+ - **\[2024/07\]** 支持训练 [DPO](https://github.com/InternLM/xtuner/tree/main/xtuner/configs/dpo), [ORPO](https://github.com/InternLM/xtuner/tree/main/xtuner/configs/orpo) 还有 [Reward Model](https://github.com/InternLM/xtuner/tree/main/xtuner/configs/reward_model) ! 并且能够支持打包数据以及序列并行功能! 请参考 [文档](https://xtuner.readthedocs.io/zh-cn/latest/dpo/overview.html) 了解更多信息。
43
+ - **\[2024/07\]** 支持 [InternLM 2.5](xtuner/configs/internlm/internlm2_5_chat_7b/) 模型!
44
+ - **\[2024/06\]** 支持 [DeepSeek V2](xtuner/configs/deepseek/deepseek_v2_chat/) models! **训练速度提升一倍!**
45
+ - **\[2024/04\]** 多模态大模型 [LLaVA-Phi-3-mini](https://huggingface.co/xtuner/llava-phi-3-mini-hf) 发布!快速开始请查阅此[文档](xtuner/configs/llava/phi3_mini_4k_instruct_clip_vit_large_p14_336)!
46
+ - **\[2024/04\]** 多模态大模型 [LLaVA-Llama-3-8B](https://huggingface.co/xtuner/llava-llama-3-8b) 和 [LLaVA-Llama-3-8B-v1.1](https://huggingface.co/xtuner/llava-llama-3-8b-v1_1) 发布!快速开始请查阅此[文档](xtuner/configs/llava/llama3_8b_instruct_clip_vit_large_p14_336)!
47
+ - **\[2024/04\]** 支持 [Llama 3](xtuner/configs/llama) 模型!
48
+ - **\[2024/04\]** 支持序列并行训练策略以实现语言模型超长上下文训练!\[[文档](https://github.com/InternLM/xtuner/blob/docs/docs/zh_cn/acceleration/train_extreme_long_sequence.rst)\] \[[速度基准](https://github.com/InternLM/xtuner/blob/docs/docs/zh_cn/acceleration/benchmark.rst)\]
49
+ - **\[2024/02\]** 支持 [Gemma](xtuner/configs/gemma) 模型!
50
+ - **\[2024/02\]** 支持 [Qwen1.5](xtuner/configs/qwen/qwen1_5) 模型!
51
+ - **\[2024/01\]** 支持 [InternLM2](xtuner/configs/internlm) 模型!同时,最新版的多模态大模型 [LLaVA-Internlm2-7B](https://huggingface.co/xtuner/llava-internlm2-7b) / [20B](https://huggingface.co/xtuner/llava-internlm2-20b) 发布,其表现出强大的性能!
52
+ - **\[2024/01\]** 支持 [DeepSeek-MoE](https://huggingface.co/deepseek-ai/deepseek-moe-16b-chat) 模型!20GB 显存即可实现 QLoRA 微调,4x80GB 即可实现全参数微调。快速开始请查阅相关[配置文件](xtuner/configs/deepseek/)!
53
+ - **\[2023/12\]** 🔥 支持多模态模型 VLM([LLaVA-v1.5](https://github.com/haotian-liu/LLaVA))预训练和指令微调!快速开始请查阅此[文档](xtuner/configs/llava/README_zh-CN.md)!
54
+ - **\[2023/12\]** 🔥 支持 [Mixtral 8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1) 模型!快速开始请查阅此[文档](xtuner/configs/mixtral/README.md)!
55
+ - **\[2023/11\]** 支持 [ChatGLM3-6B](xtuner/configs/chatglm) 模型!
56
+ - **\[2023/10\]** 支持 [MSAgent-Bench](https://modelscope.cn/datasets/damo/MSAgent-Bench) 数据集,并且微调所得大语言模型可应用至 [Lagent](https://github.com/InternLM/lagent) 框架!
57
+ - **\[2023/10\]** 优化数据处理逻辑以兼容 `system` 字段,相关细节请查阅[文档](docs/zh_cn/user_guides/dataset_format.md)!
58
+ - **\[2023/09\]** 支持 [InternLM-20B](xtuner/configs/internlm) 系列模型!
59
+ - **\[2023/09\]** 支持 [Baichuan2](xtuner/configs/baichuan) 系列模型!
60
+ - **\[2023/08\]** XTuner 正式发布!众多微调模型已上传至 [HuggingFace](https://huggingface.co/xtuner)!
61
+
62
+ ## 📖 介绍
63
+
64
+ XTuner 是一个高效、灵活、全能的轻量化大模型微调工具库。
65
+
66
+ **高效**
67
+
68
+ - 支持大语言模型 LLM、多模态图文模型 VLM 的预训练及轻量级微调。XTuner 支持在 8GB 显存下微调 7B 模型,同时也支持多节点跨设备微调更大尺度模型(70B+)。
69
+ - 自动分发高性能算子(如 FlashAttention、Triton kernels 等)以加速训练吞吐。
70
+ - 兼容 [DeepSpeed](https://github.com/microsoft/DeepSpeed) 🚀,轻松应用各种 ZeRO 训练优化策略。
71
+
72
+ **灵活**
73
+
74
+ - 支持多种大语言模型,包括但不限于 [InternLM](https://huggingface.co/internlm)、[Mixtral-8x7B](https://huggingface.co/mistralai)、[Llama 2](https://huggingface.co/meta-llama)、[ChatGLM](https://huggingface.co/THUDM)、[Qwen](https://huggingface.co/Qwen)、[Baichuan](https://huggingface.co/baichuan-inc)。
75
+ - 支持多模态图文模型 LLaVA 的预训练与微调。利用 XTuner 训得模型 [LLaVA-InternLM2-20B](https://huggingface.co/xtuner/llava-internlm2-20b) 表现优异。
76
+ - 精心设计的数据管道,兼容任意数据格式,开源数据或自定义数据皆可快速上手。
77
+ - 支持 [QLoRA](http://arxiv.org/abs/2305.14314)、[LoRA](http://arxiv.org/abs/2106.09685)、全量参数微调等多种微调算法,支撑用户根据具体需求作出最优选择。
78
+
79
+ **全能**
80
+
81
+ - 支持增量预训练、指令微调与 Agent 微调。
82
+ - 预定义众多开源对话模版,支持与开源或训练所得模型进行对话。
83
+ - 训练所得模型可无缝接入部署工具库 [LMDeploy](https://github.com/InternLM/lmdeploy)、大规模评测工具库 [OpenCompass](https://github.com/open-compass/opencompass) 及 [VLMEvalKit](https://github.com/open-compass/VLMEvalKit)。
84
+
85
+ ## 🔥 支持列表
86
+
87
+ <table>
88
+ <tbody>
89
+ <tr align="center" valign="middle">
90
+ <td>
91
+ <b>模型</b>
92
+ </td>
93
+ <td>
94
+ <b>数据集</b>
95
+ </td>
96
+ <td>
97
+ <b>数据格式</b>
98
+ </td>
99
+ <td>
100
+ <b>微调算法</b>
101
+ </td>
102
+ </tr>
103
+ <tr valign="top">
104
+ <td align="left" valign="top">
105
+ <ul>
106
+ <li><a href="https://huggingface.co/internlm">InternLM 2 / 2.5</a></li>
107
+ <li><a href="https://huggingface.co/meta-llama">Llama 2 / 3</a></li>
108
+ <li><a href="https://huggingface.co/collections/microsoft/phi-3-6626e15e9585a200d2d761e3">Phi-3</a></li>
109
+ <li><a href="https://huggingface.co/THUDM/chatglm2-6b">ChatGLM2</a></li>
110
+ <li><a href="https://huggingface.co/THUDM/chatglm3-6b">ChatGLM3</a></li>
111
+ <li><a href="https://huggingface.co/Qwen/Qwen-7B">Qwen</a></li>
112
+ <li><a href="https://huggingface.co/baichuan-inc/Baichuan2-7B-Base">Baichuan2</a></li>
113
+ <li><a href="https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1">Mixtral</a></li>
114
+ <li><a href="https://huggingface.co/deepseek-ai/DeepSeek-V2-Chat">DeepSeek V2</a></li>
115
+ <li><a href="https://huggingface.co/google">Gemma</a></li>
116
+ <li><a href="https://huggingface.co/openbmb">MiniCPM</a></li>
117
+ <li>...</li>
118
+ </ul>
119
+ </td>
120
+ <td>
121
+ <ul>
122
+ <li><a href="https://modelscope.cn/datasets/damo/MSAgent-Bench">MSAgent-Bench</a></li>
123
+ <li><a href="https://huggingface.co/datasets/fnlp/moss-003-sft-data">MOSS-003-SFT</a> 🔧</li>
124
+ <li><a href="https://huggingface.co/datasets/tatsu-lab/alpaca">Alpaca en</a> / <a href="https://huggingface.co/datasets/silk-road/alpaca-data-gpt4-chinese">zh</a></li>
125
+ <li><a href="https://huggingface.co/datasets/WizardLM/WizardLM_evol_instruct_V2_196k">WizardLM</a></li>
126
+ <li><a href="https://huggingface.co/datasets/timdettmers/openassistant-guanaco">oasst1</a></li>
127
+ <li><a href="https://huggingface.co/datasets/garage-bAInd/Open-Platypus">Open-Platypus</a></li>
128
+ <li><a href="https://huggingface.co/datasets/HuggingFaceH4/CodeAlpaca_20K">Code Alpaca</a></li>
129
+ <li><a href="https://huggingface.co/datasets/burkelibbey/colors">Colorist</a> 🎨</li>
130
+ <li><a href="https://github.com/WangRongsheng/ChatGenTitle">Arxiv GenTitle</a></li>
131
+ <li><a href="https://github.com/LiuHC0428/LAW-GPT">Chinese Law</a></li>
132
+ <li><a href="https://huggingface.co/datasets/Open-Orca/OpenOrca">OpenOrca</a></li>
133
+ <li><a href="https://huggingface.co/datasets/shibing624/medical">Medical Dialogue</a></li>
134
+ <li>...</li>
135
+ </ul>
136
+ </td>
137
+ <td>
138
+ <ul>
139
+ <li><a href="docs/zh_cn/user_guides/incremental_pretraining.md">Incremental Pre-training</a> </li>
140
+ <li><a href="docs/zh_cn/user_guides/single_turn_conversation.md">Single-turn Conversation SFT</a> </li>
141
+ <li><a href="docs/zh_cn/user_guides/multi_turn_conversation.md">Multi-turn Conversation SFT</a> </li>
142
+ </ul>
143
+ </td>
144
+ <td>
145
+ <ul>
146
+ <li><a href="http://arxiv.org/abs/2305.14314">QLoRA</a></li>
147
+ <li><a href="http://arxiv.org/abs/2106.09685">LoRA</a></li>
148
+ <li>全量参数微调</li>
149
+ <li><a href="https://arxiv.org/abs/2305.18290">DPO</a></li>
150
+ <li><a href="https://arxiv.org/abs/2403.07691">ORPO</a></li>
151
+ <li>Reward Model</a></li>
152
+ </ul>
153
+ </td>
154
+ </tr>
155
+ </tbody>
156
+ </table>
157
+
158
+ ## 🛠️ 快速上手
159
+
160
+ ### 安装
161
+
162
+ - 推荐使用 conda 先构建一个 Python-3.10 的虚拟环境
163
+
164
+ ```bash
165
+ conda create --name xtuner-env python=3.10 -y
166
+ conda activate xtuner-env
167
+ ```
168
+
169
+ - 通过 pip 安装 XTuner:
170
+
171
+ ```shell
172
+ pip install -U xtuner
173
+ ```
174
+
175
+ 亦可集成 DeepSpeed 安装:
176
+
177
+ ```shell
178
+ pip install -U 'xtuner[deepspeed]'
179
+ ```
180
+
181
+ - 从源码安装 XTuner:
182
+
183
+ ```shell
184
+ git clone https://github.com/InternLM/xtuner.git
185
+ cd xtuner
186
+ pip install -e '.[all]'
187
+ ```
188
+
189
+ ### 微调
190
+
191
+ XTuner 支持微调大语言模型。数据集预处理指南请查阅[文档](./docs/zh_cn/user_guides/dataset_prepare.md)。
192
+
193
+ - **步骤 0**,准备配置文件。XTuner 提供多个开箱即用的配置文件,用户可以通过下列命令查看:
194
+
195
+ ```shell
196
+ xtuner list-cfg
197
+ ```
198
+
199
+ 或者,如果所提供的配置文件不能满足使用需求,请导出所提供的配置文件并进行相应更改:
200
+
201
+ ```shell
202
+ xtuner copy-cfg ${CONFIG_NAME} ${SAVE_PATH}
203
+ vi ${SAVE_PATH}/${CONFIG_NAME}_copy.py
204
+ ```
205
+
206
+ - **步骤 1**,开始微调。
207
+
208
+ ```shell
209
+ xtuner train ${CONFIG_NAME_OR_PATH}
210
+ ```
211
+
212
+ 例如,我们可以利用 QLoRA 算法在 oasst1 数据集上微调 InternLM2.5-Chat-7B:
213
+
214
+ ```shell
215
+ # 单卡
216
+ xtuner train internlm2_5_chat_7b_qlora_oasst1_e3 --deepspeed deepspeed_zero2
217
+ # 多卡
218
+ (DIST) NPROC_PER_NODE=${GPU_NUM} xtuner train internlm2_5_chat_7b_qlora_oasst1_e3 --deepspeed deepspeed_zero2
219
+ (SLURM) srun ${SRUN_ARGS} xtuner train internlm2_5_chat_7b_qlora_oasst1_e3 --launcher slurm --deepspeed deepspeed_zero2
220
+ ```
221
+
222
+ - `--deepspeed` 表示使用 [DeepSpeed](https://github.com/microsoft/DeepSpeed) 🚀 来优化训练过程。XTuner 内置了多种策略,包括 ZeRO-1、ZeRO-2、ZeRO-3 等。如果用户期望关闭此功能,请直接移除此参数。
223
+
224
+ - 更多示例,请查阅[文档](./docs/zh_cn/user_guides/finetune.md)。
225
+
226
+ - **步骤 2**,将保存的 PTH 模型(如果使用的DeepSpeed,则将会是一个文件夹)转换为 HuggingFace 模型:
227
+
228
+ ```shell
229
+ xtuner convert pth_to_hf ${CONFIG_NAME_OR_PATH} ${PTH} ${SAVE_PATH}
230
+ ```
231
+
232
+ ### 对话
233
+
234
+ XTuner 提供与大语言模型对话的工具。
235
+
236
+ ```shell
237
+ xtuner chat ${NAME_OR_PATH_TO_LLM} --adapter {NAME_OR_PATH_TO_ADAPTER} [optional arguments]
238
+ ```
239
+
240
+ 例如:
241
+
242
+ 与 InternLM2.5-Chat-7B 对话:
243
+
244
+ ```shell
245
+ xtuner chat internlm/internlm2-chat-7b --prompt-template internlm2_chat
246
+ ```
247
+
248
+ 更多示例,请查阅[文档](./docs/zh_cn/user_guides/chat.md)。
249
+
250
+ ### 部署
251
+
252
+ - **步骤 0**,将 HuggingFace adapter 合并到大语言模型:
253
+
254
+ ```shell
255
+ xtuner convert merge \
256
+ ${NAME_OR_PATH_TO_LLM} \
257
+ ${NAME_OR_PATH_TO_ADAPTER} \
258
+ ${SAVE_PATH} \
259
+ --max-shard-size 2GB
260
+ ```
261
+
262
+ - **步骤 1**,使用任意推理框架部署微调后的大语言模型,例如 [LMDeploy](https://github.com/InternLM/lmdeploy) 🚀:
263
+
264
+ ```shell
265
+ pip install lmdeploy
266
+ python -m lmdeploy.pytorch.chat ${NAME_OR_PATH_TO_LLM} \
267
+ --max_new_tokens 256 \
268
+ --temperture 0.8 \
269
+ --top_p 0.95 \
270
+ --seed 0
271
+ ```
272
+
273
+ 🔥 追求速度更快、显存占用更低的推理?欢迎体验 [LMDeploy](https://github.com/InternLM/lmdeploy) 提供的 4-bit 量化!使用指南请见[文档](https://github.com/InternLM/lmdeploy/tree/main#quantization)。
274
+
275
+ ### 评测
276
+
277
+ - 推荐使用一站式平台 [OpenCompass](https://github.com/InternLM/opencompass) 来评测大语言模型,其目前已涵盖 50+ 数据集的约 30 万条题目。
278
+
279
+ ## 🤝 贡献指南
280
+
281
+ 我们感谢所有的贡献者为改进和提升 XTuner 所作出的努力。请参考[贡献指南](.github/CONTRIBUTING.md)来了解参与项目贡献的相关指引。
282
+
283
+ ## 🎖️ 致谢
284
+
285
+ - [Llama 2](https://github.com/facebookresearch/llama)
286
+ - [DeepSpeed](https://github.com/microsoft/DeepSpeed)
287
+ - [QLoRA](https://github.com/artidoro/qlora)
288
+ - [LMDeploy](https://github.com/InternLM/lmdeploy)
289
+ - [LLaVA](https://github.com/haotian-liu/LLaVA)
290
+
291
+ ## 🖊️ 引用
292
+
293
+ ```bibtex
294
+ @misc{2023xtuner,
295
+ title={XTuner: A Toolkit for Efficiently Fine-tuning LLM},
296
+ author={XTuner Contributors},
297
+ howpublished = {\url{https://github.com/InternLM/xtuner}},
298
+ year={2023}
299
+ }
300
+ ```
301
+
302
+ ## 开源许可证
303
+
304
+ 该项目采用 [Apache License 2.0 开源许可证](LICENSE)。同时,请遵守所使用的模型与数据集的许可证。
data/c.html ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html><html><head><meta name="source" content="新华网"> <meta name="publishdate" content="2024-10-08"> <meta name="contentid" content="20241008c5aff4c9f7564a4c96d80d714fba74c8"> <meta name="subject" content=""> <meta name="catalogs" content="01002003030"> <meta name="author" content=""> <meta name="publishedtype" content="1"> <meta name="filetype" content="0"> <meta name="pagetype" content="1"> <meta name="templateId" content="d2b039de7f564c3882858a6a1655f8c1"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta content="telephone=no" name="format-detection"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" name="viewport"> <div data="datasource:20241008c5aff4c9f7564a4c96d80d714fba74c8" datatype="content"><meta name="keywords" content="诺贝尔物理学奖"></div> <div data="datasource:20241008c5aff4c9f7564a4c96d80d714fba74c8" datatype="content"><meta name="description" content="两名科学家因机器学习方面的贡献分享2024年诺贝尔物理学奖-"></div> <title data="datasource:20241008c5aff4c9f7564a4c96d80d714fba74c8" datatype="content">
2
+ 两名科学家因机器学习方面的贡献分享2024年诺贝尔物理学奖-新华网
3
+ </title> <link rel="stylesheet" href="//lib.news.cn/common/reset.css"> <link rel="stylesheet" href="//lib.news.cn/swiper/swiper3.4.2/swiper.min.css"> <link rel="stylesheet" href="//www.news.cn/2021detail/css/detail2023.css"> <link rel="stylesheet" href="//www.news.cn/detail/css/cb_videoPlayer.css"> <script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> <script src="//lib.news.cn/common/share.js"></script> <script src="//lib.news.cn/jquery/jquery1.12.4/jquery.min.js"></script> <style>
4
+ #sdgc .list-item {
5
+ margin-bottom: 17px;
6
+ padding-bottom: 12px;
7
+ height: 80px;
8
+ -webkit-box-sizing: border-box;
9
+ -moz-box-sizing: border-box;
10
+ box-sizing: border-box;
11
+ border-bottom: 1px dotted #999
12
+ }
13
+
14
+ #sdgc .list-item .img {
15
+ width: 120px;
16
+ height: 67px;
17
+ float: left;
18
+ margin-right: 10px;
19
+ overflow: hidden
20
+ }
21
+
22
+ #sdgc .list-item .img img {
23
+ width: 100%;
24
+ height: 100%
25
+ }
26
+
27
+ #sdgc .list-item .tit a {
28
+ display: block;
29
+ font-size: 15px;
30
+ line-height: 22px;
31
+ height: 44px;
32
+ margin-bottom: 2px;
33
+ margin-top: -5px;
34
+ color: #333
35
+ }
36
+
37
+ #sdgc .list-item .tit span {
38
+ display: inline-block;
39
+ padding: 0 5px;
40
+ font-size: 13px;
41
+ line-height: 17px;
42
+ background: #e30000;
43
+ color: #fff
44
+ }
45
+
46
+ #sdgc .list-item .tit span a {
47
+ height: auto;
48
+ font-size: 13px;
49
+ line-height: 17px;
50
+ display: inline-block;
51
+ background: #e30000;
52
+ color: #fff
53
+ }
54
+ </style></head> <div class="fix-ewm domPC" data="datasource:20241008c5aff4c9f7564a4c96d80d714fba74c8" datatype="content"><img src="//www.news.cn/detail2020/images/ewm.png" width="94" alt=""> <div class="fxd"><span class="fxd-wx"></span> <a href="javascript:void(0)" class="fxd-wb"></a> <span class="fxd-xcx"></span> <span class="fxd-khd"></span> <div class="fxd-wx-ewm"><img src="zxcode_20241008c5aff4c9f7564a4c96d80d714fba74c8.jpg"></div> <div class="fxd-xcx-ewm"><img></div> <div class="fxd-khd-ewm"><img src="//www.news.cn/2021detail/images/qrcode-app.png"></div></div></div> <div class="domPC"><script src="//www.news.cn/2021homepro/scripts/smallTop.js"></script></div> <div class="domMobile"><script src="//www.news.cn/2021mobile/scripts/toppx.js"></script></div> <div class="topAd"><div class="domPC"><ins data-ycad-slot="2166"></ins></div> <div class="domPC"><ins data-ycad-slot="2167"></ins></div></div> <div class="header domPC" data="datasource:20241008c5aff4c9f7564a4c96d80d714fba74c8" datatype="content"><div class="header-top clearfix"><div class="header-nav left"><a href="//www.news.cn/" target="_blank">新华网</a> &gt; <a class="curColumn"></a> &gt; 正文</div></div> <div class="header-cont clearfix"><div class="header-time left"><span class="year"><em>2024</em></span> <span class="day"><em>10</em>/<em>08</em></span> <span class="time">21:27:54</span></div> <div class="source">来源:新华网
55
+ </div> <div class="head-line clearfix"><h1><span class="title">两名科学家因机器学习方面的贡献分享2024年诺贝尔物理学奖</span> <span class="btn-audio"></span></h1> <audio id="audioDom" loop="loop" src="" class="hide"></audio> <div class="pageShare"><div class="setFont">字体:
56
+ <span id="fontSmall">小</span> <span id="fontNormal" class="active">中</span> <span id="fontBig">大</span></div> <div class="share">分享到:<a href="javascript:void(0)" class="wx"></a><a href="javascript:void(0)" class="wb"></a><a href="javascript:void(0)" class="xcx"></a><a href="javascript:void(0)" class="khd"></a> <div class="wx-ewm"><img src="zxcode_20241008c5aff4c9f7564a4c96d80d714fba74c8.jpg"></div> <div class="xcx-ewm"><img></div> <div class="khd-ewm"><img src="//www.news.cn/2021detail/images/qrcode-app.png"></div></div></div></div></div></div> <div class="adv domMob"><div class="advCont" style="display:none"><ins data-ycad-slot="2305"></ins></div> <div class="advShow"></div></div> <div class="mheader domMobile" data="datasource:20241008c5aff4c9f7564a4c96d80d714fba74c8" datatype="content"><h1><span class="title">两名科学家因机器学习方面的贡献分享2024年诺贝尔物理学奖</span></h1> <div class="info">
57
+ 2024-10-08 21:27:54
58
+ <span>
59
+ 来源:新华网
60
+ </span></div></div> <div class="main clearfix"><div class="main-left left"><div id="detail" data="datasource:20241008c5aff4c9f7564a4c96d80d714fba74c8" datatype="content"><span id="detailContent"><p style="text-align: center;"><span class="pageVideo" width="640" video_width="1280" video_height="720" poster="https://vodpub6.v.news.cn/yqfbzx-original/20241009/image/94f6092c-8bba-49f9-a4d6-b6721d6a81d5.jpg" video_src="https://vodpub6.v.news.cn/yqfbzx-original/20241009/ef59a70b73c0429d9cfcb72d804e46e3.mp4"></span></p><p>&emsp;&emsp;新华社斯德哥尔摩10月8日电(记者郭爽)瑞典皇家科学院8日宣布,将2024年诺贝尔物理学奖授予美国科学家约翰·霍普菲尔德和英国裔加拿大科学家杰弗里·欣顿,以表彰他们在使用人工神经网络的机器学习方面的基础性发现和发明。</p><p><img id="CYN2JagfZ2HL8jmQQh" style="margin: 0 auto; display: block; float: none;" src="yFdtJqQwdp7AU8Rv.jpg" align="center" data-material-id="202410082217803" data-name="202410085e2aad4696d444de8f2e39f78bf65d75.jpg"></p><p>&emsp;&emsp;<span style="font-family: 楷体; color: #000080;">10月8日,在瑞典斯德哥尔摩举行的2024年诺贝尔物理学奖公布现场,屏幕显示奖项得主美国普林斯顿大学的约翰·霍普菲尔德和加拿大多伦多大学的杰弗里·欣顿。新华社记者 彭子洋 摄</span></p><p>&emsp;&emsp;瑞典皇家科学院当天发表公报说,今年的两位诺贝尔物理学奖得主使用物理学工具,为当今强大的机器学习技术奠定了基础。约翰·霍普菲尔德创建了一种联想记忆方法,可以存储和重构图像或其他类型的数据模式。杰弗里·欣顿发明了一种可以自动发现数据中属性的方法,可用于识别图片中的特定元素等任务。</p><p>&emsp;&emsp;诺贝尔物理学委员会主席埃伦·穆恩斯在当天的新闻发布会上表示,两名获奖者利用统计物理的基本概念设计了人工神经网络,构建了机器学习的基础。相关技术已被用于推动多个领域的研究,包括粒子物理、材料科学和天体物理等,也已用于日常生活中的人脸识别和语言翻译等。她同时警告说,机器学习的快速发展也引发了人们对未来的担忧,人类有责任以安全且道德的方式使用这项新技术。</p><p><img id="e4hKToVylXMSCzgTsu" style="margin: 0 auto; display: block; float: none;" src="5N1ONQw8OzlVuVqg.jpg" align="center" data-material-id="202410082117762" data-name="20241008f132fab5dcfb4319be5b8cb54e3c0147.jpg"></p><p>&emsp;&emsp;<span style="font-family: 楷体; color: #000080;">10月8日,在瑞典斯德哥尔摩举行的2024年诺贝尔物理学奖公布现场,屏幕显示奖项得主美国普林斯顿大学的约翰·霍普菲尔德和加拿大多伦多大学的杰弗里·欣顿。新华社记者 彭子洋 摄</span></p><p>&emsp;&emsp;约翰·霍普菲尔德1933年出生于美国芝加哥,1958年获得美国康奈尔大学博士学位,现任美国普林斯顿大学教授。</p><p>&emsp;&emsp;杰弗里·欣顿1947年出生于英国伦敦,1978年获得英国爱丁堡大学博士学位,现任加拿大多伦多大学教授。</p><p>&emsp;&emsp;欣顿当天在接受电话连线时表示,获得诺奖对他来说“完全没想到”。他指出,相关技术将对社会产生巨大影响,但也必须警惕技术可能造成的威胁。</p><p>&emsp;&emsp;对于今年的诺贝尔物理学奖结果,不少人认为有些出乎意料。诺贝尔物理学委员会秘书乌尔夫·丹尼尔松当天在接受新华社记者采访时表示,物理学奖可以授予理论上、实验上或者观测上的发现,也可以授予发明,今年的获奖成果从某种意义上讲也是一种发明,一种可以多种方式应用的发明。</p></span> <div id="articleEdit"><span class="tiyi1 domPC"><a href="javascript:void(0);" class="advise">【纠错】</a> <div id="advisebox01" class="tiyi01" style="display:none;"><div><iframe id="jc_link1" border="0" marginwidth="0" framespacing="0" marginheight="0" frameborder="0" noresize="noresize" scrolling="no" vspale="0" style="width:600px;height:350px;float:left;"></iframe></div> <div class="tiyi03"><div id="jc_close1" style="cursor:pointer;"></div></div></div></span> <span class="editor"> 【责任编辑:王頔】 </span></div></div> <div class="columBox relatedNews" data="datasource:20241008c5aff4c9f7564a4c96d80d714fba74c8" datatype="content"><div class="col-tit"><span>新闻链接</span></div> <div class="col-cont"><ul><li><a href="http://www.news.cn/tech/20241009/cc2155e5671a41f78ad498d1ddcac9ff/c.html" target="_blank">科普|2024年诺贝尔物理学奖跟图灵奖“抢饭碗”?——机器学习获诺奖凸显跨学科研究的惊人力量</a> <div class="info"></div> <div class="time">2024-10-09</div></li></ul></div></div> <div class="nextpage clearfix" style="display:none;"><div class="nextpage-tit">阅读下一篇:</div> <div class="nextpage-cont"><a href="#"></a></div></div> <div class="ad_right domPC" style="margin-bottom:20px"><ins data-ycad-slot="399"></ins></div> <div class="domPC"><ins data-ycad-slot="2168"></ins></div> <div class="domPC"><ins data-ycad-slot="2169"></ins></div> <div class="bookList clearfix domPC"><ul></ul></div> <div class="domPC"><ins data-ycad-slot="2169"></ins></div></div> <div class="main-right right"><div class="ad_right domPC"><ins data-ycad-slot="2174"></ins></div> <div class="columBox domPC"><div class="col-tit"><span><a href="http://www.news.cn/depthobserve/index.html" target="_blank">深度观察</a></span></div> <div id="sdgc" class="col-cont"><div class="list list-mix" data="datasource:9b3bc39868af43b6bfe1d583394c080c" datatype="ds" preview="ds_"><ul><li><div class="img breath"><a href="http://news.cn/depthobserve/xhqmtt.html" target="_blank"><img src="../../20241007/208954414afd437f8a823ef63e88d052/d0c2d8b447054e46b1549c949712b8d1.jpg"></a></div> <div class="tit"><span><a href='http://news.cn/depthobserve/xhqmtt.html' target='_blank'>新华全媒头条丨</a><a href='http://www.news.cn/politics/20241006/def59a7adc684fa395d72564338d199e/c.html' target='_blank'>中国在海外建设者书写“新时代之歌” </a></span></div></li></ul></div> <div class="list list-txt dot" data="datasource:75d2a942f9834bebb18096b033efcce3" datatype="ds" preview="ds_"><ul><li><a href='http://www.news.cn/depthobserve/xhqmj.html' target='_blank'>新华全媒+丨</a><a href='http://www.news.cn/politics/20241008/ca244d3dba4d47a0bfb910f6b97695bc/c.html' target='_blank'>一名兰考铁路职工日记本里的车站印象</a></li><li><a href='http://www.news.cn/depthobserve/qwft.html' target='_blank'>权威访谈丨</a><a href='http://www.news.cn/local/20241008/5d39114454fa4d53b15fe58f3082f4d8/c.html' target='_blank'>张建光:让朱子文化焕发时代光彩</a></li><li><a href='http://www.jjckb.cn/' target='_blank'>经济参考报丨</a><a href='http://www.news.cn/fortune/20241009/b023a5ae39d0442c9cb17f14bc91d9fb/c.html' target='_blank'>多路资金引入 央地齐打创新“组合拳”</a></li><li><a href='http://www.xinhuanet.com/mrdx/index.htm' target='_blank'>新华每日电讯丨</a><a href='http://www.news.cn/local/20241009/02686eca5a0f4277a50ec0cf5a6fac11/c.html' target='_blank'>百年矿区复“绿”记</a></li><li><a href='http://news.cn/depthobserve/xkyy.html' target='_blank'>星空有约丨</a><a href='http://www.news.cn/tech/20241009/230e020cf8084e19876bb25428c91376/c.html' target='_blank'>重阳节,来看大火星!</a></li><li><a href='http://www.news.cn/depthobserve/xwzg.html' target='_blank'>秀我中国丨</a><a href='http://www.news.cn/local/20241009/82b61b7e92f2413ca31245902abe3a4c/c.html' target='_blank'>成都蓉城:中超“公益看台”彰显城市温度</a></li></ul></div> <div class="list list-pic" data="datasource:ab6ccbeb9b384782a147ae0ba74f7635" datatype="ds" preview="ds_"><ul><li><div class="img breath"><a href="http://www.news.cn/20241009/75ef8a0620614675b9f06cc3ce66fe3a/c.html" target="_blank"><img src="../../20241009/14f958e7c7a34ebaadf95c18193d68c5/a3673d644dd34425b572f3fcb5140f02.jpg"></a></div> <div class="tit"><a href='http://www.news.cn/20241009/75ef8a0620614675b9f06cc3ce66fe3a/c.html' target='_blank'>古诗词里的24节气</a></div></li><li><div class="img breath"><a href="http://www.news.cn/local/20241009/c428207208c84f3a86e18d233f7d22f4/c.html" target="_blank"><img src="../../20241009/442ae844caf549638de2b737104e398c/ee2c7bb7456646e2ac1035200879fba1.jpg"></a></div> <div class="tit"><a href='http://www.news.cn/local/20241009/c428207208c84f3a86e18d233f7d22f4/c.html' target='_blank'>绣娘新语</a></div></li></ul></div></div> <div id="sdgc" class="col-cont"><div class="list list-mix"><ul></ul></div> <div class="list list-txt dot"><ul></ul></div> <div class="list list-pic"><ul></ul></div></div></div> <div class="ad_right domPC"><ins data-ycad-slot="2175"></ins></div> <div class="columBox book"><ul></ul></div> <div class="ad_right domPC"><ins data-ycad-slot="2176"></ins></div> <div class="ad_right domPC"><ins data-ycad-slot="2177"></ins></div></div></div> <div class="adv domMob"><div class="advCont" style="display:none"><ins data-ycad-slot="2306"></ins></div> <div class="advShow"></div></div> <div class="foot"><script src="//lib.news.cn/common/foot.js"></script></div> <div class="domPC" style="margin-bottom:20px"><ins data-ycad-slot="2262"></ins></div> <div data="datasource:20241008c5aff4c9f7564a4c96d80d714fba74c8" datatype="content"><div id="fontsize" style="display:none;">
61
+
62
+ </div> <div id="fontcolor" style="display:none;">
63
+
64
+ </div> <div id="wxpic" style="display:none;"><img src=""></div> <div id="wxtitle" style="display:none;">
65
+ 两名科学家因机器学习方面的贡献分享2024年诺贝尔物理学奖
66
+ </div></div> <script>
67
+ //微信分享图功能
68
+ var wxfxPic = $.trim($("#wxpic").find("img").attr("src"));
69
+ var wxfxTit = $.trim($("#wxtitle").html()).replace("&nbsp;", "").replace("&amp;", "&");
70
+ var detaiWxPic = $("#wxsharepic").attr("src");
71
+ if (wxfxPic == "") {
72
+ wxfxPic = 'https://lib.news.cn/common/sharelogo.jpg';
73
+ } else {
74
+ wxfxPic = window.location.href.replace("c.html", wxfxPic)
75
+ }
76
+ console.log("wxfxTit", wxfxTit);
77
+
78
+ wxConfig({
79
+ title: wxfxTit,
80
+ desc: '新华网,让新闻离你更近!',
81
+ link: window.location.href,
82
+ imgUrl: wxfxPic
83
+ });
84
+ </script> <script src="//www.news.cn/global/detail/xhCommonFun.js"></script> <script src="//www.news.cn/2021detail/js/cb-video.js"></script> <script src="//www.news.cn/2021detail/js/xh-column.js"></script> <script src="//www.news.cn/detail/js/pager.js"></script> <script src="//www.news.cn/detail/js/cb_detail_20231223.js"></script> <script src="//www.news.cn/2021detail/js/booklist.js"></script> <script type="text/javascript" src="//a2.news.cn/js/xadndelayed.js"></script> <script src="//www.news.cn/mobile/20210315mobile/scripts/ad_mobile.js"></script> <script>
85
+ // cbDetailConfig = {
86
+ // detailAtlasDisplayPc: false,
87
+ // detailAtlasDisplayMob: false,
88
+ // detailSetFontSizePc: true,
89
+ // detailSetFontSizeMob: true,
90
+ // detailSetFontColorPc: true,
91
+ // detailSetFontColorMob: true,
92
+ // }
93
+ //
94
+ </script><script src="//imgs.news.cn/webdig/xinhua_webdig.js" language="javascript" type="text/javascript" async></script></html>
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ llama-index==0.11.20
2
+ llama-index-llms-replicate==0.3.0
3
+ llama-index-llms-openai-like==0.2.0
4
+ llama-index-embeddings-huggingface==0.3.1
5
+ llama-index-embeddings-instructor==0.2.1
6
+ sentence-transformers==2.7.0