Encontrando trechos de resposta no contexto
Previsão dos tokens inicial e final.
Encontrando trechos de resposta no contexto é uma aula grátis de NLP Academy no CoddyKit. Esta é a aula 3 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de NLP Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de NLP Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em 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. 📌
Perguntas Frequentes
A aula “Encontrando trechos de resposta no contexto” é grátis?
Sim — o texto completo de “Encontrando trechos de resposta no contexto” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de NLP Academy, atualize para CoddyKit PRO. O curso de NLP Academy inclui 4 aulas no total.
O que vou aprender em “Encontrando trechos de resposta no contexto”?
Previsão dos tokens inicial e final. Você pratica NLP Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar NLP Academy?
Nenhuma experiência prévia é necessária. NLP Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 3 de 4.
Quanto tempo leva a aula “Encontrando trechos de resposta no contexto”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de NLP Academy?
Sim. Cada aula de NLP Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- QA extrativo versus generativo
- Executando um pipeline de QA
- Encontrando trechos de resposta no contexto
- Tratando ausência de resposta e documentos longos