Text Generation
Transformers
Safetensors
Chinese
pinyin_code
babylm
chinese
pinyin
causal-lm
custom_code
Instructions to use CPSPX/babylm-zho-pinyin-code-97M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CPSPX/babylm-zho-pinyin-code-97M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CPSPX/babylm-zho-pinyin-code-97M", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("CPSPX/babylm-zho-pinyin-code-97M", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CPSPX/babylm-zho-pinyin-code-97M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CPSPX/babylm-zho-pinyin-code-97M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CPSPX/babylm-zho-pinyin-code-97M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/CPSPX/babylm-zho-pinyin-code-97M
- SGLang
How to use CPSPX/babylm-zho-pinyin-code-97M 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 "CPSPX/babylm-zho-pinyin-code-97M" \ --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": "CPSPX/babylm-zho-pinyin-code-97M", "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 "CPSPX/babylm-zho-pinyin-code-97M" \ --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": "CPSPX/babylm-zho-pinyin-code-97M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use CPSPX/babylm-zho-pinyin-code-97M with Docker Model Runner:
docker model run hf.co/CPSPX/babylm-zho-pinyin-code-97M
| """Configuration for the Transformers-compatible pinyin-code causal LM.""" | |
| from __future__ import annotations | |
| from transformers import PretrainedConfig | |
| class PinyinCodeConfig(PretrainedConfig): | |
| """Configuration for the compact GPT-style pinyin-code decoder.""" | |
| model_type = "pinyin_code" | |
| def __init__( | |
| self, | |
| vocab_size: int = 8000, | |
| block_size: int = 128, | |
| n_layer: int = 6, | |
| n_head: int = 8, | |
| n_embd: int = 256, | |
| dropout: float = 0.1, | |
| bos_token_id: int | None = None, | |
| eos_token_id: int | None = None, | |
| pad_token_id: int | None = None, | |
| unk_token_id: int | None = None, | |
| **kwargs, | |
| ) -> None: | |
| super().__init__( | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| pad_token_id=pad_token_id, | |
| unk_token_id=unk_token_id, | |
| **kwargs, | |
| ) | |
| self.vocab_size = vocab_size | |
| self.block_size = block_size | |
| self.n_layer = n_layer | |
| self.n_head = n_head | |
| self.n_embd = n_embd | |
| self.dropout = dropout | |
| self.num_hidden_layers = n_layer | |
| self.num_attention_heads = n_head | |
| self.hidden_size = n_embd | |
| self.max_position_embeddings = block_size | |
| self.is_decoder = True | |
| self.is_encoder_decoder = False | |
| self.use_cache = False | |