diff --git a/README.md b/README.md index 059fa6c..6934af9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@
Qwen-7B 🤖 | 🤗  | Qwen-7B-Chat 🤖 | 🤗  | Qwen-7B-Chat-Int4 🤗
-WeChat   |   Discord   |   Demo  |  Report
+WeChat   |   Discord   |   Demo  |  Report
+## Deployment
+
+It is simple to run the model on CPU, which requires your specification of device:
+
+```python
+model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-7B-Chat", device_map="cpu", trust_remote_code=True).eval()
+```
+
+If you suffer from lack of GPU memory and you would like to run the model on more than 1 GPU, you can use our provided script `utils.py`:
+
+```python[](https://)
+from utils import load_model_on_gpus
+model = load_model_on_gpus('Qwen/Qwen-7B-Chat', num_gpus=2)
+```
+
+Then you can run the 7B chat model on 2 GPUs using the above scripts.
+
+
## Tool Usage
Qwen-7B-Chat is specifically optimized for tool usage, including API, database, models, etc., so that users can build their own Qwen-7B-based LangChain, Agent, and Code Interpreter. In our evaluation [benchmark](eval/EVALUATION.md) for assessing tool usage capabilities, we find that Qwen-7B reaches stable performance.
@@ -363,6 +388,8 @@ Additionally, we provide experimental results to show its capabilities of playin
| StarCoder-15.5B | 87.04 | 87.96 | 68.89 |
| **Qwen-7B** | 90.74 | 92.59 | 74.07 |
+
+
## Long-Context Understanding
To extend the context length and break the bottleneck of training sequence length, we introduce several techniques, including NTK-aware interpolation, window attention, and LogN attention scaling, to extend the context length to over 8K tokens. We conduct language modeling experiments on the arXiv dataset with the PPL evaluation and find that Qwen-7B can reach outstanding performance in the scenario of long context. Results are demonstrated below:
@@ -388,18 +415,26 @@ To extend the context length and break the bottleneck of training sequence lengt
+
+
## Reproduction
For your reproduction of the model performance on benchmark datasets, we provide scripts for you to reproduce the results. Check [eval/EVALUATION.md](eval/EVALUATION.md) for more information. Note that the reproduction may lead to slight differences from our reported results.
+
+
## FAQ
If you meet problems, please refer to [FAQ](FAQ.md) and the issues first to search a solution before you launch a new issue.
+
+
## License Agreement
Researchers and developers are free to use the codes and model weights of both Qwen-7B and Qwen-7B-Chat. We also allow their commercial use. Check our license at [LICENSE](LICENSE) for more details. If you have requirements for commercial use, please fill out the [form](https://dashscope.console.aliyun.com/openModelApply/qianwen) to apply.
+
+
## Contact Us
If you are interested to leave a message to either our research team or product team, feel free to send an email to qianwen_opensource@alibabacloud.com.
diff --git a/README_CN.md b/README_CN.md
index e6a83c6..7b8df0d 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -11,12 +11,10 @@
Qwen-7B 🤖 | 🤗  | Qwen-7B-Chat 🤖 | 🤗  | Qwen-7B-Chat-Int4 🤗
-WeChat   |   Discord   |   Demo  |  Report
+WeChat   |   Discord   |   Demo  |  Report
+## 部署
+
+在CPU上运行非常简单,使用方法如下所示:
+
+```python
+model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-7B-Chat", device_map="cpu", trust_remote_code=True).eval()
+```
+
+如果你遇到显存不足的问题而希望使用多张GPU进行推理,可以使用提供的脚本`utils.py`:
+
+```python
+from utils import load_model_on_gpus
+model = load_model_on_gpus('Qwen/Qwen-7B-Chat', num_gpus=2)
+```
+
+你即可使用2张GPU进行推理。
+
+
## 工具调用
Qwen-7B-Chat针对包括API、数据库、模型等工具在内的调用进行了优化。用户可以开发基于Qwen-7B的LangChain、Agent甚至Code Interpreter。在我们开源的[评测数据集](eval/EVALUATION.md)上测试模型的工具调用能力,并发现Qwen-7B-Chat能够取得稳定的表现。
@@ -370,6 +396,8 @@ For how to write and use prompts for ReAct Prompting, please refer to [the ReAct
|StarCoder-15.5B | 87.04 | 87.96 | 68.89 |
| **Qwen-7B** | 90.74 | 92.59 | 74.07 |
+
+
## 长文本理解
我们引入了NTK插值、窗口注意力、LogN注意力缩放等技术来提升模型的上下文长度并突破训练序列长度的限制。我们的模型已经突破8K的序列长度。通过arXiv数据集上的语言模型实验,我们发现Qwen-7B能够在长序列的设置下取得不错的表现。
@@ -395,18 +423,26 @@ For how to write and use prompts for ReAct Prompting, please refer to [the ReAct
+
+
## 复现
我们提供了评测脚本以供复现我们的实验结果。注意,由于内部代码和开源代码存在少许差异,评测结果可能与汇报结果存在细微的结果不一致。请阅读[eval/EVALUATION.md](eval/EVALUATION.md)了解更多信息。
+
+
## FAQ
如遇到问题,敬请查阅[FAQ](FAQ_zh.md)以及issue区,如仍无法解决再提交issue。
+
+
## 使用协议
研究人员与开发者可使用Qwen-7B和Qwen-7B-Chat或进行二次开发。我们同样允许商业使用,具体细节请查看[LICENSE](LICENSE)。如需商用,请填写[问卷](https://dashscope.console.aliyun.com/openModelApply/qianwen)申请。
+
+
## 联系我们
如果你想给我们的研发团队和产品团队留言,请通过邮件(qianwen_opensource@alibabacloud.com)联系我们。
diff --git a/README_JA.md b/README_JA.md
index 80f1241..878981f 100644
--- a/README_JA.md
+++ b/README_JA.md
@@ -10,7 +10,7 @@
Qwen-7B 🤖 | 🤗  | Qwen-7B-Chat 🤖 | 🤗  | Qwen-7B-Chat-Int4 🤗
-WeChat   |   Discord   |   Demo  |  Report
+WeChat   |   Discord   |   Demo  |  Report
+## Deployment
+
+CPU上でモデルを実行するのは簡単で、以下のようにデバイスを指定する必要がある:
+
+```python
+model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-7B-Chat", device_map="cpu", trust_remote_code=True).eval()
+```
+
+```
+メモリ不足に悩まされ、複数のGPUにモデルをデプロイしたい場合は、``utils.py`で提供されているスクリプトを使うことができます:
+
+```python
+from utils import load_model_on_gpus
+model = load_model_on_gpus('Qwen/Qwen-7B-Chat', num_gpus=2)
+```
+
+7Bチャットモデルの推論を2GPUで実行できます。
+
+
## ツールの使用
Qwen-7B-Chat は、API、データベース、モデルなど、ツールの利用に特化して最適化されており、ユーザは独自の Qwen-7B ベースの LangChain、エージェント、コードインタプリタを構築することができます。ツール利用能力を評価するための評価[ベンチマーク](eval/EVALUATION.md)では、Qwen-7B は安定した性能に達しています。
@@ -365,6 +397,8 @@ ReAct プロンプトの書き方や使い方については、[ReAct の例](ex
|StarCoder-15.5B | 87.04 | 87.96 | 68.89 |
| **Qwen-7B** | 90.74 | 92.59 | 74.07 |
+
+
## 長い文脈の理解
コンテキストの長さを拡張し、訓練シーケンスの長さのボトルネックを解消するために、NTK を考慮した補間、ウィンドウアテンション、LogN アテンションスケーリングなどの技術を導入し、コンテキストの長さを 8K トークン以上に拡張する。arXiv データセットを用いて PPL 評価による言語モデリング実験を行い、Qwen-7B が長いコンテキストのシナリオにおいて卓越した性能を達成できることを見出した。以下に結果を示します:
@@ -390,18 +424,26 @@ ReAct プロンプトの書き方や使い方については、[ReAct の例](ex
+
+
## 再現
ベンチマークデータセットでのモデル性能の再現のために、結果を再現するスクリプトを提供しています。詳しくは [eval/EVALUATION.md](eval/EVALUATION.md) を確認してください。なお、再現の結果、我々の報告結果と若干異なる場合がある。
+
+
## FAQ
問題が発生した場合は、[FAQ](FAQ_ja.md) や issue を参照し、新しい issue を立ち上げる前に解決策を探してください。
+
+
## ライセンス契約
Qwen-7B と Qwen-7B-Chat のコードとモデルウェイトは、研究者や開発者が自由に使用することができます。また、商用利用も可能です。詳しくは [LICENSE](LICENSE) をご覧ください。商用利用を希望される方は、[リクエストフォーム](https://dashscope.console.aliyun.com/openModelApply/qianwen)に必要事項をご記入の上、お申し込みください。
+
+
## お問い合わせ
研究チームまたは製品チームへのメッセージは、qianwen_opensource@alibabacloud.com までお気軽にお送りください。
diff --git a/assets/cli_demo.gif b/assets/cli_demo.gif
index 61188ec..1283612 100644
Binary files a/assets/cli_demo.gif and b/assets/cli_demo.gif differ
diff --git a/assets/openai_api.gif b/assets/openai_api.gif
index 65e494c..a8db020 100644
Binary files a/assets/openai_api.gif and b/assets/openai_api.gif differ
diff --git a/assets/web_demo.gif b/assets/web_demo.gif
index eee2c06..142d45a 100644
Binary files a/assets/web_demo.gif and b/assets/web_demo.gif differ
diff --git a/assets/wechat.png b/assets/wechat.png
new file mode 100644
index 0000000..ac03c40
Binary files /dev/null and b/assets/wechat.png differ
diff --git a/cli_demo.py b/cli_demo.py
index 4a095ad..a642b69 100644
--- a/cli_demo.py
+++ b/cli_demo.py
@@ -46,16 +46,29 @@ def _load_model_tokenizer(args):
else:
device_map = "auto"
- model = AutoModelForCausalLM.from_pretrained(
- args.checkpoint_path,
- device_map=device_map,
- trust_remote_code=True,
- resume_download=True,
- ).eval()
- model.generation_config = GenerationConfig.from_pretrained(
+ qconfig_path = os.path.join(args.checkpoint_path, 'quantize_config.json')
+ if os.path.exists(qconfig_path):
+ from auto_gptq import AutoGPTQForCausalLM
+ model = AutoGPTQForCausalLM.from_quantized(
+ args.checkpoint_path,
+ device_map=device_map,
+ trust_remote_code=True,
+ resume_download=True,
+ use_safetensors=True,
+ ).eval()
+ else:
+ model = AutoModelForCausalLM.from_pretrained(
+ args.checkpoint_path,
+ device_map=device_map,
+ trust_remote_code=True,
+ resume_download=True,
+ ).eval()
+
+ config = GenerationConfig.from_pretrained(
args.checkpoint_path, trust_remote_code=True, resume_download=True,
)
- return model, tokenizer
+
+ return model, tokenizer, config
def _clear_screen():
@@ -99,7 +112,7 @@ def main():
history, response = [], ''
- model, tokenizer = _load_model_tokenizer(args)
+ model, tokenizer, config = _load_model_tokenizer(args)
orig_gen_config = deepcopy(model.generation_config)
_clear_screen()
@@ -179,7 +192,7 @@ def main():
# Run chat.
set_seed(seed)
try:
- for response in model.chat_stream(tokenizer, query, history=history):
+ for response in model.chat_stream(tokenizer, query, history=history, generation_config=config):
_clear_screen()
print(f"\nUser: {query}")
print(f"\nQwen-7B: {response}")