Views
No views yet
1from transformers import pipeline
2
3model_id = "vemz/pythia-410m-sft-imdb"
4
5generator = pipeline("text-generation", model=model_id, device_map="auto")
6
7prompt = "At first I wad bored, but then"
8
9output = generator(prompt, max_new_tokens=50, return_full_text=False)[0]
10print(output["generated_text"])1sft_config = SFTConfig(
2 output_dir=output_dir,
3 dataset_text_field="text",
4 max_length=512,
5 packing=True,
6 learning_rate=1e-4,
7 per_device_train_batch_size=4,
8 gradient_accumulation_steps=4,
9 num_train_epochs=1,
10 fp16=False,
11 bf16=False,
12 gradient_checkpointing=True,
13 logging_steps=10,
14 save_strategy="epoch",
15)EleutherAI/pythia-410m-deduped must be loaded separately.1@misc{vonwerra2022trl,
2 title = {{TRL: Transformer Reinforcement Learning}},
3 author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
4 year = 2020,
5 journal = {GitHub repository},
6 publisher = {GitHub},
7 howpublished = {\url{https://github.com/huggingface/trl}}
8}