Probar y evaluar su aplicación RAG
Aumente la confianza en su primera aplicación RAG creando un conjunto de pruebas y midiendo la calidad de la recuperación y de las respuestas con métricas prácticas antes de publicarla.
Probar y evaluar su aplicación RAG es una lección gratuita de LLM Apps in Production (RAG + Vector DB + Caching) en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de LLM Apps in Production (RAG + Vector DB + Caching), y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de LLM Apps in Production (RAG + Vector DB + Caching) incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
Why Evaluate RAG
A RAG app can look fine on a few queries and fail badly on others. Without measurement you cannot tell if a change helped or hurt.
Evaluation gives you a repeatable score to guide improvements.
Two Things to Measure
RAG quality has two parts:
- Retrieval: did we fetch the right documents?
- Generation: did the answer use them correctly?
A bad answer can come from either, so measure both.
Building a Test Set
Create a small set of questions with known correct answers and the documents that contain them. Even 20 to 50 examples are enough to start.
testset = [
{'q': 'What is the refund window?',
'answer': '30 days',
'source': 'policy.md'}
]Retrieval Metric: Hit Rate
Hit rate (or recall@k) checks whether the correct source appears in the top-k retrieved chunks. High hit rate means retrieval is doing its job.
def hit(retrieved, expected_source):
return any(d.metadata['source'] == expected_source
for d in retrieved)Faithfulness
Faithfulness asks: is the answer supported by the retrieved context, or did the model make things up? An LLM judge can score this automatically.
Answer Relevance
Answer relevance measures whether the response actually addresses the question, regardless of sources. A faithful answer can still be off-topic.
LLM as a Judge
You can use a strong model to grade outputs against the expected answer, returning a pass or score with a reason.
judge_prompt = (
'Question: {q}\nExpected: {gold}\n'
'Got: {pred}\nIs it correct? Answer yes or no.'
)Running the Evaluation
Loop over the test set, run your pipeline, and aggregate scores into a single report you can compare across versions.
scores = []
for case in testset:
pred = rag.invoke(case['q'])
scores.append(grade(case, pred))
print(sum(scores) / len(scores))Comparing Configurations
Change one variable — chunk size, k, prompt, model — rerun the same test set, and compare scores. This turns guesswork into evidence-based tuning.
Watching for Regressions
Keep the test suite in CI. When a change drops a metric, you catch the regression before users do. Treat evaluation like unit tests for AI quality.
Improving From Results
Use failures to guide fixes:
- Low hit rate? Adjust chunking or retrieval
- Low faithfulness? Strengthen grounding instructions
- Low relevance? Improve the prompt
Quick Check
Test your evaluation knowledge.
Recap
You learned to evaluate your RAG app:
- Measure both retrieval and generation
- Build a small test set with known answers
- Use hit rate, faithfulness, and answer relevance
- Let an LLM judge grade outputs
- Compare configs and guard against regressions in CI
Evaluation turns RAG improvement into a measurable, repeatable process.
Aprende LLM Apps in Production (RAG + Vector DB + Caching) con un tutor de IA — gratis
Escribe y ejecuta código real en tu navegador, obtén ayuda instantánea de un tutor de IA disponible 24/7 y continúa donde lo dejaste en la web o en la aplicación.
- Cursos
- 12
- Lecciones
- 48
Preguntas frecuentes
¿La lección «Probar y evaluar su aplicación RAG» es gratis?
Sí — el texto completo de «Probar y evaluar su aplicación RAG» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de LLM Apps in Production (RAG + Vector DB + Caching), actualiza a CoddyKit PRO. El curso de LLM Apps in Production (RAG + Vector DB + Caching) incluye 4 lecciones en total.
¿Qué aprenderé en «Probar y evaluar su aplicación RAG»?
Aumente la confianza en su primera aplicación RAG creando un conjunto de pruebas y midiendo la calidad de la recuperación y de las respuestas con métricas prácticas antes de publicarla. Practicas LLM Apps in Production (RAG + Vector DB + Caching) con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar LLM Apps in Production (RAG + Vector DB + Caching)?
No se requiere experiencia previa. LLM Apps in Production (RAG + Vector DB + Caching) en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.
¿Cuánto tiempo toma la lección «Probar y evaluar su aplicación RAG»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de LLM Apps in Production (RAG + Vector DB + Caching)?
Sí. Cada lección de LLM Apps in Production (RAG + Vector DB + Caching) incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Elegir un proveedor de LLM
- Fundamentos de carga de datos y división de texto
- Crear una canalización RAG sencilla
- Probar y evaluar su aplicación RAG