Text Generation
Transformers
ONNX
Safetensors
English
llama
alignment-handbook
trl
sft
conversational
text-generation-inference
Run this model with HF Jobs
Run HuggingFaceTB/SmolLM-135M-Instruct 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/HuggingFaceTB/SmolLM-135M-Instruct. 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/HuggingFaceTB/SmolLM-135M-Instruct 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/HuggingFaceTB/SmolLM-135M-Instruct. 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.
Instructions to use HuggingFaceTB/SmolLM-135M-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceTB/SmolLM-135M-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceTB/SmolLM-135M-Instruct") 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("HuggingFaceTB/SmolLM-135M-Instruct") model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM-135M-Instruct", 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 HuggingFaceTB/SmolLM-135M-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceTB/SmolLM-135M-Instruct" # 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/SmolLM-135M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HuggingFaceTB/SmolLM-135M-Instruct
- SGLang
How to use HuggingFaceTB/SmolLM-135M-Instruct 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/SmolLM-135M-Instruct" \ --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/SmolLM-135M-Instruct", "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/SmolLM-135M-Instruct" \ --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/SmolLM-135M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HuggingFaceTB/SmolLM-135M-Instruct with Docker Model Runner:
docker model run hf.co/HuggingFaceTB/SmolLM-135M-Instruct
Model save
Browse filesFiles changed (14)
- README.mdAdded+60
- all_results.jsonAdded+9
- config.jsonAdded+30
- generation_config.jsonAdded+7
- merges.txtAdded
- model.safetensorsAdded+3
- runs/Jul15_23-01-23_ip-26-0-167-245/events.out.tfevents.1721084621.ip-26-0-167-245.4063478.0Added+3
- special_tokens_map.jsonAdded+34
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+154
- train_results.jsonAdded+9
- trainer_state.jsonAdded+147
- training_args.binAdded+3
- vocab.jsonAdded
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960---base_model: HuggingFaceTB/cosmo2-135M-webinst-sc2tags:- trl- dpo- generated_from_trainermodel-index:- name: cosmo2-135M-webinst-sc2-dpo-helpsteer-ep1 results: []---
<!-- This model card has been generated automatically according to the information the Trainer had access to. Youshould probably proofread and complete it, then remove this comment. -->
[<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="200" height="32"/>](https://wandb.ai/loubnabnl/huggingface/runs/bh5ijwbx)# cosmo2-135M-webinst-sc2-dpo-helpsteer-ep1
This model is a fine-tuned version of [HuggingFaceTB/cosmo2-135M-webinst-sc2](https://huggingface.co/HuggingFaceTB/cosmo2-135M-webinst-sc2) on an unknown dataset.
## Model description
More information needed
## Intended uses & limitations
More information needed
## Training and evaluation data
More information needed
## Training procedure
### Training hyperparameters
The following hyperparameters were used during training:- learning_rate: 5e-06- train_batch_size: 2- eval_batch_size: 4- seed: 42- distributed_type: multi-GPU- num_devices: 8- gradient_accumulation_steps: 8- total_train_batch_size: 128- total_eval_batch_size: 32- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08- lr_scheduler_type: cosine- lr_scheduler_warmup_ratio: 0.1- num_epochs: 1
### Training results
### Framework versions
- Transformers 4.42.3- Pytorch 2.1.2- Datasets 2.20.0- Tokenizers 0.19.1123456789{ "epoch": 0.9872958257713249, "total_flos": 0.0, "train_loss": 0.6879464878755457, "train_runtime": 373.787, "train_samples": 8806, "train_samples_per_second": 23.559, "train_steps_per_second": 0.182}123456789101112131415161718192021222324252627282930{ "_name_or_path": "HuggingFaceTB/cosmo2-135M-webinst-sc2", "architectures": [ "LlamaForCausalLM" ], "attention_bias": false, "attention_dropout": 0.0, "bos_token_id": 1, "eos_token_id": 2, "hidden_act": "silu", "hidden_size": 576, "initializer_range": 0.02, "intermediate_size": 1536, "max_position_embeddings": 2048, "mlp_bias": false, "model_type": "llama", "num_attention_heads": 9, "num_hidden_layers": 30, "num_key_value_heads": 3, "pad_token_id": 2, "pretraining_tp": 1, "rms_norm_eps": 1e-05, "rope_scaling": null, "rope_theta": 10000.0, "tie_word_embeddings": true, "torch_dtype": "bfloat16", "transformers_version": "4.42.3", "use_cache": false, "vocab_size": 49152}1234567{ "_from_model_config": true, "bos_token_id": 1, "eos_token_id": 2, "pad_token_id": 2, "transformers_version": "4.42.3"}123version https://git-lfs.github.com/spec/v1oid sha256:33e43441217210b529ffc7a25b90cb17a82e3ada35b4c3bde44287eace3ffa0dsize 269060552123version https://git-lfs.github.com/spec/v1oid sha256:137a44c3c12285b0d9da936a6a99d7456d661f209fb349d8357a02f35eeda4a3size 1029112345678910111213141516171819202122232425262728293031323334{ "additional_special_tokens": [ "<|im_start|>", "<|im_end|>" ], "bos_token": { "content": "<|im_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "eos_token": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "unk_token": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154{ "add_prefix_space": false, "added_tokens_decoder": { "0": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "1": { "content": "<|im_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "2": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "3": { "content": "<repo_name>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "4": { "content": "<reponame>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "5": { "content": "<file_sep>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "6": { "content": "<filename>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "7": { "content": "<gh_stars>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "8": { "content": "<issue_start>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "9": { "content": "<issue_comment>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "10": { "content": "<issue_closed>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "11": { "content": "<jupyter_start>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "12": { "content": "<jupyter_text>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "13": { "content": "<jupyter_code>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "14": { "content": "<jupyter_output>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "15": { "content": "<jupyter_script>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "16": { "content": "<empty_output>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "additional_special_tokens": [ "<|im_start|>", "<|im_end|>" ], "bos_token": "<|im_start|>", "chat_template": "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}", "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "model_max_length": 2048, "pad_token": "<|im_end|>", "tokenizer_class": "GPT2Tokenizer", "unk_token": "<|endoftext|>", "vocab_size": 49152}123456789{ "epoch": 0.9872958257713249, "total_flos": 0.0, "train_loss": 0.6879464878755457, "train_runtime": 373.787, "train_samples": 8806, "train_samples_per_second": 23.559, "train_steps_per_second": 0.182}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147{ "best_metric": null, "best_model_checkpoint": null, "epoch": 0.9872958257713249, "eval_steps": 100, "global_step": 68, "is_hyper_param_search": false, "is_local_process_zero": true, "is_world_process_zero": true, "log_history": [ { "epoch": 0.014519056261343012, "grad_norm": 2.4859837489271306, "learning_rate": 7.142857142857143e-07, "logits/chosen": 0.09337720274925232, "logits/rejected": 0.09554587304592133, "logps/chosen": -152.76107788085938, "logps/rejected": -188.5344696044922, "loss": 0.6931, "rewards/accuracies": 0.0, "rewards/chosen": 0.0, "rewards/margins": 0.0, "rewards/rejected": 0.0, "step": 1 }, { "epoch": 0.14519056261343014, "grad_norm": 1.9129959728137063, "learning_rate": 4.970219740227693e-06, "logits/chosen": 0.5112766027450562, "logits/rejected": 0.892162561416626, "logps/chosen": -149.86944580078125, "logps/rejected": -192.12844848632812, "loss": 0.6935, "rewards/accuracies": 0.3958333432674408, "rewards/chosen": -0.0032075627241283655, "rewards/margins": -0.0028414721600711346, "rewards/rejected": -0.0003660905349534005, "step": 10 }, { "epoch": 0.29038112522686027, "grad_norm": 6.387926383082319, "learning_rate": 4.460299516441777e-06, "logits/chosen": 0.7456380128860474, "logits/rejected": 0.9128583073616028, "logps/chosen": -145.0723876953125, "logps/rejected": -185.00823974609375, "loss": 0.692, "rewards/accuracies": 0.5249999761581421, "rewards/chosen": -0.002810679841786623, "rewards/margins": -0.0024495997931808233, "rewards/rejected": -0.00036108028143644333, "step": 20 }, { "epoch": 0.4355716878402904, "grad_norm": 2.851603494816296, "learning_rate": 3.441819734087963e-06, "logits/chosen": 0.6626991033554077, "logits/rejected": 0.8471162915229797, "logps/chosen": -145.3153076171875, "logps/rejected": -191.17898559570312, "loss": 0.6882, "rewards/accuracies": 0.53125, "rewards/chosen": -0.002587886294350028, "rewards/margins": 0.008108791895210743, "rewards/rejected": -0.010696678422391415, "step": 30 }, { "epoch": 0.5807622504537205, "grad_norm": 2.4335402011634337, "learning_rate": 2.1790041121336223e-06, "logits/chosen": 0.8962385058403015, "logits/rejected": 1.0721851587295532, "logps/chosen": -192.60690307617188, "logps/rejected": -232.34994506835938, "loss": 0.6874, "rewards/accuracies": 0.543749988079071, "rewards/chosen": -0.022678321227431297, "rewards/margins": 0.01420576311647892, "rewards/rejected": -0.03688408061861992, "step": 40 }, { "epoch": 0.7259528130671506, "grad_norm": 4.774287308012212, "learning_rate": 9.994642986290797e-07, "logits/chosen": 0.9905160665512085, "logits/rejected": 1.3741340637207031, "logps/chosen": -162.32839965820312, "logps/rejected": -209.26821899414062, "loss": 0.6823, "rewards/accuracies": 0.59375, "rewards/chosen": -0.002683633007109165, "rewards/margins": 0.022018445655703545, "rewards/rejected": -0.024702081456780434, "step": 50 }, { "epoch": 0.8711433756805808, "grad_norm": 3.010894871763621, "learning_rate": 2.092077387824884e-07, "logits/chosen": 0.9261436462402344, "logits/rejected": 1.0222227573394775, "logps/chosen": -149.97549438476562, "logps/rejected": -182.0010528564453, "loss": 0.6835, "rewards/accuracies": 0.625, "rewards/chosen": -0.006383872590959072, "rewards/margins": 0.01851298287510872, "rewards/rejected": -0.024896854534745216, "step": 60 }, { "epoch": 0.9872958257713249, "step": 68, "total_flos": 0.0, "train_loss": 0.6879464878755457, "train_runtime": 373.787, "train_samples_per_second": 23.559, "train_steps_per_second": 0.182 } ], "logging_steps": 10, "max_steps": 68, "num_input_tokens_seen": 0, "num_train_epochs": 1, "save_steps": 500, "stateful_callbacks": { "TrainerControl": { "args": { "should_epoch_stop": false, "should_evaluate": false, "should_log": false, "should_save": false, "should_training_stop": false }, "attributes": {} } }, "total_flos": 0.0, "train_batch_size": 2, "trial_name": null, "trial_params": null}123version https://git-lfs.github.com/spec/v1oid sha256:1814eb0fd93a0e71c87ba00ea1cd711059a7d8a7330086cef2bc0cc556aa6647size 6520README.mdAdded+60
all_results.jsonAdded+9
config.jsonAdded+30
generation_config.jsonAdded+7
merges.txtAdded
model.safetensorsAdded+3
runs/Jul15_23-01-23_ip-26-0-167-245/events.out.tfevents.1721084621.ip-26-0-167-245.4063478.0Added+3
special_tokens_map.jsonAdded+34
tokenizer.jsonAdded
tokenizer_config.jsonAdded+154
train_results.jsonAdded+9
trainer_state.jsonAdded+147
training_args.binAdded+3
vocab.jsonAdded