0Pricing
NLP Academy · Урок

Поиск фрагментов ответа в контексте

Предсказание начального и конечного токенов

«Поиск фрагментов ответа в контексте» — бесплатный урок NLP Academy на CoddyKit. Это урок 3 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения NLP Academy, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс NLP Academy содержит 4 уроков всего.

Части этого урока еще не переведены и отображаются на английском.

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. 📌

Часто задаваемые вопросы

Урок «Поиск фрагментов ответа в контексте» бесплатный?

Да — полный текст урока «Поиск фрагментов ответа в контексте» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс NLP Academy, подпишись на CoddyKit PRO. Курс NLP Academy содержит 4 уроков всего.

Чему я научусь в уроке «Поиск фрагментов ответа в контексте»?

Предсказание начального и конечного токенов Ты практикуешь NLP Academy с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать NLP Academy?

Предыдущий опыт не требуется. NLP Academy на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 3 из 4.

Сколько времени занимает урок «Поиск фрагментов ответа в контексте»?

Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.

Можно ли писать и запускать код в этом уроке NLP Academy?

Да. Каждый урок NLP Academy включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.

Все уроки этого курса

  1. Извлечение ответа и генерация QA
  2. Запуск конвейера QA
  3. Поиск фрагментов ответа в контексте
  4. Обработка отсутствующих ответов и длинных документов
← Назад к NLP Academy