Views
No views yet
transformers:1
2from huggingface_hub import notebook_login
3from datasets import load_dataset, Dataset
4from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
5
6model = "ArtifactAI/phi-arxiv-math-instruct"
7
8model = AutoModelForCausalLM.from_pretrained(base_model, trust_remote_code= True)
9tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True)
10
11def generate(prompt):
12 inputs = tokenizer(f'''Below is an instruction that describes a task. Write a response that appropriately completes the request If you are adding additional white spaces, stop writing".\n\n### Instruction:\n{prompt}.\n\n### Response:\n ''', return_tensors="pt", return_attention_mask=False)
13 streamer = TextStreamer(tokenizer, skip_prompt= True)
14 _ = model.generate(**inputs, streamer=streamer, max_new_tokens=500)
15
16generate("what is a transformer?")@misc{phi-arxiv-cs-ml-instruct,
title={phi-arxiv-cs-ml-instruct},
author={Matthew Kenney},
year={2023}
}