Logging for Tonic Validate
Project description
Tonic Validate Logging
Tonic Validate helps you develop your retrieval augmented generation (RAG) system by providing RAG metrics and a platform for tracking and evaluating experiments and changes to your RAG system. This is Tonic Validate Logging, the logging component of Tonic Validate - how you send your RAG system output to the Tonic Validate Application. When you log RAG system outputs using Tonic Validate Logging, the outputs are scored using Tonic Validate Metrics, and then the outputs and scores are sent to the Tonic Validate Application, where the outputs and responses are visualized allowing you to easily track the performance of you RAG system.
Getting Started
- Sign up for a free Tonic Validate account.
- Install Tonic Validate Logging via pip
pip install tvallogging
- Get a Tonic Validate API key, and set it in your environment as the
TONIC_VALIDATE_API_KEY
environment variable. - Set up a project and a benchmark dataset of questions and reference answers, and the log your RAG system responses to the questions in the benchmark. Use the following code snippet to get started. Tonic Validate uses LLM assisted evaluation to score your RAG responses, so in addition to assuming you have the
TONIC_VALIDATE_API_KEY
environment variable set to you Tonic Validate API Key, it also assumes you have theOPENAI_API_KEY
environment variable set so Open AI models can be used to evaluate your RAG responses.import os # to set the environment variables via python os.environ["OPENAI_API_KEY"] = "put-your-openai-api-key-here" os.environ["TONIC_VALIDATE_API_KEY"] = "put-your-tonic-validate-api-key-here" from tvallogging.api import TonicValidateApi from tvallogging.chat_objects import Benchmark project_name: str # name of your new project benchmark_name: str # name of your new benchmark # list of dictionaries of the form # { # "question": "question for the benchmark", # "answer": "reference answer to the question" # } question_with_answer_list: List[Dict[str, str]] api = TonicValidateApi() benchmark = Benchmark.from_json_list(question_with_answer_list) benchmark_id = api.new_benchmark(benchmark, benchmark_name) project = api.new_project(benchmark_id, project_name) llm_evaluator = "gpt-4" run = project.new_run(llm_evaluator) for question_with_answer in run.benchmark.question_with_answer_list: question = question_with_answer.question llm_answer: str # answer obtained from the RAG system retrieved_context_list: List[str] # list of context retrieved by the RAG system # log the llm_answer and retrieved_context_list to Tonic Validate # in this step, the RAG metrics are calculated locally run.log(question_with_answer, llm_answer, retrieved_context_list)
- Review how your RAG system is performing in the Tonic Validate UI.
Documentation and Tonic Validate Metrics
- Tonic Vaidation Documentation has extensive information on how Tonic Validate works and the RAG metrics used in Tonic Validate.
- Check out Tonic Validate Metrics for more information about the RAG metrics used in Tonic Validate and if you're interested in computing the RAG metrics outside of Tonic Validate.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tvallogging-1.0.0.tar.gz
.
File metadata
- Download URL: tvallogging-1.0.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31349d1e33623acc534a0d99baba5990c979712f0a7e0088326860ead8550ac6 |
|
MD5 | b92b2c9d818d59349cc443ccc936c61a |
|
BLAKE2b-256 | 866d3d40f3040caa50534fa7d15d3061229b7d409a67d190225d61767eadeb63 |
File details
Details for the file tvallogging-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: tvallogging-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bcfc77ff318aaeb9eac278badff78b6ad16a96c6cf7ce03c3b2e0632be26af2 |
|
MD5 | b6d7277190d41ad59aa148761dbb2344 |
|
BLAKE2b-256 | ef5334d50ff087b6d9ffc37f9536f221f3483d0c3d5d89504f94e78db2af5a12 |