Instructions to use MSDDDD/Kestrel-330M-Chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MSDDDD/Kestrel-330M-Chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MSDDDD/Kestrel-330M-Chat", 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("MSDDDD/Kestrel-330M-Chat", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("MSDDDD/Kestrel-330M-Chat", 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 MSDDDD/Kestrel-330M-Chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MSDDDD/Kestrel-330M-Chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MSDDDD/Kestrel-330M-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MSDDDD/Kestrel-330M-Chat
- SGLang
How to use MSDDDD/Kestrel-330M-Chat 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 "MSDDDD/Kestrel-330M-Chat" \ --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": "MSDDDD/Kestrel-330M-Chat", "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 "MSDDDD/Kestrel-330M-Chat" \ --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": "MSDDDD/Kestrel-330M-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MSDDDD/Kestrel-330M-Chat with Docker Model Runner:
docker model run hf.co/MSDDDD/Kestrel-330M-Chat
Kestrel-330M-Chat
The chat-tuned version of Kestrel-330M. Kestrel-330M is a 336M-parameter model trained from scratch by one person on a single GPU, on 6B tokens.
How it was tuned
- Data: one epoch of supervised fine-tuning on smol-smoltalk, about 298M tokens. Loss was computed on the assistant turns only.
- Optimizer: AdamW at learning rate 1e-4 with a cosine schedule.
- Identity: a short second pass taught it its name. It now says it is Kestrel, an AI language model made by an independent developer.
Chat format
The format is plain text, and the bundled chat template produces it:
User: Why is the sky blue?
Assistant: <answer><|endoftext|>
from transformers import AutoTokenizer, AutoModelForCausalLM
tok = AutoTokenizer.from_pretrained("MSDDDD/Kestrel-330M-Chat")
model = AutoModelForCausalLM.from_pretrained("MSDDDD/Kestrel-330M-Chat", trust_remote_code=True)
msgs = [{"role": "user", "content": "Write a Python function that reverses a string."}]
x = tok.apply_chat_template(msgs, return_tensors="pt")
out = model.generate(x, max_new_tokens=200, do_sample=True, temperature=0.6, top_k=40, repetition_penalty=1.1)
print(tok.decode(out[0, x.shape[1]:], skip_special_tokens=True))
trust_remote_code=True is required. It adds the final logit soft-cap that the model was trained with.
Example answers (unedited)
User: Why is the sky blue? Assistant: The sky appears blue due to the scattering of light by molecules in Earth's atmosphere. … This process is known as Rayleigh scattering.
User: Write a Python function that reverses a string. Assistant:
def reverse_string(s): return s[::-1]
User: What is the capital of Japan? Assistant: The capital of Japan is Tokyo, …
Limitations
This is a very small model, and these limitations are serious:
- Facts: it often invents facts, names, dates and places, even right after a correct answer.
- Arithmetic and reasoning: these are unreliable. For example, it gets simple additions wrong.
- Questions about itself: beyond its name, it can still role-play a human, such as a programmer, a parent or a student.
- Unsafe content: no safety tuning or preference tuning (RLHF/DPO) was applied. It can produce inappropriate, biased or crude content.
- Length: answers can drift off topic when they run long.
It is meant for research and experimentation only. Do not use it for advice or for anything important.
License
The model weights are released under Apache-2.0. The training data is under its own licenses.
- Downloads last month
- 9
Model tree for MSDDDD/Kestrel-330M-Chat
Base model
MSDDDD/Kestrel-330M