baichuan-inc / Baichuan2

A series of large language models developed by Baichuan Intelligent Technology
https://huggingface.co/baichuan-inc
Apache License 2.0
4.03k stars 289 forks source link

13B-chat-v2版本长度怎么设置为8192 #343

Closed Dusangrm closed 6 months ago

Dusangrm commented 6 months ago

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

baichuan-assistant commented 6 months ago

最新的huggingface已经是8192了,可以下载最新版本:

https://huggingface.co/baichuan-inc/Baichuan2-13B-Chat/tree/v2.0