Tune the temperature
Temperature is a configurable parameter that controls the randomness of the text output generated by the /summarize
and /generate
endpoints . This parameter ranges from 0 to 1, inclusive, and the default value is 0.7. A higher value generates more creative text, while a lower value produces more deterministic text output.
Common use cases include:
- Writers: Choose a higher temperature when seeking inspiration or a lower temperature for factual or technical writing.
- Marketing professionals: Choose a higher temperature to generate more unique and eye-catching content.
- Educators and students: Choose a lower temperature for summarizing educational content or a higher temperature for more engaging results.
- Law enforcement and security: Choose a lower temperature for generating factual reports, such as creating detailed and accurate police reports based on video evidence or drafting documents where precision is important.
- Meeting facilitators: Choose a lower temperature for taking accurate and concise meeting minutes. This setting helps capture key points, decisions, and action items.
The examples below are specific to using the /generate
endpoint. However, the principles demonstrated are similar when using the /summarize
endpoint.
Prerequisites
- You’re familiar with the concepts that are described on the Platform overview page.
- You’ve already created an index, and the Pegasus video understanding engine is enabled for this index.
- You've uploaded a video, and the platform has finished indexing it.
Example
The example code below demonstrates setting the value of the temperature
parameter to 0.2 in the body of the request for this video: Tim Urban: Inside the mind of a master procrastinator | TED. This results in a more deterministic result than the default settings.
from twelvelabs import TwelveLabs
client = TwelveLabs(api_key="<YOUR_API_KEY>")
res = client.generate.text(
video_id='<YOUR_VIDEOV_ID>',
prompt="I want to generate a description for my video with the following format: Title of the video, followed by a summary in 2-3 sentences, highlighting the main topic, key events, and concluding remarks.",
temperature=0.2
)
print(f"Open-ended text: {res.data}")
import { TwelveLabs } from 'twelvelabs-js';
const client = new TwelveLabs({ apiKey: 'YOUR_API_KEY'});
const text = await client.generate.text(
'65e9487948db9fa780cb46c0',
'I want to generate a description for my video with the following format: Title of the video, followed by a summary, highlighting the main topic, key events, and concluding remarks.',
0.5,
);
console.log(`Open-ended Text: ${text.data}`);
The result should look similar to the following one:
Open-ended text: Title: TEDx Speaker Delivers an Inspiring Talk on Innovation and Creativity\n\n
Summary:\nIn this TEDx video, a speaker delivers an engaging and inspiring talk on the topics of
innovation and creativity. The speaker, dressed in a black shirt, uses hand gestures and a remote
control to navigate through his presentation slides, which include a blank grid and a TED logo.
Throughout the talk, the speaker emphasizes the importance of embracing creativity and innovation
in various aspects of life. He encourages the audience to stay aware of their own tendencies
towards procrastination and the instant gratification monkey, and to start addressing their
procrastination tasks as soon as possible. The audience is attentively listening and responding
positively to the speaker's message, and the video concludes with the speaker smiling and
acknowledging their applause.\n\nMain Topics:\n1. The importance of creativity and innovation\n2.
Overcoming procrastination and the instant gratification monkey\n\nKey Events:\n1. The speaker uses
hand gestures and a remote control to navigate through his presentation slides\n2. He emphasizes
the importance of embracing creativity and innovation\n3. The speaker encourages the audience to
stay aware of their own procrastination tendencies\n4. He concludes the talk by acknowledging the
audience's applause\n\nConcluding Remarks:\nThe speaker's inspiring talk on innovation and
creativity encourages the audience to embrace these concepts in their own lives and to be aware of
their tendencies towards procrastination. By staying focused and addressing tasks as soon as
possible, individuals can make significant progress and achieve their goals. The video concludes
with the speaker's positive and uplifting message, leaving the audience feeling motivated and
inspired.
Setting the temperature
parameter to 0.9 would result in a more creative response, similar to the following one:
Open-ended text: In the provided video clips, there are several TED Talks occurring, each
featuring a speaker delivering engaging and thought-provoking presentations. The first talk,
titled 'TED: Ideas Worth Spreading', showcases a speaker presenting on the importance of the
spread of ideas and their impact on the world. He uses visual aids such as graphs and charts to
emphasize his points.\n\nNext, in a talk titled 'The 5 Day Startup', a speaker delivers a
presentation on starting a business within a five-day period. He highlights key steps and
considerations involved in launching a successful venture.\n\nAnother talk, named
'The Art of Public Speaking', focuses on the topic of effective communication through public
speaking. The speaker encourages the audience to understand and harness the power of storytelling
and persuasive language in their presentations. In this clip, the speaker's dynamic and expressive
presentation style is evident.\n\nFinally, in a talk titled 'Easy and Fun', a speaker discusses
the importance of balance between work and play, emphasizing that it is essential to prioritize
both. The speaker uses various visual aids, including a monkey and a ship's wheel, to illustrate
the points.\n\nAll the speakers in these talks are passionate and knowledgeable on their respective
topics, ensuring an insightful and captivating delivery. The videos are well produced, with clear
visuals and audio, further enhancing the audience's experience.
Using the default value for the temperature
parameter would result in a response similar to the following one:
Open-ended text:: Title: TEDx Talk - The Art of Procrastination\n\nSummary: In this TEDx talk,
the speaker delves into the topic of procrastination, sharing insights into the origins of this
human behavior and its psychological implications. The speaker uses vivid storytelling, humor,
and relatable examples to engage the audience and encourage them to reevaluate their relationship
with procrastination. The talk concludes with a call to action for viewers to recognize the role of
the \"instant gratification monkey\" in their lives and take steps towards overcoming their
procrastination habits.\n\nThe video opens with the speaker sharing his personal experience of
procrastination, starting from his college days when he had to write a 90-page thesis. He describes
how he came up with a plan to spread the work out evenly, but ended up procrastinating and having
to write the entire thesis in just a few days before the deadline. The speaker then discusses the
concept of short-term and long-term procrastination, explaining how the latter can be more insidious
as it often goes unnoticed and can lead to significant regret over missed opportunities.\n\nThe
speaker then introduces the idea of the \"instant gratification monkey,\" which is the part of our
brain that seeks pleasure and avoids pain in the present moment. He shares that this monkey can
cause us to delay important tasks and instead engage in activities that provide immediate
satisfaction, such as browsing social media or watching TV. However, the speaker emphasizes that
this behavior can lead to feelings of guilt, anxiety, and regret in the long term.\n\nTo illustrate
the concept further, the speaker uses the analogy of a life calendar, emphasizing that each week
of a 90-year life represents only one box. He encourages viewers to think about what they are truly
procrastinating on and to be aware of the instant gratification monkey, as everyone experiences it
to some degree. The speaker concludes his talk by thanking the audience for their attention and
encouraging them to start addressing their procrastination habits sooner rather than later.\n\n
Throughout the talk, the speaker uses body language, facial expressions, and hand gestures to
engage the audience and emphasize key points. He also uses visual aids, such as the life calendar
and a blank grid, to illustrate his concepts. The audience is attentively listening and responding
positively to the speaker's message, as evidenced by their nodding and applause. Overall, this
TEDx talk provides valuable insights into the psychology of procrastination and offers practical
advice for overcoming it.
Updated 8 months ago