0Pricing
NLP Academy · Lección

Búsqueda de fragmentos de respuesta en el contexto

Predicción de los tokens inicial y final

Búsqueda de fragmentos de respuesta en el contexto es una lección gratuita de NLP Academy en CoddyKit. Esta es la lección 3 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 NLP Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de NLP Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

The Span Mindset

Under the hood, extractive QA never writes text. It picks a span: a contiguous slice of the context defined by where it starts and ends.

Predicting Two Numbers

The model's real job is to predict two positions: the start token of the answer and the end token. The slice between them is the answer.

Tokens, Not Characters

Inside the model the context is split into tokens, not raw letters. Start and end are token indexes that get mapped back to characters.

A Score Per Position

For every token the model emits a start logit and an end logit. These scores say how likely each token begins or ends the answer.

Picking the Best Pair

The chosen span is the start and end pair with the highest combined score, with the rule that end never comes before start.

Slicing With Offsets

The pipeline returns character offsets so you can slice the original context yourself and recover the exact answer text.

answer = context[result["start"]:result["end"]]

Why Offsets Matter

Those offsets let you highlight the answer right inside the passage, which is great for showing users where a fact came from.

Limiting Answer Length

You can cap how long a span may be with max_answer_len. This stops the model from returning an entire sentence as the answer.

qa(question=q, context=c, max_answer_len=20)

Getting Several Candidates

Set top_k to return more than one candidate span. Reviewing a few options helps when the best answer is ambiguous.

qa(question=q, context=c, top_k=3)

Spans Must Be Contiguous

A span is always one continuous stretch of text. Extractive QA cannot stitch together words from different parts of the passage.

Spans Power Highlighting

Because answers are exact spans with offsets, you can highlight them in place, giving users a verifiable source for every reply. 🔦

Quick Check

How does the model decide what the answer is?

Recap

The model predicts start and end positions, picks the best valid pair, and offsets let you slice and highlight the exact answer. 📌

Preguntas frecuentes

¿La lección «Búsqueda de fragmentos de respuesta en el contexto» es gratis?

Sí — el texto completo de «Búsqueda de fragmentos de respuesta en el contexto» 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 NLP Academy, actualiza a CoddyKit PRO. El curso de NLP Academy incluye 4 lecciones en total.

¿Qué aprenderé en «Búsqueda de fragmentos de respuesta en el contexto»?

Predicción de los tokens inicial y final Practicas NLP Academy 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 NLP Academy?

No se requiere experiencia previa. NLP Academy 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 3 de 4.

¿Cuánto tiempo toma la lección «Búsqueda de fragmentos de respuesta en el contexto»?

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 NLP Academy?

Sí. Cada lección de NLP Academy 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

  1. QA extractivo frente a generativo
  2. Ejecución de una canalización de QA
  3. Búsqueda de fragmentos de respuesta en el contexto
  4. Gestión de documentos largos y sin respuesta
← Volver a NLP Academy