Downloads · 30 days
11
4% of all-time downloads
beiweixiaoxu/CultureSPA
CultureSPA is a machine learning model from beiweixiaoxu. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
The CultureSPA model from https://github.com/shaoyangxu/CultureSPA
Downloads · 30 days
11
4% of all-time downloads
All-time downloads
261
Public
Parameters
8B
16.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors16.1 GB · 100%
From the Hugging Face model README
The CultureSPA model from https://github.com/shaoyangxu/CultureSPA
## load
device = torch.device("cuda")
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch.bfloat16
).to(device)
## inference
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": instruction},
]
tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_dict = True,
return_tensors = 'pt'
).to(model.device)
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = model.generate(
input_ids = input_ids['input_ids'],
attention_mask = input_ids['attention_mask'],
max_new_tokens=256,
eos_token_id=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9,
pad_token_id=tokenizer.eos_token_id
)