by mattkevan · 2y ago · 0 comments
I run a directory site for UX articles and tools, which I've recently rebuilt in Django. It has links to over 5000 articles, making it hard to browse, so I thought it'd be fun to use RAG with citations to create a knowledge search tool.
The site fetches new articles via RSS, which are chunked, embedded and added to the vector store. On conducting a search, the site returns a summary as well as links to the original articles. I'm using LlamaIndex, OpenAI and Supabase.
It's taken a little while to figure out as I really didn't know what I was doing and there's loads of improvements to make, but you can try it out here: https://www.uxlift.org/search/
I'd love to hear what you think.
Show the question I asked. I asked something like "What are the latest trends in UX for mobile?" and got a good answer that started with "The latest trends in UX design for mobile include..." but that's not the same as just listing the exact thing I asked.
Either show a chat log or stuff it into the browser history or...something. There's no way to see the answer to the question I asked before this one.
I just went back and did another search, and the results had 6 links, while the response (only) had cites labeled [7] [6] and [8] in that order.
Again, great stuff!
Good idea about showing the question, I've just added that to the search result.
Yes, I agree a chat history is really needed - it's on the list, along with a chat-style interface.
Also need to figure out what's going on with the citations in the text - the numbers seem pretty random and don't link up to the cited articles.
Thanks again!
Given a list of separators (regexes), it goes through them in order and keeps splitting the text by them until the chunk fits within the desired size. By putting the higher level separators first (e.g., for HTML split by <h1> before <h2>), it's a pretty good proxy for maintaining context.
Which chunk size you decide on largely depends on your data, so I typically eyeball a sample of the results to determine if the splitting is satisfactory.
You can see the separators here: https://github.com/drittich/SemanticSlicer/blob/main/Semanti...
Content is stored in Django as posts, so I wrote a custom document reader that created a new LlamaIndex document for each post, attaching the post id, title, link and published date as metadata. This gave better results than just loading in all the content as a text or CSV file, which I tried first.
I did try with a bunch of different techniques to split the chunks, including by sentence count and a larger and smaller number of tokens. In the end I decided to leave it to the LlamaIndex default just to get it working.
I relied on a lot of articles and code examples when putting it together so I'm happy to do the same.