LLMs, RAG, And GraphRAG Bringing AI Assistants To SEO Field
Discover how OpenAI’s GPTs let you create custom versions of ChatGPT with instructions, knowledge, and tools to help with work, learning, and everyday tasks.
LLMs, RAG, And GraphRAG Bringing AI Assistants To SEO Field
By the end of 2023, OpenAI introduced GPTs for combining instructions, additional knowledge, and task execution. GPTs are a new way for creating a tailored version of ChatGPT to be more helpful in daily life, at specific tasks, at work, or at home, and then share that creation with others. For instance, GPTs can help you learn the rules of any board game, aid you in teaching your kids math, or design stickers.
The Promise of GPTs
GPTs paved the way for the dream of a personal assistant that now seems attainable. Conversational LLMs represent an ideal form of human-machine interface. To develop strong AI assistants, simulate reasoning, avoid hallucinations, and enhance the capacity to use external tools.
An SEO Assistant
Creating an assistant that would be capable of generating content according to briefs, delivering industry knowledge about SEO, interacting with SaaS tools, and planning tasks. LLMs are already quite advanced, as long as we can constrain them to use accurate information. Thus, focusing on work to integrate data into an assistant using RAG and Graph RAG approaches and external APIs.
RAG Approach
Creating an assistant based on the retrieval augmented generation (RAG) approach. RAG is a technique that reduces a model’s hallucinations by providing it with information from external sources rather than its internal structure (its training). It is like interacting with a brilliant but amnesiac person with access to a search engine.
Use of a vector database for building the assistant. There are many available Redis, Elasticsearch, OpenSearch, Pinecone, Milvus, FAISS, and many others. LLM's framework aims to link the LLM with the databases (and documents). LangChain, LlamaIndex, Haystack, NeMo, Langdock, Marvin, etc. are the options available.
Implementation is fairly straightforward once you choose a software stack, providing documents that framework transforming into vectors that encode the content. Technical parameters are improving the results; however, specialized search frameworks such as LlamaIndex perform quite well natively. For proof-of-concept, a few SEO books in French and a few webpages from SEO websites are given. Use of RAG enables fewer hallucinations and more complete answers.
GraphRAG Approach
GraphRAG is an advanced version of retrieval augmented generation (RAG), incorporating graph-structured data, like knowledge graphs (KGs). Unlike baseline RAG systems that rely on vector search to retrieve semantically similar text, GraphRAG leverages the relational structure of graphs to retrieve and process information based on domain-specific queries.
RAG models are enhancing LLMs by integrating external documents, but still have trouble in integrating these sources and efficiently extracting the most relevant information from a large corpus. Answers requiring a combination of multiple pieces of information from several documents, the RAG approach may not be effective. Preprocessing the textual information for extracting its underlying structure, carrying the semantics. Creating a knowledge graph, which is a data structure encoding the relationships between entities in a graph, is done in the form of a subject-relation-object triple.
Building a knowledge graph is a task that has been done for a long time with NLP techniques. However, LLMs facilitate the creation of such graphs due to their capacity to process text. Thus, LLM creates the knowledge graph. The LMI framework efficiently guides the LLM to perform this task. Furthermore, the assistant structure becomes more complex while using the graphRAG approach.
Integrating SEO Tools Data
Accurate writing and delivering knowledge. Making an assistant for delivering data from SEO tools. For gaining the goal, LangChain is used to interact with APIs using natural language. This is done with functions explaining to LLM how to use a given API. We used the API of the tool babbar. Furthermore, an assistant is able to gather information about linking metrics for a given URL, followed by the framework level (LangChain), where the function is available.
Setting up a LangChain tool from the function above and initialize a hat for crafting the answer. Note that the temperature is zero, which means that GPT-4 would output straightforward answers with no creativity, which is better for delivering data from tools. Again, the LLM does most of the work, transforming the natural question into an API request and then returning to natural language from the API output.
You can create a GraphRAG conversational agent in your own environment by downloading the Jupyter Notebook file that contains all instructions. The Python code below can be used in a Jupyter Notebook to communicate with the newly generated agent once the code above has been implemented. Run the code after setting your prompt.
Final Thoughts
Use of LLM with RAG and GraphRAG approaches, adding accessibility of external APIs, and building a proof-of-concept showing what the future of automation in SEO. This gives smooth access to all the knowledge of the field and an easy way to interact with the most complex tools.
The latency of the answers and the feeling of discussing with a bot are the two problems to solve. The computation time needed to go back and forth from the LLM to graph or vector databases could take up to 10 seconds to obtain answers to very intricate questions. While LLMs simulate the tone and writing of actual humans, the fact that the interface is proprietary says it all. These problems can be solved with a neat trick using a text interface that is well-known, mostly used by humans, and where latency is usual.
Conclusion
GraphRAG (+API) boosts LLMs to enable companies to set up their own. Such assistants help onboard new junior collaborators or provide a knowledge base for customer support teams. For those with sufficient experience to utilize it directly, we have included the source code. The majority of this code is simple, and the section about the Babbar tool can be omitted (or substituted with APIs from other tools). However, because Nebula performs poorly when running in Docker, it is crucial to understand how to build a Nebula graph store instance, ideally on-premises. Although this configuration is detailed, it may initially appear complicated.