|
| 1 | +<!-- markdownlint-disable MD013 --> |
| 2 | +# QwenModel: Qwen 2.5 + RAG + Recursive Editing |
| 3 | + |
| 4 | +This project experiments with the open-sourced model **Qwen 2.5** (2.5B parameters) combined with **Retrieval-Augmented Generation (RAG)** and **recursive editing** to test its performance across different prompt categories from the Apollo 11 dataset. |
| 5 | + |
| 6 | +## Project Structure |
| 7 | + |
| 8 | +* **main.ipynb** – The core notebook where Qwen 2.5 is set up, RAG is integrated, and recursive editing is implemented. |
| 9 | +* **output.md** – Contains the final prompts and responses generated through recursive editing, along with tracked energy and CO₂ emission metrics. |
| 10 | + |
| 11 | +## Workflow Overview |
| 12 | + |
| 13 | +### 1. Prompt Setup |
| 14 | + |
| 15 | +The notebook defines three structured prompts for iterative refinement: |
| 16 | + |
| 17 | +* **Draft Prompt** – Produces the initial answer. |
| 18 | +* **Critic Prompt** – Analyzes weaknesses in the draft. |
| 19 | +* **Refiner Prompt** – Improves the answer based on the critique. |
| 20 | + |
| 21 | +This setup enables controlled recursive editing, especially useful for summarization, creative writing, and paraphrasing. |
| 22 | + |
| 23 | +### 2. RAG Pipeline |
| 24 | + |
| 25 | +* Connected to the Hugging Face API to generate **embeddings**. |
| 26 | +* Built a **vector index** from the Apollo 11 dataset. |
| 27 | +* Prepared a **retriever** to supply relevant context for Qwen. |
| 28 | + |
| 29 | +### 3. Qwen Integration |
| 30 | + |
| 31 | +A custom function handles: |
| 32 | + |
| 33 | +* Retrieval of context |
| 34 | +* Construction of Qwen API calls |
| 35 | +* Application of recursive editing logic (3 iterations) |
| 36 | + |
| 37 | +### 4. Energy Tracking |
| 38 | + |
| 39 | +Each query is wrapped with **CodeCarbon** to record: |
| 40 | + |
| 41 | +* CPU usage |
| 42 | +* Energy consumption |
| 43 | +* CO₂ emissions |
| 44 | + |
| 45 | +All tracked metrics appear in `output.md`. |
| 46 | + |
| 47 | +## Output |
| 48 | + |
| 49 | +The final markdown file contains: |
| 50 | + |
| 51 | +* The prompts used |
| 52 | +* Recursive-editing improved final responses |
| 53 | +* Per-question energy and emission statistics |
| 54 | + |
| 55 | +## Purpose |
| 56 | + |
| 57 | +This setup provides a compact testing environment to evaluate Qwen 2.5’s performance with RAG and recursive editing, enabling comparison with larger or alternative models. |
0 commit comments