Prompt A Structured Q&A Response Using LeMUR
This Colab will demonstrate how to use AssemblyAI’s LeMUR (Leveraging Large Language Models to Understand Recognized Speech) framework to prompt a structured Question and Answer response using the Task Endpoint.
Quickstart
Getting Started
Before we begin, make sure you have an AssemblyAI account and an API key. You can sign up for an AssemblyAI account and get your API key from your dashboard.
Find more details on the current LeMUR pricing in the AssemblyAI pricing page.
Step-by-Step Instructions
In this guide, we will prompt LeMUR with a structured Q&A format and generate an XML response.
First, let’s install the AssemblyAI SDK.
Then we’ll import the SDK and set our AssemblyAI API key.
Next, we’ll use AssemblyAI to transcribe a file and save our transcript.
Construct a formatted string to structure the questions from the LemurQuestion
object. This includes the question text, optional context, an answer format (defaulting to “short sentence” if not provided), and any answer options, then returns the formatted string.
Define a list of aai.LemurQuestion
objects. For each question, you can define additional context
and specify either a answer_format
or a list of answer_options
.
Construct the formatted question string for all the Questions within the list of aai.LemurQuestion
objects.
Provide detailed instructions to prompt LeMUR to answer a series of questions. This also defines a structured XML template for the responses.
Prompt the LeMUR model using the Task Endpoint and return the response.
Clean the XML output and print the question and answer pairs.