RAG -Search¶
Install packages
Import packages
Get documents
{'text': "The purpose of this document is to capture frequently asked technical questions\nThe exact day and hour of the course will be 15th Jan 2024 at 17h00. The course will start with the first “Office Hours'' live.1\nSubscribe to course public Google Calendar (it works from Desktop only).\nRegister before the course starts using this link.\nJoin the course Telegram channel with announcements.\nDon’t forget to register in DataTalks.Club's Slack and join the channel.",
'section': 'General course-related questions',
'question': 'Course - When will the course start?',
'course': 'data-engineering-zoomcamp'}
Create a DataFrame
| course | section | question | text | |
|---|---|---|---|---|
| 0 | data-engineering-zoomcamp | General course-related questions | Course - When will the course start? | The purpose of this document is to capture fre... |
| 1 | data-engineering-zoomcamp | General course-related questions | Course - What are the prerequisites for this c... | GitHub - DataTalksClub data-engineering-zoomca... |
| 2 | data-engineering-zoomcamp | General course-related questions | Course - Can I still join the course after the... | Yes, even if you don't register, you're still ... |
| 3 | data-engineering-zoomcamp | General course-related questions | Course - I have registered for the Data Engine... | You don't need it. You're accepted. You can al... |
| 4 | data-engineering-zoomcamp | General course-related questions | Course - What can I do before the course starts? | You can start by installing and setting up all... |
Vector spaces
- Turn docs into vectors
- Term-document-matrix:
- rows: documents
- columns: words/tokens
- Bag of words: counts occurrences of each word in each document
| Document | word1 | word2 | word3 |
|---|---|---|---|
| Doc1 | 1 | 0 | 2 |
| Doc2 | 0 | 3 | 1 |
Number of distinct tokens
Tokens by occurrences
| 01 | 02 | 03 | 04 | 05 | 06 | 09 | 10 | 100 | 11 | ... | y_val | yaml | year | yellow | yellow_tripdata_2021 | yes | yml | youtube | zip | zoomcamp | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
5 rows × 1333 columns
Tokens by importance
| 01 | 02 | 03 | 04 | 05 | 06 | 09 | 10 | 100 | 11 | ... | y_val | yaml | year | yellow | yellow_tripdata_2021 | yes | yml | youtube | zip | zoomcamp | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.000000 |
| 1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.428961 |
| 2 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.279891 | 0.0 | 0.0 | 0.0 | 0.000000 |
| 3 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.000000 |
| 4 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.000000 |
5 rows × 1333 columns
Text Search¶
Relevant documents
Document example
"The purpose of this document is to capture frequently asked technical questions\nThe exact day and hour of the course will be 15th Jan 2024 at 17h00. The course will start with the first “Office Hours'' live.1\nSubscribe to course public Google Calendar (it works from Desktop only).\nRegister before the course starts using this link.\nJoin the course Telegram channel with announcements.\nDon’t forget to register in DataTalks.Club's Slack and join the channel."
Creating matrices
Scoring
Filtering
Getting most relevant documents
| course | section | question | text | |
|---|---|---|---|---|
| 7 | data-engineering-zoomcamp | General course-related questions | Course - Can I follow the course after it fini... | Yes, we will keep all the materials after the ... |
| 0 | data-engineering-zoomcamp | General course-related questions | Course - When will the course start? | The purpose of this document is to capture fre... |
| 1 | data-engineering-zoomcamp | General course-related questions | Course - What are the prerequisites for this c... | GitHub - DataTalksClub data-engineering-zoomca... |
| 34 | data-engineering-zoomcamp | General course-related questions | How can we contribute to the course? | Star the repo! Share it with friends if you fi... |
| 4 | data-engineering-zoomcamp | General course-related questions | Course - What can I do before the course starts? | You can start by installing and setting up all... |
Putting all together
Searching
[{'text': "Yes, even if you don't register, you're still eligible to submit the homeworks.\nBe aware, however, that there will be deadlines for turning in the final projects. So don't leave everything for the last minute.",
'section': 'General course-related questions',
'question': 'Course - Can I still join the course after the start date?',
'course': 'data-engineering-zoomcamp'},
{'text': "The purpose of this document is to capture frequently asked technical questions\nThe exact day and hour of the course will be 15th Jan 2024 at 17h00. The course will start with the first “Office Hours'' live.1\nSubscribe to course public Google Calendar (it works from Desktop only).\nRegister before the course starts using this link.\nJoin the course Telegram channel with announcements.\nDon’t forget to register in DataTalks.Club's Slack and join the channel.",
'section': 'General course-related questions',
'question': 'Course - When will the course start?',
'course': 'data-engineering-zoomcamp'},
{'text': 'Yes, we will keep all the materials after the course finishes, so you can follow the course at your own pace after it finishes.\nYou can also continue looking at the homeworks and continue preparing for the next cohort. I guess you can also start working on your final capstone project.',
'section': 'General course-related questions',
'question': 'Course - Can I follow the course after it finishes?',
'course': 'data-engineering-zoomcamp'},
{'text': 'No, late submissions are not allowed. But if the form is still not closed and it’s after the due date, you can still submit the homework. confirm your submission by the date-timestamp on the Course page.y\nOlder news:[source1] [source2]',
'section': 'General course-related questions',
'question': 'Homework - Are late submissions of homework allowed?',
'course': 'data-engineering-zoomcamp'},
{'text': 'You can start by installing and setting up all the dependencies and requirements:\nGoogle cloud account\nGoogle Cloud SDK\nPython 3 (installed with Anaconda)\nTerraform\nGit\nLook over the prerequisites and syllabus to see if you are comfortable with these subjects.',
'section': 'General course-related questions',
'question': 'Course - What can I do before the course starts?',
'course': 'data-engineering-zoomcamp'}]
Vector Search¶
Dense representation of documents (embeddings)
| course | section | question | text | |
|---|---|---|---|---|
| 764 | machine-learning-zoomcamp | Projects (Midterm and Capstone) | What If I submitted only two projects and fail... | If you have submitted two projects (and peer-r... |
| 0 | data-engineering-zoomcamp | General course-related questions | Course - When will the course start? | The purpose of this document is to capture fre... |
| 449 | machine-learning-zoomcamp | General course-related questions | The course has already started. Can I still jo... | Yes, you can. You won’t be able to submit some... |
| 451 | machine-learning-zoomcamp | General course-related questions | Can I submit the homework after the due date? | No, it’s not possible. The form is closed afte... |
| 814 | mlops-zoomcamp | +-General course questions | What if my answer is not exactly the same as t... | Please choose the closest one to your answer. ... |
| 2 | data-engineering-zoomcamp | General course-related questions | Course - Can I still join the course after the... | Yes, even if you don't register, you're still ... |
| 436 | machine-learning-zoomcamp | General course-related questions | Is it going to be live? When? | The course videos are pre-recorded, you can st... |
| 13 | data-engineering-zoomcamp | General course-related questions | Office Hours - I can’t attend the “Office hour... | Yes! Every “Office Hours” will be recorded and... |
| 7 | data-engineering-zoomcamp | General course-related questions | Course - Can I follow the course after it fini... | Yes, we will keep all the materials after the ... |
| 15 | data-engineering-zoomcamp | General course-related questions | Homework - Are late submissions of homework al... | No, late submissions are not allowed. But if t... |
| course | section | question | text | |
|---|---|---|---|---|
| 2 | data-engineering-zoomcamp | General course-related questions | Course - Can I still join the course after the... | Yes, even if you don't register, you're still ... |
| 0 | data-engineering-zoomcamp | General course-related questions | Course - When will the course start? | The purpose of this document is to capture fre... |
| 436 | machine-learning-zoomcamp | General course-related questions | Is it going to be live? When? | The course videos are pre-recorded, you can st... |
| 449 | machine-learning-zoomcamp | General course-related questions | The course has already started. Can I still jo... | Yes, you can. You won’t be able to submit some... |
| 814 | mlops-zoomcamp | +-General course questions | What if my answer is not exactly the same as t... | Please choose the closest one to your answer. ... |
| 764 | machine-learning-zoomcamp | Projects (Midterm and Capstone) | What If I submitted only two projects and fail... | If you have submitted two projects (and peer-r... |
| 451 | machine-learning-zoomcamp | General course-related questions | Can I submit the homework after the due date? | No, it’s not possible. The form is closed afte... |
| 437 | machine-learning-zoomcamp | General course-related questions | What if I miss a session? | Everything is recorded, so you won’t miss anyt... |
| 11 | data-engineering-zoomcamp | General course-related questions | Certificate - Can I follow the course in a sel... | No, you can only get a certificate if you fini... |
| 7 | data-engineering-zoomcamp | General course-related questions | Course - Can I follow the course after it fini... | Yes, we will keep all the materials after the ... |