Large Language Models: What are they, how they work, and how to use them?

Empowering machines with language, from training to specialization. Unveiling the magic of Large Language Models.

people working at nubank office

In this article, we’ll dive into the captivating world of language models and uncover the valuable insights shared by Nubank’s Data Scientist and ML Engineer, Vitor Rosa. Join us as we explore the key topics discussed during his enlightening lecture, which took place at the 80th edition of the Nubank DS & ML Meetup.

Vitor Rosa shed light on the fascinating capabilities, functioning, and practical applications of Large Language Models (LLMs). Throughout his engaging presentation, he provided a comprehensive overview of the remarkable GPT model, showcasing its advancements and illustrating its potential in various domains, including text generation and code processing.

In this article, we aim to summarize and highlight the key insights shared by Vitor Rosa during his lecture, offering you a deep dive into the world of LLMs. We’ll explore their remarkable abilities to comprehend numbers, perform mathematical operations, and navigate the intricacies of code. Moreover, we’ll uncover strategies to optimize interaction with these models, including the importance of step-by-step explanations and user-specific training data.

Additionally, we’ll delve into the considerations surrounding context and prompts, as well as the challenges and future perspectives associated with language models. Throughout our exploration, we’ll emphasize the practical implications of Vitor Rosa’s teachings, providing you with valuable insights to stay at the forefront of this rapidly evolving field.

What are Large Language Models (LLMs) and how They Work

Large Language Models (LLMs) represent a groundbreaking advancement in the field of natural language processing (NLP). These models, such as the one introduced by Victor Rosa, have revolutionized the way machines understand and generate human-like text, for example. Let’s delve into the concept of LLMs and explore their remarkable capabilities.

At their core, LLMs are deep learning models that have been trained on vast amounts of textual data, enabling them to acquire a deep understanding of language patterns, grammar, and semantics. These models employ a transformer architecture, which allows them to capture the contextual dependencies within a given text and generate coherent and contextually relevant responses.

LLMs undergo two major stages during their training: pre-training and fine-tuning. In the pre-training phase, models are exposed to massive datasets containing parts of the internet, books, articles, and various textual sources. This extensive exposure enables LLMs to learn grammar, syntax, and a wide range of language features.

Once pre-trained, LLMs are fine-tuned on specific tasks or domains to enhance their performance and adapt them to particular applications. Fine-tuning involves training the model on a more specific dataset with labeled examples, allowing it to specialize in tasks like language translation, text completion, sentiment analysis, or code generation.

One of the most remarkable capabilities of LLMs is their ability to generate human-like text. By providing a prompt or a starting sentence, LLMs can generate coherent paragraphs, essays, stories, or even code snippets. This text generation is based on the patterns and knowledge learned during the training process.

However, it is important to note that while LLMs can produce highly convincing and contextually appropriate text, they may sometimes generate responses that are factually incorrect or biased. This is because LLMs lack true understanding or common sense reasoning and rely solely on patterns present in the training data.

The applications of LLMs are vast and diverse. They have been employed in various industries and fields, including content generation, customer support chatbots, language translation, summarization, and code completion. LLMs have also found applications in creative writing, virtual assistants, and aiding research by providing contextual information or suggesting related articles.

The potential of LLMs extends beyond individual tasks. They can serve as powerful tools for researchers, developers, and content creators, offering assistance, inspiration, and new possibilities for innovation.

In the next section, we will delve into the specific capabilities of LLMs, focusing on their ability to comprehend numbers, perform mathematical operations, and optimize code processing.

Capabilities of LLMs

Understanding Numbers and Mathematical Operations

Despite being character-based models, Rosa revealed that the GPT model has demonstrated the remarkable ability to interpret numbers and perform mathematical operations. It can handle calculations involving small numbers without being explicitly trained for such tasks.

Rosa provided an example illustrating how GPT can effortlessly solve mathematical equations by processing the numerical input and generating accurate results. This showcases the model’s versatility and its potential applications in various mathematical and computational tasks.

Potential in Code Processing

Rosa discussed the advantages of using language models for code processing. Unlike natural language, code has a more rigid syntax and less ambiguity in denotation and figurative meaning. This makes it a suitable domain for language models to excel.

The lecture highlighted the GPT model’s capabilities in automatically completing code snippets, including variables and function definitions. Moreover, the model can generate helpful comments, providing insights into the rationale behind the code. This unique feature allows developers to leverage the model’s expertise in planning and optimizing code implementation.

Optimizing Interaction with Language Models

Encouraging Step-by-Step Explanations

In the quest for improving the performance of language models, Vitor Rosa shared an intriguing finding. He discovered that by explicitly asking the model to explain the step-by-step process leading to its response, the model’s output can be enhanced.

Training language models with the notion of providing step-by-step explanations proved to be a promising approach. By incorporating this methodology into the training process, researchers can ensure the generation of higher-quality responses.

Training with Specific Data and User Interactions

To enhance the interaction between language models and users, Rosa discussed the importance of training models with specific data and incorporating user instructions. By adapting the model to respond to user queries and instructions in a conversational manner, language models can provide more personalized and contextually appropriate responses.

Vitor Rosa also shared insights into the use of “impostors” or “strawman” instructions during training. By guiding the model’s behavior with examples of what it should not do, researchers can fine-tune the model’s response generation and improve its acceptance by users.

The lecture touched upon the challenges associated with instructing language models and introduced an innovative approach, which aims to train models to follow instructions within conversational contexts, thereby facilitating more seamless and effective user interactions.

Considerations about Contexts and Prompts

Limitations of Context Size

Rosa highlighted the limitation of context size when using language models. Typically, prompts have a token limit ranging in the thousands. This constraint poses challenges when dealing with lengthy conversations or complex information that requires a comprehensive understanding of the context.

To overcome this limitation, Vitor Rosa stressed the importance of taking into account the user’s interaction history and integrating it into the prompt. By leveraging the contextual information from previous interactions, language models can generate more coherent and contextually appropriate responses.

Strategies to Optimize Prompts

The lecture delved into strategies for optimizing prompts to enhance the performance of language models. One approach involves including supplementary elements such as lists, tables, or related documents within the prompt. These additional resources aid in tasks requiring step-by-step reasoning or specific information retrieval.

Furthermore, Rosa emphasized the significance of ensuring seamless integration with external systems. This entails structuring the model’s responses in a format that facilitates easy integration with downstream processes or external applications.

Challenges and Future Perspectives

During the lecture, Vitor Rosa addressed the challenges associated with language models, including the risks of generating false or misleading texts. The advancement of language models raises concerns about the authenticity and reliability of the generated content, emphasizing the need for critical evaluation and validation.

Rosa dedicated a significant portion of the lecture to discussing the effectiveness of language models in code generation. He underscored how these models can automatically complete code snippets, suggest improvements, and even perform complex tasks such as refactoring and migration.

The lecture concluded by highlighting the continuous evolution of language models and their application in various benchmarks. Vitor Rosa drew attention to the differences between open-source and paid models, emphasizing that paid models often have dedicated teams responsible for training and refining the model to mitigate undesirable behaviors.


In conclusion, Vitor Rosa’s lecture provided a comprehensive overview of language models. The lecture covered the capabilities of language models in understanding numbers, processing code, and optimizing interaction with users. It also delved into considerations about contexts and prompts, highlighting strategies to overcome limitations and optimize the performance of language models. The lecture concluded with a discussion on the challenges and future prospects of language models, underscoring their potential in text generation and code processing.

The insights shared by Rosa shed light on the significant advancements in language modeling and how these models can revolutionize various fields, ranging from natural language processing to software development. By understanding and harnessing the power of language models, we can unlock new possibilities and drive innovation in the way we interact with text and code.