Step 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
Step 2: Install your preferred library
Together provides an official library for Python:Shell
Python
Step 3: Process and chunk the data
You’ll RAG over Paul Graham’s latest essay titled Founder Mode. The code below will scrape and load the essay into memory.Python
Python
Step 4: Generate vector index and perform retrieval
You’ll now usemultilingual-e5-large-instruct to embed the augmented chunks above into a vector index.
Python
Python
Step 5: Rerank to improve quality
You’ll use a reranker model to improve retrieved chunk relevance quality:Python
Step 6: Call generative model
You’ll pass the final three concatenated chunks into an LLM to get the final answer.Python