--- base_model: ikedachin/llm-jp-3-13b-october-news-250128-1-merged tags: - text-generation-inference - transformers - unsloth - llama - trl - sft license: apache-2.0 language: - en - ja datasets: - llm-jp/magpie-sft-v1.0 - DeL-TaiseiOzaki/Tengentoppa-sft-mini-vol1.0 --- # Uploaded model - **Developed by:** ikedachin - **License:** apache-2.0 - **Finetuned from model :** ikedachin/llm-jp-3-13b-october-news-250128-1-merged This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library. [](https://github.com/unslothai/unsloth) # 継続事前学習モデル ikedachin/llm-jp-3-13b-october-news-e1-all-3-5 # 学習データセット 以下をシャッフルして使用 - llm-jp/magpie-sft-v1.0からランダムに5000データ - DeL-TaiseiOzaki/Tengentoppa-sft-mini-vol1.0からランダムに15000データ # 実行方法 ## ライブラリインストール ``` pip install transformers ``` ## 実行コード ```Python # import libraries import tqdm import torch from datasets import load_dataset from transformers import AutoModelForCausalLM, AutoTokenizer # config model_id = "ikedachin/llm-jp-3-13b-october-news-250128-1-merged-sft-1-bf16_merged" # set Token of Huggingface HF_TOKEN = <> # download model and tokenizer model = AutoModelForCausalLM.from_pretrained( model_id, device_map = "auto", torch_dtype = torch.bfloat16, token = HF_TOKEN ) tokenizer = AutoTokenizer.from_pretrained(model_id, token=HF_TOKEN) # define inference function def generate_from_model(input): prompt = f"""### 指示\n{input}\n### 回答\n""" input = tokenizer(prompt, return_tensors='pt', add_special_tokens=True).to(model.device) input.pop('token_type_ids') output = model.generate(**input, max_new_tokens = 1000, use_cache = False, do_sample=False, repetition_penalty=1.2) return tokenizer.decode(output[0], skip_special_tokens=True).split('### 回答\n')[-1] # input prompt and inference print(generate_from_model('石破茂さんって誰ですか?')) # 石破茂(いしばしげる、1954年-)は、日本の政治家、元防衛大臣です。彼は自民党の議員で、現在は第102代内閣総理大臣を務めています。 ```