Downloads · 30 days
9
32% of all-time downloads
surendrapratap/gemma-2b-classifier-gguf
gemma-2b-classifier-gguf is a text classification model from surendrapratap. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as gemma.
This is a fine-tuned Gemma 2B model for text classification, packaged for GGUF compatibility and MediaPipe LLM deployment.
Downloads · 30 days
9
32% of all-time downloads
All-time downloads
28
Public
Parameters
67M
272 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors268 MB · 98%
From the Hugging Face model README
This is a fine-tuned Gemma 2B model for text classification, packaged for GGUF compatibility and MediaPipe LLM deployment.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained("surendrapratap/gemma-2b-classifier-gguf")
tokenizer = AutoTokenizer.from_pretrained("surendrapratap/gemma-2b-classifier-gguf")
# Classify text
text = "Your text here"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
predicted_class_id = logits.argmax().item()
probabilities = torch.softmax(logits, dim=-1)
confidence = probabilities[0][predicted_class_id].item()
print(f"Predicted class: {predicted_class_id}")
print(f"Confidence: {confidence:.4f}")
To convert this model to GGUF format for use with llama.cpp:
# Clone llama.cpp
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
# Build llama.cpp
make
# Convert to GGUF
python convert_hf_to_gguf.py /path/to/this/model --outdir ./
# Quantize (optional)
./llama-quantize model.gguf model-q4_0.gguf q4_0
import mediapipe as mp
from mediapipe.tasks.python import genai
# Load with MediaPipe LLM (after GGUF conversion)
llm = genai.LlmInference.create_from_options(
genai.LlmInferenceOptions(model_path="model.gguf")
)
# Generate response
response = llm.generate_response("Your text here")
print(response.generated_text)
model.safetensors: Model weights in SafeTensors formatconfig.json: Model configurationtokenizer.json: Tokenizer configurationtokenizer.model: SentencePiece tokenizer modellabel_encoder.pkl: Label encoder for class namestraining_metadata.json: Training informationThis model follows the Gemma license terms. Please ensure compliance when using in production.
@misc{gemma-2b-classifier-gguf,
title={Gemma 2B Text Classifier (GGUF Compatible)},
author={Your Name},
year={2024},
publisher={Hugging Face},
url={https://huggingface.co/surendrapratap/gemma-2b-classifier-gguf}
}