You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: add info for working with intrinsics to AGENTS.md (#768)
* chore: add info for working with intrinsics to AGENTS.md
Signed-off-by: Paul S. Schweigert <paul@paulschweigert.com>
* review comments:
Signed-off-by: Paul S. Schweigert <paul@paulschweigert.com>
---------
Signed-off-by: Paul S. Schweigert <paul@paulschweigert.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+65Lines changed: 65 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,3 +146,68 @@ Found a bug, workaround, or pattern? Update the docs:
146
146
-**Issue/workaround?** → Add to Section 7 (Common Issues) in this file
147
147
-**Usage pattern?** → Add to [`docs/AGENTS_TEMPLATE.md`](docs/AGENTS_TEMPLATE.md)
148
148
-**New pitfall?** → Add warning near relevant section
149
+
150
+
## 13. Working with Intrinsics
151
+
152
+
Intrinsics are specialized LoRA adapters that add task-specific capabilities (RAG evaluation, safety checks, calibration, etc.) to Granite models. Mellea handles adapter loading and input formatting automatically — you just call the right function.
153
+
154
+
### Using Intrinsics in Mellea
155
+
156
+
**Prefer the high-level wrappers** in `mellea/stdlib/components/intrinsic/`. These handle adapter loading, context formatting, and output parsing for you:
157
+
158
+
| Module | Function | Description |
159
+
|--------|----------|-------------|
160
+
|`core`|`check_certainty(context, backend)`| Model certainty about its last response (0–1) |
161
+
|`core`|`requirement_check(context, backend, requirement)`| Whether text meets a requirement (0–1) |
162
+
|`core`|`find_context_attributions(response, documents, context, backend)`| Sentences that influenced the response |
163
+
|`rag`|`check_answerability(question, documents, context, backend)`| Whether documents can answer a question (0–1) |
164
+
|`rag`|`rewrite_question(question, context, backend)`| Rewrite question into a retrieval query |
165
+
|`rag`|`clarify_query(question, documents, context, backend)`| Generate clarification or return "CLEAR" |
166
+
|`rag`|`find_citations(response, documents, context, backend)`| Document sentences supporting the response |
167
+
|`rag`|`check_context_relevance(question, document, context, backend)`| Whether a document is relevant (0–1) |
168
+
|`rag`|`flag_hallucinated_content(response, documents, context, backend)`| Flag potentially hallucinated sentences |
169
+
170
+
```python
171
+
from mellea.backends.huggingface import LocalHFBackend
172
+
from mellea.stdlib.components import Message
173
+
from mellea.stdlib.components.intrinsic import core
.add(Message("user", "What is the square root of 4?"))
180
+
.add(Message("assistant", "The square root of 4 is 2."))
181
+
)
182
+
score = core.check_certainty(context, backend)
183
+
```
184
+
185
+
For lower-level control (custom adapters, model options), use `mfuncs.act()` with `Intrinsic` directly — see examples in `docs/examples/intrinsics/`.
186
+
187
+
### Project Resources
188
+
189
+
-**Canonical catalog**: `mellea/backends/adapters/catalog.py` — source of truth for intrinsic names, HF repo IDs, and adapter types
190
+
-**Usage examples**: `docs/examples/intrinsics/` — working code for every intrinsic
191
+
-**Helper functions**: `mellea/stdlib/components/intrinsic/rag.py` and `core.py`
192
+
193
+
### Adding New Intrinsics
194
+
195
+
When adding support for a new intrinsic (not just using an existing one), fetch its README from Hugging Face first. Each README contains the authoritative spec for input/output format, intended use, and examples.
196
+
197
+
**Writing examples?** The HF READMEs also document intended usage patterns and example inputs — useful reference when writing code in `docs/examples/intrinsics/`.
0 commit comments