개발/AI 14

[Transformer] Attention, Self-Attention 설명

출처: https://www.youtube.com/watch?v=kyIw0nHoG9w 출처: https://www.youtube.com/watch?v=6s69XY025MU Attention 개요 RNN의 단점 Encoder의 마지막 Hidden state 벡터 정보만 넘어간다. 예를들어 '오늘은' '금요일' '입니다.'에서 마지막 '입니다.'의 hidden state vector가 넘어간다. Attention 구조 여기서 Attention 제안됨 Encoder 부분에서 생성되는 각 단어에 대한 hidden state 정보를 모두 decoder로 전달 각각의 hidden state가 5차원일 경우 3*5 행렬인 [h0, h1, h2] 로 decoder로 전달 Decoder에서 'Today is Fri..

개발/AI 2024.03.08

[llama.cpp] quantize: 양자화 예시

환경 OS: Ubuntu server 22.04 GPU: 4060ti 16gb Get the Code git clone https://github.com/ggerganov/llama.cpp.git; cd llama.cpp Build 상세 내용: https://github.com/ggerganov/llama.cpp?tab=readme-ov-file#build make LLAMA_OPENBLAS=1 CLI로 로컬에 다운로드 모델 다운로드: https://huggingface.co/docs/huggingface_hub/ko/guides/download#download-from-the-cli 굵은 글씨는 수정해서 사용. huggingface-cli download yanolja/KoSOLAR-10.7B-v0.1..

개발/AI 2024.01.04

[Python] GBL : Gradient-based Learning

GBL 학습을 위해 파이썬으로 구현한다. 그리고 update 횟수, Learning rate, gradient(기울기) 등 변경하면서 그려지는 그래프를 보며 이해하면 도움이 된다. 변수가 하나일 경우 import numpy as np def f(x, grad): return grad * ((x)**2) def df_dx(x, grad): return 2 * grad *(x) gradient = [1/10, 1/8, 1/6] # 일반적인 기울기 gradient = [1/10, 1.1, 2] # 발산하는 케이스 ITERATIONS = 20 # 총 n번의 update를 할 것 lr = 0.3 # learning rate import matplotlib.pyplot as plt fig, axes = plt.su..

개발/AI 2023.11.13