목록전체 글 (110)
토니의 연습장

1. dim=0 기준 : "행 기준/고정하고 열별로 값 찾기"torch.max(A, dim=0) -> dim=0 : "dim=0(행) 기준으로 위아래에서 프레스로 눌러서 각 열별로 최대값만 살아남는다"-> 각 열별로, 결과는 열의 개수만큼 값과 해당되는 행 인덱스 반환 -> 열 개수만큼 원소 갖는 1차원 형태 결과 나옴 (shape : 상수)-> keepdim=True 를 해 주면 tensor(1행, 열개수만큼의 열) 의 2차원 행x열로 결과 나옴 ex) torch.randn(3,4) 에서 torch.max(A, dim=0) 결과 원소 4개 갖는 1차원 행 나옴 torch.max(A, dim=0, keepdim=True) 결과 tensor(1, 4) 형태 나옴dim=0: 행(0축)을..

Text-to-Image 생성모델의 시작점참고 : https://youtu.be/-e-vW1j132A

CacheBackedEmbeddingsEmbeddings는 재계산을 피하기 위해 저장되거나 일시적으로 캐시될 수 있습니다.Embeddings를 캐싱하는 것은 CacheBackedEmbeddings를 사용하여 수행될 수 있습니다. 캐시 지원 embedder는 embeddings를 키-값 저장소에 캐싱하는 embedder 주변에 래퍼입니다. 텍스트는 해시되고 이 해시는 캐시에서 키로 사용됩니다.CacheBackedEmbeddings를 초기화하는 주요 지원 방법은 from_bytes_store입니다. 이는 다음 매개변수를 받습니다:underlying_embeddings: 임베딩을 위해 사용되는 embedder.document_embedding_cache: 문서 임베딩을 캐싱하기 위한 ByteStore 중 하나..

-> Right : 과 를 이용하여 LLM 의 in-context prompt generation 을 하고, 해당 를 보고 이미지 생성으로 분기 처리하도록 구현됨

ML(Machine Learning) + 데이터 엔지니어링*데이터 랭글링 : 모델 학습에 필요한 형태로 데이터 변환하는 작업

BLIP과 CLIP이 서로 다른 방식으로 유사도를 계산하는 주요 이유는 모델 구조와 학습 목표의 차이에서 비롯됩니다.BLIP(ITM) – Image–Text Matching HeadBLIP은 사전학습 단계에서 이미지–텍스트 매칭(Image–Text Matching, ITM) 태스크를 추가로 학습합니다.use_itm_head=True일 때는, 이미지와 텍스트를 함께 입력해 매칭 여부(positive/negative) 를 분류하는 분류기 헤드(logits) 를 돌려줍니다.반면 use_itm_head=False로 설정하면, 내부에서 추출된 이미지·텍스트 임베딩을 꺼내와 (정규화된) 내적 또는 코사인 유사도 형태로 반환합니다.즉, ITM 헤드를 사용하면 “이 쌍이 매칭(올바른 캡션)”인지에 대한 분류 확신도를,..

ctrl+shift+p : Jupyter:Debug current file in interactive window 선택Debug Console 에서 각 변수값 확인하며 디버깅

- Grouped Multi-Query Attention- KV Cache

ex) linear.py 의 내부 사용 method 내부는 C++ 로 아래와 같이 구현되어 있음
요약BatchNorm: 배치 전체 통계 기반, CNN에 특화, 큰 배치에서 최고의 성능LayerNorm: 샘플별 통계 기반, 시퀀스·토큰 모델에 필수, 작은 배치에도 안정이미지 분류·객체 검출(CNN 계열)배치 크기가 충분하다면 → BatchNorm배치가 매우 작거나 온라인 추론 위주라면 → GroupNorm 또는 LayerNorm 고려자연어 처리·시퀀스 모델Transformer, RNN 계열 → LayerNorm특히 auto-regressive 생성(decoding) 시 causal 구조와 잘 맞음일반 MLP배치 독립성이 필요하면 → LayerNorm배치 통계가 풍부하면 → BatchNorm 왜 LayerNorm을 쓰는가?배치 크기 독립성BatchNorm은 배치 전체의 통계량을 사용하지만, LayerN..

* 실제 사용은 하단 전체 코드 참고미래 토큰 차단용 마스크 (causal mask)self.register_buffer( 'mask', torch.triu(torch.ones(CONTEXT_LENGTH, CONTEXT_LENGTH), diagonal=1)) (L, L) 크기의 상삼각 행렬 생성 (L = CONTEXT_LENGTH).대각선 위쪽(미래 위치)에 1이 채워져 있고, 나머지는 0.register_buffer로 저장하면 파라미터가 아니지만 .to(device) 등 이동 시 함께 따라갑니다.이후 forward에서scores = scores.masked_fill(self.mask == 1, float('-inf'))처럼 사용해서 “미래 정보”가 보이지 않도록 막음. Transformer의..
참고 : https://starknotes.tistory.com/202 MiniGPT-4MiniGPT-4: Enhancing Vision-Language Understanding with Advanced Large Language ModelsThe recent GPT-4 has demonstrated extraordinary multi-modal abilities, such as directly generating websites from handwritten text and identifying humorous elements withinstarknotes.tistory.com class MultimodalProjector(nn.Module): def __init__(self, image_embe..

MiniGPT-4: Enhancing Vision-Language Understanding with Advanced Large Language ModelsThe recent GPT-4 has demonstrated extraordinary multi-modal abilities, such as directly generating websites from handwritten text and identifying humorous elements within images. These features are rarely observed in previous vision-language models. Howevearxiv.org Minigpt-4The recent GPT-4 has demonstrated ex..

SAM-CLIP: Merging Vision Foundation Models towards Semantic and Spatial Understandinghttps://arxiv.org/pdf/2310.15308v4 논문 개요제목 : SAM-CLIP: Merging Vision Foundation Models towards Semantic and Spatial Understanding저자/소속 : Haoxiang Wang (University of Illinois U-C, Apple Intern) 외 Apple 연구진버전 / 날짜 : v4 - 2024-06-10 arXiv1. 연구 동기 & 문제 정의CLIP은 텍스트-이미지 대비 학습으로 “무엇(semantic)”을 잘 파악하지만, 고해상도에 약하고 픽셀 ..

MLLM : Multimodal Large Language ModelLMM : Large Multimodal Model *이미지 인코더 사용방식 / 이미지 토크나이저 사용방식 / 이미지 인코딩하지 않는 방식(fuyu 등) -> 아래 내용은 이미지 인코더 사용방식 ex1) HPT ex2) Idefics2 ● Architecture ○ Vision Encoder + Connector + LLM● Data ○ 2 가지 데이터셋 필요 ■ pre-train ■ instruction tune● Evaluation ○ MMMU ex1) NExT-GPT ex2) ANYGPT "결국 GPT(트랜스포머)의 입력은 토큰이기에, 멀티모달 데이터를 토큰으로 변화시키면, 다양한 입력들을 처리할 수 있다" ..