Views
No views yet
Pharia-1-LLM-7B-control.
We provide a joint model card for Pharia-1-LLM-7B-control and Pharia-1-LLM-control-aligned. Find this model card here.1import torch
2
3from transformers import AutoModelForCausalLM, PreTrainedTokenizerFast
4
5
6INPUT = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>
7
8You are a helpful assistant. You give engaging, well-structured answers to user inquiries.<|eot_id|><|start_header_id|>user<|end_header_id|>
9
10When was Rome founded?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
11
12
13"""
14
15MODEL_ID = "Aleph-Alpha/Pharia-1-LLM-7B-control-hf"
16
17tokenizer = PreTrainedTokenizerFast.from_pretrained(MODEL_ID)
18model = AutoModelForCausalLM.from_pretrained(MODEL_ID, trust_remote_code=True, torch_dtype=torch.bfloat16)
19
20device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
21model = model.to(device)
22
23inputs = tokenizer(INPUT, return_token_type_ids=False, return_tensors="pt").to(device)
24outputs = model.generate(**inputs, max_new_tokens=50)
25generated_text = tokenizer.decode(outputs[0])
26print(generated_text)