Instructions to use tripathysagar/Qwen2.5-Coder-196M-Shell with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tripathysagar/Qwen2.5-Coder-196M-Shell with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tripathysagar/Qwen2.5-Coder-196M-Shell") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tripathysagar/Qwen2.5-Coder-196M-Shell") model = AutoModelForCausalLM.from_pretrained("tripathysagar/Qwen2.5-Coder-196M-Shell") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use tripathysagar/Qwen2.5-Coder-196M-Shell with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tripathysagar/Qwen2.5-Coder-196M-Shell" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tripathysagar/Qwen2.5-Coder-196M-Shell", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tripathysagar/Qwen2.5-Coder-196M-Shell
- SGLang
How to use tripathysagar/Qwen2.5-Coder-196M-Shell 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 "tripathysagar/Qwen2.5-Coder-196M-Shell" \ --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": "tripathysagar/Qwen2.5-Coder-196M-Shell", "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 "tripathysagar/Qwen2.5-Coder-196M-Shell" \ --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": "tripathysagar/Qwen2.5-Coder-196M-Shell", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tripathysagar/Qwen2.5-Coder-196M-Shell with Docker Model Runner:
docker model run hf.co/tripathysagar/Qwen2.5-Coder-196M-Shell
Model Card for Model ID
Distiled Qwen/Qwen2.5-Coder-0.5B-Instruct by westenfelder/NL2SH-ALFA for NLP to bash command. Distiled only decoder block from 24 to 4 with the original tokenizer.
Model Details
Model Sources [optional]
- Blog: [More Information Needed]
Uses
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_name = "tripathysagar/Qwen2.5-Coder-196M-Shell"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
dtype=torch.bfloat16,
device_map="auto",
)
def infer(inp, debug=False):
msg = [
{"role": "system", "content": "Generate shell command."},
{"role": "user", "content": inp},
]
text = tokenizer.apply_chat_template(
msg,
tokenize=False,
add_generation_prompt=True,
)
if debug:
print(text)
model_inputs = tokenizer([text], return_tensors="pt")
generated_ids = model.generate(
**model_inputs,
max_new_tokens=256,
do_sample=True,
)
resp_text = tokenizer.batch_decode(generated_ids)[0]
if debug:
print(resp_text)
return (inp, resp_text[len(text):].replace('<|im_end|>', ''))
infer("get kernel name.")
- Downloads last month
- 11