Downloads · 30 days
4
1% of all-time downloads
Alpaca69B/llama-2-7b-absa-semeval-2016-2epoches
llama-2-7b-absa-semeval-2016-2epoches is a text generation model from Alpaca69B. Use it when you need the model to write or continue text. It is set up for transformers.
- Model Name: Alpaca69B/llama-2-7b-absa-semeval-2016 - Base Model: NousResearch/Llama-2-7b-chat-hf - Fine-Tuned On: Alpaca69B/semeval2016-full-absa-reviews-english-translated-resampled - Fine-Tuning Techniques: LoRA a…
Downloads · 30 days
4
1% of all-time downloads
All-time downloads
368
Public
Repo size
67.4 GB
Likes
1
Public
Click a slice to open those files.
.bin13.5 GB · 100%
From the Hugging Face model README
This model is an aspect based sentiment analysis model fine-tuned from the Llama-2-7b-chat model on an adjusted semeval-2016 dataset.
The model's performance and usage can be observed in the provided Google Colab notebook.
To use the model, follow the provided code snippet:
from transformers import AutoTokenizer
import transformers
import torch
model = "Alpaca69B/llama-2-7b-absa-semeval-2016"
tokenizer = AutoTokenizer.from_pretrained(model)
pipeline = transformers.pipeline(
"text-generation",
model=model,
torch_dtype=torch.float16,
device_map="auto",
)
def process_user_prompt(input_sentence):
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,
)
result_dict = process_output(sequences[0]['generated_text'])
return result_dict
def process_output(output):
result_dict = {}
# Extract user_prompt
user_prompt_start = output.find("### Human:")
user_prompt_end = output.find("aspect: ") + len("aspect: ")
result_dict['user_prompt'] = output[user_prompt_start:user_prompt_end].strip()
# Extract cleared_generated_output
cleared_output_end = output.find(")")
result_dict['cleared_generated_output'] = output[:cleared_output_end+1].strip()
# Extract review
human_start = output.find("Human:") + len("Human:")
assistant_start = output.find("### Assistant:")
result_dict['review'] = output[human_start:assistant_start].strip()
# Extract aspect and sentiment
aspect_start = output.find("aspect: ") + len("aspect: ")
sentiment_start = output.find("sentiment: ")
aspect_text = output[aspect_start:sentiment_start].strip()
result_dict['aspect'] = aspect_text
sentiment_end = output[sentiment_start:].find(")") + sentiment_start
sentiment_text = output[sentiment_start+len("sentiment:"):sentiment_end].strip()
result_dict['sentiment'] = sentiment_text
return result_dict
output = process_user_prompt('the first thing that attracts attention is the warm reception and the smiling receptionists.')
print(output)
Details of the fine-tuning process are available in the fine-tuning Colab notebook.
Note: Ensure that you have the necessary dependencies and resources before running the model.