HanyangTechAI / 2023-Deep-Learning-Study

2023 HAI 딥러닝 스터디 진행과정을 기록하기 위한 레포지토리입니다.
MIT License
7 stars 2 forks source link

6주차 과제 #6

Open GirinMan opened 1 year ago

GirinMan commented 1 year ago

다섯 번째 과제: Pipeline으로 다양한 NLP task 수행하기

회합 자료 링크: https://github.com/HanyangTechAI/2023-Deep-Learning-Study/issues/1#issuecomment-1543509702 image

Colab Python 노트북을 사용한 huggingface pipeline 실습

huggingface_pipelines.ipynb

Step 1. 예시 노트북을 실행해보며 huggingface pipeline 사용법 익히기

Step 2. Huggingface model hub와 dataset hub를 구경하고, 새로운 task 실행해보기

image

Reference

제출 방식

Ahngab commented 1 year ago

1조 과제 hugging face의 knkarthick/MEETING_SUMMARY model을 load 해서 하나를 실행 했고, SetFit/bbc-news dataset을 가지고 와서 직접 summary해 headline 뉴스를 만들어주는 프로그램을 제작하였다. 6주차1 6주차2

t2easure commented 1 year ago

2조 과제

  1. image t5-base 라는 모델을 불러와서 영어 -> 독일어로 바꿔주는 번역 모델 실행해 봄.

  2. image gpt2를 이용해 문장을 입력하고 그 뒤에 문장을 작문하게 만듦

  3. image pipeline에서 텍스트를 분류하는 모델을 불러와 실행했다.

  4. image image pipeline의 핵심 구성요소인 tokenizer를 통해 텍스트를 모델이 처리할 수 있도록 데이터를 변환하도록 skt/kogpt2-base-v2를 통해 토큰화를 진행해 보았고, 허깅페이스의 GPT2LMHeadModel을 통해 텍스트 생성 예제를 진행했습니다.

ymnseol commented 1 year ago

4조

강다형

roberta-base-squad2 모델로 파이프라인을 실행해봤습니다. 질문-답변 쌍으로 이루어진 데이터를 통해 학습된 모델로, question answering task를 수행합니다.

KakaoTalk_Photo_2023-05-18-16-33-35 KakaoTalk_Photo_2023-05-18-16-33-39

김율희

nlpconnect/vit-gpt2-image-captioning 모델을 이용하여 이미지를 텍스트로 변환하는 작업을 수행했습니다. KakaoTalk_Photo_2023-05-18-18-41-26 001 KakaoTalk_Photo_2023-05-18-18-41-27 002

김재명

model은 summarization model 중 영문에 pre-trained 되어있는 facebook/bart-large-cnn, dataset은 해당 모델에 잘 맞는 cnn_dailymail 을 사용했습니다. KakaoTalk_Photo_2023-05-18-16-34-13 KakaoTalk_Photo_2023-05-18-16-34-20

설유민

Code Summarization에 대해 fine-tuning된 CodeT5를 사용하여 code summarization을 수행했습니다. Pipeline은 text2text-generation을 사용했습니다! Input으로 다익스트라 알고리즘 구현 코드와 위치 정보를 디스플레이하는 코드를 각각 주었을 때, 의도를 잘 파악하는 것 같습니다!

스크린샷 2023-05-18 오후 1 52 48

표지원

FLAN에 prompt를 넣어, 특정 task 제한 없이 다양한 요청에 대해 답변을 하도록 했습니다.

스크린샷 2023-05-18 오후 7 01 57
YUNHYUNWOO commented 1 year ago

3조 hugging face에서 번역모델과 요약모델을 이용하여 영어뉴스를 한글로 요약하도록 하였습니다. HAI 6-1-모델 번역모델은 KoJLabs/nllb-finetuned-en2k을, 요약모델은 eenzeenee/t5-base-korean-summarization을 사용했습니다. HAI 6-2 데이터셋 2 데이터셋은 SetFit/bbc-news을 사용하였습니다.

결과 HAI 6-2-결과 3

jerry7129 commented 1 year ago

5조 image image image

twkang43 commented 1 year ago

강태욱

사용 모델 : t5-base-korean-summarization (링크 : https://huggingface.co/eenzeenee/t5-base-korean-summarization) Screenshot 2023-07-20 at 15 09 13

해당 모델을 통해 뉴스 기사를 요약해보았습니다. 뉴스 기사는 임의로 다음의 기사로 설정했습니다. https://sports.news.naver.com/news?oid=028&aid=0002648964

다음의 코드를 통해 뉴스 기사의 요약을 수행했습니다. 뉴스의 내용에 맞게 적절한 요약을 제공한 것을 확인할 수 있었습니다. Screenshot 2023-07-20 at 15 10 58

mnxcv commented 1 year ago

임세훈

사용 모델

from transformers import pipeline

QA = pipeline("question-answering", model="deepset/roberta-base-squad2", device=device)

Question-Answering task를 수행하는 deepset/roberta-base-squad2 model을 사용하였습니다.

사용 예시

code

news_article = '''
(내용 생략)
'''

BAD_EXAMPLE = {
    'question': "What is the reason of this record-breaking rainfall?",
    'context': news_article
}
print(f"{BAD_EXAMPLE['question']} -> {QA(BAD_EXAMPLE)['answer']}")

GOOD_EXAMPLE = {
    'question': "How many people have been left without power?",
    'context': news_article
}
print(f"{GOOD_EXAMPLE['question']} -> {QA(GOOD_EXAMPLE)['answer']}")

output

What is the reason of this record-breaking rainfall? -> climate change
How many people have been left without power? -> More than 80,000

좋은 예시와 나쁜 예시를 하나씩 찾았습니다.

전체적으로 문장과 잘 연결되어 있는 Question의 경우 옳은 답변을 내놓았지만 그렇지 않은 경우 잘못된 답변을 내놓았습니다.

사용한 Colab Notebook 주소는 여기에서 확인할 수 있습니다.

DHki commented 1 year ago

김동하

사용 모델

knkarthick/MEETING_SUMMARY 모델을 사용해서 간단한 텍스트를 요약해봤습니다.

image

간단한 소개를 입력했을 때, 이와 같이 요약이 잘 되었습니다.

image BBC 뉴스기사를 입력했을 때에도 마찬가지로 요약이 잘 되는 것을 확인했습니다.

KangMeanWoo commented 1 year ago

강민우

사용 모델

VisualQuestionAnswering task를 수행하는 dandelin/vilt-b32-finetuned-vqa모델을 사용하였습니다.

from transformers import pipeline

oracle = pipeline(model="dandelin/vilt-b32-finetuned-vqa")
image_url = "https://datasets-server.huggingface.co/assets/dali-does/clevr-math/--/general/train/15/image/image.png"
oracle(question="How many things are there?", image=image_url, top_k = 1)

[{'score': 0.3569360375404358, 'answer': '6'}]

image

image_url = "https://datasets-server.huggingface.co/assets/dali-does/clevr-math/--/general/train/21/image/image.png"
oracle(question="How many things are there?", image=image_url, top_k = 1)

[{'score': 0.6242725253105164, 'answer': '3'}]

image

두 사진의 사물의 개수에 대해 물어보았는데 첫 번째 사진은 사물도 많고 여러 개의 사물이 붙어 있어서 6이라는 잘못된 답이 나왔고 두 번째 사진에서는 비교적 쉬운 사진이라 3이라는 알맞은 답이 나왔습니다.