You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Aspect Extraction Model for Laptop Reviews using Llama 3.1 8b

This repository contains a fine-tuned version of unsloth/meta-llama-3.1-8b-instruct-bnb-4bit, trained specifically for Aspect Extraction tasks using the SemEval 2014 Laptop Dataset. The model employs the InstructABSA instruction prompt format combined with the Alpaca prompting structure, optimizing its performance on real-world laptop review analysis.

Model Overview

Performance Metrics

Dataset F1 Score
Train 91.42%
Test 91.89%

Use Cases

This model is well-suited for:

  • Research purposes: Explore novel methodologies or validate existing theories in ABSA.
  • Real-world applications: Deriving actionable insights from laptop reviews for businesses, marketers, and product developers.

Inference Speed

  • Approximate inference time: ~1 second per review (tested on NVIDIA GPUs with 4-bit quantization).

Installation

Install the required dependencies using pip:

import os
if "COLAB_" not in "".join(os.environ.keys()):
    !pip install unsloth
else:
    # Do this only in Colab notebooks! Otherwise, use pip install unsloth
    !pip install --no-deps bitsandbytes accelerate xformers==0.0.29 peft trl triton
    !pip install --no-deps cut_cross_entropy unsloth_zoo
    !pip install sentencepiece protobuf datasets huggingface_hub hf_transfer
    !pip install --no-deps unsloth

!pip uninstall unsloth -y && pip install --upgrade --no-cache-dir --no-deps git+https://github.com/unslothai/unsloth.git

Example Usage

from unsloth import FastLanguageModel
import torch

model, tokenizer = FastLanguageModel.from_pretrained(
    "RichardLu/Llama3_AE_laptop",
    load_in_4bit=True,
    max_seq_length=2048,
)

FastLanguageModel.for_inference(model)

# Define the instruction for aspect extraction
instructabsa_instruction = """Definition: The output will be the aspects (both implicit and explicit) which have an associated opinion that are extracted from the input text. In cases where there are no aspects the output should be noaspectterm.
Positive example 1-
input: I charge it at night and skip taking the cord with me because of the good battery life.
output: battery life
Positive example 2-
input: I even got my teenage son one, because of the features that it offers, like, iChat, Photobooth, garage band and more!.
output: features, iChat, Photobooth, garage band
Negative example 1-
input: Speaking of the browser, it too has problems.
output: browser
Negative example 2-
input: The keyboard is too slick.
output: keyboard
Neutral example 1-
input: I took it back for an Asus and same thing- blue screen which required me to remove the battery to reset.
output: battery
Neutral example 2-
input: Nightly my computer defrags itself and runs a virus scan.
output: virus scan
Now complete the following example:"""
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:
{}
### Input:
{}
### Response:
{}"""

prompt = alpaca_prompt.format(instructabsa_instruction, "The laptop has great battery life, but the screen resolution is disappointing.", "")

inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
output_ids = model.generate(**inputs, max_new_tokens=128)
output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)

print(output_text.split("### Response:")[-1].strip())

License

This model is intended for research and educational purposes. Please ensure proper citation if utilized in academic or industry research.

Citation

If you utilize this model in your research, please cite it appropriately and reference this repository.

@misc{yourcitation2024,
  author = {Lu Phone Maw},
  title = {Aspect Extraction Model for Laptop Reviews using Llama 3.1 8b},
  year = {2025},
  publisher = {Lu Phone Maw},
  journal = {Hugging Face repository},
  howpublished = {\url{https://huggingface.co/RichardLu/Llama3_AE_laptop}}
}

For any questions or feedback, please contact the repository maintainer.

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 RichardLu/Llama3_AE_laptop

Finetuned
(1308)
this model