1. Register for an account
First, register for an account to get an API key. Once you’ve registered, set your account’s API key to an environment variable namedTOGETHER_API_KEY
:
Shell
2. Install your preferred library
Together provides an official library for Python:Python
Python
3. Data Processing and Chunking
We will RAG over Paul Grahams latest essay titled Founder Mode. The code below will scrape and load the essay into memory.Python
Python
4. Generate Vector Index and Perform Retrieval
We will now usebge-large-en-v1.5
to embed the augmented chunks above into a vector index.
Python
Python
5. Rerank To Improve Quality
We will use a reranker model to improve retrieved chunk relevance quality:Python
6. Call Generative Model - Llama 405b
We will pass the final 3 concatenated chunks into an LLM to get our final answer.Python