MedRAG_test / app.py
limyehji's picture
Create app.py
0273ec0 verified
raw
history blame
488 Bytes
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" ν•„λ“œ ν™œμš©