Kestrel
Collection
Experimental looped transformer models with neural memory. โข 4 items โข Updated
How to use lillycham/Kestrel-34M-instruct with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="lillycham/Kestrel-34M-instruct", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # pip install -U transformers accelerate
# Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("lillycham/Kestrel-34M-instruct", trust_remote_code=True, device_map="auto")How to use lillycham/Kestrel-34M-instruct with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "lillycham/Kestrel-34M-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": "lillycham/Kestrel-34M-instruct",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/lillycham/Kestrel-34M-instruct
How to use lillycham/Kestrel-34M-instruct with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "lillycham/Kestrel-34M-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": "lillycham/Kestrel-34M-instruct",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "lillycham/Kestrel-34M-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": "lillycham/Kestrel-34M-instruct",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use lillycham/Kestrel-34M-instruct with Docker Model Runner:
docker model run hf.co/lillycham/Kestrel-34M-instruct
Supervised fine-tuning run initialized from Kestrel-34M-base using assistant-only loss.
prelude=1, core=4 x 3 loops, coda=1, hidden_size=512, attention_window=256, memory_chunk_size=64, memory_heads=4, vocab_size=16384)This model uses a custom KestrelForCausalLM architecture (trust_remote_code=True):
from transformers import AutoModelForCausalLM, AutoTokenizer
repo_id = "lillycham/Kestrel-34M-instruct"
tokenizer = AutoTokenizer.from_pretrained(repo_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo_id, trust_remote_code=True)
prompt = tokenizer.apply_chat_template([{"role": "user", "content": "Hello!"}], tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt")
out = model.generate(inputs.input_ids, max_new_tokens=64, temperature=0.7, top_p=0.9)
print(tokenizer.decode(out[0], skip_special_tokens=False))
2000, Batch size: 8 x grad_accum 4, Sequence length: 1024lr=0.004) + AdamW (lr=0.0002), weight decay 0.01bf16 on cuda