Extract structured key-value pairs from unstructured LLM output using regex, fuzzy matching, and schema validation.
Project description
SlotMatch
SlotMatch is a lightweight Python package for extracting structured key-value pairs from unstructured or noisy LLM outputs. It supports regex-based parsing, fuzzy key recovery, schema validation, and confidence scoring. Perfect for production RAG, chatbot, and NLU pipelines.
Installation
pip install slotmatch
## Features
- Regex-based value extraction
- Fuzzy key mapping (e.g., intnt → intent)
- Schema validation for expected keys and types
- Type coercion (str, int, float, bool)
- Confidence scoring (regex = high, fuzzy = partial, fallback = 0)
- Lightweight, no external dependencies
## Usage
from slotmatch import SlotExtractor
schema = {
"name": str,
"intent": str,
"destination": str
}
llm_output = '''
Hi, I'm Alice.
{
"intnt": "book_flight",
"dest": "NYC",
"name": "Alice"
}
'''
extractor = SlotExtractor(schema)
print(extractor.extract(llm_output))
## Output
{
'name': {'value': 'Alice', 'confidence': 1.0},
'intent': {'value': 'book_flight', 'confidence': ~0.64},
'destination': {'value': None, 'confidence': 0.0}
}
## Example Use Cases
- Post-processing LLM outputs (chatbots, assistants, tools)
- Extracting form fields or user intents
- Structuring data for downstream APIs or storage
- Integrating LLMs with business logic (field validation, routing)
## License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slotmatch-0.1.0.tar.gz.
File metadata
- Download URL: slotmatch-0.1.0.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0befc55ef7d54506405f3482f16ecd09c6cdea49f91a65a957218745ef1d7a27
|
|
| MD5 |
3804f9ab4ecfcef4c080cdfa66d824af
|
|
| BLAKE2b-256 |
69b82d8d2e1062d284defb96ba66611877fdbe7353b839da1cc5adfe483a6b93
|
File details
Details for the file slotmatch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: slotmatch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 1.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6ed6ef1bdbeef379f3895ad38e6f4c67143007a1fb98f3f82dd0b4f4a12e7bd
|
|
| MD5 |
413077c2eb9cbc4fe33d3a8c9baef328
|
|
| BLAKE2b-256 |
b508512c9bf1016b3a5b4fb3cc2a0f6c98863b46038e6fc2591fca38a0391817
|