Search code examples
machine-learningnlpartificial-intelligencelarge-language-model

How are LLMs assigned tasks in Python code?


I'm following Nicholas' Renotte's tutorials on VSCode, LangChain, and OpenAI using Python.

These are the codeblocks I've seen from the aforementioned tutorials, and I don't see any other lines of code that tell the AI what to do.

title_template = PromptTemplate(
    input_variables = ['topic'],
    template='write me a youtube video title about {topic}'
)

So is AI given a task using this kind of conversational language? Is that really all that's needed, and wouldn't this place a lot of pressure on precise wording of the assignment?


Solution

  • You're right. The template (write me a youtube video title about {topic}) is called a prompt template, and the only difference between such a template and an actual prompt (like the ones you give to ChatGPT for instance) is that prompt templates are formatted strings: {topic} gets substituted by something else. It is true that the wording of the assignment is important - writing good prompts has become something of a domain in itself, called 'prompt engineering' (https://en.wikipedia.org/wiki/Prompt_engineering#:~:text=Prompt%20engineering%20(also%20known%20as,of%20it%20being%20explicitly%20given.). If you want to learn more about generative AI and large language models, I would recommend taking a look at Cohere's free LLM University: https://docs.cohere.com/docs/llmu