ChatGPT is proscribed for a lot of sensible enterprise use instances outdoors of code era. The limitation arises from the coaching information, and the mannequin’s propensity to hallucinate. On the time of writing, if you happen to attempt to ask the Chat-GPT questions on occasions occurring after September 2021, you’ll in all probability obtain a response like this:
This isn’t useful, so how can we go about rectifying it?
Choice 1 — Prepare or fine-tune the mannequin on up-to-date information.
High-quality-tuning or coaching a mannequin might be impractical and costly. Placing apart the prices, the hassle required to arrange the information units is sufficient to forgo this selection.
Choice 2 — Use retrieval augmented era (RAG) strategies.
RAG strategies allow us to present the big language mannequin entry to an up-to-date information base. That is less expensive than coaching a mannequin from scratch or fine-tuning, and far simpler to implement. On this article, I present you find out how to leverage RAG along with your OpenAI mannequin. We are going to put the mannequin to the take a look at by conducting a brief evaluation of its capability to reply questions concerning the Russia-Ukraine battle of 2022 from a Wikipedia information base.
Notice: This matter, though delicate, was chosen for the apparent purpose that the present ChatGPT mannequin has no information of it.
You’ll require an OpenAI API key, you possibly can seize one straight from their web site or observe this tutorial. The framework used for RAG is Haystack by Deepset, which is open supply. They supply APIs enabling you to construct functions on prime of enormous language fashions. We additionally leverage sentence transformers and the transformers library from Hugging Face.