Llama-3-8b-ABSA-Summarizer-LoRA

This is a LoRA adapter for Llama-3-8b, fine-tuned for Aspect-Based Sentiment Analysis (ABSA) and Review Summarization. It is specifically designed to analyze restaurant reviews, extracting sentiment for specific aspects (Ambiance, Cleanliness, Food, Service, Value) and generating a concise summary.

This llama model was trained 2x faster with Unsloth.

Model Capabilities

This model performs two tasks simultaneously given a customer review:

  1. Aspect Analysis: Classifies sentiment as 'Positive', 'Negative', or 'Neutral' for:
    • Ambiance (Decor, atmosphere, noise, lighting)
    • Cleanliness (Hygiene, tidiness)
    • Food (Taste, temperature, portion, variety)
    • Service (Staff behavior, speed)
    • Value (Price appropriateness)
  2. Summarization: Generates a one-sentence summary of the main pros and cons.

Usage

You can use unsloth to load this model.

1. Load the Model

First, install the necessary libraries and load the model and tokenizer.

from unsloth import FastLanguageModel
import torch

# Define the model name
model_name = "navdeep-singh/Llama-3-8b-ABSA-Summarizer-LoRA"

max_seq_length = 2048
dtype = None # None for auto detection
load_in_4bit = True # Use 4bit quantization to reduce memory usage

# Load model and tokenizer
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = model_name,
    max_seq_length = max_seq_length,
    dtype = dtype,
    load_in_4bit = load_in_4bit,
)

2. Model Inference

Set the model to inference and pass below prompt to generate result.

# Enable native 2x faster inference
FastLanguageModel.for_inference(model)

# Define the prompt template
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.

### Instruction:
You are an expert restaurant critic and sentiment analyst. Your task is to analyze the customer review provided below and extract structured insights.

Follow these specific steps:
1. **Aspect Analysis**: Analyze the text to determine the sentiment for specific categories. You must classify each category as 'Positive', 'Negative', or 'Neutral'.
   - **Ambiance**: Decor, atmosphere, noise level, lighting.
   - **Cleanliness**: Hygiene, tidiness of the space.
   - **Food**: Taste, temperature, portion size, menu variety.
   - **Service**: Staff behavior, speed, attentiveness.
   - **Value**: Price appropriateness, worth the money.
   
   If a category is not explicitly mentioned but can be strongly inferred, classify it. If absolutely no info is present, use 'Neutral'.

2. **Summarization**: Write a concise, one-sentence summary of the review that captures the main pros and cons.

### Input:
{}

### Response:
"""

# Example Review
review_text = "The food was absolutely delicious, especially the pasta, but the service was incredibly slow. We waited 40 minutes for our main course. The ambiance was cozy though."

# Format the prompt
inputs = tokenizer(
[
    alpaca_prompt.format(review_text)
], return_tensors = "pt").to("cuda")

# Generate output
outputs = model.generate(**inputs, max_new_tokens = 512, use_cache = True, temperature = 0.1)
prediction = tokenizer.batch_decode(outputs[:, inputs['input_ids'].shape[1]:], skip_special_tokens=True)[0]

# Print the result
print(prediction)
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for navdeep-singh/Llama-3-8b-ABSA-Summarizer-LoRA

Finetuned
(3068)
this model

Dataset used to train navdeep-singh/Llama-3-8b-ABSA-Summarizer-LoRA