Code Monkey home page Code Monkey logo

llm-rag-for-ui-creation's Introduction

LLM + RAG Setup ๐Ÿ“š

This is a simple template for generating UI elements in React using LLMs. After a good amount of experimentation, the Mistral-7b-Instruct-v0.1 model has been chosen for both tokenization and as the main LLM model. Given its relatively small size and better accuracy to size ratio, it seemed perfect for the use case. Although it runs locally on a MacBook Pro (M2, 16GB), the quantization is not properly configured, leading to slower results and occasional garbage values.

For a RAG (Retrieval-Augmented Generation) setup, embeddings need to be created first. The FAISS library has been used for this purpose. The task is to generate UI components in React. While the base model is proficient at generating JSX and HTML, it struggles with styling. This is where RAG becomes essential. Before feeding data to the LLM, a large store of embeddings is created from websites like Bootstrap, Tailwind, etc. Various tools from the LangChain library, such as AsyncChromiumLoader, Html2TextTransformer have been utilized for this purpose.

Setup โš™

The code presented here is a result of curiosity-driven experimentation, so the workflow may not be optimal.

Note

RAG creation is done locally, while LLM prompting is performed in Google Colab.
RAG creation involves merging multiple embeddings into a one.

To create embeddings and RAG:

  1. Gather all required links for RAG creation
  2. Place these links in a text file under the data folder
  3. Use the embeddings.py script to generate vector embeddings for that article
  4. Use the create_rag function in data_loader.py to create a RAG

Tip

Check out the rag_mistral_7b.py file to get a good idea on how to create and use RAGs
We will be using a somewhat modified version of it in Colab though

To prompt the LLM:

  1. Open the RAG_Mistral_7b.ipynb notebook in Google Colab
  2. Upload your embeddings (in the notebook, we call it bootstrap_rag)
  3. Run the notebook cell by cell to understand it better

llm-rag-for-ui-creation's People

Contributors

vishvam10 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.