This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from transformers import AutoTokenizer,AutoModelForCausalLM | |
import pandas | |
model_name_or_path = "cyberagent/calm2-7b-chat" | |
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path) | |
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, device_map="cpu", torch_dtype=torch.float32) | |
# https://github.com/nlp-waseda/JMMLU/blob/main/JMMLU/college_computer_science.csv | |
df=pandas.read_csv("college_computer_science.csv",header=None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference #1: https://note.com/npaka/n/nc55e44e407ff | |
# Reference #2: https://huggingface.co/blog/gemma-peft | |
# Licence: MIT | |
from peft import LoraConfig | |
lora_config = LoraConfig( | |
r=8, | |
target_modules=["q_proj", "o_proj", "k_proj", "v_proj", "gate_proj", "up_proj", "down_proj"], | |
task_type="CAUSAL_LM", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MIT | |
from diffusers import StableDiffusionXLPipeline | |
import torch | |
pipe = StableDiffusionXLPipeline.from_single_file('/path/to/checkpoint.safetensors', torch_dtype=torch.float16) | |
pipe.save_pretrained('/path/to/diffusers_version') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from diffusers import DiffusionPipeline | |
import torch | |
from consistencydecoder import ConsistencyDecoder | |
from PIL import Image | |
import numpy as np | |
pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", torch_dtype=torch.float32) | |
decoder_consistency = ConsistencyDecoder(device="cuda:0") # Model size: 2.49 GB |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datasets import load_dataset | |
import requests | |
from PIL import Image | |
from tqdm import tqdm | |
dataset = load_dataset("laion/dalle-3-dataset",split="train") | |
for i,row in enumerate(tqdm(dataset)): | |
with open(f"dalle3/{i:06}.txt","w") as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MIT License | |
from transformers import AutoTokenizer | |
import transformers | |
from langchain.document_loaders import PyPDFLoader | |
import torch | |
model = "NousResearch/Yarn-Llama-2-13b-128k" | |
tokenizer = AutoTokenizer.from_pretrained(model) | |
pipeline = transformers.pipeline( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MIT License | |
# This code will run on VRAM 12GB+ GPU such as T4, RTX 3060 | |
import torch | |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline | |
from langchain.text_splitter import RecursiveCharacterTextSplitter | |
from langchain.document_loaders import PyPDFLoader | |
from langchain.vectorstores import FAISS | |
from langchain.chains import RetrievalQA | |
from langchain.embeddings import HuggingFaceEmbeddings | |
from langchain.llms.huggingface_pipeline import HuggingFacePipeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
import torch | |
from denoising_diffusion_pytorch import Unet, GaussianDiffusion, Trainer | |
from torchvision import datasets, transforms | |
from torch.optim import Adam | |
from torch.utils.data import Dataset | |
from torch.utils import data | |
from torch.cuda.amp import GradScaler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch.utils.data import Dataset | |
from torchvision import datasets, transforms | |
import torch.optim as optim | |
import cv2 | |
from tqdm import tqdm | |
from denoising_diffusion_pytorch import Unet, GaussianDiffusion |
NewerOlder