0Pricing
NLP Academy · Lezione

Trovare gli span di risposta nel contesto

Prevedere il token iniziale e quello finale

Trovare gli span di risposta nel contesto è una lezione NLP Academy gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento NLP Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso NLP Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

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

Domande Frequenti

La lezione «Trovare gli span di risposta nel contesto» è gratuita?

Sì — il testo completo di «Trovare gli span di risposta nel contesto» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso NLP Academy, passa a CoddyKit PRO. Il corso NLP Academy include 4 lezioni in totale.

Cosa imparerò in «Trovare gli span di risposta nel contesto»?

Prevedere il token iniziale e quello finale Eserciti NLP Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare NLP Academy?

Non è richiesta alcuna esperienza precedente. NLP Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.

Quanto tempo richiede la lezione «Trovare gli span di risposta nel contesto»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione NLP Academy?

Sì. Ogni lezione NLP Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. QA estrattivo e generativo
  2. Eseguire una pipeline di QA
  3. Trovare gli span di risposta nel contesto
  4. Gestire risposte assenti e documenti lunghi
← Torna a NLP Academy