How to use from
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:
# Run inference directly in the terminal:
llama cli -hf bastienp/Gemma-2-2B-Instruct-structured-output:
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:
# Run inference directly in the terminal:
llama cli -hf bastienp/Gemma-2-2B-Instruct-structured-output:
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:
# Run inference directly in the terminal:
./llama-cli -hf bastienp/Gemma-2-2B-Instruct-structured-output:
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:
# Run inference directly in the terminal:
./build/bin/llama-cli -hf bastienp/Gemma-2-2B-Instruct-structured-output:
Use Docker
docker model run hf.co/bastienp/Gemma-2-2B-Instruct-structured-output:
Quick Links

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
102
GGUF
Model size
3B params
Architecture
gemma2
Hardware compatibility
Log In to add your hardware

4-bit

5-bit

8-bit

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for bastienp/Gemma-2-2B-Instruct-structured-output

Adapter
(506)
this model

Dataset used to train bastienp/Gemma-2-2B-Instruct-structured-output