Instructions to use Snowflake/snowflake-arctic-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Snowflake/snowflake-arctic-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Snowflake/snowflake-arctic-instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Snowflake/snowflake-arctic-instruct", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Snowflake/snowflake-arctic-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Snowflake/snowflake-arctic-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": "Snowflake/snowflake-arctic-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Snowflake/snowflake-arctic-instruct
- SGLang
How to use Snowflake/snowflake-arctic-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 "Snowflake/snowflake-arctic-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": "Snowflake/snowflake-arctic-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 "Snowflake/snowflake-arctic-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": "Snowflake/snowflake-arctic-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Snowflake/snowflake-arctic-instruct with Docker Model Runner:
docker model run hf.co/Snowflake/snowflake-arctic-instruct
Add Arctic modeling/config/tokenization files
Hello!
This PR should add trust_remote_code=True support for pure transformers, without having to rely on a fork.
Requirements
deepspeed>=0.14.2
transformers
huggingface_hub
hf_transfer
Usage
import os
# enable hf_transfer for faster ckpt download
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
from dataclasses import dataclass
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(
"Snowflake/snowflake-arctic-instruct",
trust_remote_code=True,
revision="refs/pr/3",
)
@dataclass
class ArcticQuantizationConfig:
q_bits: int = 8
rounding: str = "nearest"
mantissa_bits: int = 3
group_size: int = 512
quant_config = ArcticQuantizationConfig(q_bits=8)
model = AutoModelForCausalLM.from_pretrained(
"Snowflake/snowflake-arctic-instruct",
trust_remote_code=True,
low_cpu_mem_usage=True,
device_map="auto",
ds_quantization_config=quant_config,
max_memory={i: "150GiB" for i in range(8)},
torch_dtype=torch.bfloat16,
revision="refs/pr/3",
)
messages = [{"role": "user", "content": "What is 1 + 1 "}]
input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to("cuda")
outputs = model.generate(input_ids=input_ids, max_new_tokens=20)
print(tokenizer.decode(outputs[0]))
This is still untested. Also note that it specifically pulls from the refs/pr/3 branch, i.e. this PR. On my local device, this is able to correctly pull the tokenizer - I haven't tried pulling the model yet as there's no 8xH100s available on AWS for me right now. Instead, I can run the code up until the model downloads to verify that 1) the tokenizer works, 2) the model complains if deepspeed and flash_attn are not installed, 3) the download starts correctly: https://gist.github.com/tomaarsen/3bfaa73c7876dce2b96b4590a4ce2ddc
- Tom Aarsen
Hello @tomaarsen I tried adding the trust_remote_code=True, but it still doesn't work for me.
Attached is the screenshot.
Hello!
I think your transformers version might be too old. You can try upgrading it: pip install -U transformers.
- Tom Aarsen
Hello @tomaarsen @jeffra
I've updated to transformers==4.40.2.
This is the tokenizer code :
AutoTokenizer.from_pretrained("snowflake/snowflake-arctic-instruct", trust_remote_code=True)
I still get the same error as @neha-ori
Error:
File "/home/appuser/.cache/huggingface/modules/transformers_modules/snowflake/snowflake-arctic-instruct/fd069fdeadfd41eac22caac59261372ee58a63ee/tokenization_arctic.py", line 5, in
from transformers.models.llama import LlamaTokenizer
EDIT 1: Using the AutoTokenizer.from_pretrained('Snowflake/snowflake-arctic-embed-l') worked. Shouldn't the tokenizer be a text-embedding model instead of the "snowflake-arctic-instruct"?
Hey @nishantguvvada ,
Just go to your tokenization_arctic.py config file and change:
transformers.models.llama import LlamaTokenizer
to
from transformers import LlamaTokenizer
Should work for you.