diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6c80238 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM deepset/haystack:base-cpu-v1.23.0 + +COPY requirements.txt . +RUN pip install -r requirements.txt + +# copy only the application files in /app +# Streamlit does not allow running an app from the root directory +COPY Rock_fact_checker.py app/ +COPY pages app/pages +COPY app_utils app/app_utils +COPY data app/data + +WORKDIR app + +EXPOSE 8501 + +ENTRYPOINT ["streamlit", "run", "Rock_fact_checker.py"] diff --git a/README.md b/README.md index d7e547a..0ed8009 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,8 @@ title: Fact Checking rocks! emoji: 🎸 colorFrom: purple colorTo: blue -sdk: streamlit -sdk_version: 1.19.0 -app_file: Rock_fact_checker.py +sdk: docker +app_port: 8501 pinned: true models: [sentence-transformers/msmarco-distilbert-base-tas-b, microsoft/deberta-v2-xlarge-mnli, google/flan-t5-large] tags: [fact-checking, rock, natural language inference, dense retrieval, large language models, haystack, neural search] diff --git a/app_utils/config.py b/app_utils/config.py index 4d7e3d1..a41aacb 100644 --- a/app_utils/config.py +++ b/app_utils/config.py @@ -1,4 +1,4 @@ -import streamlit as st +import os INDEX_DIR = "data/index" STATEMENTS_PATH = "data/statements.txt" @@ -9,17 +9,11 @@ # In HF Space, we use microsoft/deberta-v2-xlarge-mnli # for local testing, a smaller model is better -try: - NLI_MODEL = st.secrets["NLI_MODEL"] -except: - NLI_MODEL = "valhalla/distilbart-mnli-12-1" +NLI_MODEL = os.environ.get("NLI_MODEL", "valhalla/distilbart-mnli-12-1") print(f"Used NLI model: {NLI_MODEL}") # In HF Space, we use google/flan-t5-large # for local testing, a smaller model is better -try: - PROMPT_MODEL = st.secrets["PROMPT_MODEL"] -except: - PROMPT_MODEL = "google/flan-t5-small" +PROMPT_MODEL = os.environ.get("PROMPT_MODEL", "google/flan-t5-small") print(f"Used Prompt model: {PROMPT_MODEL}") diff --git a/requirements.txt b/requirements.txt index c943e14..b940297 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ -farm-haystack[faiss,inference]==1.23.0 +# we now use the Haystack Docker image, so the following line is not needed anymore +# farm-haystack[faiss,inference]==1.23.0 + haystack-entailment-checker plotly==5.14.1 pydantic<2 -# commented to not interfere with streamlit SDK in HF spces -# uncomment for local installation -# streamlit==1.19.0 +streamlit==1.19.0 altair<5