Spaces:
Running
Running
File size: 1,724 Bytes
d004a6b 183d6b2 d004a6b 183d6b2 d004a6b 8983b2d f8c143d 8983b2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
---
---
title: slotmatch
emoji: 🧩
colorFrom: purple
colorTo: indigo
sdk: static
pinned: false
---
---
---
[](https://pypi.org/project/slotmatch/)
[](https://opensource.org/licenses/MIT)
# 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
```bash
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. |