Model Card for llm-jp-3-13b-finetune
This model is a fine-tuned version of llm-jp/llm-jp-3-13b, using the Hugging Face Transformers library,
created for the submission of the final exam in "大規模言語モデル Deep Learning 応用講座 2024 Fall".
Model Details
This is quantized and fine-tuned model from llm-jp/llm-jp-3-13b.
What have been done:
- 4b quantization
- LoRA fine-tuning with "Ichikara Instruction" dataset
Model Description
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
- Developed by: @sugiyama34
- Funded by [optional]: -
- Shared by [optional]: -
- Model type: AutoModelForCausalLM
- Language(s) (NLP): Japanese
- License: CC-BY-NC-SA, Apache License, Version 2.0
- Finetuned from model [optional]:
llm-jp/llm-jp-3-13b
instruction dataset "Ichikara Instruction" is given by:
関根聡, 安藤まや, 後藤美知子, 鈴木久美, 河原大輔, 井之上直也, 乾健太郎. ichikara-instruction: LLMのための日本語インストラクションデータの構築. 言語処理学会第30回年次大会(2024)
Model Sources [optional]
- Repository: -
- Paper [optional]: -
- Demo [optional]: -
Uses
Only for submission of final exam.
Direct Use
Only for submission of final exam.
Downstream Use [optional]
Only for submission of final exam.
Out-of-Scope Use
Anything other than my submission of final exam.
Bias, Risks, and Limitations
I'm not sure right now, I need to study hard.
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
松尾研 LLM 講座 2024 Fall の最終課題の評価を動かすためのコードは以下です。
In the Google Colab. env. with GPU, use the code below to get started with the model.
When running the following code,
- replace
"YOUR TOKEN" below with your hugging face token,
- replace
PATH TO YOUR DATA below with the path to the evaluation data
After running, we can get jsonl file in the "files" in the Colab.
1# install necessary libraries
2!pip install -U pip
3!pip install -U transformers
4!pip install -U bitsandbytes
5
6# import
7from transformers import (
8 AutoModelForCausalLM,
9 AutoTokenizer,
10 BitsAndBytesConfig,
11)
12import os, torch, gc, re
13import bitsandbytes as bnb
14import json
15from tqdm import tqdm
16
17# setting model id
18base_model_id = "llm-jp/llm-jp-3-13b"
19new_model_id = "llm-jp-3-13b-finetune" # evaluation に利用するモデルの名称
20
21# YOUR HUGGING FACE TOKEN HERE
22HF_TOKEN = "YOUR TOKEN"
23
24# BitsAndBytesConfig
25bnb_config = BitsAndBytesConfig(
26 load_in_4bit=True,
27 bnb_4bit_quant_type="nf4",
28 bnb_4bit_compute_dtype=torch.bfloat16,
29)
30
31# load model
32model_name = 'sugiyama34/llm-jp-3-13b-finetune'
33tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
34model = AutoModelForCausalLM.from_pretrained(
35 model_name,
36 quantization_config=bnb_config,
37 device_map='auto'
38)
39
40# load data
41datasets = []
42
43elyza_tasks_100_tv_0_path = "PATH TO YOUR DATA"
44
45with open(elyza_tasks_100_tv_0_path, "r") as f:
46 item = ""
47 for line in f:
48 line = line.strip()
49 item += line
50 if item.endswith("}"):
51 datasets.append(json.loads(item))
52 item = ""
53
54# inference
55results = []
56for data in tqdm(datasets):
57
58 input = data["input"]
59
60 prompt = f"""### 指示
61 {input}
62 ### 回答
63 """
64
65 tokenized_input = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt").to(model.device)
66 attention_mask = torch.ones_like(tokenized_input)
67
68 with torch.no_grad():
69 outputs = model.generate(
70 tokenized_input,
71 attention_mask=attention_mask,
72 max_new_tokens=100,
73 do_sample=False,
74 repetition_penalty=1.2,
75 pad_token_id=tokenizer.eos_token_id
76 )[0]
77 output = tokenizer.decode(outputs[tokenized_input.size(1):], skip_special_tokens=True)
78
79 results.append({"task_id": data["task_id"], "input": input, "output": output})
80
81# export output data
82jsonl_id = re.sub(".*/", "", new_model_id)
83with open(f"./{jsonl_id}-outputs.jsonl", 'w', encoding='utf-8') as f:
84 for result in results:
85 json.dump(result, f, ensure_ascii=False) # ensure_ascii=False for handling non-ASCII characters
86 f.write('\n')
Training Details
Training Data
ichikara-instruction: LLMのための日本語インストラクションデータ – LIAT-AIP homepage
instruction dataset "Ichikara Instruction" is given by:
関根聡, 安藤まや, 後藤美知子, 鈴木久美, 河原大輔, 井之上直也, 乾健太郎. ichikara-instruction: LLMのための日本語インストラクションデータの構築. 言語処理学会第30回年次大会(2024)
Training Procedure
I'm not sure right now, I need to study hard.
Preprocessing [optional]
The data of ichikara instruction dataset is transformed into the following format:
1prompt = """### 指示
2{input}
3### 回答
4{output}"""
And then feeded into LoRA training.
Training Hyperparameters
I'm not sure right now, I need to study hard.
- Training regime: [More Information Needed]
Speeds, Sizes, Times [optional]
I'm not sure right now, I need to study hard.
Evaluation
I'm not sure right now, I need to study hard.
Testing Data, Factors & Metrics
Testing Data
I'm not sure right now, I need to study hard.
Factors
I'm not sure right now, I need to study hard.
Metrics
I'm not sure right now, I need to study hard.
Results
I'm not sure right now, I need to study hard.
Summary
I'm not sure right now, I need to study hard.
Model Examination [optional]
I'm not sure right now, I need to study hard.
Environmental Impact
I'm not sure right now, I need to study hard.
Carbon emissions can be estimated using the
Machine Learning Impact calculator presented in
Lacoste et al. (2019).
- Hardware Type: [More Information Needed]
- Hours used: [More Information Needed]
- Cloud Provider: [More Information Needed]
- Compute Region: [More Information Needed]
- Carbon Emitted: [More Information Needed]
Technical Specifications [optional]
Model Architecture and Objective
I'm not sure right now, I need to study hard.
Compute Infrastructure
I'm not sure right now, I need to study hard.
Hardware
I'm not sure right now, I need to study hard.
Software
I'm not sure right now, I need to study hard.
Citation [optional]
No paper for this work.
Glossary [optional]
not yet written
More Information [optional]
not yet written
Model Card Authors [optional]
Satoshi Sugiyama
Model Card Contact
not given here