Retrievals
Retrieval Augmented Generation (RAG) starts and ends with embeddings. In between, we need to retrieve the text that is most relevant to the query from the user. This post is about this retrieval task
In November 2023, I started this new section, AI STUFF. The AI STUFF posts will alternate with my regular posts. The AI STUFF posts will be in English and Turkish. They are written in English and translated to Turkish. Both will be on the same page.
Kasım 2023 den itibaren yeni bir bölüme başlıyorum: AI STUFF. AI STUFF gönderileri normal gönderilerimle dönüşümlü olarak yayınlanacak ve ayni sayfada İngilizce ve Türkçe olacak.
This week I created a Jupyter Notebook that does the following:
Create an index for all my posts under the GENERAL tag
Create embeddings for these posts using Open AI Portal. This is not free but for such small jobs the charge is very small. It was less than 3 US cents for the entire notebook.
Save the embeddings so that you do not have to recreate them when you re-run the notebook. The embeddings are stored in the
data
folder in the github repository.Let the user enter a query and retrieve the top ten matching entries from my blog posts
The following are the list of my posts that are processed in the notebook
Bu hafta şu aşağıdakileri yapan bir Jupyter Notebook oluşturdum:
GENERAL etiketi altındaki tüm gönderilerim (yukarıdaki liste) için bir dizin oluşturdum
Open AI Portal'ı kullanarak bu gönderiler için embeddings vektörleri hesapladım. Bu ücretsiz değil ama bu tür küçük işler için OpenAI çok az ücret talep ediyor. Bütün bu hafta hesapları için toplam maliyet 3 ABD sentinden azdı.
Not defterini yeniden çalıştırdığınızda yeniden embeddings hesabı gerekmesind diye vektörleri kaydettim. github deposundaki
data
klasöründe bulabilirsiniz.Kullanıcının bir soru girip blog yazılarımdan o soruyla eşleşen ilk on girişi görmesini sağladım
You will remember from my first post that I am trying to implement an RAG process to answer arbitraries using the info in my blog posts. The first letter R stands for Retrieval, which is the topic of this week’s post. To start creating answers, I need to learn how to access the new OpenAI Assistants API. I am hoping I will get there in my next post.
There is not much else I can tell you here. If you are interested in learning more you should download the probot
repository from GitHub.
Blog yazılarımda yer alan bilgileri kullanarak keyfi yanıtlar vermek için bir RAG süreci uygulamaya çalıştığımı ilk yazımdan hatırlayacaksınız. İlk harf R, bu haftaki yazımızın konusu olan Retrieval anlamında. Sorulara yanıt vermek için yeni OpenAI Assistants API'sine nasıl erişeceğimi öğrenmem gerekiyor. Bir sonraki yazımda inşallah.
Burada söyleyebileceğim daha fazla bir şey yok. Gerisini öğrenmek istiyorsanız GitHub'dan probot deposunu indirmelisiniz.
How to repeat what I did
If you have an area of expertise which you would like to share with the world using this new technology, please join me. I will be regularly (hopefully fortnightly) posting my progress on Substack. I will also be posting my code on Github. I will be using Python and the OpenAI API. In addition, I created an X (formerly known as Twitter) Community Group 'Building AI Tutors'. If you are interested, please join the group. I will be posting my progress there as well.
You do not need to be an experienced Python programmer but some knowledge of Python will be helpful. Below I list the steps you need to take to join me and explain how to go about it:
Install VS Code from https://code.visualstudio.com/download. This is a free code editor and development environment. It is the tool I am using therefore should be able to help you if you have problems.
Install Python from https://www.python.org/downloads/. At the time I started this notebook,
Download my
probot
files from my account on github. I do not think you need to have a github account to do this. The name of the project is probot. You can download the wholeprobot
folder as a zip pack and unzip to your local disk.
Bu yeni teknolojiyi kullanarak dünyayla paylaşmak istediğiniz bir uzmanlık alanınız varsa lütfen bu öğrenme yolculuğunda bana katılın. Ben yaptıklarımı düzenli olarak (umarım iki haftada bir) Substack'ta özetleyeceğim. Detaylı anlatım ve programlarımı Github'da yayınlayacağım. Python ve OpenAI API'sini kullanacağım. Ek olarak, bir X (eski adıyla Twitter) Topluluk Grubu 'Yapı Yapay Zeka Eğitmenleri' oluşturdum. Eğer ilgileniyorsanız lütfen gruba katılın. Gelişmelerimi orada da paylaşacağım.
Deneyimli bir Python programcısı olmanıza gerek yok ancak biraz Python bilgisi faydalı olacaktır. Aşağıda bana katılmak için atmanız gereken adımları listeliyorum ve bunu nasıl yapacağınızı açıklıyorum:
VS Code'u https://code.visualstudio.com/download adresinden yükleyin. Bu ücretsiz bir program ve benim kullandığım araçtır, dolayısıyla sorun yaşamanız durumunda size yardımcı olabilirim.
Python'u https://www.python.org/downloads/ adresinden yükleyin.
Tüm program ve detaylı anlatımları github'daki hesabımdan indirin. Bunu yapmak için bir github hesabınızın olması gerektiğini sanmıyorum. Projenin adı probot. Probot klasörünün tamamını zip paketi olarak indirebilir ve zip dosyasını yerel diskinize açabilirsiniz
Please download this zip pack and read 'introduction.html’ on your computer before you make your decision whether this is something you would like to pursue. If you do not want it, you will still continue the AI STUFF posts every two weeks if you are a subscriber to my blog because I cannot target different subscriber sections for different sections.
Lütfen bu zip paketini indirin ve bu yolculukta beni takip edip etmeme kararınızı vermeden önce bilgisayarınızda 'introduction.html'yi okuyun. Bloğuma abone iseniz iki haftada bir AI STUFF paylaşımlarına devam edeceksiniz çünkü farklı bölümler için farklı abone bölümlerini hedefleyemiyorum