Instructions to use google/madlad400-8b-lm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/madlad400-8b-lm with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="google/madlad400-8b-lm", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("google/madlad400-8b-lm", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("google/madlad400-8b-lm", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use google/madlad400-8b-lm with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/madlad400-8b-lm" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/madlad400-8b-lm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/google/madlad400-8b-lm
- SGLang
How to use google/madlad400-8b-lm 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 "google/madlad400-8b-lm" \ --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": "google/madlad400-8b-lm", "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 "google/madlad400-8b-lm" \ --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": "google/madlad400-8b-lm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use google/madlad400-8b-lm with Docker Model Runner:
docker model run hf.co/google/madlad400-8b-lm
Regenerate the tokenizer.json pipeline from spiece.model
spiece.model keeps whitespace (remove_extra_whitespaces: false) and uses byte fallback, but tokenizer.json collapses repeated spaces and has byte_fallback: false, and transformers v5 additionally rebuilds the T5 pipeline with a whitespace split. Tabs and newlines are lost, which matters for translating documents:
| text | spiece.model |
current (transformers v5) |
with this PR |
|---|---|---|---|
a\tb |
▁a, <0x09>, b |
▁a, ▁b |
▁a, <0x09>, b |
line one\nline two |
▁line, ▁one, \n, line, ▁two |
▁line, ▁one, ▁line, ▁two |
▁line, ▁one, \n, line, ▁two |
two spaces |
▁two, ▁, ▁space, s |
▁two, ▁space, s |
▁two, ▁, ▁space, s |
This PR replaces the normalizer, pre-tokenizer and decoder in tokenizer.json with the ones transformers generates from spiece.model (with legacy=True), turns on byte_fallback, and sets "tokenizer_class": "PreTrainedTokenizerFast" in tokenizer_config.json (TokenizersBackend in transformers v5), so the file is used as-is on v4 and v5, as suggested by the transformers maintainers in huggingface/transformers#51269. The vocabulary and the post-processor are unchanged, so token ids do not move, and the <2xx> language tags are tokenized as before.
I checked it on 33,013 texts (FLORES-200 sentences in 205 languages, Hindi/Malayalam code-mixed text, and Unicode edge cases): the texts that tokenize differently from spiece.model go from 4,494 to 11, and decoding matches SentencePiece on all of them. </s> is still appended.