Run this model with HF Jobs
Run zai-org/codegeex2-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/codegeex2-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/codegeex2-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/codegeex2-6b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/codegeex2-6b with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("zai-org/codegeex2-6b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload tokenization_chatglm.py
Browse files65 unmodified lines666768696970713 unmodified lines75767778798081143 unmodified lines22522622722822822923023116 unmodified lines24824925025125225325425525625125225325425525725825926026126225625765 unmodified lines model_input_names = ["input_ids", "attention_mask", "position_ids"]
def __init__(self, vocab_file, padding_side="left", clean_up_tokenization_spaces=False, **kwargs): super().__init__(padding_side=padding_side, clean_up_tokenization_spaces=clean_up_tokenization_spaces, **kwargs) self.name = "GLMTokenizer"
self.vocab_file = vocab_file3 unmodified lines "<eos>": self.tokenizer.eos_id, "<pad>": self.tokenizer.pad_id } super().__init__(padding_side=padding_side, clean_up_tokenization_spaces=clean_up_tokenization_spaces, **kwargs)
def get_command(self, token): if token in self.special_tokens:143 unmodified lines (optional) Set to False to avoid returning attention mask (default: set to model specifics) """ # Load from model defaults # assert self.padding_side == "left" assert self.padding_side == "left"
required_input = encoded_inputs[self.model_input_names[0]] seq_length = len(required_input)16 unmodified lines if needs_to_be_padded: difference = max_length - len(required_input)
if self.padding_side == "left": if "attention_mask" in encoded_inputs: encoded_inputs["attention_mask"] = [0] * difference + encoded_inputs["attention_mask"] if "position_ids" in encoded_inputs: encoded_inputs["position_ids"] = [0] * difference + encoded_inputs["position_ids"] encoded_inputs[self.model_input_names[0]] = [self.pad_token_id] * difference + required_input if "attention_mask" in encoded_inputs: encoded_inputs["attention_mask"] = [0] * difference + encoded_inputs["attention_mask"] if "position_ids" in encoded_inputs: encoded_inputs["position_ids"] = [0] * difference + encoded_inputs["position_ids"] encoded_inputs[self.model_input_names[0]] = [self.pad_token_id] * difference + required_input else: if "attention_mask" in encoded_inputs: encoded_inputs["attention_mask"] = encoded_inputs["attention_mask"] + [0] * difference if "position_ids" in encoded_inputs: encoded_inputs["position_ids"] = encoded_inputs["position_ids"] + [0] * difference encoded_inputs[self.model_input_names[0]] = required_input + [self.pad_token_id] * difference
return encoded_inputstokenization_chatglm.py+7-14