๐Ÿš€ New multimodal model: Command A Vision! (Learn more) ๐Ÿš€

Introduction to Text Generation at Cohere

Large language models are impressive for many reasons, but among the most prominent is their ability to quickly generate text. With just a little bit of prompting, they can crank out conceptual explanations, blog posts, web copy, poetry, and almost anything else. Their style can be tweaked to be suitable for children and adults, technical people and laymen, and they can be asked to work in dozens of different natural languages.

In this article, weโ€™ll cover some of the basics of what makes this functionality possible. If youโ€™d like to skip straight to a more hands-on treatment, check out โ€œUsing the Chat API.โ€

How are Large Language Models Trained?

Eliding a great deal of technical complexity, a large language model is just a neural network trained to predict the next token, given the tokens that have come before. Take a sentence like โ€œHang on, I need to go inside and grab my ___.โ€ As a human being with a great deal of experience using natural language, you can make some reasonable guesses about which token will complete this sentence even with no additional context:

  • โ€œHang on, I need to go inside and grab my bag.โ€
  • โ€œHang on, I need to go inside and grab my keys.โ€
  • Etc.

Of course, there are other possibilities that are plausible, but less likely:

  • โ€œHang on, I need to go inside and grab my friend.โ€
  • โ€œHang on, I need to go inside and grab my book.โ€

And, thereโ€™s a long-tail of possibilities that are technically grammatically correct but which effectively never occur in a real exchange:

  • โ€œHang on, I need to go inside and grab my giraffe.โ€

You have an intuitive sense of how a sentence like this will end because youโ€™ve been using language all your life. A model like Command R+ must learn how to perform the same feat by seeing billions of token sequences and figuring out a statistical distribution over them that allows it to predict what comes next.

Once itโ€™s done so, it can take a prompt like โ€œHelp me generate some titles for a blog post about quantum computing,โ€ and use the distribution it has learned to generate the series of tokens it thinks would follow such a request. Since itโ€™s an AI system generating tokens, itโ€™s known as โ€œgenerative AI,โ€ and with models as powerful as Cohereโ€™s, the results are often surprisingly good.

Learn More

The rest of the โ€œText Generationโ€ section of our documentation walks you through how to work with Cohereโ€™s models. Check out โ€œUsing the Chat APIโ€ to get set up and understand what a response looks like, or reading the streaming guide to figure out how to integrate generative AI into streaming applications.

You might also benefit from reading the retrieval-augmented generation, tool-use, and agent-building guides.