LangGPT: Structured Prompt Design Framework

repository·main·Indexed 11 days ago

https://github.com/langgptai/langgpt

A systematic, template-based methodology for creating high-quality LLM prompts, treating prompt engineering like a programming language. It utilizes a role-based framework with modular components such as Role, Profile, Goal, Skills, Rules, and Workflow. The ecosystem includes tools like PromptShow for creating prompt images, PromptVer for semantic versioning, and specialized meta-prompts for automated prompt generation.

Tokens
58K
Snippets
94
Records
236
Agent score
95%

What's inside LangGPT

  1. Overview of PromptShow

    main
    PromptShow is a tool designed to create and share visually appealing images of LLM (Large Language Model) prompts. It allows users to transform text-based prompts into beautiful, shareable snippets with customizable themes, making them suitable for social media platforms like Twitter and Slack.
  2. Explore the LangGPT Ecosystem

    main

    The LangGPT ecosystem consists of several specialized tools and collections:

    Core Framework & Tools

    • LangGPT: The core framework and methodology.
    • PromptVer: Semantic versioning for prompts (version control like Git).
    • PromptShow: Tool to create beautiful prompt images.
    • Minstrel: A multi-agent system for auto-generating prompts.
    • claude_marketplace: Official Claude Code skill marketplace.

    Model-Specific Prompt Collections

    Curated prompts optimized for specific models:

    • ChatGPT: wonderful-prompts
    • Anthropic Claude: awesome-claude-prompts
    • DeepSeek & R1: awesome-deepseek-prompts
    • Google Gemini: awesome-gemini-prompts
    • xAI Grok: awesome-grok-prompts
    • Alibaba Qwen: qwen-prompts
    • Meta Llama 2/3: awesome-llama-prompts
    • ByteDance Doubao: awesome-doubao-prompts

    Specialized Domains

    • Multimodal: GPT-4V, DALL-E 3, image/video prompts.
    • Deep Research: Research-focused prompts across models.
    • Voice AI: Conversational agents and voice prompts.
    • GraphRAG: Graph-based retrieval prompts.
    • Security: LLM jailbreaks and defense research.
  3. What is a Structured Prompt?

    main

    A Structured Prompt is a method of writing prompts using organizational patterns similar to writing an article or using templates (like a CV or a research paper). Instead of providing a single block of unstructured text, you use a combination of Identifiers and Attribute Words to define the semantic structure of the prompt.

    Key Components:

    • Identifiers: Symbols like #, ##, <>, [], or - used to denote hierarchy, headings, or variables. LangGPT primarily uses Markdown syntax (# for H1, ## for H2, etc.) to control content levels.
    • Attribute Words: Semantic labels like Role, Profile, Rules, Workflow, and Initialization. These act like section headings in an academic paper (e.g., Abstract, Methods, Conclusion) to tell the model what the following content describes.

    Comparison with Frameworks:

    While frameworks like CRISPE (Capacity, Insight, Statement, Personality, Experiment) provide a mental model for what to include, Structured Prompting provides a formal template for how to present that information to the LLM.

  4. What is Relationship Expression (关系表达)?

    main

    Relationship Expression is a prompting strategy designed to overcome the limitations of using technical terminology (Entity Expression). Instead of trying to 'compress' complex feelings into precise terms like 'Minimalism' or 'Material Design'—which can lead to ambiguity or information loss—you 'expand' your requirements by describing the relationships between known and unknown things.

    This method is highly effective for AI because LLMs operate on vector mathematics, understanding concepts based on their position in a 'relationship space' relative to other concepts.

  5. What is LangGPT?

    main

    LangGPT (Language for GPT-like LLMs) is a natural language programming framework designed to improve the quality, reusability, and structure of prompts for Large Language Models (LLMs).

    Inspired by the structure and reusability of programming languages, LangGPT moves away from unstructured natural language instructions toward a structured, two-layer design consisting of modules and internal elements. This approach aims to reduce the learning curve for non-AI experts and allow LLMs to automatically generate high-quality prompts in a manner similar to code generation.

  6. What is a Prompt and Prompt Engineering?

    main

    Prompt

    A Prompt is any content used by a Large Language Model (LLM) to predict an output. This includes:

    • Pre-set system prompts.
    • Direct user inputs.
    • The model's own previous outputs (in multi-turn conversations).

    Core Concept: "Everything that is used by the model to predict an output result is a Prompt."

    Prompt Engineering

    Prompt Engineering is the practice of designing and adjusting prompts to obtain ideal model results. It is the interface used to call and optimize the capabilities of an LLM. It is a foundational step in LLM application development, serving as the basis for performance optimization, RAG (Retrieval-Augmented Generation), and fine-tuning data construction.

  7. LangGPT Design Principles for Prompt Engineering

    main

    To optimize prompts, LangGPT follows four core design principles derived from the comparison between natural language and programming languages:

    1. Standardized Format: Prompts should use a standardized format to make user intent and requirements stand out, overcoming the ambiguity of natural language.
    2. Extensible Structure: The structure must be extensible, allowing users to design custom structures tailored to specific domains and tasks.
    3. Explicit and Complete Requirements: Instructions and additional constraints must be explicit and complete to avoid misunderstanding or bias.
    4. Flexible Language: While maintaining structure, the language used should remain flexible to adapt to different domains and ease of learning.
  8. Understand the advantages of Structured Prompts

    main

    Structured Prompts offer several key advantages over unstructured text:

    1. Hierarchical Structure: Uses clear levels (e.g., # Role, ## Profile, ### Skill) to unify form and content, improving readability for humans and aligning with the hierarchical training data of LLMs like ChatGPT.
    2. Improved Semantic Cognition: Identifiers (attribute words) group similar semantics together, reducing the cognitive load for both the user and the model. Attribute words act as semantic cues that help the model grasp the overall intent.
    3. Targeted Capability Activation: Using specific top-level identifiers like Role, Expert, or Master directly triggers the model's role-playing capabilities. Using Rules or Constraints helps mitigate hallucinations and ensure safety.
    4. Production-Grade Engineering: Structured prompts behave like code. They are modular, easier to maintain, version-control (via Git), and support collaborative development (e.g., defining Input and Output modules for multi-agent chains).
  9. The ultimate purpose and cognitive benefits of prompting

    main

    The essence of prompting is a cognitive practice rather than a mere technical skill. It is designed to teach four core abilities:

    1. Fine Observation: Describing requires closer looking.
    2. Precise Articulation: Finding exact words to communicate with AI.
    3. Open Creation: Utilizing the 'gaps' in symbolic systems to invite surprises.
    4. Critical Reflection: Understanding how technology alters perception.

    Core Principle: AI can generate content, but it cannot confer meaning. Meaning remains the exclusive domain of human intention, choice, and interpretation.

  10. Core Concepts: Variables, Commands, and Logic

    main

    Enhance prompt intelligence using these advanced syntax patterns:

    1. Variables and References Use <Variable> syntax to create self-referential prompts that maintain consistency. Example: As a <Role>, you must follow <Rules>.

    2. Commands Define reusable actions for better UX, typically using a / prefix. Example:

    ## Commands
    - Prefix: "/"
    - Commands:
        - help: Display all available commands
        - continue: Resume interrupted output

    3. Conditional Logic Use If/Else structures to handle different user inputs. Example:

    If user provides [code], then analyze and suggest improvements
    Else if user asks [question], then provide detailed explanation
    Else, prompt for clarification

    4. Reminders Use a ## Reminder section to combat context loss in long conversations by explicitly restating active rules or language settings.