Instructions to use singtan/gemma-2b-finetuned-pdf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use singtan/gemma-2b-finetuned-pdf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="singtan/gemma-2b-finetuned-pdf")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("singtan/gemma-2b-finetuned-pdf") model = AutoModelForCausalLM.from_pretrained("singtan/gemma-2b-finetuned-pdf") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use singtan/gemma-2b-finetuned-pdf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "singtan/gemma-2b-finetuned-pdf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "singtan/gemma-2b-finetuned-pdf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/singtan/gemma-2b-finetuned-pdf
- SGLang
How to use singtan/gemma-2b-finetuned-pdf 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 "singtan/gemma-2b-finetuned-pdf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "singtan/gemma-2b-finetuned-pdf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "singtan/gemma-2b-finetuned-pdf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "singtan/gemma-2b-finetuned-pdf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use singtan/gemma-2b-finetuned-pdf with Docker Model Runner:
docker model run hf.co/singtan/gemma-2b-finetuned-pdf
Gemma 2B Finetuned Pdf
Model Summary
This model is a fine-tuned version of google/gemma-2b, specifically optimized for high-context understanding of technical documents processed via a Vision-Aided Document Engine. It leverages the same research and technology used in Google's Gemini models, condensed into a lightweight 2B parameter architecture suitable for edge deployment.
Description
Gemma is a family of lightweight, state-of-the-art open models built by Google. This specific variant has been adapted using QLoRA (4-bit Quantization) to internalize specialized knowledge from a custom PDF corpus, preserving layout nuances through a hybrid Vision-OCR pipeline.
Context Length
The model maintains its native training context length of 8,192 tokens, making it well-suited for long-form document summarization and complex reasoning tasks.
Usage
Running the model on a GPU
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
import torch
model_id = "singtan/gemma-2b-finetuned-pdf"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
quantization_config=BitsAndBytesConfig(load_in_4bit=True)
)
input_text = "Summarize the key findings of the provided documentation."
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
outputs = model.generate(**input_ids, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Training Details
Training Dataset
The model was fine-tuned on a diverse set of documents sourced from /content/. The data was processed using a Hybrid Vision-Aided Engine:
- Digital Extraction: Native text stream recovery for high-fidelity digital PDFs.
- Vision Fallback: Tesseract-based OCR for scanned or image-heavy documents.
- Chunking: Sliding-window strategy with 512 tokens and 64 token overlap.
Training Configuration
| Parameter | Value |
|---|---|
| Epochs | 3 |
| Batch Size | 1 |
| Learning Rate | 0.0001 |
| Optimizer | AdamW (8-bit) |
| Hardware | cuda |
| Quantization | 4-bit (bitsandbytes) |
Performance Metrics
- Final Training Loss: N/A
- Total Runtime: N/A seconds
Ethics and Safety
This model inherits the safety principles of the Gemma family. Evaluations were conducted across categories including child safety, content safety, and representational harms. Users are encouraged to implement their own application-specific safety safeguards as outlined in the Responsible Generative AI Toolkit.
Limitations
- Factual Accuracy: Like all LLMs, the model may hallucinate if prompted outside its fine-tuned context.
- Language: Optimized primarily for English-language documents.
- Common Sense: While strong, the model relies on statistical patterns and may lack reasoning in extreme edge cases.
Authors
Fine-tuned by Bibek | Base model by Google.
- Downloads last month
- 840
Model tree for singtan/gemma-2b-finetuned-pdf
Base model
google/gemma-2b