Instructions to use abhishekyadav16/gemma-2b-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use abhishekyadav16/gemma-2b-finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="abhishekyadav16/gemma-2b-finetuned") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("abhishekyadav16/gemma-2b-finetuned") model = AutoModelForMultimodalLM.from_pretrained("abhishekyadav16/gemma-2b-finetuned") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use abhishekyadav16/gemma-2b-finetuned with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "abhishekyadav16/gemma-2b-finetuned" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "abhishekyadav16/gemma-2b-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/abhishekyadav16/gemma-2b-finetuned
- SGLang
How to use abhishekyadav16/gemma-2b-finetuned 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 "abhishekyadav16/gemma-2b-finetuned" \ --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": "abhishekyadav16/gemma-2b-finetuned", "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 "abhishekyadav16/gemma-2b-finetuned" \ --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": "abhishekyadav16/gemma-2b-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use abhishekyadav16/gemma-2b-finetuned with Docker Model Runner:
docker model run hf.co/abhishekyadav16/gemma-2b-finetuned
π€ Gemma 2B Fine-tuned A fine-tuned version of google/gemma-2b trained using Supervised Fine-Tuning (SFT) with the TRL library. The model is quantized to 4-bit using bitsandbytes for efficient inference.
π Quick Start pythonfrom transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig import torch
model_id = "abhishekyadav16/gemma-2b-finetuned"
4-bit quantization config
bnb_config = BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.float16, )
tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained( model_id, quantization_config=bnb_config, device_map="auto", )
Inference
prompt = "What is machine learning?" inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad(): outputs = model.generate( **inputs, max_new_tokens=200, temperature=0.7, do_sample=True, pad_token_id=tokenizer.eos_token_id, )
response = tokenizer.decode(outputs[0], skip_special_tokens=True) print(response)
ποΈ Training Details ParameterValueBase Modelgoogle/gemma-2bFine-tuning MethodSFT (Supervised Fine-Tuning)LibraryTRL + TransformersQuantization4-bit (bitsandbytes)Parameters~1.1BHardwareGoogle Colab (T4 GPU)FrameworkPyTorch
π¦ Model Architecture
Architecture: Gemma (LlamaForCausalLM-based) Parameters: 1,116.3M (~1.1B) Context Length: 8192 tokens Quantization: NF4 4-bit via bitsandbytes
π‘ Use Cases
Conversational AI / Chatbot Text generation and completion Question answering Instruction following
β οΈ Limitations
This model is fine-tuned for research and learning purposes. May produce incorrect or biased outputs β not recommended for production use without further evaluation. Performance is limited by the base Gemma 2B capacity.
π¨βπ» Author Abhishek Yadav β AI Engineer | LLMs Β· RAG Β· Agentic AI Β· MCP
π Portfolio: 3-d-portfolio.vercel.app πΌ LinkedIn: abhishek-yadav72 π GitHub: CodeBy-Abhishek π€ HuggingFace: abhishekyadav16
π License This model is released under the Gemma License. Please review Google's terms before commercial use.
- Downloads last month
- 17
Model tree for abhishekyadav16/gemma-2b-finetuned
Base model
google/gemma-2b