Spaces:
Sleeping
Sleeping
Updated to reflect recent changes
Browse files
README.md
CHANGED
|
@@ -6,129 +6,140 @@ colorTo: yellow
|
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.44.1
|
| 8 |
app_file: app.py
|
| 9 |
-
pinned:
|
| 10 |
python_version: '3.10'
|
| 11 |
short_description: Advanced prompt engineering for educational AI systems.
|
| 12 |
thumbnail: >-
|
| 13 |
https://cdn-uploads.huggingface.co/production/uploads/68700e7552b74a1dcbb2a87e/Z7P8DJ57rc5P1ozA5gwp3.png
|
| 14 |
---
|
| 15 |
|
| 16 |
-
#
|
| 17 |
## Advanced Prompt Engineering Portfolio Project
|
| 18 |
|
| 19 |
### Project Overview
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
| 23 |
|
|
|
|
| 24 |
**Core Technologies:**
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
**Key Frameworks:**
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
### Prompt Engineering Techniques Demonstrated
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
- **
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
- **Scaffolding**: Breaking complex concepts into manageable components
|
| 56 |
-
- **Socratic Method**: Guiding discovery rather than providing direct answers
|
| 57 |
-
- **Metacognitive Strategies**: Teaching learning-how-to-learn approaches
|
| 58 |
-
|
| 59 |
-
#### 4. **Academic Integrity Constraints**
|
| 60 |
-
Implemented ethical AI guidelines through prompt engineering:
|
| 61 |
-
- Explicit instructions to avoid homework completion
|
| 62 |
-
- Focus on process over product delivery
|
| 63 |
-
- Critical thinking skill development emphasis
|
| 64 |
|
| 65 |
### Advanced Implementation Features
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
#### **Response Streaming & Truncation**
|
| 75 |
-
- Smart text truncation preserving sentence integrity
|
| 76 |
-
- Real-time response streaming for improved UX
|
| 77 |
-
- Error handling and fallback mechanisms
|
| 78 |
-
|
| 79 |
-
#### **Template Chaining Architecture**
|
| 80 |
-
```python
|
| 81 |
-
chain = template | llm
|
| 82 |
-
response = chain.invoke({
|
| 83 |
-
"question": message,
|
| 84 |
-
"system_message": educational_context
|
| 85 |
-
})
|
| 86 |
-
```
|
| 87 |
|
| 88 |
-
|
|
|
|
| 89 |
|
| 90 |
-
####
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
|
| 95 |
-
####
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
### Prompt Engineering Methodologies Applied
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
-
|
| 103 |
-
2. **Behavioral Constraint Definition**: Explicit instruction sets for ethical AI behavior
|
| 104 |
-
3. **Domain-Specific Language Modeling**: Educational vocabulary and pedagogical terminology integration
|
| 105 |
-
4. **Multi-Modal Response Formatting**: Structured output generation with educational formatting
|
| 106 |
|
| 107 |
### Professional Applications
|
| 108 |
-
|
| 109 |
This project demonstrates competency in:
|
| 110 |
-
- **Enterprise-Grade Prompt Design**: Scalable template architecture
|
| 111 |
-
- **Educational Technology Integration**: Pedagogically-informed AI system design
|
| 112 |
-
- **Ethical AI Implementation**: Academic integrity safeguards and responsible AI practices
|
| 113 |
-
- **Full-Stack AI Application Development**: End-to-end system implementation
|
| 114 |
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
|
|
|
|
|
|
|
|
|
| 117 |
**Dependencies:**
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
**Deployment:**
|
| 124 |
-
- Hugging Face Spaces compatible
|
| 125 |
-
- Environment variable configuration for API keys
|
| 126 |
-
- Production-ready error handling and logging
|
| 127 |
|
| 128 |
-
|
|
|
|
|
|
|
| 129 |
|
| 130 |
-
|
| 131 |
|
| 132 |
-
|
|
|
|
| 133 |
|
| 134 |
-
**Portfolio Demonstration**: This project evidences advanced prompt engineering capabilities, full-stack AI application development, and domain-specific AI system design suitable for enterprise educational technology environments.
|
|
|
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.44.1
|
| 8 |
app_file: app.py
|
| 9 |
+
pinned: true
|
| 10 |
python_version: '3.10'
|
| 11 |
short_description: Advanced prompt engineering for educational AI systems.
|
| 12 |
thumbnail: >-
|
| 13 |
https://cdn-uploads.huggingface.co/production/uploads/68700e7552b74a1dcbb2a87e/Z7P8DJ57rc5P1ozA5gwp3.png
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# Mimir: Educational AI Assistant
|
| 17 |
## Advanced Prompt Engineering Portfolio Project
|
| 18 |
|
| 19 |
### Project Overview
|
| 20 |
+
Mimir demonstrates sophisticated prompt engineering techniques applied to educational technology, showcasing the implementation of context-aware AI systems that prioritize pedagogical effectiveness over simple answer generation. A key feature is its ability to **dynamically generate custom data visualizations**, determined by an intelligent decision engine that assesses whether a visual aid will enhance the pedagogical explanation. This project exemplifies professional-grade prompt design for educational applications, embodying the role of an educational partner that guides students to discover answers for themselves.
|
| 21 |
|
| 22 |
+
***
|
| 23 |
|
| 24 |
+
### Technical Architecture
|
| 25 |
**Core Technologies:**
|
| 26 |
+
|
| 27 |
+
* **LangChain**: Prompt template management and conversation chain orchestration.
|
| 28 |
+
* **LangGraph**: Orchestrates the application's flow as a state machine (**StateGraph**). It manages the conditional logic for the tool-use decision engine, routing user queries between the LLM, a pre-built **ToolNode** for graph generation, and the final response node.
|
| 29 |
+
* **Gradio**: Full-stack web interface with custom CSS styling.
|
| 30 |
+
* **Hugging Face Inference API**: Model deployment and response generation.
|
| 31 |
+
* **Python**: Backend logic and integration layer.
|
| 32 |
+
* **Matplotlib**: Powers the dynamic, in-memory generation of educational graphs and charts.
|
| 33 |
|
| 34 |
**Key Frameworks:**
|
| 35 |
+
|
| 36 |
+
* `langchain.prompts.ChatPromptTemplate` for dynamic prompt construction.
|
| 37 |
+
* `langchain_huggingface.HuggingFaceEndpoint` for model interface.
|
| 38 |
+
* `langchain.schema` message objects (HumanMessage, AIMessage, SystemMessage).
|
| 39 |
+
* `langgraph.graph.StateGraph` & `langgraph.prebuilt.ToolNode` for building and executing the conditional logic graph.
|
| 40 |
+
* `langgraph.checkpoint.memory.MemorySaver` for persistent conversation state.
|
| 41 |
+
|
| 42 |
+
***
|
| 43 |
|
| 44 |
### Prompt Engineering Techniques Demonstrated
|
| 45 |
+
#### 1. Unified System Prompt Architecture
|
| 46 |
+
Employs a single, comprehensive system prompt that establishes the AI's core persona as **Mimir, an expert multi-concept tutor**. This foundational prompt meticulously defines the AI's behavior, tone, and pedagogical mission. It integrates:
|
| 47 |
+
|
| 48 |
+
* **Core Educational Principles**: A directive to prioritize teaching methodology, foster critical thinking, and provide comprehensive explanations over direct answers.
|
| 49 |
+
* **Defined Persona & Tone**: Specific instructions to maintain an engaging, supportive, and intellectually appropriate tone for high school students, while avoiding fluff and emojis.
|
| 50 |
+
* **Specific Response Guidelines**: Contextual rules for handling different academic tasks, such as explaining concepts in math problems instead of solving them, or discussing research strategies for essays rather than writing them.
|
| 51 |
+
|
| 52 |
+
#### 2. Instructional Design Integration
|
| 53 |
+
The core prompt incorporates evidence-based instructional design principles:
|
| 54 |
|
| 55 |
+
* **Scaffolding**: Breaking complex concepts into manageable components.
|
| 56 |
+
* **Socratic Method**: Guiding discovery rather than providing direct answers.
|
| 57 |
+
* **Metacognitive Strategies**: Teaching learning-how-to-learn approaches.
|
| 58 |
+
|
| 59 |
+
#### 3. Academic Integrity Constraints
|
| 60 |
+
Implemented ethical AI guidelines directly into the system prompt:
|
| 61 |
+
|
| 62 |
+
* Explicit instructions to avoid homework completion.
|
| 63 |
+
* Focus on **process over product delivery**.
|
| 64 |
+
* Critical thinking skill development emphasis.
|
| 65 |
+
|
| 66 |
+
#### 4. Two-Stage Tool-Use Prompting
|
| 67 |
+
A sophisticated two-stage prompting strategy governs the use of the `Create_Graph_Tool`:
|
| 68 |
+
|
| 69 |
+
* **Tool-Use Decision Prompt**: A highly-constrained template is used by the `Tool_Decision_Engine` to determine if a tool should be used. This prompt forces a **YES** or **NO** response based on whether a visual aid would significantly enhance learning, using explicit **INCLUDE** and **EXCLUDE** criteria.
|
| 70 |
+
* **Tool-Execution Guidance**: The main system prompt contains separate, explicit instructions on how to use the tool once the decision has been made. It provides the exact **JSON structure** the model must output, including fields like `data`, `plot_type`, and `educational_context`, ensuring the generated graphs are pedagogically sound.
|
| 71 |
+
|
| 72 |
+
***
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
### Advanced Implementation Features
|
| 75 |
+
#### Intelligent Graphing Tool Integration
|
| 76 |
+
A custom, dynamic visualization system was developed to provide multi-modal educational responses.
|
| 77 |
|
| 78 |
+
* **LLM-Powered Analysis**: For relevant queries, a targeted LLM call is made using the specialized YES/NO decision prompt.
|
| 79 |
+
* **Dynamic Visualization Tool (`Create_Graph_Tool`)**: Designed and implemented a custom visualization tool using **matplotlib**. The tool receives a JSON configuration from the LLM and generates high-quality bar, line, or pie charts. The entire process occurs in-memory:
|
| 80 |
+
* The plot is rendered into a `BytesIO` buffer.
|
| 81 |
+
* The image is encoded into a **base64 string**.
|
| 82 |
+
* The final output is an HTML `<img>` tag with the embedded base64 data, which is displayed directly in the chat interface, eliminating the need for file I/O.
|
| 83 |
+
* The tool's docstring provides a clear schema and usage instructions for the LLM, ensuring reliable and pedagogically sound visualizations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
+
#### Stateful Conversation Management with LangGraph
|
| 86 |
+
Implements persistent, multi-turn conversations using LangGraph's **MemorySaver**. This allows the application's state, including the full message history (`add_messages`), to be saved and resumed, ensuring robust context management even when tool use is involved.
|
| 87 |
|
| 88 |
+
#### Response Streaming & Truncation
|
| 89 |
+
* Smart text truncation preserving sentence integrity.
|
| 90 |
+
* Real-time response streaming for improved UX.
|
| 91 |
+
* Error handling and fallback mechanisms.
|
| 92 |
|
| 93 |
+
#### Template Chaining Architecture
|
| 94 |
+
The core logic utilizes **LangChain Expression Language (LCEL)** to pipe inputs through templates, models, and tools.
|
| 95 |
+
|
| 96 |
+
***
|
| 97 |
+
|
| 98 |
+
### User Interface Engineering
|
| 99 |
+
* **Gradio Layout & Custom Styling**: The interface is built with `gr.Blocks`, using `gr.Column` and `gr.Row` to structure the main components. A custom `styles.css` file is loaded to apply specific theming, responsive design, and layout rules, moving beyond default Gradio styling for a tailored user experience.
|
| 100 |
+
* **Component Architecture**: Modular Gradio component structure with custom CSS class integration and accessibility-compliant patterns.
|
| 101 |
+
|
| 102 |
+
***
|
| 103 |
|
| 104 |
### Prompt Engineering Methodologies Applied
|
| 105 |
+
* **Template Parameterization**: Dynamic variable injection for contextual responses.
|
| 106 |
+
* **Persona-Driven Response Generation**: Crafting a detailed persona within the system prompt to guide the AI's tone, style, and pedagogical approach consistently.
|
| 107 |
+
* **Domain-Specific Language Modeling**: Educational vocabulary and pedagogical terminology integration.
|
| 108 |
+
* **Multi-Modal Response Formatting**: Structured output generation with educational formatting.
|
| 109 |
+
* **Agentic Tool Routing**: Designing prompts and logic that enable an AI system to intelligently decide which tool is appropriate for a given task, simulating agent-like behavior.
|
| 110 |
|
| 111 |
+
***
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
### Professional Applications
|
|
|
|
| 114 |
This project demonstrates competency in:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
* **Enterprise-Grade Prompt Design**: Scalable template and tool-use architecture.
|
| 117 |
+
* **Educational Technology Integration**: Designing AI tutors with robust pedagogical frameworks and dynamic, multi-modal response capabilities.
|
| 118 |
+
* **Ethical AI Implementation**: Academic integrity safeguards and responsible AI practices.
|
| 119 |
+
* **Full-Stack AI Application Development**: End-to-end system implementation.
|
| 120 |
+
* **Intelligent Agent & Tool Development**: Building AI agents that can utilize custom tools to solve complex problems.
|
| 121 |
|
| 122 |
+
***
|
| 123 |
+
|
| 124 |
+
### Technical Specifications
|
| 125 |
**Dependencies:**
|
| 126 |
+
|
| 127 |
+
* **Core ML/AI**: `transformers`, `torch`, `accelerate`
|
| 128 |
+
* **LangChain & LangGraph**: `langgraph`, `langchain-core`, `langchain-community`, `langchain-huggingface`
|
| 129 |
+
* **UI Framework**: `gradio`
|
| 130 |
+
* **Visualization**: `matplotlib`, `plotly`, `pandas`, `numpy`, `scipy`
|
| 131 |
+
* **Utilities**: `python-dotenv`
|
| 132 |
+
* **Monitoring**: `langsmith` (Optional)
|
| 133 |
|
| 134 |
**Deployment:**
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
+
* Hugging Face Spaces compatible.
|
| 137 |
+
* Environment variable configuration for API keys.
|
| 138 |
+
* Production-ready error handling and logging.
|
| 139 |
|
| 140 |
+
***
|
| 141 |
|
| 142 |
+
### Results & Impact
|
| 143 |
+
Mimir represents a synthesis of prompt engineering best practices with educational technology requirements. The integration of an intelligent, conditional graphing tool demonstrates the ability to create AI systems that augment and enhance human learning processes, embodying the role of an educational partner who empowers students to succeed through genuine understanding.
|
| 144 |
|
| 145 |
+
> **Portfolio Demonstration**: This project evidences advanced prompt engineering capabilities, full-stack AI application development, and domain-specific AI system design suitable for enterprise educational technology environments.
|