Repository navigation
Conversation
… examples Towards generative-computing#1746. Standardize header docstrings (description, Prerequisites, Usage) across intrinsics/, granite-switch/, aLora/, and sofai/. Reduce intri nsics/, granite-switch/, and sofai/ READMEs to a description plus an Examples table, linking to the site docs for concepts. Keep the aLoRA train/upload/add- readme workflow in its README since no script covers it. Assisted-by: IBM Bob Signed-off-by: Rafael Vasquez <rafvasq21@gmail.com>
47f3c65 to
f66eb4f
Compare
…n example_readme_generator Signed-off-by: Rafael Vasquez <rafvasq21@gmail.com> Assisted-by: IBM Bob
584f779 to
6eb6f07
Compare
|
cc @planetf1 as you wrote pretty much all of these |
planetf1
left a comment
There was a problem hiding this comment.
Thanks for doing this, the new structure and Examples tables are a clear improvement. I'm requesting changes because a few of the docs now say things that aren't true when you run them. The details are inline. The aLora/102_example.py failure was already there on main, so I've opened #1790 for it, and #1791 covers the upload error. The changed .py files differ from base only in their docstrings, and CI is green. Thanks for the cc @ajbozarth.
| Uploading requires a Hugging Face account; run `huggingface-cli login` first, or | ||
| `m alora upload` and `m alora add-readme` fail with "Hugging Face token not found". |
There was a problem hiding this comment.
I ran m alora upload with no token and it never says "Hugging Face token not found". It exits with ImportError: The 'm alora upload' command requires extra dependencies, even with all extras installed. cli/alora/upload.py:15 imports HfFolder, and huggingface_hub 1.16.1 (what uv.lock pins) no longer has it. The huggingface-cli login advice is fine, so I'd just drop the quoted error. The import itself is existing code, so I've opened #1791 for that.
| Uploading requires a Hugging Face account; run `huggingface-cli login` first, or | |
| `m alora upload` and `m alora add-readme` fail with "Hugging Face token not found". | |
| Uploading requires a Hugging Face account; run `huggingface-cli login` first. |
| using fast and slow models. For usage guidance and `s2_solver_mode`, see | ||
| [Inference-time scaling](../../docs/advanced/inference-time-scaling.md#sofai--dual-model-escalation). | ||
| The `SOFAISamplingStrategy` docstring in `mellea/stdlib/sampling/sofai.py` documents | ||
| the remaining options, including `judge_backend` and `feedback_strategy`. |
There was a problem hiding this comment.
The old README had a short section saying what simple, first_error and all_errors mean for feedback_strategy. The docstring this now points to only lists the three values, and I couldn't find them in inference-time-scaling.md either, so that explanation has gone from the docs. A sentence or two on the three values in the SOFAI section of that page would cover it. They only matter when judge_backend is set, which is probably worth saying too.
There was a problem hiding this comment.
Added a section to docs/docs/advanced/inference-time-scaling.md to capture this.
| `mfuncs.act(Intrinsic(...))`. The raw JSON output | ||
| (`{"requirement_check": {"score": ...}}`) is printed; `ALoraRequirement` parses | ||
| the same output when validating. Prefer the helper functions for everyday use; | ||
| see `mellea/stdlib/components/intrinsic/` for them. |
There was a problem hiding this comment.
Nit: this docstring has the right path (mellea/stdlib/components/intrinsic/), but line 39 still says mellea/stdlib/intrinsics/rag.py, which doesn't exist. It was there before this PR, but since you're in the file anyway it's a cheap fix:
# This is an example for how you would directly use intrinsics. See `mellea/stdlib/components/intrinsic/rag.py`| `{"item": ..., "label": "<json string>"}` — the format `m alora train` expects (see | ||
| `stembolt_failure_dataset.jsonl`). Output goes to stdout unless `-o` is given. | ||
|
|
||
| Usage: |
There was a problem hiding this comment.
Nit: the trailing \ sits inside a regular (non-raw) docstring, so Python treats it as a line continuation and joins the two lines. ast.get_docstring gives you the command on one line with a stretch of spaces before the file name. It's cosmetic, since it only shows in help() or generated docs, but making it r""" or putting the command on one line avoids it.
There was a problem hiding this comment.
Used r""" here and in a couple of others too where the command is long.
| ```bash | ||
| git clone github.com/generative-computing/mellea; | ||
| git clone https://github.com/generative-computing/mellea; | ||
| cd mellea; |
There was a problem hiding this comment.
why are there ; at the end of each line in this section?
There was a problem hiding this comment.
Seems they were there previously, removed now
| Compose the adapter from an `Identity`, an output contract, and a `LocalFileBinding`, | ||
| then register it on a `LocalHFBackend` with `backend.add_adapter()`. The code is in | ||
| [LoRA and aLoRA adapters](../../docs/advanced/lora-and-alora-adapters.md), and | ||
| `stembolts_intrinsic.py` is a complete, runnable version with the `stembolts` adapter; |
There was a problem hiding this comment.
This says stembolts_intrinsic.py is "a complete, runnable version", but the file has no entry point, and the example that uses it (102_example.py) doesn't work at the moment. I ran it with two notes piped in and it stops with AloraActivationError: aLoRA 'stembolts' ... never activates for this call. That happens on current main too, so it isn't from this PR.
The cause is io.yaml. It has no instruction: line, so the <|start_of_role|>check_requirement<|end_of_role|> tokens the aLoRA needs never reach the prompt. The copy in this directory is identical to the one on nfulton/stembolts, and m alora train defaults to that same invocation string. With the instruction: line added to a copy of io.yaml, the example ran and returned a diagnosis. Since 102 is skip-marked, CI never runs it.
For this PR, could the sentence just say it's the helper 102_example.py imports, rather than a runnable version? I've opened #1790 for the real fix (the instruction: line here, plus the HF repo).
There was a problem hiding this comment.
Updated the description here.
| | [`101_example.py`](./101_example.py) | Comparing aLoRA-backed requirement validation against LLM-as-a-judge, using the catalog-native `requirement-check` adapter (not a custom one — see `stembolts_intrinsic.py` for loading your own). | | ||
| | [`102_example.py`](./102_example.py) | Interactive loop that exercises the custom `stembolts` adapter — skip-marked because it blocks on stdin in an infinite loop. | | ||
| | [`stembolts_intrinsic.py`](./stembolts_intrinsic.py) | Helper module for loading and calling the fully custom `stembolts` adapter (no standalone entry point — `102_example.py` consumes it). | | ||
| | [`make_training_data.py`](./make_training_data.py) | Utility for preparing training datasets for adapter training. | |
There was a problem hiding this comment.
Nit: the old README listed "Data validation" for this script, and that is worth keeping in the description. It checks each label against a JSON schema (so it needs jsonschema installed) and stops with an error on a row that doesn't match, which "Utility for preparing training datasets" doesn't tell you.
There was a problem hiding this comment.
Updated the description.
| Ollama can retain one model identity (mapped through `adapter_models`). Unless | ||
| `MELLEA_OLLAMA_UNCERTAINTY_MODEL` names an existing tag, the script builds one by | ||
| running `test/scripts/build_ollama_uncertainty_adapter.sh` (needs `git`, `uv`, and | ||
| network access to download the base model and adapter). If the build fails, the |
There was a problem hiding this comment.
This example can't succeed on current Ollama, and the docstring doesn't say so. Ollama removed adapter creation in v0.34.1. I ran the build script on 0.40.14 and it fails with Error: LoRA adapters are no longer supported, after which the script prints "SKIPPED" and exits 0. "If the build fails..." reads like an edge case, but for anyone starting from scratch it is the only outcome, and the same is true for the section in advanced/intrinsics.md that points readers here. Because it exits 0, the examples runner reports it as passed, not skipped, so CI shows green without exercising anything.
I think this should be marked as deprecated rather than left as a fallback. Something like this at the top of the docstring:
Deprecated: Ollama no longer supports building LoRA/aLoRA adapter models (v0.34.1 and later), so this example cannot run on current Ollama. See #1633.
I'd leave removal itself (the build script, the uncertainty_adapter_model test fixture, the CI step, the intrinsics.md section) to #1633, since that touches tests and CI and the issue is still deciding between freezing and maintaining.
There was a problem hiding this comment.
Added a deprecated line and pointed to #1633 here.
| | [`query_rewrite.py`](./query_rewrite.py) | Demonstrates rewriting queries for better retrieval. | | ||
| | [`requirement_check.py`](./requirement_check.py) | Demonstrates validating requirements against model outputs. | | ||
| | [`uncertainty.py`](./uncertainty.py) | Demonstrates assessing model certainty about its response. | | ||
| | [`uncertainty_ollama.py`](./uncertainty_ollama.py) | `core.check_certainty()` on `OllamaModelBackend` using an Ollama model that bundles the uncertainty aLoRA. | |
There was a problem hiding this comment.
Related to my comment on uncertainty_ollama.py: this row presents the example as working. If the docstring gets a deprecation note, this row should say so too, e.g. "(deprecated: Ollama no longer supports building adapter models, see #1633)". I'd keep the row in the table rather than drop it, so the removal can be decided in #1633 and readers who find the file aren't left wondering why it isn't listed.
There was a problem hiding this comment.
Added a deprecated line and pointed to #1633 here too.
Signed-off-by: Rafael Vasquez <rafvasq21@gmail.com> Assisted-by: IBM Bob
Pull Request
Issue
Towards #1746
Description
Standardizes
intrinsics/,granite-switch/,aLora/, andsofai/, keeping the original docstring and README wording and adding structure.Docstrings
Prerequisites:andUsage:blocksREADMEs
## Examplestable, using the original per-file descriptions where they were accurate.advanced/intrinsics.md,advanced/lora-and-alora-adapters.md, andadvanced/inference-time-scaling.md. Content that isn't covered wasn't removed: the Granite Switch overview, the architecture diagram, and the SOFAI flow diagram.aLora/since no script contains it.Other fixes
intrinsics/andgranite-switch/. The image moved todocs/static/images/in docs: migrate from Mintlify to Docusaurus 3 #1174.aLora/README.md:https://) and quoted".[all]"so it works in zsh.\in the--hintscommand.huggingface-cli loginprerequisite.sofai/README.mdused parameter names that don't exist (s1_backend,escalate_on_failure). I removed them along with the code sample.# pytest: huggingface, e2etoquery_rewrite.py, which had no marker.Testing
Attribution
Adding a new component, requirement, sampling strategy, or tool?
If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.