cloudyu / mistral_pretrain_demo

huggingface.co
Total runs: 358
24-hour runs: 0
7-day runs: 73
30-day runs: 296
Model's Last Updated: March 07 2024
text-generation

Introduction of mistral_pretrain_demo

Model Details of mistral_pretrain_demo

This is a demo of how to pretrain a mistral architecture model by SFT Trainer ,and it needs only 70 lines Python code.

import torch
from transformers import TrainingArguments, MistralForCausalLM, MistralModel, MistralConfig, AutoTokenizer
from datasets import load_dataset
from trl import SFTTrainer

configuration = MistralConfig(vocab_size=32000,
        hidden_size=2048,
        intermediate_size=7168,
        num_hidden_layers=24,
        num_attention_heads=32,
        num_key_value_heads=8,
        hidden_act="silu",
        max_position_embeddings=4096,
        pad_token_id=2,
        bos_token_id=1,
        eos_token_id=2)

model = MistralForCausalLM(configuration)
#model = MistralForCausalLM.from_pretrained("./6B_code_outputs/checkpoint-10000")
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2", local_files_only=False)
tokenizer.pad_token = tokenizer.eos_token

dataset = load_dataset('HuggingFaceTB/cosmopedia-20k', split="train")
#dataset = load_dataset('Elriggs/openwebtext-100k', split="train")
dataset = dataset.shuffle(seed=42)
print(f'Number of prompts: {len(dataset)}')
print(f'Column names are: {dataset.column_names}')

def create_prompt_formats(sample):
    """
    Format various fields of the sample ('instruction', 'context', 'response')
    Then concatenate them using two newline characters
    :param sample: Sample dictionnary
    """
    output_texts = []
    for i in range(len(sample['text'])):
      formatted_prompt = sample['text'][i]
      output_texts.append(formatted_prompt)
    #print(output_texts)
    return output_texts


trainer = SFTTrainer(
    model,
    train_dataset=dataset,
    tokenizer = tokenizer,
    max_seq_length=2048,
    formatting_func=create_prompt_formats,
    args=TrainingArguments(
            per_device_train_batch_size=2,
            gradient_accumulation_steps=1,
            warmup_steps=2,
            max_steps=10000,
            learning_rate=1e-4,
            logging_steps=1,
            output_dir="1B_outputs", overwrite_output_dir=True,save_steps=1000,
            optim="paged_adamw_32bit",report_to="none"
        )
)
trainer.train()
trainer.model.save_pretrained("1B-final", dtype=torch.float32)
trainer.tokenizer.save_pretrained("1B-final")

Runs of cloudyu mistral_pretrain_demo on huggingface.co

358
Total runs
0
24-hour runs
72
3-day runs
73
7-day runs
296
30-day runs

More Information About mistral_pretrain_demo huggingface.co Model

More mistral_pretrain_demo license Visit here:

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

mistral_pretrain_demo huggingface.co

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

mistral_pretrain_demo huggingface.co Url

https://huggingface.co/cloudyu/mistral_pretrain_demo

cloudyu mistral_pretrain_demo online free

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

cloudyu mistral_pretrain_demo online free url in huggingface.co:

https://huggingface.co/cloudyu/mistral_pretrain_demo

mistral_pretrain_demo install

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

mistral_pretrain_demo install url in huggingface.co:

https://huggingface.co/cloudyu/mistral_pretrain_demo

Url of mistral_pretrain_demo

mistral_pretrain_demo huggingface.co Url

Provider of mistral_pretrain_demo 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: 179
Run Growth: 0
Growth Rate: 0.00%
Updated:September 17 2026
huggingface.co

Total runs: 78
Run Growth: 21
Growth Rate: 26.92%
Updated:January 30 2024
huggingface.co

Total runs: 75
Run Growth: 22
Growth Rate: 29.33%
Updated:January 23 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