Instructions to use HuggingFaceTB/nanowhale-100m-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceTB/nanowhale-100m-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceTB/nanowhale-100m-base", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/nanowhale-100m-base", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/nanowhale-100m-base", trust_remote_code=True) 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use HuggingFaceTB/nanowhale-100m-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceTB/nanowhale-100m-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceTB/nanowhale-100m-base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HuggingFaceTB/nanowhale-100m-base
- SGLang
How to use HuggingFaceTB/nanowhale-100m-base 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 "HuggingFaceTB/nanowhale-100m-base" \ --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": "HuggingFaceTB/nanowhale-100m-base", "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 "HuggingFaceTB/nanowhale-100m-base" \ --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": "HuggingFaceTB/nanowhale-100m-base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HuggingFaceTB/nanowhale-100m-base with Docker Model Runner:
docker model run hf.co/HuggingFaceTB/nanowhale-100m-base
Is the bos token used during training?
The bos token is defined but doesn't seem to be used in the training code? It's in the chat template of the final model though. Also the tokenizer doesn't add it by default.
So I'm assuming the bos_token was not used in training and should not be used in inference. But that sounds weird
gpt answer via github copilot in case it's useful
Probably yes, implicitly — but this repo does not manually prepend a BOS token in the base-model pretraining script.
Why I say that:
- The pretraining script uses
trl.SFTTraineron rawtextwithprocessing_class=tokenizer, and there is no explicit code that adds a BOS token before each sample. - The tokenizer/config defines a BOS token:
bos_token_id=0in the model configbos_tokenis set intokenizer/tokenizer_config.json
- So whether BOS is actually inserted during pretraining depends on the tokenizer/TR L tokenization path, not on custom repo code. In this repo, there is no custom BOS-prepend logic for base-model training.
Relevant spots:
def build_tokenizer(tokenizer_path="tokenizer"):
"""Load the DeepSeek-V4 tokenizer."""
tok = PreTrainedTokenizerFast.from_pretrained(tokenizer_path)
if tok.pad_token is None:
tok.pad_token = tok.eos_token
return tok
# SFT Config for pretraining (raw text, no chat template)
sft_config = SFTConfig(
output_dir=output_dir,
max_length=max_seq_length,
packing=True,
dataset_text_field="text",
...
)
trainer = SFTTrainer(
model=model,
args=sft_config,
train_dataset=dataset,
processing_class=tokenizer,
)
pad_token_id=None,
bos_token_id=0,
eos_token_id=1,
tie_word_embeddings=False,
rope_theta=10000.0,
{
"backend": "tokenizers",
"bos_token": "<|begin▁of▁sentence|>",
"eos_token": "<|end▁of▁sentence|>",
"model_max_length": 1000000000000000019884624838656,
"pad_token": "<|end▁of▁sentence|>"
}
Bottom line:
- Repo code: no explicit BOS insertion for base pretraining.
- Tokenizer behavior: BOS token exists, so it may still be added automatically by the tokenizer pipeline/TR L defaults.
If you want, I can check the tokenizer files more closely to determine whether PreTrainedTokenizerFast here is configured to automatically add special tokens during encoding.