--- license: apache-2.0 tags: - edge-impulse - rag - qwen - faiss - documentation - tinyml pipeline_tag: text-generation --- # Edge Impulse Docs RAG for Qwen This workspace builds a local Retrieval-Augmented Generation index over the Edge Impulse docs, then queries it with a small Qwen model. It is designed as the training/prototyping repo for an Edge Impulse docs-aware assistant that can later be plugged into the Hugging Face MCP demo or another agent. ## Quick Start ```powershell cd C:\Users\Eoin\git\edgeimpulse=docs-rag-qwen python -m venv .venv .\.venv\Scripts\Activate.ps1 python -m pip install --upgrade pip pip install -r requirements.txt python -m ipykernel install --user --name edgeimpulse-docs-rag-qwen --display-name "Edge Impulse Docs RAG Qwen" ``` Fetch the docs: ```powershell python scripts\fetch_docs.py --source https://docs.edgeimpulse.com/llms.txt ``` Build the FAISS index. This includes Markdown, text, and PDF files under `data/raw_docs`, including `data/raw_docs/pdfs/*.pdf`: ```powershell python scripts\build_index.py --docs data\raw_docs --out data\index ``` Ask a question: ```powershell python scripts\ask.py "How do I create an Edge Impulse JWT token?" python scripts\ask.py "How do I start a training job from the Studio API?" ``` Run a local API: ```powershell python scripts\serve.py --host 127.0.0.1 --port 8080 ``` Then query it: ```powershell curl -X POST http://127.0.0.1:8080/ask -H "Content-Type: application/json" -d "{\"question\":\"How do I deploy to Arduino?\"}" ``` ## Notebook Open [notebooks/edge_impulse_docs_rag_qwen.ipynb](notebooks/edge_impulse_docs_rag_qwen.ipynb) and select the `Edge Impulse Docs RAG Qwen` kernel. The notebook runs the same workflow as the scripts: 1. Fetch Edge Impulse docs into `data/raw_docs`. 2. Chunk and embed Markdown/text docs and PDFs with `sentence-transformers/all-MiniLM-L6-v2`. 3. Save a FAISS cosine-similarity index in `data/index`. 4. Retrieve relevant chunks for a question. 5. Generate a grounded answer with Qwen. ## Defaults - Base model: `Qwen/Qwen2.5-Coder-0.5B-Instruct` - Optional LoRA adapter: set `--adapter eoinedge/edgeai-docs-embedding-qwen1.5-0.5b-instruct` - Embedding model: `sentence-transformers/all-MiniLM-L6-v2` - Index: FAISS `IndexFlatIP` with L2-normalized vectors - Docs source: `https://docs.edgeimpulse.com/llms.txt` ## Notes RAG does not train the model weights. It trains/builds the retrieval index. If you later fine-tune a Qwen adapter, keep this RAG layer anyway so the assistant can answer from current docs and PDFs without a new model training run.