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:Shell
Python
3. Data processing and chunking
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
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
5. Rerank to improve quality
You’ll use a reranker model to improve retrieved chunk relevance quality:Python
6. Call generative model
You’ll pass the final 3 concatenated chunks into an LLM to get the final answer.Python