Chapter 31
chatglm3 load
Notebooktransformers5 cells
In [1]python · cell 1
python
from transformers import AutoTokenizer, AutoModelIn [3]python · cell 2
python
tokenizer = AutoTokenizer.from_pretrained("d:/Pretrained_models/ZhipuAI/chatglm3-6b/", trust_remote_code=True)
tokenizerOutput
ChatGLMTokenizer(name_or_path='d:/Pretrained_models/ZhipuAI/chatglm3-6b/', vocab_size=64798, model_max_length=1000000000000000019884624838656, is_fast=False, padding_side='left', truncation_side='right', special_tokens={'eos_token': '</s>', 'unk_token': '<unk>', 'pad_token': '<unk>'}, clean_up_tokenization_spaces=False), added_tokens_decoder={
}In [4]python · cell 3
python
model = AutoModel.from_pretrained("d:/Pretrained_models/ZhipuAI/chatglm3-6b/", trust_remote_code=True)Output
Loading checkpoint shards: 0%| | 0/7 [00:00<?, ?it/s]
In [5]python · cell 4
python
modelOutput
ChatGLMForConditionalGeneration(
(transformer): ChatGLMModel(
(embedding): Embedding(
(word_embeddings): Embedding(65024, 4096)
)
(rotary_pos_emb): RotaryEmbedding()
(encoder): GLMTransformer(
(layers): ModuleList(
(0-27): 28 x GLMBlock(
(input_layernorm): RMSNorm()
(self_attention): SelfAttention(
(query_key_value): Linear(in_features=4096, out_features=4608, bias=True)
(core_attention): CoreAttention(
(attention_dropout): Dropout(p=0.0, inplace=False)
)
(dense): Linear(in_features=4096, out_features=4096, bias=False)
)
(post_attention_layernorm): RMSNorm()
(mlp): MLP(
(dense_h_to_4h): Linear(in_features=4096, out_features=27392, bias=False)
(dense_4h_to_h): Linear(in_features=13696, out_features=4096, bias=False)
)
)
)
(final_layernorm): RMSNorm()
)
(output_layer): Linear(in_features=4096, out_features=65024, bias=False)
)
)In [ ]python · cell 5
python
