Run this model with HF Jobs
Run zai-org/chatglm-6b on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/zai-org/chatglm-6b. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/zai-org/chatglm-6b on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use zai-org/chatglm-6b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/chatglm-6b with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("zai-org/chatglm-6b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
duzx16 commited on
Commit ·
fb23542
1
Parent(s): 08bc851
Fix generate
Browse filesFiles changed (2)
1053 unmodified lines105410551056105710581059106010611062106310641065106625 unmodified lines1092109310941095109610971098109915 unmodified lines1115111611171118111911201053 unmodified lines# update attention maskif "attention_mask" in model_kwargs:attention_mask = model_kwargs["attention_mask"]attention_mask = torch.cat([attention_mask, attention_mask.new_ones((*attention_mask.shape[:3], 1))], dim=3)new_attention_mask = attention_mask[:, :, -1:].clone()new_attention_mask[..., -1] = Falsemodel_kwargs["attention_mask"] = torch.cat([attention_mask, new_attention_mask], dim=2)# update position idsif "position_ids" in model_kwargs:25 unmodified lines# only last token for input_ids if past is not Noneif past is not None or past_key_values is not None:last_token = input_ids[:, -1].unsqueeze(-1)if attention_mask is not None:attention_mask = attention_mask[:, :, -1:]if position_ids is not None:position_ids = position_ids[..., -1:]else:15 unmodified lines"attention_mask": attention_mask}else:if attention_mask is None:attention_mask = self.get_masks(input_ids,1053 unmodified lines1054105510561057105810591060106110621063106410651066106725 unmodified lines109310941095109610971098109911001101110215 unmodified lines1118111911201121112211231124112511261053 unmodified lines# update attention maskif "attention_mask" in model_kwargs:attention_mask = model_kwargs["attention_mask"]if attention_mask is not None and attention_mask.dtype == torch.bool:attention_mask = torch.cat([attention_mask, attention_mask.new_ones((*attention_mask.shape[:3], 1))], dim=3)new_attention_mask = attention_mask[:, :, -1:].clone()new_attention_mask[..., -1] = Falsemodel_kwargs["attention_mask"] = torch.cat([attention_mask, new_attention_mask], dim=2)# update position idsif "position_ids" in model_kwargs:25 unmodified lines# only last token for input_ids if past is not Noneif past is not None or past_key_values is not None:last_token = input_ids[:, -1].unsqueeze(-1)if attention_mask is not None and attention_mask.dtype == torch.bool:attention_mask = attention_mask[:, :, -1:]else:attention_mask = Noneif position_ids is not None:position_ids = position_ids[..., -1:]else:15 unmodified lines"attention_mask": attention_mask}else:if attention_mask is not None and attention_mask.dtype != torch.bool:logger.warning_once(f"The dtype of attention mask ({attention_mask.dtype}) is not bool")attention_mask = Noneif attention_mask is None:attention_mask = self.get_masks(input_ids,
381 unmodified lines382383384385386387388389381 unmodified linesmask_token_id = self.sp_tokenizer[self.mask_token]gmask_token_id = self.sp_tokenizer[self.gmask_token]assert self.padding_side == "left"if return_attention_mask is None:return_attention_mask = "attention_mask" in self.model_input_namesrequired_input = encoded_inputs[self.model_input_names[0]]seq_length = len(required_input)381 unmodified lines382383384385386387381 unmodified linesmask_token_id = self.sp_tokenizer[self.mask_token]gmask_token_id = self.sp_tokenizer[self.gmask_token]assert self.padding_side == "left"required_input = encoded_inputs[self.model_input_names[0]]seq_length = len(required_input)
modeling_chatglm.py+14-8
tokenization_chatglm.py-2