Downloads · 30 days
0
ymatsuda-97/llm-jp-3-1.8B-finetune-ver3
llm-jp-3-1.8B-finetune-ver3 is a machine learning model from ymatsuda-97. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
Downloads · 30 days
0
Access
Public
Updated Dec 15, 2024
Repo size
67.7 MB
Likes
0
Public
Click a slice to open those files.
.safetensors67.7 MB · 91%
From the Hugging Face model README
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
Use the code below to get started with the model.
from google.colab import drive
drive.mount('/content/drive')
from google.colab import userdata
submit_key = userdata.get('submit_key') # "submit用key"
# python 3.10.12
!pip install -U pip
!pip install -U transformers
!pip install -U bitsandbytes
!pip install -U accelerate
!pip install -U datasets
!pip install -U peft
!pip install -U trl
!pip install -U wandb
!pip install ipywidgets --upgrade
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
TrainingArguments,
logging,
)
from peft import (
LoraConfig,
PeftModel,
get_peft_model,
)
import os, torch, gc
import bitsandbytes as bnb
from trl import SFTTrainer
from datasets import Dataset, DatasetDict, concatenate_datasets, load_dataset
from tqdm import tqdm
from google.colab import output
output.enable_custom_widget_manager()
new_model_id = "ymatsuda-97/llm-jp-3-1.8B-finetune-ver3"
"""
bnb_config: 量子化の設定
- load_in_4bit:
- 4bit量子化形式でモデルをロード
- bnb_4bit_quant_type:
- 量子化の形式を指定
- bnb_4bit_compute_dtype:
- 量子化された重みを用いて計算する際のデータ型
"""
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4", # nf4は通常のINT4より精度が高く、ニューラルネットワークの分布に最適です
bnb_4bit_compute_dtype=torch.bfloat16,
)
"""
model: モデル
- base_model:
- 読み込むベースモデル (事前に定義したもの)
- quantization_config:
- bnb_configで設定した量子化設定
- device_map:
- モデルを割り当てるデバイス (CPU/GPU) "auto"で自動に割り当てられます。
tokenizer: トークナイザー
- base_model:
- 読み込むベースモデル (事前に定義したもの)
- trust_remote_code:
- リモートコードの実行を許可 (カスタムモデルなど)
"""
model = AutoModelForCausalLM.from_pretrained(
new_model_id,
quantization_config=bnb_config,
device_map="auto",
token=submit_key,
)
tokenizer = AutoTokenizer.from_pretrained(
new_model_id,
trust_remote_code=True,
token=submit_key
)
# # モデルによるタスクの推論。
# prompt = """### 指示
# {}
# ### 回答
# """
#
# def evaluate_task(task, filename, prompt):
# results = []
# for data in tqdm(task):
# input = data["input"]
# input_prompt = prompt.format(input)
#
# tokenized_input = tokenizer.encode(input_prompt, add_special_tokens=False, return_tensors="pt").to(model.device)
# attention_mask = tokenized_input.ne(tokenizer.pad_token_id) # torch.ones_like(tokenized_input)
#
# with torch.no_grad():
# outputs = model.generate(
# tokenized_input,
# attention_mask=attention_mask,
# max_new_tokens=1024,
# do_sample=False,
# repetition_penalty=1.2,
# pad_token_id=tokenizer.eos_token_id
# )[0]
# output = tokenizer.decode(outputs[tokenized_input.size(1):], skip_special_tokens=True)
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]