FastCCG GitHub Repo Here
Hey everyone — I’ve been learning about Retrieval-Augmented Generation (RAG), and thought I’d share how I got an async LLM answering questions using my own local text documents. You can add your own real model provider from Mistral, Gemini, OpenAI or Claude, read the docs in the repo to learn more.
This tutorial uses a small open-source library I’m contributing to called fastccg, but the code’s vanilla Python and focuses on learning, not just plugging in tools.
🔧 Step 1: Install Dependencies
pip install fastccg rich
📄 Step 2: Create Your Python File
# async_rag_demo.py import asyncio from fastccg import add_mock_key, init_embedding, init_model from fastccg.vector_store.in_memory import InMemoryVectorStore from fastccg.models.mock import MockModel from fastccg.embedding.mock import MockEmbedding from fastccg.rag import RAGModel async def main(): api = add_mock_key() # Generates a fake key for testing # Initialize mock embedding and model embedder = init_embedding(MockEmbedding, api_key=api) llm = init_model(MockModel, api_key=api) store = InMemoryVectorStore() # Add docs to memory docs = { « d1 »: « The Eiffel Tower is in Paris. », « d2 »: « Photosynthesis allows plants to make food from sunlight. » } texts = list(docs.values()) ids = list(docs.keys()) vectors = await embedder.embed(texts) for i, id in enumerate(ids): store.add(id, vectors[i], metadata={« text »: texts[i]}) # Setup async RAG rag = RAGModel(llm=llm, embedder=embedder, store=store, top_k=1) # Ask a question question = « Where is the Eiffel Tower? » answer = await rag.ask_async(question) print(« Answer: », answer.content) if __name__ == « __main__ »: asyncio.run(main())
▶️ Step 3: Run It
python async_rag_demo.py
Expected output:
Answer: This is a mock response to: Context: The Eiffel Tower is in Paris. Question: Where is the Eiffel Tower? Answer the question based on the provided context.
Why This Is Useful for Learning
You learn how RAG pipelines are structured You learn how async Python works in practice You don’t need any paid API keys (mock models are included) You see how vector search + context-based prompts are combined
I built and use fastccg for experimenting — not a product or business, just a learning tool. You can check it out Here
submitted by /u/step-czxn to r/learnmachinelearning
[link] [comments]
Laisser un commentaire