mssfj's picture
Update README.md
969a502 verified
metadata
library_name: transformers
datasets:
  - llm-jp/magpie-sft-v1.0
base_model:
  - google/gemma-2-9b
license: gemma
language:
  - ja
  - en

Model Card for Model ID

Model Details

Model Description

このモデルはgemma-2-9bをbitsandbytesで4bit量子化し、llm-jp/magpie-sft-v0.1を用いQloraでInstruction Turnnigしたモデルです。 loraアダプターはmssfj/gemma-2-9b-4bit-magpieになります。

以下のチャットテンプレートを定義しています。 {%- for message in messages %} {{ message.role }}: {{ message.content }} {%- endfor %}{% if add_generation_prompt %} assistant: {% endif %}

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: [More Information Needed]
  • Funded by [optional]: [More Information Needed]
  • Shared by [optional]: [More Information Needed]
  • Model type: [More Information Needed]
  • Language(s) (NLP): [More Information Needed]
  • License: [More Information Needed]
  • Finetuned from model [optional]: [More Information Needed]

Model Sources [optional]

  • Repository: [More Information Needed]
  • Paper [optional]: [More Information Needed]
  • Demo [optional]: [More Information Needed]

Uses

使用方法は以下です。

from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
from peft import PeftModel, PeftConfig

model_name = "mssfj/gemma-2-9b-bnb-4bit-chat-template"
lora_weight = "mssfj/gemma-2-9b-4bit-magpie"

quantization_config = BitsAndBytesConfig(
    load_in_4bit=False,
    bnb_4bit_compute_dtype=torch.bfloat16,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_use_double_quant=False
)

base_model = AutoModelForCausalLM.from_pretrained(
    model_name,
    quantization_config=quantization_config,
    device_map="auto"
    )

model = PeftModel.from_pretrained(base_model, lora_weight)

tokenizer = AutoTokenizer.from_pretrained(model_name)

input="""日本で一番高い山は?
"""

messages = [
    {"role": "system", "content": """あなたは誠実で優秀な日本人のアシスタントです。あなたはユーザと日本語で会話しています。アシスタントは以下の原則を忠実に守り丁寧に回答します。
    - 日本語で簡潔に回答する
    - 回答は必ず完結した文で終える
    - 質問の文脈に沿った自然な応答をする
    """},
    {"role": "user", "content": input},
]

input_ids = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt"
).to(model.device)

outputs = model.generate(
    input_ids,
    max_new_tokens=512,
    temperature=0.2,
    do_sample=True,
    eos_token_id=tokenizer.eos_token_id,
    pad_token_id=tokenizer.pad_token_id,
    early_stopping=True,
)

response = tokenizer.decode(outputs[0][input_ids.shape[1]:], skip_special_tokens=True)

Direct Use

[More Information Needed]

Downstream Use [optional]

[More Information Needed]

Out-of-Scope Use

[More Information Needed]

Bias, Risks, and Limitations

[More Information Needed]

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

Use the code below to get started with the model.

[More Information Needed]

Training Details

Training Data

[More Information Needed]

Training Procedure

Preprocessing [optional]

[More Information Needed]

Training Hyperparameters

  • Training regime: [More Information Needed]

Speeds, Sizes, Times [optional]

[More Information Needed]

Evaluation

Testing Data, Factors & Metrics

Testing Data

[More Information Needed]

Factors

[More Information Needed]

Metrics

[More Information Needed]

Results

[More Information Needed]

Summary

Model Examination [optional]

[More Information Needed]

Environmental Impact

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

[More Information Needed]

Compute Infrastructure

[More Information Needed]

Hardware

[More Information Needed]

Software

[More Information Needed]

Citation [optional]

BibTeX:

[More Information Needed]

APA:

[More Information Needed]

Glossary [optional]

[More Information Needed]

More Information [optional]

[More Information Needed]

Model Card Authors [optional]

[More Information Needed]

Model Card Contact

[More Information Needed]