File size: 488 Bytes
0273ec0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI, HTTPException
import faiss
import numpy as np
from sentence_transformers import SentenceTransformer
from datasets import load_dataset

app = FastAPI()

# 1. ์ž„๋ฒ ๋”ฉ ๋ชจ๋ธ ๋กœ๋“œ
embed_model = SentenceTransformer("all-MiniLM-L6-v2")

# 2. Hugging Face์—์„œ MedRAG ๋ฐ์ดํ„ฐ์…‹ ๋กœ๋“œ
dataset = load_dataset("MedRAG/textbooks", split="train", streaming=True)

# 3. ๋ฐ์ดํ„ฐ ๋ณ€ํ™˜
texts = [entry["content"] for entry in dataset]  # "content" ํ•„๋“œ ํ™œ์šฉ