Instructions to use 0x404/Qwen2.5-Coder-7B-ccs with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use 0x404/Qwen2.5-Coder-7B-ccs with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="0x404/Qwen2.5-Coder-7B-ccs") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("0x404/Qwen2.5-Coder-7B-ccs") model = AutoModelForCausalLM.from_pretrained("0x404/Qwen2.5-Coder-7B-ccs", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use 0x404/Qwen2.5-Coder-7B-ccs with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "0x404/Qwen2.5-Coder-7B-ccs" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "0x404/Qwen2.5-Coder-7B-ccs", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/0x404/Qwen2.5-Coder-7B-ccs
- SGLang
How to use 0x404/Qwen2.5-Coder-7B-ccs 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 "0x404/Qwen2.5-Coder-7B-ccs" \ --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": "0x404/Qwen2.5-Coder-7B-ccs", "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 "0x404/Qwen2.5-Coder-7B-ccs" \ --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": "0x404/Qwen2.5-Coder-7B-ccs", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use 0x404/Qwen2.5-Coder-7B-ccs with Docker Model Runner:
docker model run hf.co/0x404/Qwen2.5-Coder-7B-ccs
How to use
from datasets import load_dataset
from transformers import pipeline, AutoTokenizer
from sklearn.metrics import accuracy_score, f1_score
model_name = "0x404/Qwen2.5-Coder-7B-ccs"
test_dataset = load_dataset("0x404/ccs_dataset", split="test")
tokenizer = AutoTokenizer.from_pretrained(model_name)
def apply_prompt_template(row):
prompt = tokenizer.init_kwargs["ccs_prompt_template"].format(
diff=row["git_diff"],
message=row["masked_commit_message"]
)
return {"input_prompt": prompt}
test_dataset_with_prompts = test_dataset.map(apply_prompt_template)
pipe = pipeline("text-generation", model=model_name, device_map="auto")
outputs = pipe(test_dataset_with_prompts["input_prompt"], max_new_tokens=10, pad_token_id=pipe.tokenizer.eos_token_id)
predicted_labels = [output[0]["generated_text"].split()[-1] for output in outputs]
accuracy = accuracy_score(test_dataset["annotated_type"], predicted_labels)
f1 = f1_score(test_dataset["annotated_type"], predicted_labels, average="macro")
print("Accuracy:", accuracy)
print("F1 Score (Macro):", f1)
- Downloads last month
- 7