mirror of https://github.com/InternLM/InternLM
fix(readme): fix deprecated model path in code examples (#554)
parent
fc1f05c265
commit
cb922d44e2
|
@ -86,8 +86,8 @@ Transformers を使用して InternLM 7B チャットモデルをロードする
|
||||||
|
|
||||||
```python
|
```python
|
||||||
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
|
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
|
||||||
>>> tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-chat-7b-v1_1", trust_remote_code=True)
|
>>> tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-chat-7b", trust_remote_code=True)
|
||||||
>>> model = AutoModelForCausalLM.from_pretrained("internlm/internlm-chat-7b-v1_1", trust_remote_code=True).cuda()
|
>>> model = AutoModelForCausalLM.from_pretrained("internlm/internlm-chat-7b", trust_remote_code=True).cuda()
|
||||||
>>> model = model.eval()
|
>>> model = model.eval()
|
||||||
>>> response, history = model.chat(tokenizer, "こんにちは", history=[])
|
>>> response, history = model.chat(tokenizer, "こんにちは", history=[])
|
||||||
>>> print(response)
|
>>> print(response)
|
||||||
|
|
|
@ -182,7 +182,7 @@ InternLM-7B 包含了一个拥有70亿参数的基础模型和一个为实际场
|
||||||
```python
|
```python
|
||||||
from modelscope import snapshot_download, AutoTokenizer, AutoModelForCausalLM
|
from modelscope import snapshot_download, AutoTokenizer, AutoModelForCausalLM
|
||||||
import torch
|
import torch
|
||||||
model_dir = snapshot_download('Shanghai_AI_Laboratory/internlm-chat-7b-v1_1', revision='v1.0.0')
|
model_dir = snapshot_download('Shanghai_AI_Laboratory/internlm-chat-7b', revision='v1.0.0')
|
||||||
tokenizer = AutoTokenizer.from_pretrained(model_dir, device_map="auto", trust_remote_code=True,torch_dtype=torch.float16)
|
tokenizer = AutoTokenizer.from_pretrained(model_dir, device_map="auto", trust_remote_code=True,torch_dtype=torch.float16)
|
||||||
model = AutoModelForCausalLM.from_pretrained(model_dir,device_map="auto", trust_remote_code=True,torch_dtype=torch.float16)
|
model = AutoModelForCausalLM.from_pretrained(model_dir,device_map="auto", trust_remote_code=True,torch_dtype=torch.float16)
|
||||||
model = model.eval()
|
model = model.eval()
|
||||||
|
|
|
@ -158,8 +158,8 @@ To load the InternLM 7B Chat model using Transformers, use the following code:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
|
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
|
||||||
>>> tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-chat-7b-v1_1", trust_remote_code=True)
|
>>> tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-chat-7b", trust_remote_code=True)
|
||||||
>>> model = AutoModelForCausalLM.from_pretrained("internlm/internlm-chat-7b-v1_1", trust_remote_code=True).cuda()
|
>>> model = AutoModelForCausalLM.from_pretrained("internlm/internlm-chat-7b", trust_remote_code=True).cuda()
|
||||||
>>> model = model.eval()
|
>>> model = model.eval()
|
||||||
>>> response, history = model.chat(tokenizer, "hello", history=[])
|
>>> response, history = model.chat(tokenizer, "hello", history=[])
|
||||||
>>> print(response)
|
>>> print(response)
|
||||||
|
@ -182,7 +182,7 @@ To load the InternLM model using ModelScope, use the following code:
|
||||||
```python
|
```python
|
||||||
from modelscope import snapshot_download, AutoTokenizer, AutoModelForCausalLM
|
from modelscope import snapshot_download, AutoTokenizer, AutoModelForCausalLM
|
||||||
import torch
|
import torch
|
||||||
model_dir = snapshot_download('Shanghai_AI_Laboratory/internlm-chat-7b-v1_1', revision='v1.0.0')
|
model_dir = snapshot_download('Shanghai_AI_Laboratory/internlm-chat-7b', revision='v1.0.0')
|
||||||
tokenizer = AutoTokenizer.from_pretrained(model_dir, device_map="auto", trust_remote_code=True,torch_dtype=torch.float16)
|
tokenizer = AutoTokenizer.from_pretrained(model_dir, device_map="auto", trust_remote_code=True,torch_dtype=torch.float16)
|
||||||
model = AutoModelForCausalLM.from_pretrained(model_dir,device_map="auto", trust_remote_code=True,torch_dtype=torch.float16)
|
model = AutoModelForCausalLM.from_pretrained(model_dir,device_map="auto", trust_remote_code=True,torch_dtype=torch.float16)
|
||||||
model = model.eval()
|
model = model.eval()
|
||||||
|
|
Loading…
Reference in New Issue