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
# pip install -U bitsandbytes | |
# pip install -U git+https://github.com/huggingface/transformers.git | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1" | |
path_to_hub = XXX | |
tokenizer = AutoTokenizer.from_pretrained(model_id) | |
model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True) | |
model.push_to_hub(path_to_hub) |
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 transformers import AutoModelForCausalLM, AwqConfig | |
model_name = "TheBloke/Mistral-7B-OpenOrca-AWQ" | |
code_revision = "f1b2cd1b7459ceecfdc1fac5bb8725f13707c589" | |
quantization_config = AwqConfig( | |
bits=4, | |
fuse_max_seq_len=512, | |
modules_to_fuse={ | |
"attention": ["q_proj", "k_proj", "v_proj", "o_proj"], |
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 argparse | |
import torch | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
device = torch.device("cuda:0") | |
def get_parser(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument( | |
"--max-new-tokens", |
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 argparse | |
from mistral.cache import RotatingBufferCache | |
import torch | |
import inspect | |
from typing import List | |
from pathlib import Path | |
from mistral.model import Transformer | |
from mistral.tokenizer import Tokenizer |
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 | |
# model_id = "andrewrreed/falcon-7b-guanaco-qlora-arr" | |
# tokenizer = AutoTokenizer.from_pretrained(model_id) | |
# model = AutoModelForCausalLM.from_pretrained(model_id, | |
# torch_dtype=torch.bfloat16, | |
# load_in_4bit=True, | |
# ) |
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 | |
import os | |
import argparse | |
import matplotlib.pyplot as plt | |
from tqdm import tqdm | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
import seaborn as sns | |
def get_parser(): |
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
# You need the following libraries | |
# transformers == 4.32.0 | |
# bitsandbytes == 0.41.0 | |
# auto-gptq == 0.4.2 | |
# optimum == 1.12.0 | |
import torch | |
import matplotlib.pyplot as plt | |
from tqdm import tqdm | |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig | |
import seaborn as sns |
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 torch | |
from peft import LoraConfig, prepare_model_for_int8_training | |
from trl import SFTTrainer | |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, AutoTokenizer, TrainingArguments | |
dataset_name = "timdettmers/openassistant-guanaco" | |
dataset = load_dataset(dataset_name, split="train") | |
model_name = "facebook/opt-350m" |
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
# coding=utf-8 | |
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |
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
# coding=utf-8 | |
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |
NewerOlder