Instructions to use bastienp/Gemma-2-2B-Instruct-structured-output with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use bastienp/Gemma-2-2B-Instruct-structured-output with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/gemma-2-2b-it") model = PeftModel.from_pretrained(base_model, "bastienp/Gemma-2-2B-Instruct-structured-output") - Transformers
How to use bastienp/Gemma-2-2B-Instruct-structured-output with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("bastienp/Gemma-2-2B-Instruct-structured-output", device_map="auto") - llama-cpp-python
How to use bastienp/Gemma-2-2B-Instruct-structured-output with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="bastienp/Gemma-2-2B-Instruct-structured-output", filename="unsloth.F16.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use bastienp/Gemma-2-2B-Instruct-structured-output with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M # Run inference directly in the terminal: llama cli -hf bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M # Run inference directly in the terminal: llama cli -hf bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M
Use Docker
docker model run hf.co/bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use bastienp/Gemma-2-2B-Instruct-structured-output with Ollama:
ollama run hf.co/bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M
- Unsloth Studio
How to use bastienp/Gemma-2-2B-Instruct-structured-output 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 bastienp/Gemma-2-2B-Instruct-structured-output 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 bastienp/Gemma-2-2B-Instruct-structured-output to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for bastienp/Gemma-2-2B-Instruct-structured-output to start chatting
- Atomic Chat new
- Docker Model Runner
How to use bastienp/Gemma-2-2B-Instruct-structured-output with Docker Model Runner:
docker model run hf.co/bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M
- Lemonade
How to use bastienp/Gemma-2-2B-Instruct-structured-output with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull bastienp/Gemma-2-2B-Instruct-structured-output:Q4_K_M
Run and chat with the model
lemonade run user.Gemma-2-2B-Instruct-structured-output-Q4_K_M
List all available models
lemonade list
Gemma-2 2B Instruct fine-tuned on JSON dataset
This model is a Gemma-2 2b model fine-tuned to paraloq/json_data_extraction.
The model has been fine-tuned to extract data from a text according to a json schema.
Prompt
The prompt used during training is:
"""Below is a text paired with input that provides further context. Write JSON output that matches the schema to extract information.
### Input:
{input}
### Schema:
{schema}
### Response:
"""
Using the Model
You can use the model with the transformer library or with the wrapper from [unsloth] (https://unsloth.ai/blog/gemma2), which allows faster inference.
import torch
from unsloth import FastLanguageModel
# Required to avoid cache size exceeded
torch._dynamo.config.accumulated_cache_size_limit = 2048
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = f"bastienp/Gemma-2-2B-it-JSON-data-extration",
max_seq_length = 2048,
dtype = torch.float16,
load_in_4bit = False,
token = HF_TOKEN_READ,
)
Using the Quantized model (llama.cpp)
The model is supplied in GGFU format in 4bit and 8bit.
Example code with Llamacpp:
from llama_cpp import Llama
llm = Llama.from_pretrained(
"bastienp/Gemma-2-2B-it-JSON-data-extration",
filename="*Q4_K_M.gguf", #*Q8_K_M.gguf for the 8 bit version
verbose=False,
)
The base model used for fine-tuning is google/gemma-2-2b-it. This repository is NOT affiliated with Google.
Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms.
- Developed by: bastienp
- License: gemma
- Finetuned from model : google/gemma-2-2b-it
- Downloads last month
- 311
4-bit
5-bit
8-bit
16-bit