Phân tích sâu và sinh mã

Làm việc với DeepSeek bằng Python

James Chapman

Curriculum Manager, DataCamp

Tóm tắt...

Đầu ra suy luận
<think>
Quy trình suy nghĩ...
</think>

Phản hồi cuối: ...
  • NghĩLàmCập nhật
  • model="deepseek-ai/DeepSeek-R1"
  • Không có tham số temperature cho mô hình suy luận
Làm việc với DeepSeek bằng Python

1. Giữ mọi thứ đơn giản

  • Nhắc gọn

What are the differences between lists and tuples in Python?

In Python, there are different data structures. Lists are...

  • Cung cấp ví dụ (ví dụ: few-shot) có thể giảm hiệu suất

Who developed the Python programming language?

Example 1:
Q: Who developed the R programming language?
A: Ross Ihaka and Robert Gentleman
Làm việc với DeepSeek bằng Python

2. Khuyến khích suy luận

 

"... Take your time and think through each step."

 

Độ chính xác cao hơn

Tốn nhiều token hơn

Thời gian phản hồi lâu hơn

Làm việc với DeepSeek bằng Python

3. Tránh các tác vụ quá đơn giản!

 

Mô hình chat

Một mô hình chat dễ dàng hoàn thành tác vụ đơn giản.

 

Mô hình suy luận

Một mô hình suy luận gặp khó với vấn đề đơn giản.

1 Tạo với GPT-4o
Làm việc với DeepSeek bằng Python

3. Tránh các tác vụ quá đơn giản!

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-R1",
    messages=[{"role": "user", "content": "Return the result of 1+1."}]
)
<think>
Okay, so the user is asking for the result of 1 plus 1. Let me think about this. Well, basic
arithmetic tells me that when you add two numbers together, you combine their values. So 1 added
to another 1 should be... hmm. Let me visualize it. If I have one apple and someone gives me
another apple, I now have two apples. That makes sense. So 1 + 1 equals 2. Wait, is there any
trick here? The question seems straightforward, but maybe I should double-check. Let me count on
my fingers. One finger up, then add another...
</think>

Kết quả của 1 + 1 là **2**.
Làm việc với DeepSeek bằng Python

3. Tránh các tác vụ quá đơn giản!

Đầu ra chat

The result of \(1 + 1\) is \(2\). 
\[
1 + 1 = 2
\]
Làm việc với DeepSeek bằng Python

Ví dụ: Gỡ lỗi mã

Một người đang gỡ lỗi mã.

Quy trình của mô hình suy luận.

1 Tạo với GPT-4o
Làm việc với DeepSeek bằng Python

Ví dụ: Gỡ lỗi mã

Một mô hình suy luận sửa mã dựa trên lỗi.

1 Tạo với GPT-4o
Làm việc với DeepSeek bằng Python

Ví dụ: Gỡ lỗi mã

prompt = """
[Task: Fix the following code.]

Code:
def count_to_ten(start):
    while start < 10:
        print(start)
    return "Done"

count_to_ten(1)
"""
Làm việc với DeepSeek bằng Python
<think>
Okay, let's see. The user provided a Python function called count_to_ten...

The function uses a while loop: while start < 10. Then it prints start. But wait, inside the loop,
there's no increment for the start variable. Oh right, that's the issue...

So the fix is to add an increment to start inside the loop. Like start += 1...
</think>

Đây là mã đã sửa:

def count_to_ten(start):
    while start < 10:
        print(start)
        start += 1
    return "Done"

count_to_ten(1)
Làm việc với DeepSeek bằng Python

Vamos praticar!

Làm việc với DeepSeek bằng Python

Preparing Video For Download...