taoki's picture
Update README.md
1226e9d verified
metadata
language:
  - ja
license: other
tags:
  - text-generation-inference
  - transformers
  - unsloth
  - trl
  - gemma
datasets:
  - kunishou/amenokaku-code-instruct
license_name: gemma
base_model: unsloth/gemma-2b-it-bnb-4bit

Uploaded model

  • Developed by: taoki
  • License: gemma
  • Finetuned from model : unsloth/gemma-2b-it-bnb-4bit

Usage

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

tokenizer = AutoTokenizer.from_pretrained(
  "taoki/gemma-2b-it-qlora-amenokaku-code"
)
model = AutoModelForCausalLM.from_pretrained(
  "taoki/gemma-2b-it-qlora-amenokaku-code"
)

if torch.cuda.is_available():
    model = model.to("cuda")

prompt="""<start_of_turn>user
紫式部と清少納言の作風をjsonで出力してください。
<end_of_turn>
<start_of_turn>model
"""

input_ids = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
    **input_ids,
    max_new_tokens=512,
    do_sample=True,
    top_p=0.95,
    temperature=0.1,
    repetition_penalty=1.0,
)
print(tokenizer.decode(outputs[0]))

Output

<bos><start_of_turn>user
紫式部と清少納言の作風をjsonで出力してください。<end_of_turn>
<start_of_turn>model
 ```json
{
  "紫式部": {
    "style": "紫式部",
    "name": "紫式部",
    "description": "紫式部の作風"
  },
  "清少納言": {
    "style": "清少納言",
    "name": "清少納言",
    "description": "清少納言の作風"
  }
}
```<eos>

This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.