Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
RAG-Driven Generative AI

You're reading from   RAG-Driven Generative AI Build custom retrieval augmented generation pipelines with LlamaIndex, Deep Lake, and Pinecone

Arrow left icon
Product type Paperback
Published in Sep 2024
Publisher Packt
ISBN-13 9781836200918
Length 334 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Denis Rothman Denis Rothman
Author Profile Icon Denis Rothman
Denis Rothman
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Why Retrieval Augmented Generation? FREE CHAPTER 2. RAG Embedding Vector Stores with Deep Lake and OpenAI 3. Building Index-Based RAG with LlamaIndex, Deep Lake, and OpenAI 4. Multimodal Modular RAG for Drone Technology 5. Boosting RAG Performance with Expert Human Feedback 6. Scaling RAG Bank Customer Data with Pinecone 7. Building Scalable Knowledge-Graph-Based RAG with Wikipedia API and LlamaIndex 8. Dynamic RAG with Chroma and Hugging Face Llama 9. Empowering AI Models: Fine-Tuning RAG Data and Human Feedback 10. RAG for Video Stock Production with Pinecone and OpenAI 11. Other Books You May Enjoy
12. Index
Appendix

2. Fine-tuning the model

To train the model, we retrieve our training file and create a fine-tuning job. We begin by creating an OpenAI client:

from openai import OpenAI
import jsonlines
client = OpenAI()

Then we use the file we generated to create another training file that is uploaded to OpenAI:

# Uploading the training file
result_file = client.files.create(
  file=open("QA_prompts_and_completions.json", "rb"),
  purpose="fine-tune"
)

We print the file information for the dataset we are going to use for fine-tuning:

print(result_file)
param_training_file_name = result_file.id
print(param_training_file_name)

We now create and display the fine-tuning job:

# Creating the fine-tuning job
 
ft_job = client.fine_tuning.jobs.create(
  training_file=param_training_file_name,
  model="gpt-4o-mini-2024-07-18"
)
# Printing the fine-tuning job
print(ft_job)

The output first provides the name of the file, its purpose...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime