gemma4-text-kie

Keyed information extraction (KIE) from text, also known as key-value (pair) extraction: a keyed information extractor that applies a Gemma 4 language model, run with llama.cpp from a GGUF file, to input TextDocuments (e.g., OCR transcriptions of chyrons or slates) and writes, for each, the keyed information (a JSON dictionary of keys and values, such as a person’s name and title) as a new TextDocument. The keys parameter lists the keys: the app appends them to the end of the system prompt, and builds from them a JSON schema that llama.cpp enforces during decoding, so every response is a dictionary with exactly those keys. Each input text is appended to the final user turn of prompt (the first one in user-only mode); the prompts describe what each key holds, and a multi-value prompt in turn-taking mode can carry few-shot examples. The default prompts are a general fallback that copies values from the text; a task with its own conventions (e.g., a “Lastname, Firstname” order for normalized names) needs a system prompt that describes them. Keyed information stored as JSON in a TextDocument is provisional, until it has its own annotation types (clamsproject/clams-vocabulary#13). A model runtime parameter selects the Gemma 4 size and quantization (default ggml-org/gemma-4-E4B-it-GGUF:Q8_0); see metadata.py for the GPU memory each needs. The app runs its own llama-server process and needs the llama-server executable (included in the container image).