cloudyu / microsoft-phi-2-sft

huggingface.co
Total runs: 0
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Model's Last Updated: April 16 2024

Introduction of microsoft-phi-2-sft

Model Details of microsoft-phi-2-sft

this is a demo how fine tune phi-2 model on a 24G VRAM A10 or 4090 Card.

import torch
import datasets
from transformers import TrainingArguments, AutoConfig, AutoTokenizer, AutoModelForCausalLM
import trl
from transformers import BitsAndBytesConfig

train_dataset = datasets.load_dataset('HuggingFaceTB/cosmopedia-20k', split='train')

args = TrainingArguments(
    output_dir="./test-sft",
    max_steps=20000,
    per_device_train_batch_size=1,
    optim="adafactor", report_to="none",
)

model_id = "microsoft/phi-2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
nf4_config = BitsAndBytesConfig(
   load_in_4bit=True,
   bnb_4bit_quant_type="nf4",
   bnb_4bit_use_double_quant=True,
   bnb_4bit_compute_dtype=torch.bfloat16
)

model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=nf4_config,device_map="auto")
print(model)

from peft import LoraConfig

peft_config = LoraConfig(
    lora_alpha=16,
    lora_dropout=0.1,
    r=64, target_modules=["q_proj", "v_proj", "k_proj", "dense", "lm_head", "fc1", "fc2"],
    bias="none", 
    task_type="CAUSAL_LM",
)
model.add_adapter(peft_config)

trainer = trl.SFTTrainer(
    model=model, 
    args=args,
    train_dataset=train_dataset,
    dataset_text_field='text',
    max_seq_length=1024
)

trainer.train()

trainer.model.save_pretrained("sft", dtype=torch.bfloat16)
trainer.tokenizer.save_pretrained("sft")

Runs of cloudyu microsoft-phi-2-sft on huggingface.co

0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About microsoft-phi-2-sft huggingface.co Model

More microsoft-phi-2-sft license Visit here:

https://choosealicense.com/licenses/apache-2.0

microsoft-phi-2-sft huggingface.co

microsoft-phi-2-sft huggingface.co is an AI model on huggingface.co that provides microsoft-phi-2-sft's model effect (), which can be used instantly with this cloudyu microsoft-phi-2-sft model. huggingface.co supports a free trial of the microsoft-phi-2-sft model, and also provides paid use of the microsoft-phi-2-sft. Support call microsoft-phi-2-sft model through api, including Node.js, Python, http.

microsoft-phi-2-sft huggingface.co Url

https://huggingface.co/cloudyu/microsoft-phi-2-sft

cloudyu microsoft-phi-2-sft online free

microsoft-phi-2-sft huggingface.co is an online trial and call api platform, which integrates microsoft-phi-2-sft's modeling effects, including api services, and provides a free online trial of microsoft-phi-2-sft, you can try microsoft-phi-2-sft online for free by clicking the link below.

cloudyu microsoft-phi-2-sft online free url in huggingface.co:

https://huggingface.co/cloudyu/microsoft-phi-2-sft

microsoft-phi-2-sft install

microsoft-phi-2-sft is an open source model from GitHub that offers a free installation service, and any user can find microsoft-phi-2-sft on GitHub to install. At the same time, huggingface.co provides the effect of microsoft-phi-2-sft install, users can directly use microsoft-phi-2-sft installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

microsoft-phi-2-sft install url in huggingface.co:

https://huggingface.co/cloudyu/microsoft-phi-2-sft

Url of microsoft-phi-2-sft

microsoft-phi-2-sft huggingface.co Url

Provider of microsoft-phi-2-sft huggingface.co

cloudyu
ORGANIZATIONS

Other API from cloudyu

huggingface.co

Total runs: 915
Run Growth: 512
Growth Rate: 55.96%
Updated:July 11 2026
huggingface.co

Total runs: 70
Run Growth: 24
Growth Rate: 34.29%
Updated:January 23 2024
huggingface.co

Total runs: 68
Run Growth: 17
Growth Rate: 25.00%
Updated:January 30 2024
huggingface.co

Total runs: 5
Run Growth: 3
Growth Rate: 60.00%
Updated:December 16 2024
huggingface.co

Total runs: 5
Run Growth: 5
Growth Rate: 100.00%
Updated:December 07 2024
huggingface.co

Total runs: 4
Run Growth: 2
Growth Rate: 50.00%
Updated:December 16 2024
huggingface.co

Total runs: 4
Run Growth: 3
Growth Rate: 75.00%
Updated:December 17 2024
huggingface.co

Total runs: 4
Run Growth: 4
Growth Rate: 100.00%
Updated:September 09 2024
huggingface.co

Total runs: 2
Run Growth: 1
Growth Rate: 50.00%
Updated:December 18 2024
huggingface.co

Total runs: 2
Run Growth: 2
Growth Rate: 100.00%
Updated:November 28 2024
huggingface.co

Total runs: 0
Run Growth: -5
Growth Rate: 0.00%
Updated:November 28 2024
huggingface.co

Total runs: 0
Run Growth: -2
Growth Rate: 0.00%
Updated:November 28 2024
huggingface.co

Total runs: 0
Run Growth: -2
Growth Rate: 0.00%
Updated:December 06 2024