<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/wcgpvzeyk" -->

---
title: Code a simple RAG from scratch | daily.dev
description: A hands-on guide to building a Retrieval-Augmented Generation (RAG) system from scratch using Python and Ollama. Covers the core components: an embedding model...
canonical: https://daily.dev/posts/wcgpvzeyk
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Code a simple RAG from scratch | daily.dev
og:description: A hands-on guide to building a Retrieval-Augmented Generation (RAG) system from scratch using Python and Ollama. Covers the core components: an embedding model...
og:url: https://daily.dev/posts/wcgpvzeyk
og:image: https://api.daily.dev/og/posts/WcGPVzeYK.png
og:image:alt: Post cover image
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Code a simple RAG from scratch

**[DevShareVietNam](https://daily.dev/sources/devsharevietnam)** · [@hoanguyencoder](https://daily.dev/hoanguyencoder) · 0 upvotes · 0 comments

## Summary

A hands-on guide to building a Retrieval-Augmented Generation (RAG) system from scratch using Python and Ollama. Covers the core components: an embedding model (bge-base-en-v1.5), an in-memory vector database with cosine similarity search, and a language model (Llama-3.2-1B) for response generation. Walks through the full pipeline—indexing documents into chunks, embedding them, retrieving top-N relevant chunks via cosine similarity, and injecting them into a prompt for the LLM. Also discusses limitations (multi-topic queries, scalability, chunking strategies) and briefly introduces advanced RAG variants like Graph RAG, Hybrid RAG, and Modular RAG.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://huggingface.co/blog/ngxson/make-your-own-rag>

## Similar posts on daily.dev

- [Medium](https://daily.dev/posts/medium-ollye3mqw) · Medium · 1 upvotes · 0 comments
- [RAG Explained Simply with a Real Project](https://daily.dev/posts/rag-explained-simply-with-a-real-project-pgy15jzg7) · freeCodeCamp · 23 upvotes · 1 comments
- [Build an End-to-End RAG Pipeline for LLM Applications](https://daily.dev/posts/build-an-end-to-end-rag-pipeline-for-llm-applications-qvdk8tsyf) · DigitalOcean Community · 1 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#llm](https://daily.dev/tags/llm), [#rag](https://daily.dev/tags/rag), [#vector-search](https://daily.dev/tags/vector-search), [#ollama](https://daily.dev/tags/ollama)

[View this post on daily.dev](https://daily.dev/posts/wcgpvzeyk)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/wcgpvzeyk","headline":"Code a simple RAG from scratch","text":"Shared: Code a simple RAG from scratch","url":"https://daily.dev/posts/wcgpvzeyk","datePublished":"2026-02-24T03:49:24.569Z","dateModified":"2026-02-24T03:50:15.306Z","author":{"@type":"Person","name":"Hòa Nguyễn Coder","url":"https://daily.dev/hoanguyencoder","image":"https://media.daily.dev/image/upload/s--SCsZnAEj--/f_auto/v1751094071/avatars/avatar_hv0ugE9ii7tYkZ7uDsO6N?_a=BAMClqZW0","description":"Web Developer","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":1610}},"image":"https://media.daily.dev/image/upload/s--P4t4XyoV--/f_auto/v1722860399/public/Placeholder%2001","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"sharedContent":{"@type":"WebPage","url":"https://api.daily.dev/r/0qY5PxI4b"},"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/devsharevietnam","name":"DevShareVietNam"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DevShareVietNam","item":"https://daily.dev/squads/devsharevietnam"},{"@type":"ListItem","position":3,"name":"Code a simple RAG from scratch"}]}
```

