import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.generation.utils import GenerationConfig
import re
tokenizer = AutoTokenizer.from_pretrained("/mnt/workspace/baichuan/model/beichuan2-13b-v2",
revision="v2.0",
use_fast=False,
trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("/mnt/workspace/baichuan/model/beichuan2-13b-v2",
revision="v2.0",
device_map="auto",
torch_dtype=torch.bfloat16,
trust_remote_code=True)
model.generation_config = GenerationConfig.from_pretrained("/mnt/workspace/baichuan/model/beichuan2-13b-v2", revision="v2.0")
直接调用会报错,显示最大长度还是4096
Token indices sequence length is longer than the specified maximum sequence length for this model (4638 > 4096). Running this sequence through the model will result in indexing errors
import torch from transformers import AutoModelForCausalLM, AutoTokenizer from transformers.generation.utils import GenerationConfig import re tokenizer = AutoTokenizer.from_pretrained("/mnt/workspace/baichuan/model/beichuan2-13b-v2", revision="v2.0", use_fast=False, trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("/mnt/workspace/baichuan/model/beichuan2-13b-v2", revision="v2.0", device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True) model.generation_config = GenerationConfig.from_pretrained("/mnt/workspace/baichuan/model/beichuan2-13b-v2", revision="v2.0")
直接调用会报错,显示最大长度还是4096 Token indices sequence length is longer than the specified maximum sequence length for this model (4638 > 4096). Running this sequence through the model will result in indexing errors