Debgging and Trusing LLMS like Pro

by SkillAiNest

Debgging and Trusing LLMS like ProDebgging and Trusing LLMS like Pro
Photo by Author | Canva

. Introduction

With traditional debugging print() Or the logging works, but it is slow and low with LLMS. Phoenix provides a timeline theory of every stage, quick and response inspection, error detection with efforts, delays and expenses, and a complete visual understanding of your app. Phoenix by Ariz AI is a powerful open source observation and tracing tool specifically designed for LLM applications. This helps you monitor, debug and trace everything in LLM pipelines. In this article, we will go through the works of Phoenix and why it is important, how to connect Phoenix with a step -by -step Langchen, and how to consider the marks in Phoenix UI.

. What is Phoenix?

Phoenix is an open source observation and debugging tool made for large language model applications. It captures detailed telemetry data from your LLM workflow, which includes indicators, reactions, delays, errors, and device use, and offers this information to intuitive, interactive dashboard. Phoenix developers allow deeper understanding of how their LLM pipelines behave within the system, identifying and debugging issues with immediate results, analyzing performance barriers, using tokens and its affiliate costs, monitoring and monitoring. It supports permanent integration with popular framework such as Langchen and Lemandex, and also offers open lamery support for maximum customized setup.

. Stepped Setup

!! 1. Installing the desired libraries

Make sure you have 3.8+ and install dependent:

pip install arize-phoenix langchain langchain-together openinference-instrumentation-langchain langchain-community

!! 2. To launch Phoenix

Add this line to launch a Phoenix dashboard:

import phoenix as px
px.launch_app()

This starts a local dashboard .

!! 3. Make a Langchin Pipeline with Phoenix Callback

Let’s understand Phoenix using the case. We’re making a simple langchin -driven chat boot. Now, we want:

  • DEBG if the gesture is working
  • Monitor how much time it takes to respond to the model
  • Instant structure, track model use and results
  • See all this vapor instead of manually logining everything

!! Step 1: Launch Phoenix Dash Board in the background

import threading
import phoenix as px

# Launch Phoenix app locally (access at 
def run_phoenix():
    px.launch_app()

threading.Thread(target=run_phoenix, daemon=True).start()

!! Step 2: Register Phoenix with Open Limmetry and Device Langchin

from phoenix.otel import register
from openinference.instrumentation.langchain import LangChainInstrumentor

# Register OpenTelemetry tracer
tracer_provider = register()

# Instrument LangChain with Phoenix
LangChainInstrumentor().instrument(tracer_provider=tracer_provider)

!! Step 3: Start LLM (Found API)

from langchain_together import Together

llm = Together(
    model="meta-llama/Llama-3-8b-chat-hf",
    temperature=0.7,
    max_tokens=256,
    together_api_key="your-api-key",  # Replace with your actual API key
)

Please don’t forget to change your original “Your API-Key” together. API key. You can get it by using Link.

!! Step 4: Specify Quick Template

from langchain.prompts import ChatPromptTemplate

prompt = ChatPromptTemplate.from_messages((
    ("system", "You are a helpful assistant."),
    ("human", "{question}"),
))

!! Step 5: Collect the prompt and model in a series

!! Step 6: Ask multiple questions and print answers

questions = (
    "What is the capital of France?",
    "Who discovered gravity?",
    "Give me a motivational quote about perseverance.",
    "Explain photosynthesis in one sentence.",
    "What is the speed of light?",
)

print("Phoenix running at 

for q in questions:
    print(f" Question: {q}")
    response = chain.invoke({"question": q})
    print(" Answer:", response, "\n")

!! Step 7: Keep the app alive for monitoring

try:
    while True:
        pass
except KeyboardInterrupt:
    print(" Exiting.")

. Understanding Foxics signs and matrix

Before watching the output, we must first understand the Phoenix Matrix. You will need to understand what marks and far away are:
Trace: Each trace represents a complete run of your LLM pipeline. For example, every question like “What is the capital of France?” Prepares a new trace.
Spains: Each trace is mixed in more than one period, each representing a stage in your chain:

  • Chat Promptimplate. Format: Quick formatting
  • Together Invoke: LLM Call
  • Any customs components that you add

Matrix is shown per trace

MetricMeaning and significance
Litanisi (MS)

Full LLM measures total time for implementation, including quick formatting, LLM response, and post processing. Helps to identify performance barriers and debugged slow response.

Input tokens

Number of tokens sent to the model. Input size is important to monitor and control API costs, as mostly used token is based.

Output token

The number of tokens manufactured by the model. Useful for understanding the function, the quality of the response and the costs of the cost.

Instant template

Shows full indication with the variables inserted. It helps to confirm whether the indicator structure is formed and filled properly.

Input / output text

Shows both the user’s input and the model’s response. Useful for checking the quality of the conversation and spotting fraud or wrong answers.

During the period

Every step breaks the time (such as instant creation or model request). Helps to identify performance barriers in the series.

Name of China

It explains which part of the pipeline is a period of time (such as, prompt.formatFor, for, for,. TogetherLLM.invoke) Helps in isolated where problems are occurring.

Tags / metad data

Additional information such as the model name, temperature, etc. is useful for filter runs, compare the results and analyze the impact of the parameter.

See now Phoenix dashboard to see. You will look like something like this:
Phoenix dashboardPhoenix dashboard
Open the first trace to see the details.
Phoenix First TracePhoenix First Trace

. Wrap

Wrap it up, making phoenix, makes your LLM applications into incredibly easy to debug, trace and monitor. You do not have to guess what has been wrong or dig through the log. Everything is fine: gestures, answers, times and more. This helps you highlight problems, understand performance and develop only AI’s better experiences with low stress.

Kanwal seals A machine is a learning engineer and is a technical author that has a deep passion for data science and has AI intersection with medicine. He authored EBook with “Maximum Production Capacity with Chat GPT”. As a Google Generation Scholar 2022 for the APAC, the Champions Diversity and the Educational Virtue. He is also recognized as a tech scholar, Mitacs Global Research Scholar, and Harvard Vacod Scholar as a Taradata diversity. Kanwal is a passionate lawyer for change, who has laid the foundation of a Fame Code to empower women in stem fields.

You may also like

Leave a Comment

At Skillainest, we believe the future belongs to those who embrace AI, upgrade their skills, and stay ahead of the curve.

Get latest news

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

@2025 Skillainest.Designed and Developed by Pro