Skip to content

Commit 76f38c3

Browse files
committed
modified output subsections
1 parent e3f365f commit 76f38c3

File tree

1 file changed

+12
-58
lines changed

1 file changed

+12
-58
lines changed

content/posts/machine learning/deep learning/NLP/Gemma2+RAG/gemma-2-rag-llamaindex-faiss.md

Lines changed: 12 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
2+
13
# Gemma-2 + RAG + LlamaIndex + VectorDB
2-
Load Gemma-2 9B (IT - fine-tuned on instructions)
34

45

56

6-
# Introduction
7+
## Introduction
78
Retrieval-Augmented Generation (RAG) is an advanced AI technique that enhances large language models (LLMs) with the ability to access and utilize external knowledge. This guide will walk you through a practical implementation of RAG using Python and various libraries, explaining each component in detail.
89

910
[![](https://mermaid.ink/img/pako:eNp1kt9ugjAUxl-l6ZXLdA_AxRIF_0VQp9tuiheVHpEEWlLaZcb47ju2uOGWcXHC6fdr-fpxzjRTAmhAc83rI3mNUknwGbK3BjR5saBPOzIYPJMRcw1Za5VB0xQy33l05OSQRYWGzJA4Tv5jIrYZTv-KvjZ27y2k9J5KqQfGLOKGk7nMoTGFkt7WhI2rPQiBIAk1cKf4DRMHTNk72lKabLHAbyZyzIyFShr4NGQDRhfwwctWnzl9ztBOVRuCWGO0zTongBTda_gaum0LhmG02NyvdKGFW4rZBpoazwUyBQm66y52RMJW1tTWkEeyVVZjLHfBjcngCakl60UqsxVI46_60FJLr8--Q7l2K9b7yS3BCShv-OoOn_puzXrdFG_sumVpn1agK14IHKTzVUupOUIFKQ3wVcCB29Jcf-QFUW6N2p5kRgOMEvpUK5sfaXDgZYOdrQU3EBUcp6G6ISAK_G7iJzVT8lDk9PIFuI7TUA?type=png)](https://mermaid.live/edit#pako:eNp1kt9ugjAUxl-l6ZXLdA_AxRIF_0VQp9tuiheVHpEEWlLaZcb47ju2uOGWcXHC6fdr-fpxzjRTAmhAc83rI3mNUknwGbK3BjR5saBPOzIYPJMRcw1Za5VB0xQy33l05OSQRYWGzJA4Tv5jIrYZTv-KvjZ27y2k9J5KqQfGLOKGk7nMoTGFkt7WhI2rPQiBIAk1cKf4DRMHTNk72lKabLHAbyZyzIyFShr4NGQDRhfwwctWnzl9ztBOVRuCWGO0zTongBTda_gaum0LhmG02NyvdKGFW4rZBpoazwUyBQm66y52RMJW1tTWkEeyVVZjLHfBjcngCakl60UqsxVI46_60FJLr8--Q7l2K9b7yS3BCShv-OoOn_puzXrdFG_sumVpn1agK14IHKTzVUupOUIFKQ3wVcCB29Jcf-QFUW6N2p5kRgOMEvpUK5sfaXDgZYOdrQU3EBUcp6G6ISAK_G7iJzVT8lDk9PIFuI7TUA)
@@ -252,7 +253,7 @@ for i, resp in enumerate(llm_responses):
252253
```
253254

254255

255-
## Which scientists contributed the most to superconductivity?
256+
### Which scientists contributed the most to superconductivity?
256257

257258

258259
It's impossible to name just a few scientists who "contributed the most" to superconductivity, as it's a field built on the work of many brilliant minds over decades.
@@ -281,10 +282,10 @@ It's important to remember that scientific progress is a collaborative effort, b
281282

282283

283284

284-
## Which are the differences between Type-I and Type-II superconductors? Describe magnetical properties and show formulas.
285+
### Which are the differences between Type-I and Type-II superconductors? Describe magnetical properties and show formulas.
285286

286287

287-
## Type-I vs. Type-II Superconductors
288+
#### Type-I vs. Type-II Superconductors
288289

289290
Superconductors are materials that exhibit zero electrical resistance below a critical temperature (Tc). They are classified into two main types: Type-I and Type-II, based on their response to magnetic fields.
290291

@@ -333,7 +334,7 @@ Superconductors are materials that exhibit zero electrical resistance below a cr
333334

334335

335336

336-
## What are the London Equation? Why are they important?
337+
### What are the London Equation? Why are they important?
337338

338339

339340
The London equations are a set of equations that describe the behavior of superconductors. They were first derived by Fritz and Heinz London in 1935.
@@ -374,7 +375,7 @@ Despite their limitations, the London equations are a cornerstone of superconduc
374375

375376

376377

377-
## Solve this problem: Consider a bulk superconductor containing a cylindrical hole of 0.1 mm diameter. There are 7 magnetic flux quanta trapped in the hole. Find the magnetic field in the hole.
378+
### Solve this problem: Consider a bulk superconductor containing a cylindrical hole of 0.1 mm diameter. There are 7 magnetic flux quanta trapped in the hole. Find the magnetic field in the hole.
378379

379380

380381
Here's how to solve the problem:
@@ -439,31 +440,7 @@ index.storage_context.persist()
439440
```
440441

441442

442-
Parsing nodes: 0%| | 0/28 [00:00<?, ?it/s]
443-
444-
445-
446-
Generating embeddings: 0%| | 0/43 [00:00<?, ?it/s]
447-
448-
449-
450-
Batches: 0%| | 0/1 [00:00<?, ?it/s]
451-
452-
453-
454-
Batches: 0%| | 0/1 [00:00<?, ?it/s]
455-
456-
457-
458-
Batches: 0%| | 0/1 [00:00<?, ?it/s]
459-
460-
461-
462-
Batches: 0%| | 0/1 [00:00<?, ?it/s]
463-
464-
465443

466-
Batches: 0%| | 0/1 [00:00<?, ?it/s]
467444

468445

469446
## RAG Querying
@@ -486,21 +463,6 @@ for query in queries:
486463
```
487464

488465

489-
Batches: 0%| | 0/1 [00:00<?, ?it/s]
490-
491-
492-
493-
Batches: 0%| | 0/1 [00:00<?, ?it/s]
494-
495-
496-
497-
Batches: 0%| | 0/1 [00:00<?, ?it/s]
498-
499-
500-
501-
Batches: 0%| | 0/1 [00:00<?, ?it/s]
502-
503-
504466

505467
```python
506468
for i, resp in enumerate(rag_responses):
@@ -512,7 +474,7 @@ for i, resp in enumerate(rag_responses):
512474
```
513475

514476

515-
## Which scientists contributed the most to superconductivity?
477+
### Which scientists contributed the most to superconductivity?
516478
Sources: _['Lecture1.pdf', 'Lecture1.pdf', 'Lecture1.pdf', 'Lecture1.pdf', 'Lecture1.pdf']_
517479

518480

@@ -538,7 +500,7 @@ The text emphasizes the importance of understanding the microscopic mechanism of
538500

539501

540502

541-
## Which are the differences between Type-I and Type-II superconductors? Describe magnetical properties and show formulas.
503+
### Which are the differences between Type-I and Type-II superconductors? Describe magnetical properties and show formulas.
542504
Sources: _['Lecture2.pdf', 'Lecture2.pdf', 'Lecture1.pdf', 'Lecture3.pdf', 'Lecture1.pdf']_
543505

544506

@@ -586,7 +548,7 @@ Let me know if you have any other questions.
586548

587549

588550

589-
## What are the London Equation? Why are they important?
551+
### What are the London Equation? Why are they important?
590552
Sources: _['Lecture1.pdf', 'Lecture3.pdf', 'Lecture3.pdf', 'Lecture3.pdf', 'Lecture1.pdf']_
591553

592554

@@ -626,7 +588,7 @@ The provided text highlights the historical development of superconductivity the
626588

627589

628590

629-
## Solve this problem: Consider a bulk superconductor containing a cylindrical hole of 0.1 mm diameter. There are 7 magnetic flux quanta trapped in the hole. Find the magnetic field in the hole.
591+
### Solve this problem: Consider a bulk superconductor containing a cylindrical hole of 0.1 mm diameter. There are 7 magnetic flux quanta trapped in the hole. Find the magnetic field in the hole.
630592
Sources: _['Lecture3.pdf', 'Lecture3.pdf', 'Lecture3.pdf', 'Lecture3.pdf', 'Lecture3.pdf']_
631593

632594

@@ -675,11 +637,3 @@ This implementation demonstrates the power of RAG in combining the strengths of
675637
The comparison between direct LLM responses and RAG responses would likely show the benefits of RAG in providing more detailed, accurate, and source-backed information. This approach is particularly valuable in domains requiring up-to-date or specialized knowledge, where the LLM's pre-trained knowledge might be insufficient or outdated.
676638

677639

678-
```python
679-
680-
```
681-
682-
683-
```python
684-
685-
```

0 commit comments

Comments
 (0)