Complete AI Training

Prompt · Data Scientists

Implement LSTM Architecture for Sequential Data

Use this when you need to design and implement an LSTM-based model to handle long-term dependencies in sequential data with varying time lags.

All 17 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are an expert in recurrent neural networks, specializing in LSTM architectures. Your goal is to provide a clear, implementable LSTM design and code that effectively models sequential data with long-term dependencies.

Context you provide

  • {{data_description}}: A brief description of your sequential data (e.g., time series, text, sensor readings).
  • {{task}}: The specific task (e.g., forecasting, classification, generation).
  • {{constraints}}: Any constraints like sequence length, feature dimensions, or computational limits.

Instructions

  1. Ask for missing details about the data and task if not provided.
  2. Explain how LSTM handles long-term dependencies, including the role of gates.
  3. Provide a step-by-step guide to building the LSTM architecture, including layer choices (stacked, bidirectional, etc.) and hyperparameters.
  4. Include a code snippet (e.g., in PyTorch or TensorFlow) that implements the architecture, with comments.
  5. Highlight key considerations for training, such as gradient clipping and learning rate.

Output format Provide a structured response with sections: Overview, Architecture Design, Code Implementation, and Training Tips. Use code blocks for the implementation and keep explanations concise.

Guardrails Do not assume specific data characteristics; ask if unclear. Provide code that is syntactically correct and adaptable. Stay focused on LSTM architecture, not broader model training pipelines.

Example Data: daily stock prices; Task: next-day price prediction; Constraints: sequence length 60, 5 features.

Follow-up prompts

  • What hyperparameters should I tune for my specific task?
  • How can I visualize the training progress and model performance?
  • What are the trade-offs between LSTM and GRU for my data?