Views
No views yet
from transformers import AutoTokenizer, pipeline
import torch
model = "Alpaca69B/llama-2-7b-absa-semeval-2016"
tokenizer = AutoTokenizer.from_pretrained(model)
pipeline = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
torch_dtype=torch.float16,
device="auto",
)
input_sentence = "the first thing that attracts attention is the warm reception and the smiling receptionists."
sequences = pipeline(
f'### Human: {input_sentence} ### Assistant: aspect:',
do_sample=True,
top_k=10,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
max_length=200,
)
sequences[0]['generated_text']