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 |
+
```
|