Run this model with HF Jobs
Run openbmb/cpm-bee-2b 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 and TRL to fine-tune https://huggingface.co/openbmb/cpm-bee-2b. 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/openbmb/cpm-bee-2b 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.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/openbmb/cpm-bee-2b. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/openbmb/cpm-bee-2b. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use openbmb/cpm-bee-2b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/cpm-bee-2b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openbmb/cpm-bee-2b", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("openbmb/cpm-bee-2b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openbmb/cpm-bee-2b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openbmb/cpm-bee-2b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/cpm-bee-2b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/openbmb/cpm-bee-2b
- SGLang
How to use openbmb/cpm-bee-2b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "openbmb/cpm-bee-2b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/cpm-bee-2b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "openbmb/cpm-bee-2b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/cpm-bee-2b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use openbmb/cpm-bee-2b with Docker Model Runner:
docker model run hf.co/openbmb/cpm-bee-2b
Gong Baitao commited on
Commit ·
c197e2f
1
Parent(s): 9c2f19e
Update max_length
Browse filesFiles changed (2)
6 unmodified lines7891011126 unmodified lines"pad_token_id": 0,"eos_token_id": 7,"bos_token_id": 6,"max_length": 100,"vocab_size": 86583}6 unmodified lines7891011126 unmodified lines"pad_token_id": 0,"eos_token_id": 7,"bos_token_id": 6,"max_new_tokens": 100,"vocab_size": 86583}
1728 unmodified lines1729173017311732173317341735357 unmodified lines20932094209520962097209820999 unmodified lines2109211021112112211321148 unmodified lines212321242125212621272128212918 unmodified lines21482149215021512152215321541728 unmodified lineseos_token_id = eos_token_id if eos_token_id is not None else self.generation_config.eos_token_idbos_token_id = bos_token_id if bos_token_id is not None else self.generation_config.bos_token_idvocab_size = vocab_size if vocab_size is not None else self.generation_config.vocab_sizemax_length = max_length if max_length is not None else self.generation_config.max_lengthoutput_scores = output_scores if output_scores is not None else self.generation_config.output_scoresoutput_attentions = (output_attentions if output_attentions is not None else self.generation_config.output_attentions357 unmodified lineslength_penalty=generation_config.length_penalty,do_early_stopping=generation_config.early_stopping,num_beam_hyps_to_keep=generation_config.num_return_sequences,max_length=generation_config.max_length,**kwargs,)# 9. interleave input_ids with `num_beams` additional sequences per batch9 unmodified linesbeam_scorer,repetition_penalty=repetition_penalty,logits_processor=logits_processor,pad_token_id=generation_config.pad_token_id,eos_token_id=generation_config.eos_token_id,vocab_size=kwargs.get("vocab_size", None),8 unmodified linesself,data_list: Union[Dict, List[Dict]],tokenizer: CpmBeeTokenizer,generation_config=None,**kwargs,):"""18 unmodified linesdata_list = [data_list]input_encoded = tokenizer(data_list, return_tensors="pt", padding=True, device=self.device)input_encoded.update(kwargs)input_encoded["generation_config"] = generation_configinput_encoded["vocab_size"] = tokenizer.vocab_sizedecode_res = self._generate(**input_encoded)1728 unmodified lines1729173017311732173317341735357 unmodified lines20932094209520962097209820999 unmodified lines21092110211121122113211421158 unmodified lines21242125212621272128212918 unmodified lines2148214921502151215221531728 unmodified lineseos_token_id = eos_token_id if eos_token_id is not None else self.generation_config.eos_token_idbos_token_id = bos_token_id if bos_token_id is not None else self.generation_config.bos_token_idvocab_size = vocab_size if vocab_size is not None else self.generation_config.vocab_sizemax_length = max_length if max_length is not None else self.generation_config.max_new_tokensoutput_scores = output_scores if output_scores is not None else self.generation_config.output_scoresoutput_attentions = (output_attentions if output_attentions is not None else self.generation_config.output_attentions357 unmodified lineslength_penalty=generation_config.length_penalty,do_early_stopping=generation_config.early_stopping,num_beam_hyps_to_keep=generation_config.num_return_sequences,max_length=generation_config.max_new_tokens,**kwargs,)# 9. interleave input_ids with `num_beams` additional sequences per batch9 unmodified linesbeam_scorer,repetition_penalty=repetition_penalty,logits_processor=logits_processor,max_length=generation_config.max_new_tokens,pad_token_id=generation_config.pad_token_id,eos_token_id=generation_config.eos_token_id,vocab_size=kwargs.get("vocab_size", None),8 unmodified linesself,data_list: Union[Dict, List[Dict]],tokenizer: CpmBeeTokenizer,**kwargs,):"""18 unmodified linesdata_list = [data_list]input_encoded = tokenizer(data_list, return_tensors="pt", padding=True, device=self.device)input_encoded.update(kwargs)input_encoded["vocab_size"] = tokenizer.vocab_sizedecode_res = self._generate(**input_encoded)
generation_config.json+1-1
modeling_cpmbee.py+3-4