Views
No views yet
1from transformers import LlamaTokenizer, LlamaForCausalLM
2
3# Specify the model name or path from the Hugging Face Hub
4org_in = "BEE-spoke-data/"
5org_out = "baseten/"
6model_name = "smol_llama-101M-GQA"
7embedding = False
8embedding_name = "embedding-" if embedding else ""
9tokenizer = LlamaTokenizer.from_pretrained(org_in+model_name)
10model = LlamaForCausalLM.from_pretrained(org_in+model_name)
11
12prompt = "Hello, this is a test."
13inputs = tokenizer(prompt, return_tensors="pt")
14outputs = model.generate(**inputs, max_new_tokens=50)
15print(tokenizer.decode(outputs[0], skip_special_tokens=True))
16
17model_llama = model
18if embedding:
19 model_llama = model_llama.model
20
21# 2. Push to a new Hugging Face repository
22# Make sure you have run `huggingface-cli login` beforehand to authenticate
23model_llama.push_to_hub(org_out+embedding_name+model_name, token="xxx")
24tokenizer.push_to_hub(org_out+embedding_name+model_name, token="xx")