Text Generation
Transformers
Safetensors
MLX
starcoder2
code
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use mlx-community/starcoder2-15b-instruct-v0.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mlx-community/starcoder2-15b-instruct-v0.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mlx-community/starcoder2-15b-instruct-v0.1") 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("mlx-community/starcoder2-15b-instruct-v0.1") model = AutoModelForCausalLM.from_pretrained("mlx-community/starcoder2-15b-instruct-v0.1", 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]:])) - MLX
How to use mlx-community/starcoder2-15b-instruct-v0.1 with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("mlx-community/starcoder2-15b-instruct-v0.1") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- vLLM
How to use mlx-community/starcoder2-15b-instruct-v0.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mlx-community/starcoder2-15b-instruct-v0.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/starcoder2-15b-instruct-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mlx-community/starcoder2-15b-instruct-v0.1
- SGLang
How to use mlx-community/starcoder2-15b-instruct-v0.1 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 "mlx-community/starcoder2-15b-instruct-v0.1" \ --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": "mlx-community/starcoder2-15b-instruct-v0.1", "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 "mlx-community/starcoder2-15b-instruct-v0.1" \ --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": "mlx-community/starcoder2-15b-instruct-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - MLX LM
How to use mlx-community/starcoder2-15b-instruct-v0.1 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/starcoder2-15b-instruct-v0.1"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/starcoder2-15b-instruct-v0.1" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/starcoder2-15b-instruct-v0.1", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use mlx-community/starcoder2-15b-instruct-v0.1 with Docker Model Runner:
docker model run hf.co/mlx-community/starcoder2-15b-instruct-v0.1
- Atomic Chat
Commit History
-
Upload folder using huggingface_hub (#1)
Verified signature- baf58b8d32b39736cd6eaa17467bf72776d59cc4fe084078788790d465c8e300 (c606b81c122c27ff22bf9f4376528ec496daf6b5) - 515432b03557f9483718e17007975f7d9472fea814e0c7b0f2d6fbb64f4f2d38 (24bc1e0317f8fc76d348a07de1a57d930689289c) - 894ab3687b11c4306d7572309979f2e8aca428b5acd32b14d206349446d66bd3 (97b21cd90fa649ae06dad9f7ba195267e795edd8) - 4ce6f099a3ae51d6a7267946888be2ba475e5d8c4979825b7e9d6859762b1515 (49d91409fff50a4ed34562abc4155e5bbfeabad2) - 0ff4b00625712f552408143403f0011918f11131ecdd9282003761d7506e062d (c8ee86a6b4ccb869592dc1ecd6e0e03d218a54bc) - 36d4b9780e92c87e263a809fc39b752b4bd724f492f1ba8fb4a755f82d48031b (54b6bfe4dcd2181c73341304c38a7e1b0eed8cd5) - fbdd6a7c7fd5ae5aaa2735d6c49deadb47c38018dd7435700d422752823000d1 (023875b1d941a50afd7827b5b4c44cc5a6a2e7ec) - f9523db01079b42011e08321c32a8d8a324a236ed06b409c0ea2d06bfeb3c3ad (4420f84db970e9586ba70db7e2db28cb817d4a88) - ffc723ef63cdd1bcc608a9e0ecfda6bdceb5e384b3ff3180f36ddc0f0f4a3920 (e533e01da5a035dbc0d15c3589d553577be25009) - 851c4546…8e396f3 -
initial commit
9e62c93