Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- ja
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
tags:
|
| 6 |
+
- text-generation-inference
|
| 7 |
+
- code
|
| 8 |
+
- transformers
|
| 9 |
+
- trl
|
| 10 |
+
- qwen2
|
| 11 |
+
datasets:
|
| 12 |
+
- sakusakumura/databricks-dolly-15k-ja-scored
|
| 13 |
+
- nu-dialogue/jmultiwoz
|
| 14 |
+
- kunishou/amenokaku-code-instruct
|
| 15 |
+
- HachiML/alpaca_jp_python
|
| 16 |
+
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# Uploaded model
|
| 20 |
+
|
| 21 |
+
- **Developed by:** taoki
|
| 22 |
+
- **License:** apache-2.0
|
| 23 |
+
- **Finetuned from model :** Qwen/Qwen2.5-Coder-7B-Instruct
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# Usage
|
| 27 |
+
|
| 28 |
+
```python
|
| 29 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 30 |
+
|
| 31 |
+
model_name = "taoki/Qwen2.5-Coder-7B-Instruct_lora_jmultiwoz-dolly-amenokaku-alpaca_jp_python"
|
| 32 |
+
|
| 33 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 34 |
+
model_name,
|
| 35 |
+
torch_dtype="auto",
|
| 36 |
+
device_map="auto"
|
| 37 |
+
)
|
| 38 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 39 |
+
|
| 40 |
+
prompt = "OpenCVを用いて定点カメラから画像を保存するコードを示してください。"
|
| 41 |
+
messages = [
|
| 42 |
+
{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. 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(model.device)
|
| 51 |
+
|
| 52 |
+
generated_ids = model.generate(
|
| 53 |
+
**model_inputs,
|
| 54 |
+
max_new_tokens=512
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=False)[0]
|
| 58 |
+
print(response)
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
# Output
|
| 62 |
+
````
|
| 63 |
+
<|im_start|>system
|
| 64 |
+
You are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>
|
| 65 |
+
<|im_start|>user
|
| 66 |
+
クイックソートのアルゴリズムを書いて<|im_end|>
|
| 67 |
+
<|im_start|>assistant
|
| 68 |
+
```python
|
| 69 |
+
def quicksort(arr):
|
| 70 |
+
if len(arr) <= 1:
|
| 71 |
+
return arr
|
| 72 |
+
pivot = arr[len(arr) // 2]
|
| 73 |
+
left = [x for x in arr if x < pivot]
|
| 74 |
+
middle = [x for x in arr if x == pivot]
|
| 75 |
+
right = [x for x in arr if x > pivot]
|
| 76 |
+
return quicksort(left) + middle + quicksort(right)
|
| 77 |
+
|
| 78 |
+
print(quicksort([3,6,8,10,1,2,1]))
|
| 79 |
+
```<|im_end|>
|
| 80 |
+
````
|