Transformers documentation

DePlot

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v5.22.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

이 모델은 2022-12-20에 HF papers에 게시되었으며, 2023-06-20에 Hugging Face Transformers에 기여되었습니다.

DePlot

개요

DePlot은 Fangyu Liu, Julian Martin Eisenschlos, Francesco Piccinno, Syrine Krichene, Chenxi Pang, Kenton Lee, Mandar Joshi, Wenhu Chen, Nigel Collier, Yasemin Altun의 논문 DePlot: One-shot visual language reasoning by plot-to-table translation에서 제안되었습니다.

해당 논문의 초록은 다음과 같이 서술합니다:

차트와 플롯과 같은 시각적 언어는 인간 세계에서 보편적입니다. 플롯과 차트를 이해하려면 강력한 추론 능력이 필요합니다. 기존의 최첨단(SOTA) 모델은 최소 수만 개의 학습 예제가 필요하며, 특히 복잡한 사람이 작성한 쿼리에 대해서는 추론 능력이 여전히 크게 제한되어 있습니다. 이 논문은 시각적 언어 추론에 대한 최초의 원샷(one-shot) 해결책을 제시합니다. 우리는 시각적 언어 추론의 과제를 두 단계로 분해합니다: (1) 플롯에서 텍스트로의 변환, (2) 변환된 텍스트에 대한 추론. 이 방법의 핵심은 DePlot이라고 명명된 모달리티 변환 모듈로, 플롯이나 차트의 이미지를 선형화된 테이블로 변환합니다. DePlot의 출력은 사전 학습된 대규모 언어 모델(LLM)의 프롬프트로 직접 사용될 수 있으며, 이를 통해 LLM의 소수샷(few-shot) 추론 능력을 활용할 수 있습니다. DePlot을 얻기 위해, 우리는 플롯에서 테이블로 변환하는 작업을 통일된 작업 형식과 메트릭을 확립하여 표준화하고, 이 작업을 기반으로 DePlot을 엔드투엔드로 학습시킵니다. 이후 DePlot은 LLM과 함께 플러그 앤 플레이 방식으로 즉시 사용할 수 있습니다. 28,000개 이상의 데이터 포인트로 파인튜닝된 SOTA 모델과 비교할 때, 원샷 프롬프팅만 사용한 DePlot+LLM은 차트 QA 작업의 사람이 작성한 쿼리에서 파인튜닝된 SOTA 대비 24.0%의 성능 향상을 달성합니다.

DePlot은 Pix2Struct 아키텍처를 사용하여 학습된 모델입니다. Pix2Struct에 대한 자세한 내용은 Pix2Struct 문서에서 확인하실 수 있습니다. DePlot은 Pix2Struct 아키텍처의 Visual Question Answering 하위 집합입니다. 입력 질문을 이미지에 렌더링하고 답변을 예측합니다.

사용 예시

현재 DePlot에 사용할 수 있는 체크포인트는 하나입니다:

  • google/deplot: ChartQA 데이터셋으로 fine-tuning된 DePlot
import requests
from PIL import Image

from transformers import AutoProcessor, Pix2StructForConditionalGeneration


model = Pix2StructForConditionalGeneration.from_pretrained("google/deplot", device_map="auto")
processor = AutoProcessor.from_pretrained("google/deplot")
url = "https://raw.githubusercontent.com/vis-nlp/ChartQA/main/ChartQA%20Dataset/val/png/5090.png"
image = Image.open(requests.get(url, stream=True).raw)

inputs = processor(images=image, text="Generate underlying data table of the figure below:", return_tensors="pt").to(model.device)
predictions = model.generate(**inputs, max_new_tokens=512)
print(processor.decode(predictions[0], skip_special_tokens=True))

파인튜닝

DePlot를 fine-tune하려면 pix2struct fine-tuning notebook을 참고하세요. Pix2Struct 모델의 경우, Adafactor와 cosine learning rate scheduler를 사용하여 모델을 fine-tune하면 수렴이 더 빠르게 이루어진다는 것을 확인했습니다:

from transformers.optimization import Adafactor, get_cosine_schedule_with_warmup


optimizer = Adafactor(self.parameters(), scale_parameter=False, relative_step=False, lr=0.01, weight_decay=1e-05)
scheduler = get_cosine_schedule_with_warmup(optimizer, num_warmup_steps=1000, num_training_steps=40000)

DePlot는 Pix2Struct 아키텍처를 사용하여 학습된 모델입니다. API 참조는 Pix2Struct 문서를 확인하세요.

Update on GitHub