Instructions to use IFM/K2-Chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use IFM/K2-Chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="IFM/K2-Chat") 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("IFM/K2-Chat") model = AutoModelForCausalLM.from_pretrained("IFM/K2-Chat", 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 IFM/K2-Chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "IFM/K2-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": "IFM/K2-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/IFM/K2-Chat
- SGLang
How to use IFM/K2-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 "IFM/K2-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": "IFM/K2-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 "IFM/K2-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": "IFM/K2-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use IFM/K2-Chat with Docker Model Runner:
docker model run hf.co/IFM/K2-Chat
Commit History
-
Update README.md
Verified signaturefe59027
-
Update README.md
Verified signature58fdb6c -
Update README.md
Verified signature933682d -
Update README.md
Verified signature99e0342 -
Update README.md
Verified signature4d89b34 -
Update README.md
Verified signaturec6d651f -
Update README.md
Verified signature67655c6 -
Delete files * . s a f e t e n s o r s * with huggingface_hub
Verified signatured68cefa -
Delete files t o k e n i z e r _ c o n f i g _ b k . j s o n with huggingface_hub
Verified signature50aecd6 -
Add files using upload-large-folder tool
Verified signaturedfd72b0 -
Update README.md
Verified signature6f5866f -
Update README.md
Verified signatured02e2d1
-
Update README.md
Verified signature274ce6d
-
Upload folder using huggingface_hub
Verified signature8228132 -
Update config.json
Verified signature1f2d8fb
-
Update README.md (#2)
Verified signature- Update README.md (66a39e6319f1f5434ac4e7572f0bfb4d08591381)5454f2d -
Upload tokenizer
Verified signatureaaf824f
-
Update config.json
Verified signaturefa4fcfb
-
Update README.md
Verified signature85981b8 -
Update README.md
Verified signaturea25352f -
Update README.md
Verified signature3e3276a -
Update README.md
Verified signature6adcc00 -
Update README.md
Verified signaturef5dcc9c -
Update README.md
Verified signature998f2fd -
Rename k2_chat_evals.png to k2_chat_table_of_tables.png
Verified signaturee928084 -
Upload k2_chat_evals.png
Verified signaturebc127e7 -
Update README.md
Verified signature84a7b49 -
Update README.md
Verified signature4f313e1 -
Update README.md
Verified signature8ae4d54
-
Update README.md
Verified signature64d1f17 -
Update README.md
Verified signatureb3a134a -
Upload config.json with huggingface_hub
Verified signature43cea23 -
Upload config.json with huggingface_hub
Verified signature510dfb8 -
Delete folder .ipynb_checkpoints with huggingface_hub
Verified signature41a4121 -
Upload folder using huggingface_hub
Verified signaturee92c40c -
Delete folder .ipynb_checkpoints with huggingface_hub
Verified signature0c3b6c6 -
Upload folder using huggingface_hub
Verified signature73b7003 -
Upload folder using huggingface_hub
Verified signature9a461e4 -
Rename Screen Shot 2024-05-28 at 10.47.26 AM.png to k2_chat_eval_table.png
Verified signaturef894f6f -
Upload Screen Shot 2024-05-28 at 10.47.26 AM.png
Verified signaturedc5991d -
Update README.md
Verified signature1f28ab9
-
initial commit
Verified signature0ab34e4