심층 분석과 코드 생성

Python으로 DeepSeek 활용하기

James Chapman

AI Curriculum Lead, DataCamp

요약...

print(response.choices[0].message.content)
Step 1 - ...
Step 2 - ...
Final Answer: ...
  • 추론 기능은 기본적으로 켜져 있습니다 → reasoning_effort="high" 또는 "max"로 조정하세요
  • 추론 중에는 temperature가 영향을 미치지 않습니다
Python으로 DeepSeek 활용하기

1. 간단하게 유지하세요

  • 간결한 프롬프트

✅ What are the differences between lists and tuples in Python?

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

  • 예시 제공(예: few-shot)은 성능을 저하시킬 수 있습니다

✅ Who developed the Python programming language?

❌

Example 1:
Q: Who developed the R programming language?
A: Ross Ihaka and Robert Gentleman
Python으로 DeepSeek 활용하기

2. 추론을 유도하세요

 

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

 

❌ 토큰 사용량 증가

❌ 응답 시간 증가

Python으로 DeepSeek 활용하기

3. 간단한 작업에는 사용하지 마세요!

 

채팅 모드

간단한 작업을 쉽게 수행하는 채팅 모델

 

추론 모드

간단한 문제에 어려움을 겪는 추론 모델

Python으로 DeepSeek 활용하기

3. 간단한 작업에는 사용하지 마세요!

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4.1-Flash",
    messages=[{"role": "user", "content": "Return the result of 1+1."}]
)
print(response.choices[0].message.content)
Let's count step by step.
- Start with 1.
- Add another 1.
- 1 + 1 = 2.

**Final Answer: 2**
  • 간단한 조회 작업에는 구조화된 추론이 과합니다
  • 채팅 방식 답변보다 토큰과 지연 시간이 더 많이 듭니다
Python으로 DeepSeek 활용하기

예시: 코드 디버깅

코드를 디버깅하는 사람

추론 모델 워크플로

Python으로 DeepSeek 활용하기

예시: 코드 디버깅

오류를 기반으로 코드를 수정하는 추론 모델

Python으로 DeepSeek 활용하기

예시: 코드 디버깅

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

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

count_to_ten(1)
"""
Python으로 DeepSeek 활용하기
print(response.choices[0].message.content)
Let me walk through the function step by step.

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 — that's the issue.

The fix is to add an increment to start inside the loop. Like start += 1.

Here is the corrected code:

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

count_to_ten(1)
Python으로 DeepSeek 활용하기

연습해 봅시다!

Python으로 DeepSeek 활용하기

Preparing Video For Download...