BaşlayınÜcretsiz Başlayın

Using the correct model structure

Question-answering can be either extractive or generative, each requiring a different transformer structure to process input and output correctly.

They use either:

  • Encoder-only models such as "distilbert-base-uncased-distilled-squad"
  • Decoder-only models such as "gpt2"

Use your knowledge of common models for specific tasks to select the appropriate one. pipeline is loaded, as well as text on the Mona Lisa.

Bu egzersiz

Introduction to LLMs in Python

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

question = "Who painted the Mona Lisa?"

# Define the appropriate model
qa = pipeline(task="question-answering", model=____)

output = qa(question=question, context=text)
print(output['answer'])
Kodu Düzenle ve Çalıştır