--- license: apache-2.0 language: - ja --- ## モデルについて 与えられたinstructionをより難易度の高いものに書き換えるモデルを試験的に作成したものになります。 instructionデータセット作成にお役立てください。 不適切なinstructionが生成される可能性がありますので、出力のチェックは必須です。 詳細については[こちら](https://zenn.dev/kendama/articles/85ed50d31207bf)をご覧ください。 ## 使い方 ```python from transformers import AutoModelForCausalLM, AutoTokenizer from peft import PeftModel model_path = "Rakuten/RakutenAI-7B-instruct" tokenizer = AutoTokenizer.from_pretrained(model_path) model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.bfloat16, device_map="auto") model = PeftModel.from_pretrained( model, "Kendamarron/jimba-instruction-evolver-alpha_RakutenAI-7B-instruct_lora" ) model.eval() input_instruction = "今日の夜ご飯を考えてください。" system_message = """A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: 次の指示文をより複雑なものに修正してください。 指示文: {orininal_instruction} ASSISTANT: """ inputs = tokenizer(system_message.format(original_instruction=input_instruction), return_tensors="pt").to(device=model.device) with torch.no_grad(): outputs = model.generate( **inputs, max_new_tokens=256, do_sample=True, temperature=0.8, eos_token_id=tokenizer.eos_token_id ) print(tokenizer.decode(outputs[0],skip_special_tokens=True)) ``` ## 備考 Discordサーバー「ローカルLLMに向き合う会」とメタデータラボ株式会社が共同開催された「[LOCAL AI HACKATHON #000](https://prtimes.jp/main/html/rd/p/000000007.000056944.html)」にて作成した成果物になります。