데이터 과학 노트

[deeplearning.ai] How Diffusion Models Work 본문

Computer Vision/생성 모델

[deeplearning.ai] How Diffusion Models Work

Data Scientist Note 2023. 6. 19. 12:35

(deeplearning.ai) How Diffusion Models Work

강좌 정보

  • Instructors: Sharon Zhou, Andrew Ng (Stanford)
  • 강좌 링크
  • (왼쪽) 주피터 노트북 / (오른쪽) 강좌

Introduction

  •  

Intuition

  • Goal
    • sprite images → even more sprites
  • NN to learn what a sprite is:
    • add different noise levels to the training data of sprites

Sampling

Principle 1: 명확하고 구체적인 명력어 사용 (Write clear and specific instructions)

  • clear / short
  • Tactic 1: 구분 기호 사용: 따옴표, 백틱, 대시, 꺽쇠 괄호, XML 태그 (Use delimiters: triple quotes, triple backticks, triple dashes, angle brackets, XML tags)
    • avoiding prompt injections
  • * seperate sections
  • Tactic 2: 구조화된 출력 요청 (Ask for structured output)
  • Tactic 3: 조건 만족 여부 확인, 작업 수행에 필요한 가정 확인 (Check whether conditions are satisfied, Check assumptions required to do the task)
  • Tactic 4: 작업을 성공적으로 완료한 사례를 제시 ("Few-shot" prompting; Give successful examples of completing tasks. Then ask model to perform the task)
# tactic 1
prompt = f"""
Summarize the text delimited by triple backticks \ 
into a single sentence.
```{text}```
"""
response = get_completion(prompt)
print(response)
# tactic 2
prompt = f"""
Generate a list of three made-up book titles along \ 
with their authors and genres. 
Provide them in JSON format with the following keys: 
book_id, title, author, genre.
"""
response = get_completion(prompt)
print(response)
# tactic 3
prompt = f"""
You will be provided with text delimited by triple quotes. 
If it contains a sequence of instructions, \ 
re-write those instructions in the following format:

Step 1 - ...
Step 2 - …
…
Step N - …

If the text does not contain a sequence of instructions, \ 
then simply write \"No steps provided.\"

\"\"\"{text_1}\"\"\"
"""
response = get_completion(prompt)
print("Completion for Text 1:")
print(response)
# tactic 4
prompt = f"""
Your task is to answer in a consistent style.

<child>: Teach me about patience.

<grandparent>: The river that carves the deepest \ 
valley flows from a modest spring; the \ 
grandest symphony originates from a single note; \ 
the most intricate tapestry begins with a solitary thread.

<child>: Teach me about resilience.
"""
response = get_completion(prompt)
print(response)

Principle 2: 모델에게 생각할 시간 주기 (Give the model time to think)

  • Tactic 1: 작업을 완료하는 데 필요한 단계 지정 (Specify the steps required to complete a task)
  • Tactic 2: 성급하게 결론을 내리기 전에 모델이 자체 솔루션을 해결하도록 지시 (Instruct the model to work out its own solution before rushing to a conclusion)
# tactic 1
prompt_1 = f"""
Perform the following actions: 
1 - Summarize the following text delimited by triple \
backticks with 1 sentence.
2 - Translate the summary into French.
3 - List each name in the French summary.
4 - Output a json object that contains the following \
keys: french_summary, num_names.

Separate your answers with line breaks.

Text:
```{text}```
"""
response = get_completion(prompt_1)
print("Completion for prompt 1:")
print(response)
# tactic 2
- First, work out your own solution to the problem. 
- Then compare your solution to the student's solution \ 
and evaluate if the student's solution is correct or not. 
Don't decide if the student's solution is correct until 
you have done the problem yourself.

그 외 강좌

  • ChatGPT Prompt Engineering for Developers
  • LangChain for LLM Application Development
  • How Diffusion Models Work
  • Building Systems with the ChatGPT API

References

'Computer Vision > 생성 모델' 카테고리의 다른 글

생성 모델 평가 지표 PSNR, SSIM  (0) 2024.04.09