mistral-300m-sft

Overview

Welcome to my model card!

This Model feature is ...

Yukkuri shite ittene!

How to use the model

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

def inference(model_path:str, device: str = "cuda", prompt:str = ""):

    if (device != "cuda" and device != "cpu"):
        device = "cpu"
    if not torch.cuda.is_available():
        device = "cpu"
    print("device:", device)

    tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
    model = AutoModelForCausalLM.from_pretrained(model_path,trust_remote_code=True).to(device)

    messages = [{"role": "user", "content": prompt}]
    tokenized_chat = tokenizer.apply_chat_template(
        messages,
        tokenize=True,
        add_generation_prompt=True,
        return_tensors="pt"
    )
    # token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
    # print("token_ids:",token_ids)

    with torch.no_grad():
        generated_tokens = model.generate(
            tokenized_chat.to("cuda"), 
            use_cache=True, 
            early_stopping=False,
            max_new_tokens=1024,
            top_p=0.95,
            top_k=50,
            temperature=0.2,
            do_sample=True,
            no_repeat_ngram_size=2,
            num_beams=3,
        )
    generated_text = tokenizer.decode(generated_tokens[0])
    print(generated_text.replace(tokenizer.eos_token, "\n"))

prompt = "ใ“ใ‚“ใซใกใฏ๏ผ"
inference("ce-lery/mistral-300m-sft", "cuda", prompt)
#<s>User:ใ“ใ‚“ใซใกใฏ๏ผ
#<s>Assistant:ใŠใฏใ‚ˆใ†ใ”ใ–ใ„ใพใ™ใ€‚็งใฏใ‚ชใƒผใƒ—ใƒณใ‚ขใ‚ทใ‚นใ‚ฟใƒณใƒˆใงใ™ใ€‚ใ‚ใชใŸใฎ่ณชๅ•ใซ็ญ”ใˆใŸใ‚Šใ€ใ‚ใชใŸใฎ่ณชๅ•ใซใŠ็ญ”ใˆใ—ใพใ™ใ€‚ไฝ•ใ‹ใŠๆ‰‹ไผใ„ใงใใ‚‹ใ“ใจใŒใ‚ใ‚Œใฐใ€้ ๆ…ฎใชใ่žใ„ใฆใใ ใ•ใ„ใ€‚

prompt = "่‡ชๅ‹•่ปŠใ‚’้‹่ปขใ™ใ‚‹้š›ใซๅฟ…่ฆใชใ‚‚ใฎใฏ๏ผŸ"
inference("ce-lery/mistral-300m-sft", "cuda", prompt)
#<s>User:่‡ชๅ‹•่ปŠใ‚’้‹่ปขใ™ใ‚‹้š›ใซๅฟ…่ฆใชใ‚‚ใฎใฏ๏ผŸ
#<s>Assistant:้‹่ปขใซๅฟ…่ฆใชใ™ในใฆใฎ้“ๅ…ทใจ่ฃ…ๅ‚™ใ‚’ใใ‚ใˆใ‚‹ใซใฏใ€ใ„ใใคใ‹ใฎใ‚นใƒ†ใƒƒใƒ—ใ‚’่ธใ‚€ๅฟ…่ฆใŒใ‚ใ‚Šใพใ™ใ€‚ไปฅไธ‹ใฏใใฎใ‚นใƒ†ใƒƒใƒ—ใฎใ‚นใƒ†ใƒƒใƒ—ใƒปใƒใ‚คใƒปใ‚นใƒ†ใƒƒใƒ—ใงใ™ใ€‚
#
#1.  ้‹่ปขใ™ใ‚‹ๅ ดๆ‰€ใฎ้“่ทฏ็Šถๆณใ‚’่ชฟในใ‚‹ใ€‚ใ“ใ‚Œใฏใ€้“่ทฏใฎ็Šถๆณใ‚’ๆŠŠๆกใ™ใ‚‹ใฎใซๅฝน็ซ‹ใกใพใ™ใ€‚ใพใŸใ€ไบค้€š้‡ใ‚„้“่ทฏใฎๆทท้›‘็Šถๆณใชใฉใ€ใ•ใพใ–ใพใช่ฆๅ› ใ‚’่€ƒๆ…ฎใ™ใ‚‹ใ“ใจใ‚‚้‡่ฆใงใ™ใ€‚ไพ‹ใˆใฐใ€้ซ˜้€Ÿ้“่ทฏใงใฎ้‹่ปขใฏใ€ๆธ‹ๆปžใ‚„ไบ‹ๆ•…ใฎใƒชใ‚นใ‚ฏใŒ้ซ˜ใพใ‚‹ใŸใ‚ใ€้ฟใ‘ใ‚‹ในใใงใ‚ใ‚‹ใ€‚ใ•ใ‚‰ใซใ€่ปŠ้–“่ท้›ขใ‚’ๅๅˆ†ใซใจใฃใฆใ€ๅ‘จๅ›ฒใฎ็Šถๆณใซๆณจๆ„ใ‚’ๆ‰•ใ„ใ€ๅฑ้™บใ‚’ๅ›ž้ฟใ—ใ€ๅฎ‰ๅ…จใ‚’็ขบไฟใ™ใ‚‹ใŸใ‚ใซๅๅˆ†ใชๆณจๆ„ใ‚’ๆ‰•ใ†ใ“ใจใ‚‚้‡่ฆใงใ‚ใ‚‹ใ€‚ๆ›ดใซใ€ๅฎ‰ๅ…จใช้‹่ปขใ‚’ใ™ใ‚‹ใŸใ‚ใซใ€ใƒ–ใƒฌใƒผใ‚ญใจใ‚ขใ‚ฏใ‚ปใƒซใฎ่ธใฟ้–“้•ใ„ใ‚„ใ€ใ‚ขใ‚ฏใ‚ปใƒซใจใƒ–ใƒฌใƒผใ‚ญใ‚’้–“้•ใˆใ‚‹ใชใฉใฎใƒŸใ‚นใ‚’็Šฏใ•ใชใ„ใ‚ˆใ†ใ€ๆณจๆ„ๆทฑใ้‹่ปขใ™ใ‚‹ใ“ใจใ‚‚ๅฟ…่ฆใงใ™ใ€‚

prompt = "ๆ—ฅๆœฌใฎ้ฆ–้ƒฝใฏ๏ผŸ"
inference("ce-lery/mistral-300m-sft", "cuda", prompt)
#<s>User:ๆ—ฅๆœฌใฎ้ฆ–้ƒฝใฏ๏ผŸ
#<s>Assistant:ๆฑไบฌใฏๆ—ฅๆœฌใงๆœ€ใ‚‚ไบบๅฃใฎๅคšใ„้ƒฝๅธ‚ใงใ‚ใ‚Šใ€ไบบๅฃๅฏ†ๅบฆใฎ้ซ˜ใ„้ƒฝๅธ‚ใงใ™ใ€‚

Receipe

If you want to restruct this model, you can refer this Github repository.
And the manual of this repository is here. Please refer it.

If you find my mistake,error,...etc, please create issue. If you create pulreqest, I'm very happy!

Training procedure

Framework versions

  • Transformers 4.55.2
  • Pytorch 2.8.0+cu128
  • Datasets 4.0.0
  • Tokenizers 0.21.4
  • PEFT 0.17.1
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for ce-lery/mistral-300m-sft

Adapter
(1)
this model