YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Demo Image 1

Demo Image 2

Demo Image 3

Demo Image 4


license: gemma

Gemma 2B LoRA - AQI Fine-tuned

This model is a LoRA adapter fine-tuned on the google/gemma-2b base model for air quality index (AQI) related question answering.

🧠 Base Model

google/gemma-2b

Note: This repository contains only the LoRA adapter weights. To use the model, you must load it on top of google/gemma-2b.

License

Gemma is provided under and subject to the Gemma Terms of Use.
See the included NOTICE file.

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch

# Load the base Gemma 2B model
base_model = AutoModelForCausalLM.from_pretrained("google/gemma-2b", device_map="auto")

# Load tokenizer and LoRA adapter weights from this repo
tokenizer = AutoTokenizer.from_pretrained("alifarooq77/aqi-model")
model = PeftModel.from_pretrained(base_model, "alifarooq77/aqi-model")

model.eval()

# Prepare prompt format used during training
def prepare_prompt(question: str) -> str:
    return f"### Instruction:\n{question}\n\n### Answer:\n"

# Generate response function
def generate_response(question: str) -> str:
    prompt = prepare_prompt(question)
    inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

    outputs = model.generate(
        **inputs,
        max_new_tokens=120,
        eos_token_id=tokenizer.eos_token_id,
        do_sample=True,
        temperature=0.95,
        top_p=0.9,
        repetition_penalty=1.15,
    )
    generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
    answer = generated_text.split("### Answer:\n")[-1].strip()
    return answer

# Example usage
question = "What should be done to lower AQI?"
print("Question:", question)
print("Answer:", generate_response(question))
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