Spaces:
Sleeping
Sleeping
Commit
·
d352740
1
Parent(s):
3349639
deepset/tinyroberta-squad2 added
Browse files
main.py
CHANGED
|
@@ -2,12 +2,14 @@ from fastapi import FastAPI
|
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
-
# Load
|
| 6 |
-
qa_pipeline = pipeline("text2text-generation", model="google/flan-t5-small")
|
| 7 |
with open("resume.txt", "r", encoding="utf-8") as f:
|
| 8 |
resume_text = f.read()
|
| 9 |
|
| 10 |
-
#
|
|
|
|
|
|
|
|
|
|
| 11 |
app = FastAPI()
|
| 12 |
|
| 13 |
class Question(BaseModel):
|
|
@@ -15,6 +17,8 @@ class Question(BaseModel):
|
|
| 15 |
|
| 16 |
@app.post("/predict")
|
| 17 |
async def predict(question: Question):
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
# Load resume text
|
|
|
|
| 6 |
with open("resume.txt", "r", encoding="utf-8") as f:
|
| 7 |
resume_text = f.read()
|
| 8 |
|
| 9 |
+
# Load extractive QA pipeline
|
| 10 |
+
qa_pipeline = pipeline("question-answering", model="deepset/tinyroberta-squad2")
|
| 11 |
+
|
| 12 |
+
# FastAPI setup
|
| 13 |
app = FastAPI()
|
| 14 |
|
| 15 |
class Question(BaseModel):
|
|
|
|
| 17 |
|
| 18 |
@app.post("/predict")
|
| 19 |
async def predict(question: Question):
|
| 20 |
+
result = qa_pipeline({
|
| 21 |
+
"question": question.query,
|
| 22 |
+
"context": resume_text
|
| 23 |
+
})
|
| 24 |
+
return {"answer": result["answer"]}
|