Instructions to use NTQAI/Nxcode-CQ-7B-orpo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NTQAI/Nxcode-CQ-7B-orpo with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NTQAI/Nxcode-CQ-7B-orpo") 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("NTQAI/Nxcode-CQ-7B-orpo") model = AutoModelForCausalLM.from_pretrained("NTQAI/Nxcode-CQ-7B-orpo", 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 NTQAI/Nxcode-CQ-7B-orpo with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NTQAI/Nxcode-CQ-7B-orpo" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NTQAI/Nxcode-CQ-7B-orpo", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NTQAI/Nxcode-CQ-7B-orpo
- SGLang
How to use NTQAI/Nxcode-CQ-7B-orpo 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 "NTQAI/Nxcode-CQ-7B-orpo" \ --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": "NTQAI/Nxcode-CQ-7B-orpo", "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 "NTQAI/Nxcode-CQ-7B-orpo" \ --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": "NTQAI/Nxcode-CQ-7B-orpo", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NTQAI/Nxcode-CQ-7B-orpo with Docker Model Runner:
docker model run hf.co/NTQAI/Nxcode-CQ-7B-orpo
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: tongyi-qianwen
|
| 4 |
+
license_link: >-
|
| 5 |
+
https://huggingface.co/Qwen/CodeQwen1.5-7B-Chat/blob/main/LICENSE
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
pipeline_tag: text-generation
|
| 9 |
+
tags:
|
| 10 |
+
- chat
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Nxcode-CQ-7B-orpo
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
## Introduction
|
| 17 |
+
|
| 18 |
+
Nxcode-CQ-7B-orpo is the Code-Specific version of Qwen1.5. It is a transformer-based decoder-only language model pretrained on a large amount of data of codes.
|
| 19 |
+
|
| 20 |
+
* Strong code generation capabilities and competitve performance across a series of benchmarks;
|
| 21 |
+
* Supporting long context understanding and generation with the context length of 64K tokens;
|
| 22 |
+
* Supporting 92 coding languages
|
| 23 |
+
* Excellent performance in text-to-SQL, bug fix, etc.
|
| 24 |
+
|
| 25 |
+
## Quickstart
|
| 26 |
+
|
| 27 |
+
Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
|
| 28 |
+
|
| 29 |
+
```python
|
| 30 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 31 |
+
device = "cuda" # the device to load the model onto
|
| 32 |
+
|
| 33 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 34 |
+
"Qwen/CodeQwen1.5-7B-Chat",
|
| 35 |
+
torch_dtype="auto",
|
| 36 |
+
device_map="auto"
|
| 37 |
+
)
|
| 38 |
+
tokenizer = AutoTokenizer.from_pretrained("NTQAI/Nxcode-CQ-7B-orpo")
|
| 39 |
+
|
| 40 |
+
prompt = "Write a quicksort algorithm in python."
|
| 41 |
+
messages = [
|
| 42 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 43 |
+
{"role": "user", "content": prompt}
|
| 44 |
+
]
|
| 45 |
+
text = tokenizer.apply_chat_template(
|
| 46 |
+
messages,
|
| 47 |
+
tokenize=False,
|
| 48 |
+
add_generation_prompt=True
|
| 49 |
+
)
|
| 50 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
| 51 |
+
|
| 52 |
+
generated_ids = model.generate(
|
| 53 |
+
model_inputs.input_ids,
|
| 54 |
+
max_new_tokens=512
|
| 55 |
+
)
|
| 56 |
+
generated_ids = [
|
| 57 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 58 |
+
]
|
| 59 |
+
|
| 60 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 61 |
+
```
|