Merge pull request #5 from 00INDEX/patch-2

Doc(README-zh-Hans.md): update AutoModelForCausalLM
pull/6/head
Xingcheng Zhang 2023-07-06 16:24:53 +08:00 committed by GitHub
commit ce02dcf54f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -74,9 +74,9 @@ InternLM 即书生·浦语大模型包含面向实用场景的70亿参数
### 通过 Transformers 加载
通过以下的代码加载 InternLM 7B Chat 模型
```python
>>> from transformers import AutoTokenizer, AutoModel
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
>>> tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-chat-7b", trust_remote_code=True)
>>> model = AutoModel.from_pretrained("internlm/internlm-chat-7b", trust_remote_code=True, device='cuda')
>>> model = AutoModelForCausalLM.from_pretrained("internlm/internlm-chat-7b", trust_remote_code=True, device='cuda')
>>> model = model.eval()
>>> response, history = model.chat(tokenizer, "你好", history=[])
>>> print(response)