Text Generation
Transformers
PyTorch
Chinese
English
llama
conversational
custom_code
text-generation-inference
Run this model with HF Jobs
Run openbmb/BitCPM-CANN-1B-unquantized 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/BitCPM-CANN-1B-unquantized. 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/BitCPM-CANN-1B-unquantized 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/BitCPM-CANN-1B-unquantized. 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/BitCPM-CANN-1B-unquantized. 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/BitCPM-CANN-1B-unquantized with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/BitCPM-CANN-1B-unquantized with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openbmb/BitCPM-CANN-1B-unquantized", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openbmb/BitCPM-CANN-1B-unquantized", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("openbmb/BitCPM-CANN-1B-unquantized", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openbmb/BitCPM-CANN-1B-unquantized with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openbmb/BitCPM-CANN-1B-unquantized" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/BitCPM-CANN-1B-unquantized", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/openbmb/BitCPM-CANN-1B-unquantized
- SGLang
How to use openbmb/BitCPM-CANN-1B-unquantized 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/BitCPM-CANN-1B-unquantized" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/BitCPM-CANN-1B-unquantized", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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/BitCPM-CANN-1B-unquantized" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/BitCPM-CANN-1B-unquantized", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use openbmb/BitCPM-CANN-1B-unquantized with Docker Model Runner:
docker model run hf.co/openbmb/BitCPM-CANN-1B-unquantized
Upload configuration_llama.py with huggingface_hub
Browse files27 unmodified lines2829303132333416 unmodified lines515253545556575847 unmodified lines1061071081091101111121131141151168 unmodified lines12512612712812913013110 unmodified lines14214314414514614714814915015115215315415515615715815916016116257 unmodified lines22022122222322422527 unmodified linesThis is the configuration class to store the configuration of a [`LlamaModel`]. It is used to instantiate an LLaMAmodel according to the specified arguments, defining the model architecture. Instantiating a configuration with thedefaults will yield a similar configuration to that of the LLaMA-7B.e.g. [meta-llama/Llama-2-7b-hf](https://huggingface.co/meta-llama/Llama-2-7b-hf)Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read thedocumentation from [`PretrainedConfig`] for more information.16 unmodified lines`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. Whenconverting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructedby meanpooling all the original heads within that group. For more details, check out [thispaper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to`num_attention_heads`.hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):The non-linear activation function (function or string) in the decoder.47 unmodified lines`beta_slow` (`float`, *optional*):Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linearramp function. If unspecified, it defaults to 1.`short_factor` (`list[float]`, *optional*):Only used with 'longrope'. The scaling factor to be applied to short contexts (<`original_max_position_embeddings`). Must be a list of numbers with the same length as the hiddensize divided by the number of attention heads divided by 2`long_factor` (`list[float]`, *optional*):Only used with 'longrope'. The scaling factor to be applied to long contexts (<`original_max_position_embeddings`). Must be a list of numbers with the same length as the hiddensize divided by the number of attention heads divided by 28 unmodified linesmlp_bias (`bool`, *optional*, defaults to `False`):Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.head_dim (`int`, *optional*):The attention head dimension. If None, it will default to hidden_size // num_attention_heads```python>>> from transformers import LlamaModel, LlamaConfig10 unmodified linesmodel_type = "llama"keys_to_ignore_at_inference = ["past_key_values"]# Default tensor parallel plan for base model `LlamaModel`base_model_tp_plan = {"layers.*.self_attn.q_proj": "colwise","layers.*.self_attn.k_proj": "colwise","layers.*.self_attn.v_proj": "colwise","layers.*.self_attn.o_proj": "rowwise","layers.*.mlp.gate_proj": "colwise","layers.*.mlp.up_proj": "colwise","layers.*.mlp.down_proj": "rowwise",}base_model_pp_plan = {"embed_tokens": (["input_ids"], ["inputs_embeds"]),"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),"norm": (["hidden_states"], ["hidden_states"]),}def __init__(self,57 unmodified linestie_word_embeddings=tie_word_embeddings,**kwargs,)__all__ = ["LlamaConfig"]27 unmodified lines28293031323316 unmodified lines505152535455565747 unmodified lines1051061071081091101111121131141158 unmodified lines12412512612712812913010 unmodified lines14114214314414514657 unmodified lines20420520627 unmodified linesThis is the configuration class to store the configuration of a [`LlamaModel`]. It is used to instantiate an LLaMAmodel according to the specified arguments, defining the model architecture. Instantiating a configuration with thedefaults will yield a similar configuration to that of the LLaMA-7B.Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read thedocumentation from [`PretrainedConfig`] for more information.16 unmodified lines`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. Whenconverting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructedby meanpooling all the original heads within that group. For more details checkout [thispaper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to`num_attention_heads`.hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):The non-linear activation function (function or string) in the decoder.47 unmodified lines`beta_slow` (`float`, *optional*):Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linearramp function. If unspecified, it defaults to 1.`short_factor` (`List[float]`, *optional*):Only used with 'longrope'. The scaling factor to be applied to short contexts (<`original_max_position_embeddings`). Must be a list of numbers with the same length as the hiddensize divided by the number of attention heads divided by 2`long_factor` (`List[float]`, *optional*):Only used with 'longrope'. The scaling factor to be applied to long contexts (<`original_max_position_embeddings`). Must be a list of numbers with the same length as the hiddensize divided by the number of attention heads divided by 28 unmodified linesmlp_bias (`bool`, *optional*, defaults to `False`):Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.head_dim (`int`, *optional*):The attention head dimension. If None, it will default to hidden_size // num_heads```python>>> from transformers import LlamaModel, LlamaConfig10 unmodified linesmodel_type = "llama"keys_to_ignore_at_inference = ["past_key_values"]def __init__(self,57 unmodified linestie_word_embeddings=tie_word_embeddings,**kwargs,)
configuration_llama.py+5-24