Edit model card

Aerner LM-v2

事前学習から全部日本語で学習させたモデルのバージョン2です。 LLaMAベースで、24GBのVRAMで事前学習できる規模に小さなモデルです。

Flash Attentionが使用されているOpenLLaMAを使用しています。 Wikipediaのデータが中心なので、回答はWikipediaっぽい感じになります。

V1に比べると、モノや場所などの概念を持っているようないないような。 データセットはV1と同じですが、学習ステップ数が76,000と延長。

学習記録はこちら https://wandb.ai/tahomatx/huggingface/runs/xyy19rbx

Instruction-Answer例 ※ モデルは、Instructionの後に、Answerを追記します。入力は、Instruction部分までを入力します。

### Instruction:
東京駅について説明してください。

### Context:



### Answer:
東急東横線・神楽坂駅から徒歩約10分のところに位置している。改札口は1ヶ所のみで、乗車券は駅前ロータリーに設置されており、自動券売機等の設備はない。出入口は1番から4番までの合計6ヵ所あり、それぞれのホームには駐輪場が設けられている(2019年3月現在)。 ⁇ 無人駅である。 ⁇ 簡易委託駅であったが、2018年3月31日をもって廃止され、有人駅時代の駅舎は取り壊されてしまった。
JR東日本ステーションサービスによる業務
### Instruction:
ドラえもんについて説明してください。


### Context:



### Answer:
2007年10月1日から2008年3月31日まで放送された約5分の短編ドラマ。主演は声優の山口智充、脚本・演出は鈴木亜美子。原作とは異なるストーリーが展開されており、登場人物の設定もそれに合わせて変更され ている。

サンプルコードです。

from transformers import OpenLlamaForCausalLM, LlamaTokenizer, GenerationConfig, TextStreamer, AutoModelForCausalLM
import torch
import random
import numpy as np
import time


#
# Fix seed
#

seed = 42

random.seed(seed)
# Numpy
np.random.seed(seed)
# Pytorch
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True
torch.use_deterministic_algorithms = True

torch.set_default_dtype(torch.bfloat16)


model_id = "aerner/lm-v2"

text = """### Instruction:
東京駅について説明してください。

### Context:



### Answer:
"""

with torch.no_grad():
    tokenizer = LlamaTokenizer.from_pretrained(model_id)
    model = AutoModelForCausalLM.from_pretrained(
        model_id,
        device_map="auto",
        torch_dtype=torch.bfloat16,
        # load_in_8bit=True,
    )

    generation_config = GenerationConfig(
        max_new_tokens=256,
        min_new_tokens=1,
        early_stopping=True,

        do_sample=True,
        num_beams=8,

        temperature=1.0,
        top_p=0.6,

        penalty_alpha=0.4,
        no_repeat_ngram_size=4,
        repetition_penalty=1.4,

        remove_invalid_values=True,
        num_return_sequences=1,
    )

    start = time.time()

    tokenized_input = tokenizer(text, return_tensors="pt").to('cuda')
    generation_output = model.generate(
        input_ids=tokenized_input['input_ids'],
        generation_config=generation_config,
        return_dict_in_generate=True,
        output_scores=True,
    )
    for s in generation_output.sequences:
        output = tokenizer.decode(s)
        print(output)

    print(time.time() - start)
Downloads last month
65
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Datasets used to train aerner/lm-v2