File size: 1,043 Bytes
5f75e42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
license: apache-2.0
datasets:
- common-pile/caselaw_access_project
language:
- en
base_model:
- openai/gpt-oss-120b
new_version: openai/gpt-oss-20b
pipeline_tag: fill-mask
library_name: adapter-transformers
tags:
- content
---
That error is happening because your script is trying to save the FAISS index into a folder called rag_index/, but that folder doesn’t exist yet.

FAISS doesn’t auto-create directories, so you have to make sure the folder exists before writing.

### Quick fix
In your project folder (RAG_practicle), run:

```bash
mkdir rag_index
```
Then rerun:

```bash
python rag.py --build-corpus sample_docs
```
### Permanent fix in code
Inside rag.py, right before saving the index in self.index.fit(...) or before faiss.write_index(...), add:

```python
import os
os.makedirs("rag_index", exist_ok=True)
```
That way the script will automatically create the folder if it doesn’t exist.

Do you want me to update your rag.py so it auto-creates rag_index/ and avoids this crash forever? That would make it more robust.