EXAONE-Deep
HomeModel OverviewTechnical FeaturesPerformanceApplicationsDeploymentTutorials

EXAONE-Deep Tutorials

Getting Started with EXAONE-Deep

This page provides step-by-step tutorials for using the EXAONE-Deep model for various tasks. EXAONE-Deep excels at mathematical reasoning, scientific understanding, and code generation. The following tutorials will help you get started with this powerful language model.

Basic Usage Tutorial


This example demonstrates how to load the EXAONE-Deep model and use it for a basic inference task:

python

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load the model and tokenizer
model_id = "LGAI-EXAONE/EXAONE-Deep-7.8B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")

# Prepare input
prompt = "Explain the concept of quantum computing in simple terms."
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

# Generate
outputs = model.generate(
    inputs.input_ids,
    max_new_tokens=512,
    do_sample=True,
    temperature=0.7,
    top_p=0.9,
)

# Decode and print the response
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response)
Key Parameters:
  • temperature

    Controls randomness. Lower values (e.g., 0.3) make responses more deterministic, while higher values (e.g., 0.8) create more diverse outputs.

  • top_p

    Nucleus sampling parameter that determines how many tokens are considered for each next token selection.

  • max_new_tokens

    Maximum number of tokens to generate in the response.

Mathematical Problem Solving


EXAONE-Deep excels at mathematical reasoning. Here's how to use it to solve complex math problems:

python

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load the model and tokenizer
model_id = "LGAI-EXAONE/EXAONE-Deep-32B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")

# Math problem example
problem = """
Solve the differential equation:
dy/dx + 2y = x^2 - x
Given the initial condition y(0) = 1.
Show all steps of your solution.
"""

inputs = tokenizer(problem, return_tensors="pt").to(model.device)

# Generate with math-focused parameters
outputs = model.generate(
    inputs.input_ids,
    max_new_tokens=1024,
    do_sample=True,
    temperature=0.3,  # Lower temperature for more deterministic answers
    top_p=0.95,
)

# Decode and print the response
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response)

For optimal mathematical reasoning:

  • Use the 32B model

    The largest model provides the best performance on complex mathematical tasks.

  • Prompt for step-by-step solutions

    Explicitly asking for steps improves accuracy and makes the reasoning process transparent.

  • Use a lower temperature

    A temperature between 0.2-0.4 works best for mathematical reasoning tasks.

Code Generation Tutorial


EXAONE-Deep can generate code across multiple programming languages. Here's an example of how to use it for code generation:

python

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load the model and tokenizer
model_id = "LGAI-EXAONE/EXAONE-Deep-7.8B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")

# Programming task
prompt = """
Write a Python function to find the longest common subsequence of two strings.
Include comments and test cases.
"""

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

# Generate with code-focused parameters
outputs = model.generate(
    inputs.input_ids,
    max_new_tokens=1024,
    do_sample=True,
    temperature=0.4,
    top_p=0.95,
)

# Decode and print the response
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response)

Tips for effective code generation:

Provide Clear Requirements

Specify the exact functionality you need, including input and output formats, edge cases to handle, and any performance constraints.

Request Test Cases

Ask the model to include test cases that demonstrate the functionality and handle edge cases properly.

Advanced Usage Patterns


For more advanced use cases and integration scenarios, check out the comprehensive documentation on our GitHub repository and Hugging Face model pages.

GitHub DocumentationHugging Face Models