Skip to main content

Guided Infilling Modeling

Project description

GIMKit

PyPI Version Supported Python versions Supported Platforms

Installation

Install GIMKit using pip:

pip install gimkit

For vLLM support, install with the optional dependency:

pip install gimkit[vllm]

Quick Start

Here's a simple example using the OpenAI backend:

from openai import OpenAI
from gimkit import from_openai, guide as g

# Initialize the client and model
client = OpenAI()  # Uses OPENAI_API_KEY environment variable
model = from_openai(client, model_name="gpt-4")

# Create a query with masked tags
result = model(f"Hello, {g(desc='a single word')}!", use_gim_prompt=True)
print(result)  # Output: Hello, world!

Usage

Creating Masked Tags: Use the guide helper (imported as g) to create masked tags

from gimkit import guide as g

# Basic tag with description
tag = g(name="greeting", desc="A friendly greeting")

# Specialized tags
name_tag = g.person_name(name="user_name")
email_tag = g.e_mail(name="email")
phone_tag = g.phone_number(name="phone")
word_tag = g.single_word(name="word")

# Selection from choices
choice_tag = g.select(name="color", choices=["red", "green", "blue"])

# Tag with regex constraint
custom_tag = g(name="code", desc="A 4-digit code", regex=r"\d{4}")

Building Queries: Combine masked tags with text to build queries

from gimkit import from_openai, guide as g
from openai import OpenAI

client = OpenAI()
model = from_openai(client, model_name="gpt-4")

query = f"""
Name: {g.person_name(name="name")}
Email: {g.e_mail(name="email")}
Favorite color: {g.select(name="color", choices=["red", "green", "blue"])}
"""

result = model(query, use_gim_prompt=True)
print(result)

Accessing Results: Access filled tags from the result

result = model(query, use_gim_prompt=True)

# Iterate over all tags
for tag in result.tags:
    print(f"{tag.name}: {tag.content}")

# Access by name
print(result.tags["name"].content)

# Modify tag content
result.tags["email"].content = "REDACTED"

Design Philosophy

  • Stable over feature
  • Small open-source model first

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gimkit-0.1.1.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gimkit-0.1.1-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file gimkit-0.1.1.tar.gz.

File metadata

  • Download URL: gimkit-0.1.1.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gimkit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 898351e0ef9561edcb7139fff2df02bc874db5c9810e15ff1c19ae9242e5cb98
MD5 a25832f2dfd8880f770c7afa2fb083d7
BLAKE2b-256 a7c80aaac5a546a4c5cb44faaf44c6e73be111353d1ab5ed140c6de0be7b7653

See more details on using hashes here.

File details

Details for the file gimkit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gimkit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gimkit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5156ac1da63405f372af26250797a50aad9b203671fbb9e3ce3df927f0675367
MD5 6a803c43d2c29dd96c68698fa7fadf01
BLAKE2b-256 d0be64d4e5d65db51582e08d17e2800670eea0e9f4c1446572d42890385c5541

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page