Skip to main content

TruLens-Eval Llama-Pack

TruLens

The best way to support TruLens is to give us a ⭐ on GitHub and join our slack community!

TruLens provides three Llamma Packs for LLM app observability:

  • The first is the TruLensRAGTriadPack (context relevance, groundedness, answer relevance). This triad holds the key to detecting hallucination.

  • Second, is the TruLensHarmlessPack including moderation and safety evaluations like criminality, violence and more.

  • Last is the TruLensHelpfulPack, including evaluations like conciseness and language match.

No matter which TruLens LlamaPack you choose, all three provide evaluation and tracking for your LlamaIndex app with TruLens, an open-source LLM observability library from TruEra.

CLI Usage

You can download llamapacks directly using llamaindex-cli, which comes installed with the llama-index python package:

llamaindex-cli download-llamapack TruLensRAGTriadPack --download-dir ./trulens_pack

You can then inspect the files at ./trulens_pack and use them as a template for your own project.

Code Usage

You can download each pack to a ./trulens_pack directory:

from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
TruLensRAGTriadPack = download_llama_pack(
    "TruLensRAGTriadPack", "./trulens_pack"
)

From here, you can use the pack, or inspect and modify the pack in ./trulens_pack.

Then, you can set up the pack like so:

import os

os.environ["OPENAI_API_KEY"] = "sk-..."

from tqdm.auto import tqdm
from llama_index.core.node_parser import SentenceSplitter
from llama_index.readers.web import SimpleWebPageReader

documents = SimpleWebPageReader(html_to_text=True).load_data(
    ["http://paulgraham.com/worked.html"]
)

splitter = SentenceSplitter()
nodes = splitter.get_nodes_from_documents(documents)

trulens_ragtriad_pack = TruLensRAGTriadPack(
    nodes=nodes, app_id="Query Engine v1: RAG Triad Evals"
)

Then run your queries and evaluate!

queries = [
    "What did Paul Graham do growing up?",
    "When and how did Paul Graham's mother die?",
    "What, in Paul Graham's opinion, is the most distinctive thing about YC?",
    "When and how did Paul Graham meet Jessica Livingston?",
    "What is Bel, and when and where was it written?",
]
for query in tqdm(queries):
    print("Query")
    print("=====")
    print(query)
    print()
    response = trulens_ragtriad_pack.run(query)
    print("Response")
    print("========")
    print(response)

You can access the internals of the LlamaPack, including your TruLens session and your query engine, via the get_modules method.

modules = trulens_ragtriad_pack.get_modules()
tru = modules["session"]
index = modules["index"]
query_engine = modules["query_engine"]
tru_query_engine = modules["tru_query_engine"]
tru.get_leaderboard(app_ids=["Query Engine v1: RAG Triad Evals"])

Resources

There is a more complete notebook demo available in the llama-hub repo.

Check out the TruLens documentation for more information!

Metadata

Release files for llama-index-packs-trulens-eval-packs 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-packs-trulens-eval-packs 0.4.1
File Size Uploaded Provenance Actions
llama_index_packs_trulens_eval_packs-0.4.1.tar.gz 6.2 kB Without provenance Details for llama_index_packs_trulens_eval_packs-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-packs-trulens-eval-packs 0.4.1
File Interpreter ABI Platform Actions
llama_index_packs_trulens_eval_packs-0.4.1-py3-none-any.whl Python 3 none any Details for llama_index_packs_trulens_eval_packs-0.4.1-py3-none-any.whl

Total release size: 12.3 kB

Release files / llama_index_packs_trulens_eval_packs-0.4.1.tar.gz

Download URL llama_index_packs_trulens_eval_packs-0.4.1.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f817c5a747181498b1c31e890950cfcb62f72ecd19a565c058c35fdb960f57ea
BLAKE2b-256 checksum
How to use checksums
1fd6db46202bcd378230adb83702ab8044acc0a84165569e904175420f94507f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Release files / llama_index_packs_trulens_eval_packs-0.4.1-py3-none-any.whl

Download URL llama_index_packs_trulens_eval_packs-0.4.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
117054ca1f2ba42b09246462bb71ee48f5457fcb4aef501810903cd86881aa6e
BLAKE2b-256 checksum
How to use checksums
ec4b25b3d43b03bfb516ae2057d51303873ddca54d3810cc989847a6d598506f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Security for llama-index-packs-trulens-eval-packs 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page