Update README.md
Browse files
README.md
CHANGED
@@ -20,6 +20,65 @@ datasets:
|
|
20 |
- **License:** deepseek
|
21 |
- **Finetuned from model :** deepseek-ai/deepseek-coder-7b-instruct-v1.5
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
24 |
|
25 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
20 |
- **License:** deepseek
|
21 |
- **Finetuned from model :** deepseek-ai/deepseek-coder-7b-instruct-v1.5
|
22 |
|
23 |
+
|
24 |
+
# Usage
|
25 |
+
|
26 |
+
```python
|
27 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
28 |
+
import torch
|
29 |
+
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
31 |
+
"taoki/deepseek-coder-7b-instruct-v1.5-qlora-amenokaku-code"
|
32 |
+
)
|
33 |
+
model = AutoModelForCausalLM.from_pretrained(
|
34 |
+
"taoki/deepseek-coder-7b-instruct-v1.5-qlora-amenokaku-code"
|
35 |
+
)
|
36 |
+
|
37 |
+
|
38 |
+
if torch.cuda.is_available():
|
39 |
+
model = model.to("cuda")
|
40 |
+
|
41 |
+
prompt="""You are an AI programming assistant, utilizing the DeepSeek Coder model, developed by DeepSeek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer.
|
42 |
+
### Instruction:
|
43 |
+
OpenCVを用いて定点カメラから画像を保存するコードを示してください。
|
44 |
+
### Response:
|
45 |
+
"""
|
46 |
+
|
47 |
+
input_ids = tokenizer(prompt, return_tensors="pt").to(model.device)
|
48 |
+
outputs = model.generate(
|
49 |
+
**input_ids,
|
50 |
+
max_new_tokens=256,
|
51 |
+
do_sample=True,
|
52 |
+
top_p=0.9,
|
53 |
+
temperature=0.2,
|
54 |
+
repetition_penalty=1.1,
|
55 |
+
)
|
56 |
+
print(tokenizer.decode(outputs[0]))
|
57 |
+
|
58 |
+
"""
|
59 |
+
<|begin▁of▁sentence|>You are an AI programming assistant, utilizing the DeepSeek Coder model, developed by DeepSeek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer.
|
60 |
+
### Instruction:
|
61 |
+
OpenCVを用いて定点カメラから画像を保存するコードを示してください。
|
62 |
+
### Response:
|
63 |
+
```python
|
64 |
+
import cv2
|
65 |
+
cap = cv2.VideoCapture(0) # カメラの設定
|
66 |
+
fourcc = cv2.VideoWriter_fourcc(*'XVID') # 動画の形式
|
67 |
+
out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640, 480)) # 出力先、fps、解像度
|
68 |
+
while True:
|
69 |
+
ret, frame = cap.read() # 映像読み込み
|
70 |
+
if not ret: break
|
71 |
+
out.write(frame) # 書き込み
|
72 |
+
cv2.imshow('Frame', frame) # 表示
|
73 |
+
if cv2.waitKey(1) & 0xFF == ord('q'): # qで終了
|
74 |
+
break
|
75 |
+
cap.release()
|
76 |
+
cv2.destroyAllWindows()
|
77 |
+
```
|
78 |
+
<|EOT|>
|
79 |
+
"""
|
80 |
+
|
81 |
+
|
82 |
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
83 |
|
84 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|