ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Build an LLM Evaluation System to Detect Hallucinations | AI Project

Автор: CodeVisium

Загружено: 2026-09-04

Просмотров: 718

Описание: Build a real-world LLM Evaluation & Hallucination Detection Platform with Python.

The goal is simple: instead of asking whether an AI application "looks good", automatically measure whether its answers are reliable enough to deploy.

This project is especially useful for AI Engineer, ML Engineer, LLM Engineer, GenAI Engineer and MLOps/LLMOps portfolios.

🏗️ Architecture

Evaluation Dataset
↓
LLM / RAG Application
↓
Generated Answer + Retrieved Context
↓
Evaluation Engine
↓
PostgreSQL
↓
Streamlit Dashboard
↓
CI/CD Quality Gate

🛠️ Tech Stack

Python
OpenAI or another LLM provider
DeepEval / custom evaluators
Sentence Transformers
PostgreSQL
FastAPI
Streamlit
Docker
GitHub Actions

📁 Project Structure
llm-eval-platform/
├── data/
│ └── eval_dataset.jsonl
├── app/
│ ├── llm.py
│ └── evaluator.py
├── dashboard/
│ └── app.py
├── tests/
│ └── test_eval.py
├── requirements.txt
├── Dockerfile
└── README.md
1️⃣ Create Your Evaluation Dataset

Create 20–100 realistic questions.

Example:

{
"question": "What is CDC in data engineering?",
"context": "CDC captures inserts, updates and deletes from a source database.",
"expected_answer": "CDC means Change Data Capture and tracks changes made to source data."
}

Include difficult cases:

• Normal questions
• Questions with incomplete context
• Out-of-domain questions
• Questions designed to trigger hallucinations
• Long questions
• Similar questions with different answers

2️⃣ Generate the AI Answer

Your application should return:

result = {
"question": question,
"answer": answer,
"context": context
}

For a RAG application, save the retrieved context along with every response.

3️⃣ Evaluate the Response

Install:

pip install deepeval pandas streamlit sqlalchemy psycopg2-binary

Example DeepEval hallucination test:

from deepeval import evaluate
from deepeval.metrics import HallucinationMetric
from deepeval.test_case import LLMTestCase

test_case = LLMTestCase(
input="What is CDC?",
actual_output="CDC captures database changes.",
context=[
"CDC captures inserts, updates and deletes from a source database."
]
)

metric = HallucinationMetric(
threshold=0.5,
include_reason=True
)

evaluate(
test_cases=[test_case],
metrics=[metric]
)

For a RAG system, also evaluate faithfulness against the retrieved context.

4️⃣ Track More Than Accuracy

Store:

question
model
answer
faithfulness
relevance
hallucination_score
latency_ms
input_tokens
output_tokens
estimated_cost
timestamp

Useful metrics:

Faithfulness: Is the answer supported by the supplied evidence?

Relevance: Does the answer actually address the question?

Hallucination: Does the response contradict trusted context?

Latency: How long did the request take?

Cost: How expensive is each request?

5️⃣ Add a Deployment Gate

Example:

def deployment_gate(avg_score, hallucination_rate):
return (
avg_score v= 0.85
and hallucination_rate v= 0.05
)

if not deployment_gate(0.82, 0.08):
raise SystemExit("AI evaluation failed — deployment blocked")

Now every prompt/model/retriever change can be evaluated before deployment.

📊 Streamlit Dashboard

Display:

• Total test cases
• Pass rate
• Average faithfulness
• Hallucination rate
• Average latency
• Cost per request
• Failed test cases
• Model comparison
• Evaluation score over time

🚀 Portfolio Upgrade

Compare 2–3 models using the exact same evaluation dataset.

Then experiment with:

Model A → Model B

Chunk Size 500 → 1000

Top-K 3 → 5

Prompt V1 → Prompt V2

Show which configuration improves quality while controlling latency and cost.

For an advanced version, connect the evaluation pipeline to GitHub Actions so a pull request automatically runs the golden dataset and blocks deployment when quality falls below your threshold.

Important: automated LLM evaluation is not perfect. Treat evaluator scores as signals, combine them with deterministic tests and human review for high-risk applications.

5 INTERVIEW QUESTIONS

1. Why can't we evaluate an LLM using traditional accuracy alone?
Because many valid answers can have different wording. LLM applications require metrics such as relevance, faithfulness, safety and task success.

2. What is hallucination?
A hallucination occurs when an AI system generates information that is unsupported, fabricated or inconsistent with the available evidence.

3. What is LLM-as-a-judge?
Another language model evaluates an AI response against criteria such as correctness, relevance or faithfulness.

4. Why should evaluation datasets contain difficult examples?
Easy examples can hide weaknesses. Edge cases, adversarial prompts and out-of-domain questions reveal failure modes.

5. What is an AI quality gate?
It is an automated rule that allows or blocks deployment based on predefined evaluation thresholds.

Build this project and showcase the architecture, evaluation dataset, metrics dashboard, failed test cases and CI/CD gate in your GitHub README.

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Build an LLM Evaluation System to Detect Hallucinations | AI Project

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]