Instructions to use RichardLu/Llama3_AE_laptop with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RichardLu/Llama3_AE_laptop with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RichardLu/Llama3_AE_laptop") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("RichardLu/Llama3_AE_laptop", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use RichardLu/Llama3_AE_laptop with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RichardLu/Llama3_AE_laptop" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RichardLu/Llama3_AE_laptop", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RichardLu/Llama3_AE_laptop
- SGLang
How to use RichardLu/Llama3_AE_laptop with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "RichardLu/Llama3_AE_laptop" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RichardLu/Llama3_AE_laptop", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "RichardLu/Llama3_AE_laptop" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RichardLu/Llama3_AE_laptop", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use RichardLu/Llama3_AE_laptop with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for RichardLu/Llama3_AE_laptop to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for RichardLu/Llama3_AE_laptop to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for RichardLu/Llama3_AE_laptop to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="RichardLu/Llama3_AE_laptop", max_seq_length=2048, ) - Docker Model Runner
How to use RichardLu/Llama3_AE_laptop with Docker Model Runner:
docker model run hf.co/RichardLu/Llama3_AE_laptop
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
- Base Model: unsloth/meta-llama-3.1-8b-instruct-bnb-4bit
- Fine-tuning Dataset: SemEval 2014 Laptop Dataset
- Task: Aspect Extraction
- Prompt Format: InstructABSA within Alpaca prompt format
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.
Model tree for RichardLu/Llama3_AE_laptop
Base model
meta-llama/Llama-3.1-8B