-
Notifications
You must be signed in to change notification settings - Fork 37
Llama stack assembly + 1 of 2 scenarios for lmeval #926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,167 @@ | ||||||||||||||||||||||||||||||||||||||
| :_module-type: PROCEDURE | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ifdef::context[:parent-context: {context}] | ||||||||||||||||||||||||||||||||||||||
| [id="using-llama-stack-external-eval-provider-with-lm-evaluation-harness-in-TrustyAI_{context}"] | ||||||||||||||||||||||||||||||||||||||
| = Using Llama Stack external eval provider with lm-evaluation-harness in TrustyAI | ||||||||||||||||||||||||||||||||||||||
| [role='_abstract'] | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| This example demonstrates how to evaluate a language model in {productname-long}} using the LMEval Llama Stack external eval provider, using Python in a workbench. To do this, you configure a Llama Stack server to use the LMEval Eval provider, register a benchmark dataset, and run a benchmark evaluation job on a language model. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| .Prerequisites | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ifdef::upstream[] | ||||||||||||||||||||||||||||||||||||||
| * You have installed {productname-long}, version 2.29 or later. | ||||||||||||||||||||||||||||||||||||||
| endif::[] | ||||||||||||||||||||||||||||||||||||||
| ifndef::upstream[] | ||||||||||||||||||||||||||||||||||||||
| * You have installed {productname-long}, version 2.20 or later. | ||||||||||||||||||||||||||||||||||||||
| endif::[] | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| * You have cluster administrator privileges for your {productname-short} cluster. | ||||||||||||||||||||||||||||||||||||||
| * You have downloaded and installed the {productname-short} command-line interface (CLI). For more information, see link:https://docs.redhat.com/en/documentation/openshift_container_platform/{ocp-latest-version}/html/cli_tools/openshift-cli-oc[Installing the OpenShift CLI^]. | ||||||||||||||||||||||||||||||||||||||
| * You have a large language model (LLM) for chat generation or text classification, or both, deployed in your namespace. | ||||||||||||||||||||||||||||||||||||||
| * You have installed TrustyAI Operator in your {OpenShift} cluster. | ||||||||||||||||||||||||||||||||||||||
| * You have set KServe to Raw Deployment mode in your cluster. | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
19
to
27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Attribute usage: CLI and platform names are inconsistent. The CLI is for {openshift-platform} (oc), not {productname-short}. Also keep attribute names consistent with other modules. -* You have cluster administrator privileges for your {productname-short} cluster.
+* You have cluster administrator privileges for your {openshift-platform} cluster.
@@
-* You have downloaded and installed the {productname-short} command-line interface (CLI). For more information, see link:https://docs.redhat.com/en/documentation/openshift_container_platform/{ocp-latest-version}/html/cli_tools/openshift-cli-oc[Installing the OpenShift CLI^].
+* You have downloaded and installed the {openshift-platform} command-line interface (CLI). For more information, see link:https://docs.redhat.com/en/documentation/openshift_container_platform/{ocp-latest-version}/html/cli_tools/openshift-cli-oc[Installing the OpenShift CLI^].
@@
-* You have installed TrustyAI Operator in your {OpenShift} cluster.
+* You have installed the TrustyAI Operator in your {openshift-platform} cluster.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| .Procedure | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| . Configure a Python virtual environment for this tutorial in your `DataScienceCluster`: | ||||||||||||||||||||||||||||||||||||||
| + | ||||||||||||||||||||||||||||||||||||||
| [source,bash] | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| python3 -m venv .venv | ||||||||||||||||||||||||||||||||||||||
| source .venv/bin/activate | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| . Install the link:https://pypi.org/project/llama-stack/[Llama Stack provider] from the Python Package Index (PyPI): | ||||||||||||||||||||||||||||||||||||||
| + | ||||||||||||||||||||||||||||||||||||||
| [source,bash] | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| pip install llama-stack-provider-lmeval | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| . Configure the Llama Stack server. Set the variables to configure the runtime endpoint and namespace. The VLLM_URL value should be the `v1/completions` endpoint of your model route and the TRUSTYAI_LM_EVAL_NAMESPACE should be the namespace where your model is deployed. For example: | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+39
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Missing required packages for server and client. You install only the provider. The server CLI and client library aren’t installed, causing later steps to fail. -. Install the link:https://pypi.org/project/llama-stack/[Llama Stack provider] from the Python Package Index (PyPI):
+. Install the required packages from PyPI:
@@
----
-pip install llama-stack-provider-lmeval
+pip install \
+ llama-stack \
+ llama-stack-client \
+ llama-stack-provider-lmeval
---- 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| + | ||||||||||||||||||||||||||||||||||||||
| [source,bash] | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| export VLLM_URL=https://$(oc get $(oc get ksvc -o name | grep predictor) --template='{{.status.url}}')/v1/completions | ||||||||||||||||||||||||||||||||||||||
| export TRUSTYAI_LM_EVAL_NAMESPACE=$(oc project | cut -d '"' -f2) | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| . Download the `providers.d` provider configuration directory and the `run.yaml` execution file: | ||||||||||||||||||||||||||||||||||||||
| + | ||||||||||||||||||||||||||||||||||||||
| [source, bash] | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| curl --create-dirs --output providers.d/remote/eval/trustyai_lmeval.yaml https://raw.githubusercontent.com/trustyai-explainability/llama-stack-provider-lmeval/refs/heads/main/providers.d/remote/eval/trustyai_lmeval.yaml | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| curl --create-dirs --output run.yaml https://raw.githubusercontent.com/trustyai-explainability/llama-stack-provider-lmeval/refs/heads/main/run.yaml | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| . Start the Llama Stack server in a virtual environment, which uses port `8321` by default: | ||||||||||||||||||||||||||||||||||||||
| + | ||||||||||||||||||||||||||||||||||||||
| [source,bash] | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| llama stack run run.yaml --image-type venv | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| . Create a Python script in a Jupyter workbench and import the following libraries and modules, to interact with the server and run an evaluation: | ||||||||||||||||||||||||||||||||||||||
| + | ||||||||||||||||||||||||||||||||||||||
| [source,python] | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||||||||||||||||
| import subprocess | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| import logging | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| import time | ||||||||||||||||||||||||||||||||||||||
| import pprint | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| . Start the Llama Stack Python client to interact with the running Llama Stack server: | ||||||||||||||||||||||||||||||||||||||
| + | ||||||||||||||||||||||||||||||||||||||
| [source,python] | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| BASE_URL = "http://localhost:8321" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def create_http_client(): | ||||||||||||||||||||||||||||||||||||||
| from llama_stack_client import LlamaStackClient | ||||||||||||||||||||||||||||||||||||||
| return LlamaStackClient(base_url=BASE_URL) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| client = create_http_client() | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| Print a list of the current available benchmarks: | ||||||||||||||||||||||||||||||||||||||
| + | ||||||||||||||||||||||||||||||||||||||
| [source,python] | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| benchmarks = client.benchmarks.list() | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| pprint.print(f"Available benchmarks: {benchmarks}") | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| Print a list of the current available benchmarks: | |
| + | |
| [source,python] | |
| ---- | |
| benchmarks = client.benchmarks.list() | |
| pprint.print(f"Available benchmarks: {benchmarks}") | |
| ---- | |
| benchmarks = client.benchmarks.list() | |
| pprint.pprint(f"Available benchmarks: {benchmarks}") |
🤖 Prompt for AI Agents
In
modules/using-llama-stack-external-eval-provider-with-lm-evaluation-harness-in-TrustyAI.adoc
around lines 90 to 97, the snippet calls pprint.print(...) which does not exist;
replace it with either pprint.pprint(benchmarks) or simply print(benchmarks),
and if choosing pprint.pprint ensure the module is imported (import pprint) or
reference via from pprint import pprint so the call resolves correctly.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| :_module-type: ASSEMBLY | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify assembly location vs. type File sits under modules/ but declares ASSEMBLY. Confirm that upstream assemblies include this path correctly (or relocate to assemblies/). 🏁 Script executed: #!/usr/bin/env bash
# Find all occurrences of using-llama-stack-with-trustyai.adoc and who includes them
fd -a 'using-llama-stack-with-trustyai.adoc'
rg -n 'include::.*using-llama-stack-with-trustyai\.adoc' -C2Length of output: 574 Sync file location with includes 🤖 Prompt for AI Agents |
||
|
|
||
| ifdef::context[:parent-context: {context}] | ||
| [id="modules/using-llama-stack-with-trustyai_{context}"] | ||
| = Using llama stack with Trusty AI | ||
|
|
||
| This section contains tutorials for working with Llama Stack in Trusty AI. These tutorials demonstrate how to use various Llama Stack components and providers to evaluate and work with language models. | ||
|
|
||
| The following sections describe how to work with llama stack and provide example use cases: | ||
|
|
||
| * Using the Llama Stack external eval provider with lm-evaluation-harness in Trusty AI | ||
| * Running custom evaluations with LMEval Llama Stack external eval provider | ||
| * Use the trustyai-fms Guardrails Orchestrator with Llama-stack | ||
| include::../modules/using-guardrails-orchestrator-with-llama-stack.adoc[leveloffset=+1] | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
|
|
||
| ifdef::parent-context[:context: {parent-context}] | ||
| ifndef::parent-context[:!context:] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,4 +31,7 @@ include::assemblies/evaluating-large-language-models.adoc[leveloffset=+1] | |
|
|
||
| include::assemblies/configuring-the-guardrails-orchestrator-service.adoc[leveloffset=+1] | ||
|
|
||
| include::assemblies/using-llama-stack-with-trustyai.adoc[leveloffset=+1] | ||
|
|
||
| // currently bias-monitoring is only in ODH | ||
|
Comment on lines
+34
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify include target exists and path is correct (assemblies vs modules). The include points to assemblies/using-llama-stack-with-trustyai.adoc, but this PR shows modules/using-llama-stack-with-trustyai.adoc. If the assemblies/ file doesn’t exist, the build will fail. Update the path or add the assembly file accordingly. Run to confirm presence and pick the correct path: 🏁 Script executed: #!/bin/bash
# List any matching files so we can choose the right include path.
fd -a 'using-llama-stack-with-trustyai.adoc' -t f -HLength of output: 116 Fix include path to modules/using-llama-stack-with-trustyai.adoc 🤖 Prompt for AI Agents |
||
| include::assemblies/bias-monitoring-tutorial.adoc[leveloffset=+1] | ||
Uh oh!
There was an error while loading. Please reload this page.